annotate liberebus/src/geomobj.h @ 35:4901cf062c70
added COPYING and augmented the README file
author |
John Tsiombikas <nuclear@member.fsf.org> |
date |
Mon, 09 Jun 2014 07:24:22 +0300 |
parents |
e2d9bf168a41 |
children |
2e817711d0f6 |
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@18
|
37
|
nuclear@18
|
38 Vector3 calc_normal(const RayHit &hit) const override;
|
nuclear@18
|
39 Vector3 calc_tangent(const RayHit &hit) const override;
|
nuclear@18
|
40 Vector2 calc_texcoords(const RayHit &hit) const override;
|
nuclear@2
|
41 };
|
nuclear@2
|
42
|
nuclear@2
|
43 class Triangle : public GeomObject {
|
nuclear@2
|
44 public:
|
nuclear@2
|
45 Vector3 v[3];
|
nuclear@2
|
46 Vector3 normal;
|
nuclear@2
|
47 Vector3 vnorm[3];
|
nuclear@2
|
48 Vector2 vtex[3];
|
nuclear@2
|
49
|
nuclear@2
|
50 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
|
nuclear@2
|
51 };
|
nuclear@2
|
52
|
nuclear@2
|
53 class Mesh : public GeomObject {
|
nuclear@2
|
54 private:
|
nuclear@2
|
55 std::vector<Triangle> faces;
|
nuclear@2
|
56
|
nuclear@2
|
57 public:
|
nuclear@2
|
58 void begin();
|
nuclear@2
|
59 void vertex(float x, float y, float z);
|
nuclear@2
|
60 void normal(float x, float y, float z);
|
nuclear@2
|
61 void texcoord(float u, float v);
|
nuclear@2
|
62 void end();
|
nuclear@2
|
63
|
nuclear@2
|
64 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
|
nuclear@2
|
65 };
|
nuclear@2
|
66
|
nuclear@2
|
67 #endif // GEOMOBJ_H_
|