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