source: GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.cpp @ 2660

Revision 2660, 2.6 KB checked in by mattausch, 16 years ago (diff)
Line 
1#include "Intersectable.h"
2#include "SimpleRay.h"
3
4using namespace std;
5
6#if _WIN32
7#define ALIGN16 __declspec(align(16))
8#else
9#ifdef USE_HAVRAN_RAYCASTER
10#include "ktbconf.h"
11#define ALIGN16 GALIGN16
12#else
13#define ALIGN16
14#endif
15#endif
16
17namespace GtpVisibilityPreprocessor {
18
19
20int Intersectable::sMailId = 10000;//2147483647;
21int Intersectable::sReservedMailboxes = 1;
22
23int Intersectable::sMailId2 = 10000;//2147483647;
24int Intersectable::sReservedMailboxes2 = 1;
25
26// This is the result of computing intersection
27// static data member
28  ALIGN16  IntersectionStr
29  SimpleRay::IntersectionRes[32];
30
31Intersectable::Intersectable():
32mMailbox(0),
33mBvhLeaf(0),
34mVssRays(NULL),
35mRenderedFrame(0)
36#if STORE_VIEWCELLS_WITH_BVH
37, mViewCells(NULL)
38#endif
39{}
40
41
42
43Intersectable::~Intersectable()
44{
45        DEL_PTR(mVssRays);
46}
47
48
49string Intersectable::GetTypeName(Intersectable *obj)
50{
51        switch(obj->Type())
52        {
53        case MESH_INSTANCE:
54                return "mesh instance";
55        case TRANSFORMED_MESH_INSTANCE:
56                return "transformed mesh instance";
57        case SPHERE:
58                return "sphere";
59        case VIEW_CELL:
60                return "view cell";
61        case OGRE_MESH_INSTANCE:
62                return "ogre_mesh_instance";
63        case KD_INTERSECTABLE:
64                return "kd";
65        case TRIANGLE_INTERSECTABLE:
66                return "triangle";
67        case BVH_INTERSECTABLE:
68                return "bvh";
69        default:
70                return "unknown";
71        }
72}
73
74 
75Vector3 Intersectable::GetNormal(const int idx) const
76{
77        return Vector3(0, 0, 0);
78}
79
80
81VssRayContainer *Intersectable::GetOrCreateRays()
82{
83        if (!mVssRays)
84                mVssRays = new VssRayContainer();
85
86        return mVssRays;
87}
88
89#if STORE_VIEWCELLS_WITH_BVH
90
91ViewCellContainer *Intersectable::GetOrCreateViewCells()
92{
93        if (!mViewCells)
94                mViewCells = new ViewCellContainer();
95
96        return mViewCells;
97}
98
99
100void Intersectable::DelViewCells()
101{
102        DEL_PTR(mViewCells);
103}
104
105#endif
106
107
108void Intersectable::DelRayRefs()
109{
110        DEL_PTR(mVssRays);
111}
112
113
114int Intersectable::GenerateSilhouetteRays(const int nrays,
115                                                                                  const AxisAlignedBox3 &originBox,
116                                                                                  const AxisAlignedBox3 &directionBox,
117                                                                                  VssRayContainer &rays)
118{
119        return 0;
120}
121
122
123int Intersectable::GetRandomSurfacePoint(const float u,
124                                                                                 const float v,
125                                                                                 Vector3 &point,
126                                                                                 Vector3 &normal)
127{
128        cerr << "GetRandomSurfacePoint(u,v...) not yet implemented for type " << Type() << endl;
129        return 1;
130}
131
132
133bool Intersectable::GreaterCounter(const Intersectable *a,
134                                                                   const Intersectable *b)
135{
136        return a->mCounter > b->mCounter;
137}
138
139
140float Intersectable::GetArea() const
141{
142        cerr << "GetArea not implemented yet for this type" << endl;
143        return 0;
144}
145
146
147}
Note: See TracBrowser for help on using the repository browser.