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

Revision 1074, 2.2 KB checked in by mattausch, 18 years ago (diff)

wked on view space object space partition

Line 
1#ifndef __INTERSECTABLE_H
2#define __INTERSECTABLE_H
3
4#include "AxisAlignedBox3.h"
5#include "Pvs.h"
6#include <set>
7
8namespace GtpVisibilityPreprocessor {
9
10struct VssRayContainer;
11class KdLeaf;
12
13class Intersectable {
14public:
15  // last mail id -> warning not thread safe!
16  // both mailId and mailbox should be unique for each thread!!!
17  static int sMailId;
18  static int sReservedMailboxes;
19  int mMailbox;
20 
21  /// unique object Id
22  int mId;
23 
24  /// universal counter
25  int mCounter;
26       
27  /// object based pvs
28  KdPvs mKdPvs;
29 
30  /// kd leaves that this intersectable belongs to
31  set<KdLeaf *> mKdLeaves;
32
33  enum { MESH_INSTANCE, TRANSFORMED_MESH_INSTANCE, SPHERE, VIEW_CELL, OGRE_MESH_INSTANCE };
34 
35  Intersectable():mMailbox(0) {}
36
37        void SetId(const int id) { mId = id; }
38        int GetId() { return mId; }
39       
40
41        static void NewMail(const int reserve = 1) {
42                sMailId += sReservedMailboxes;
43                sReservedMailboxes = reserve;
44        }
45       
46        void Mail() { mMailbox = sMailId; }
47        bool Mailed() const { return mMailbox == sMailId; }
48
49        void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }
50        bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }
51
52        int IncMail() { return ++mMailbox - sMailId; }
53
54
55    virtual AxisAlignedBox3 GetBox() const = 0;
56        virtual int CastRay(GtpVisibilityPreprocessor::Ray &ray) = 0;
57       
58        virtual bool IsConvex() const = 0;
59        virtual bool IsWatertight() const = 0;
60        virtual float IntersectionComplexity() = 0;
61 
62        virtual int NumberOfFaces() const = 0;
63        virtual int Type() const = 0;
64
65        virtual int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) = 0;
66
67        virtual int GetRandomVisibleSurfacePoint(Vector3 &point,
68                                                                                         Vector3 &normal,
69                                                                                         const Vector3 &viewpoint,
70                                                                                         const int maxTries) = 0;
71 
72        virtual ostream &Describe(ostream &s) = 0;
73       
74        virtual int GenerateSilhouetteRays(const int nrays,
75                                                                           const AxisAlignedBox3 &originBox,
76                                                                           const AxisAlignedBox3 &directionBox, VssRayContainer &rays)
77        {
78                return 0;
79        }
80
81        static bool GreaterCounter(const Intersectable *a,
82                                                         const Intersectable *b)
83        {
84                return a->mCounter > b->mCounter;
85        }
86};
87
88}
89
90#endif
Note: See TracBrowser for help on using the repository browser.