erebus

view liberebus/src/geomobj.h @ 36:6eab83024d28

small markdown fix in readme
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 09 Jun 2014 07:28:03 +0300
parents e2d9bf168a41
children 2e817711d0f6
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 calc_normal(const RayHit &hit) const;
21 virtual Vector3 calc_tangent(const RayHit &hit) const;
22 virtual Vector2 calc_texcoords(const RayHit &hit) const;
23 };
25 class Sphere : public GeomObject {
26 public:
27 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
29 Vector3 calc_normal(const RayHit &hit) const override;
30 Vector3 calc_tangent(const RayHit &hit) const override;
31 Vector2 calc_texcoords(const RayHit &hit) const override;
32 };
34 class Box : public GeomObject {
35 public:
36 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
38 Vector3 calc_normal(const RayHit &hit) const override;
39 Vector3 calc_tangent(const RayHit &hit) const override;
40 Vector2 calc_texcoords(const RayHit &hit) const override;
41 };
43 class Triangle : public GeomObject {
44 public:
45 Vector3 v[3];
46 Vector3 normal;
47 Vector3 vnorm[3];
48 Vector2 vtex[3];
50 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
51 };
53 class Mesh : public GeomObject {
54 private:
55 std::vector<Triangle> faces;
57 public:
58 void begin();
59 void vertex(float x, float y, float z);
60 void normal(float x, float y, float z);
61 void texcoord(float u, float v);
62 void end();
64 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
65 };
67 #endif // GEOMOBJ_H_