erebus

annotate liberebus/src/geomobj.h @ 48:9971a08f4104

merged
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 24 Feb 2016 00:29:31 +0200
parents 2e817711d0f6
children
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@46 20 virtual Vec3 gen_surface_point() const;
nuclear@41 21
nuclear@46 22 virtual Vec3 calc_normal(const RayHit &hit) const;
nuclear@46 23 virtual Vec3 calc_tangent(const RayHit &hit) const;
nuclear@46 24 virtual Vec2 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@46 31 Vec3 gen_surface_point() const override;
nuclear@41 32
nuclear@46 33 Vec3 calc_normal(const RayHit &hit) const override;
nuclear@46 34 Vec3 calc_tangent(const RayHit &hit) const override;
nuclear@46 35 Vec2 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@46 42 Vec3 gen_surface_point() const override;
nuclear@41 43
nuclear@46 44 Vec3 calc_normal(const RayHit &hit) const override;
nuclear@46 45 Vec3 calc_tangent(const RayHit &hit) const override;
nuclear@46 46 Vec2 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@46 51 Vec3 v[3];
nuclear@46 52 Vec3 normal;
nuclear@46 53 Vec3 vnorm[3];
nuclear@46 54 Vec2 vtex[3];
nuclear@2 55
nuclear@2 56 bool intersect(const Ray &ray, RayHit *hit = 0) const override;
nuclear@41 57
nuclear@46 58 Vec3 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@46 74 Vec3 gen_surface_point() const override;
nuclear@2 75 };
nuclear@2 76
nuclear@2 77 #endif // GEOMOBJ_H_