source: GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h @ 1281

Revision 1281, 3.3 KB checked in by bittner, 18 years ago (diff)

mlrt 16 ray tracing support

RevLine 
[162]1#ifndef __INTERSECTABLE_H
2#define __INTERSECTABLE_H
3
[176]4#include "AxisAlignedBox3.h"
5#include "Pvs.h"
[1074]6#include <set>
[1184]7#include "VssRay.h"
[162]8
[860]9namespace GtpVisibilityPreprocessor {
10
[497]11struct VssRayContainer;
[1072]12class KdLeaf;
[1233]13class BvhLeaf;
[176]14
[1281]15class Intersectable;
16struct Face;
[1233]17
[1281]18struct FaceParentInfo {
19  // intersectable
20  Intersectable *mObject;
21  // face index
22  int mFaceIndex;
23 
24  FaceParentInfo(Intersectable *obj,
25                                 const int fi):
26        mObject(obj),
27        mFaceIndex(fi)
28  {}
29};
30
[162]31class Intersectable {
[176]32public:
[811]33  // last mail id -> warning not thread safe!
34  // both mailId and mailbox should be unique for each thread!!!
35  static int sMailId;
36  static int sReservedMailboxes;
37  int mMailbox;
38 
[1072]39  /// unique object Id
[811]40  int mId;
41 
[1072]42  /// universal counter
[811]43  int mCounter;
[339]44       
[1072]45  /// object based pvs
[811]46  KdPvs mKdPvs;
[162]47 
[1174]48  /// view cell based pvs per object
[1077]49  ViewCellPvs mViewCellPvs;
50
[1233]51  /// pointer to the container bvh leaf
52  BvhLeaf *mBvhLeaf;
53
[1193]54  VssRayContainer mVssRays;
55
[1233]56  /// # of references to this instance
[1143]57  int mReferences;
[1135]58
59  enum { MESH_INSTANCE,
60                 TRANSFORMED_MESH_INSTANCE,
61                 SPHERE,
62                 VIEW_CELL,
63                 OGRE_MESH_INSTANCE,
[1233]64                 KD_INTERSECTABLE,
65                 BVH_INTERSECTABLE
[1135]66                };
[162]67 
[1176]68  Intersectable(): mMailbox(0), mReferences(0) {}
[245]69
[339]70        void SetId(const int id) { mId = id; }
71        int GetId() { return mId; }
72       
[1184]73////////////////////////////////////////////////
74//      Mailing stuff
[382]75
76        static void NewMail(const int reserve = 1) {
77                sMailId += sReservedMailboxes;
78                sReservedMailboxes = reserve;
79        }
80       
[339]81        void Mail() { mMailbox = sMailId; }
[837]82        bool Mailed() const { return mMailbox == sMailId; }
[339]83
[382]84        void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }
85        bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }
86
[1176]87        int IncMail() { return ++ mMailbox - sMailId; }
[382]88
[1184]89////////////////////////////////////////////////////
[1020]90    virtual AxisAlignedBox3 GetBox() const = 0;
[870]91        virtual int CastRay(GtpVisibilityPreprocessor::Ray &ray) = 0;
[382]92       
[1020]93        virtual bool IsConvex() const = 0;
94        virtual bool IsWatertight() const = 0;
[850]95        virtual float IntersectionComplexity() = 0;
[176]96 
[850]97        virtual int NumberOfFaces() const = 0;
98        virtual int Type() const = 0;
[176]99
[850]100        virtual int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) = 0;
101
102        virtual int GetRandomVisibleSurfacePoint(Vector3 &point,
103                                                                                         Vector3 &normal,
104                                                                                         const Vector3 &viewpoint,
105                                                                                         const int maxTries) = 0;
[492]106 
[850]107        virtual ostream &Describe(ostream &s) = 0;
108       
109        virtual int GenerateSilhouetteRays(const int nrays,
110                                                                           const AxisAlignedBox3 &originBox,
111                                                                           const AxisAlignedBox3 &directionBox, VssRayContainer &rays)
112        {
113                return 0;
114        }
[556]115
[850]116        static bool GreaterCounter(const Intersectable *a,
117                                                         const Intersectable *b)
118        {
119                return a->mCounter > b->mCounter;
120        }
[1166]121
122        static string GetTypeName(Intersectable *obj)
123        {
124                switch(obj->Type())
125                {
126                case MESH_INSTANCE:
127                        return "mesh_instance\n";
128               
129                case TRANSFORMED_MESH_INSTANCE:
130                        return "transformed_mesh_instance\n";
131                       
132                case SPHERE:
133                        return "sphere\n";
134
135                case VIEW_CELL:
136                        return "view cell\n";
137               
138                case OGRE_MESH_INSTANCE:
139                        return "ogre_mesh_instance\n";
140
141                case KD_INTERSECTABLE:
142                        return "kd_intersectable\n";
143
144                default:
145                        return "unknown\n";
146                }
147        }
[162]148};
149
[1135]150
[860]151}
[162]152
153#endif
Note: See TracBrowser for help on using the repository browser.