erebus

view liberebus/src/geomobj.h @ 44:a2afaf8af09b

helpful comment
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 18 Sep 2015 06:47:41 +0300
parents 09028848f276
children c4d48a21bc4a
line source
1 #ifndef GEOMOBJ_H_
2 #define GEOMOBJ_H_
4 #include <vector>
5 #include "object.h"
6 #include "material.h"
7 #include "brdf.h"
9 class GeomObject : public Object {
10 public:
11 Material mtl;
12 Reflectance *brdf;
14 GeomObject();
16 ObjType get_type() const override;
18 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
20 virtual Vector3 gen_surface_point() const;
22 virtual Vector3 calc_normal(const RayHit &hit) const;
23 virtual Vector3 calc_tangent(const RayHit &hit) const;
24 virtual Vector2 calc_texcoords(const RayHit &hit) const;
25 };
27 class Sphere : public GeomObject {
28 public:
29 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
31 Vector3 gen_surface_point() const override;
33 Vector3 calc_normal(const RayHit &hit) const override;
34 Vector3 calc_tangent(const RayHit &hit) const override;
35 Vector2 calc_texcoords(const RayHit &hit) const override;
36 };
38 class Box : public GeomObject {
39 public:
40 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
42 Vector3 gen_surface_point() const override;
44 Vector3 calc_normal(const RayHit &hit) const override;
45 Vector3 calc_tangent(const RayHit &hit) const override;
46 Vector2 calc_texcoords(const RayHit &hit) const override;
47 };
49 class Triangle : public GeomObject {
50 public:
51 Vector3 v[3];
52 Vector3 normal;
53 Vector3 vnorm[3];
54 Vector2 vtex[3];
56 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
58 Vector3 gen_surface_point() const override;
59 };
61 class Mesh : public GeomObject {
62 private:
63 std::vector<Triangle> faces;
65 public:
66 void begin();
67 void vertex(float x, float y, float z);
68 void normal(float x, float y, float z);
69 void texcoord(float u, float v);
70 void end();
72 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
74 Vector3 gen_surface_point() const override;
75 };
77 #endif // GEOMOBJ_H_