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

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