erebus

annotate liberebus/src/geomobj.h @ 44:a2afaf8af09b

helpful comment
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 18 Sep 2015 06:47:41 +0300
parents 09028848f276
children c4d48a21bc4a
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@41 20 virtual Vector3 gen_surface_point() const;
nuclear@41 21
nuclear@8 22 virtual Vector3 calc_normal(const RayHit &hit) const;
nuclear@8 23 virtual Vector3 calc_tangent(const RayHit &hit) const;
nuclear@8 24 virtual Vector2 calc_texcoords(const RayHit &hit) const;
nuclear@2 25 };
nuclear@2 26
nuclear@2 27 class Sphere : public GeomObject {
nuclear@2 28 public:
nuclear@2 29 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
nuclear@8 30
nuclear@41 31 Vector3 gen_surface_point() const override;
nuclear@41 32
nuclear@8 33 Vector3 calc_normal(const RayHit &hit) const override;
nuclear@8 34 Vector3 calc_tangent(const RayHit &hit) const override;
nuclear@8 35 Vector2 calc_texcoords(const RayHit &hit) const override;
nuclear@2 36 };
nuclear@2 37
nuclear@2 38 class Box : public GeomObject {
nuclear@2 39 public:
nuclear@2 40 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
nuclear@18 41
nuclear@41 42 Vector3 gen_surface_point() const override;
nuclear@41 43
nuclear@18 44 Vector3 calc_normal(const RayHit &hit) const override;
nuclear@18 45 Vector3 calc_tangent(const RayHit &hit) const override;
nuclear@18 46 Vector2 calc_texcoords(const RayHit &hit) const override;
nuclear@2 47 };
nuclear@2 48
nuclear@2 49 class Triangle : public GeomObject {
nuclear@2 50 public:
nuclear@2 51 Vector3 v[3];
nuclear@2 52 Vector3 normal;
nuclear@2 53 Vector3 vnorm[3];
nuclear@2 54 Vector2 vtex[3];
nuclear@2 55
nuclear@2 56 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
nuclear@41 57
nuclear@41 58 Vector3 gen_surface_point() const override;
nuclear@2 59 };
nuclear@2 60
nuclear@2 61 class Mesh : public GeomObject {
nuclear@2 62 private:
nuclear@2 63 std::vector<Triangle> faces;
nuclear@2 64
nuclear@2 65 public:
nuclear@2 66 void begin();
nuclear@2 67 void vertex(float x, float y, float z);
nuclear@2 68 void normal(float x, float y, float z);
nuclear@2 69 void texcoord(float u, float v);
nuclear@2 70 void end();
nuclear@2 71
nuclear@2 72 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
nuclear@41 73
nuclear@41 74 Vector3 gen_surface_point() const override;
nuclear@2 75 };
nuclear@2 76
nuclear@2 77 #endif // GEOMOBJ_H_