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

Revision 2670, 2.6 KB checked in by mattausch, 16 years ago (diff)
RevLine 
[2066]1#include "Intersectable.h"
[2575]2#include "SimpleRay.h"
[2066]3
[2176]4using namespace std;
[2066]5
[2575]6#if _WIN32
7#define ALIGN16 __declspec(align(16))
8#else
[2582]9#ifdef USE_HAVRAN_RAYCASTER
10#include "ktbconf.h"
11#define ALIGN16 GALIGN16
12#else
13#define ALIGN16
[2575]14#endif
[2582]15#endif
[2176]16
[2670]17namespace GtpVisibilityPreprocessor
18{
[2066]19
[2660]20
21int Intersectable::sMailId = 10000;//2147483647;
[2643]22int Intersectable::sReservedMailboxes = 1;
[2066]23
[2660]24int Intersectable::sMailId2 = 10000;//2147483647;
[2643]25int Intersectable::sReservedMailboxes2 = 1;
26
[2670]27
[2575]28// This is the result of computing intersection
29// static data member
[2670]30ALIGN16  IntersectionStr
31SimpleRay::IntersectionRes[32];
[2575]32
[2670]33
34
[2066]35Intersectable::Intersectable():
36mMailbox(0),
37mBvhLeaf(0),
[2543]38mVssRays(NULL),
39mRenderedFrame(0)
[2198]40#if STORE_VIEWCELLS_WITH_BVH
41, mViewCells(NULL)
42#endif
[2066]43{}
44
45
[2575]46
[2066]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:
[2538]58                return "mesh instance";
[2066]59        case TRANSFORMED_MESH_INSTANCE:
[2538]60                return "transformed mesh instance";
[2066]61        case SPHERE:
[2538]62                return "sphere";
[2066]63        case VIEW_CELL:
[2538]64                return "view cell";
[2066]65        case OGRE_MESH_INSTANCE:
[2538]66                return "ogre_mesh_instance";
[2066]67        case KD_INTERSECTABLE:
[2538]68                return "kd";
69        case TRIANGLE_INTERSECTABLE:
70                return "triangle";
71        case BVH_INTERSECTABLE:
72                return "bvh";
[2066]73        default:
[2538]74                return "unknown";
[2066]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
[2198]93#if STORE_VIEWCELLS_WITH_BVH
[2066]94
[2198]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
[2066]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{
[2231]132        cerr << "GetRandomSurfacePoint(u,v...) not yet implemented for type " << Type() << endl;
[2066]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{
[2206]146        cerr << "GetArea not implemented yet for this type" << endl;
[2066]147        return 0;
148}
149
150
151}
Note: See TracBrowser for help on using the repository browser.