erebus
view liberebus/src/geomobj.h @ 48:9971a08f4104
merged
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 24 Feb 2016 00:29:31 +0200 |
parents | 2e817711d0f6 |
children |
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 Vec3 gen_surface_point() const;
22 virtual Vec3 calc_normal(const RayHit &hit) const;
23 virtual Vec3 calc_tangent(const RayHit &hit) const;
24 virtual Vec2 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 Vec3 gen_surface_point() const override;
33 Vec3 calc_normal(const RayHit &hit) const override;
34 Vec3 calc_tangent(const RayHit &hit) const override;
35 Vec2 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 Vec3 gen_surface_point() const override;
44 Vec3 calc_normal(const RayHit &hit) const override;
45 Vec3 calc_tangent(const RayHit &hit) const override;
46 Vec2 calc_texcoords(const RayHit &hit) const override;
47 };
49 class Triangle : public GeomObject {
50 public:
51 Vec3 v[3];
52 Vec3 normal;
53 Vec3 vnorm[3];
54 Vec2 vtex[3];
56 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
58 Vec3 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 Vec3 gen_surface_point() const override;
75 };
77 #endif // GEOMOBJ_H_