1 | #include "Intersectable.h"
|
---|
2 |
|
---|
3 | using namespace std;
|
---|
4 |
|
---|
5 |
|
---|
6 | namespace GtpVisibilityPreprocessor {
|
---|
7 |
|
---|
8 |
|
---|
9 | Intersectable::Intersectable():
|
---|
10 | mMailbox(0),
|
---|
11 | mBvhLeaf(0),
|
---|
12 | mVssRays(NULL),
|
---|
13 | mRenderedFrame(0)
|
---|
14 | #if STORE_VIEWCELLS_WITH_BVH
|
---|
15 | , mViewCells(NULL)
|
---|
16 | #endif
|
---|
17 | {}
|
---|
18 |
|
---|
19 |
|
---|
20 | Intersectable::~Intersectable()
|
---|
21 | {
|
---|
22 | DEL_PTR(mVssRays);
|
---|
23 | }
|
---|
24 |
|
---|
25 |
|
---|
26 | string Intersectable::GetTypeName(Intersectable *obj)
|
---|
27 | {
|
---|
28 | switch(obj->Type())
|
---|
29 | {
|
---|
30 | case MESH_INSTANCE:
|
---|
31 | return "mesh instance";
|
---|
32 | case TRANSFORMED_MESH_INSTANCE:
|
---|
33 | return "transformed mesh instance";
|
---|
34 | case SPHERE:
|
---|
35 | return "sphere";
|
---|
36 | case VIEW_CELL:
|
---|
37 | return "view cell";
|
---|
38 | case OGRE_MESH_INSTANCE:
|
---|
39 | return "ogre_mesh_instance";
|
---|
40 | case KD_INTERSECTABLE:
|
---|
41 | return "kd";
|
---|
42 | case TRIANGLE_INTERSECTABLE:
|
---|
43 | return "triangle";
|
---|
44 | case BVH_INTERSECTABLE:
|
---|
45 | return "bvh";
|
---|
46 | default:
|
---|
47 | return "unknown";
|
---|
48 | }
|
---|
49 | }
|
---|
50 |
|
---|
51 |
|
---|
52 | Vector3 Intersectable::GetNormal(const int idx) const
|
---|
53 | {
|
---|
54 | return Vector3(0, 0, 0);
|
---|
55 | }
|
---|
56 |
|
---|
57 |
|
---|
58 | VssRayContainer *Intersectable::GetOrCreateRays()
|
---|
59 | {
|
---|
60 | if (!mVssRays)
|
---|
61 | mVssRays = new VssRayContainer();
|
---|
62 |
|
---|
63 | return mVssRays;
|
---|
64 | }
|
---|
65 |
|
---|
66 | #if STORE_VIEWCELLS_WITH_BVH
|
---|
67 |
|
---|
68 | ViewCellContainer *Intersectable::GetOrCreateViewCells()
|
---|
69 | {
|
---|
70 | if (!mViewCells)
|
---|
71 | mViewCells = new ViewCellContainer();
|
---|
72 |
|
---|
73 | return mViewCells;
|
---|
74 | }
|
---|
75 |
|
---|
76 |
|
---|
77 | void Intersectable::DelViewCells()
|
---|
78 | {
|
---|
79 | DEL_PTR(mViewCells);
|
---|
80 | }
|
---|
81 |
|
---|
82 | #endif
|
---|
83 |
|
---|
84 |
|
---|
85 | void Intersectable::DelRayRefs()
|
---|
86 | {
|
---|
87 | DEL_PTR(mVssRays);
|
---|
88 | }
|
---|
89 |
|
---|
90 |
|
---|
91 | int Intersectable::GenerateSilhouetteRays(const int nrays,
|
---|
92 | const AxisAlignedBox3 &originBox,
|
---|
93 | const AxisAlignedBox3 &directionBox,
|
---|
94 | VssRayContainer &rays)
|
---|
95 | {
|
---|
96 | return 0;
|
---|
97 | }
|
---|
98 |
|
---|
99 |
|
---|
100 | int Intersectable::GetRandomSurfacePoint(const float u,
|
---|
101 | const float v,
|
---|
102 | Vector3 &point,
|
---|
103 | Vector3 &normal)
|
---|
104 | {
|
---|
105 | cerr << "GetRandomSurfacePoint(u,v...) not yet implemented for type " << Type() << endl;
|
---|
106 | return 1;
|
---|
107 | }
|
---|
108 |
|
---|
109 |
|
---|
110 | bool Intersectable::GreaterCounter(const Intersectable *a,
|
---|
111 | const Intersectable *b)
|
---|
112 | {
|
---|
113 | return a->mCounter > b->mCounter;
|
---|
114 | }
|
---|
115 |
|
---|
116 |
|
---|
117 | float Intersectable::GetArea() const
|
---|
118 | {
|
---|
119 | cerr << "GetArea not implemented yet for this type" << endl;
|
---|
120 | return 0;
|
---|
121 | }
|
---|
122 |
|
---|
123 |
|
---|
124 | }
|
---|