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