annotate liberebus/src/geomobj.h @ 17:e9da2916bc79
fixed the normal bug
author |
John Tsiombikas <nuclear@member.fsf.org> |
date |
Mon, 26 May 2014 05:41:28 +0300 |
parents |
93894c232d65 |
children |
09028848f276 |
rev |
line source |
nuclear@2
|
1 #ifndef GEOMOBJ_H_
|
nuclear@2
|
2 #define GEOMOBJ_H_
|
nuclear@2
|
3
|
nuclear@3
|
4 #include <vector>
|
nuclear@2
|
5 #include "object.h"
|
nuclear@4
|
6 #include "material.h"
|
nuclear@2
|
7 #include "brdf.h"
|
nuclear@2
|
8
|
nuclear@2
|
9 class GeomObject : public Object {
|
nuclear@2
|
10 public:
|
nuclear@4
|
11 Material mtl;
|
nuclear@2
|
12 Reflectance *brdf;
|
nuclear@2
|
13
|
nuclear@4
|
14 GeomObject();
|
nuclear@4
|
15
|
nuclear@2
|
16 ObjType get_type() const override;
|
nuclear@2
|
17
|
nuclear@2
|
18 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
|
nuclear@8
|
19
|
nuclear@8
|
20 virtual Vector3 calc_normal(const RayHit &hit) const;
|
nuclear@8
|
21 virtual Vector3 calc_tangent(const RayHit &hit) const;
|
nuclear@8
|
22 virtual Vector2 calc_texcoords(const RayHit &hit) const;
|
nuclear@2
|
23 };
|
nuclear@2
|
24
|
nuclear@2
|
25 class Sphere : public GeomObject {
|
nuclear@2
|
26 public:
|
nuclear@2
|
27 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
|
nuclear@8
|
28
|
nuclear@8
|
29 Vector3 calc_normal(const RayHit &hit) const override;
|
nuclear@8
|
30 Vector3 calc_tangent(const RayHit &hit) const override;
|
nuclear@8
|
31 Vector2 calc_texcoords(const RayHit &hit) const override;
|
nuclear@2
|
32 };
|
nuclear@2
|
33
|
nuclear@2
|
34 class Box : public GeomObject {
|
nuclear@2
|
35 public:
|
nuclear@2
|
36 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
|
nuclear@2
|
37 };
|
nuclear@2
|
38
|
nuclear@2
|
39 class Triangle : public GeomObject {
|
nuclear@2
|
40 public:
|
nuclear@2
|
41 Vector3 v[3];
|
nuclear@2
|
42 Vector3 normal;
|
nuclear@2
|
43 Vector3 vnorm[3];
|
nuclear@2
|
44 Vector2 vtex[3];
|
nuclear@2
|
45
|
nuclear@2
|
46 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
|
nuclear@2
|
47 };
|
nuclear@2
|
48
|
nuclear@2
|
49 class Mesh : public GeomObject {
|
nuclear@2
|
50 private:
|
nuclear@2
|
51 std::vector<Triangle> faces;
|
nuclear@2
|
52
|
nuclear@2
|
53 public:
|
nuclear@2
|
54 void begin();
|
nuclear@2
|
55 void vertex(float x, float y, float z);
|
nuclear@2
|
56 void normal(float x, float y, float z);
|
nuclear@2
|
57 void texcoord(float u, float v);
|
nuclear@2
|
58 void end();
|
nuclear@2
|
59
|
nuclear@2
|
60 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
|
nuclear@2
|
61 };
|
nuclear@2
|
62
|
nuclear@2
|
63 #endif // GEOMOBJ_H_
|