erebus

view liberebus/src/geomobj.h @ 12:ea4bcf186d66

whatever
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 24 May 2014 21:52:19 +0300
parents 93894c232d65
children 09028848f276
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;
37 };
39 class Triangle : public GeomObject {
40 public:
41 Vector3 v[3];
42 Vector3 normal;
43 Vector3 vnorm[3];
44 Vector2 vtex[3];
46 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
47 };
49 class Mesh : public GeomObject {
50 private:
51 std::vector<Triangle> faces;
53 public:
54 void begin();
55 void vertex(float x, float y, float z);
56 void normal(float x, float y, float z);
57 void texcoord(float u, float v);
58 void end();
60 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
61 };
63 #endif // GEOMOBJ_H_