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