1 | #ifndef _SeparatingPlanesBox3_H__ |
---|
2 | #define _SeparatingPlanesBox3_H__ |
---|
3 | |
---|
4 | #include "AxisAlignedBox3.h" |
---|
5 | #include "Matrix4x4.h" |
---|
6 | #include "Vector3.h" |
---|
7 | #include "Plane3.h" |
---|
8 | #include "Containers.h" |
---|
9 | |
---|
10 | namespace GtpVisibilityPreprocessor { |
---|
11 | |
---|
12 | |
---|
13 | // Written by Vlastimil Havran, May 2008, in the scope |
---|
14 | // of Progressive Visibility Sampling project. |
---|
15 | |
---|
16 | // This class given two axis aligned boxes can construct all the |
---|
17 | // separating planes between two boxes. It gets the boxes as 'origBox' |
---|
18 | // containing ray origin, and 'shadBox', containing shadowing object, |
---|
19 | // to which the ray is aimed at. The constructed planes can found if a |
---|
20 | // 'testBox' cannot be intersected by a ray starting from the origBox |
---|
21 | // and intersecting the 'shadBox'. |
---|
22 | |
---|
23 | class CSeparatingAxisTester |
---|
24 | { |
---|
25 | // the number of separating planes |
---|
26 | int cntPlanes; |
---|
27 | Plane3 planes[32]; |
---|
28 | AxisAlignedBox3 origBox; |
---|
29 | AxisAlignedBox3 shadBox; |
---|
30 | |
---|
31 | void InsertPlane(const Plane3 &pl); |
---|
32 | |
---|
33 | void OnePhase(const AxisAlignedBox3 &origBox, |
---|
34 | const AxisAlignedBox3 &shadBox, |
---|
35 | const Vector3 &pointBACKSIDE); |
---|
36 | |
---|
37 | public: |
---|
38 | CSeparatingAxisTester(); |
---|
39 | |
---|
40 | // Initialize with two boxe, the 'origBox' contains |
---|
41 | // origin of the ray, 'shadBox' is the shadowing |
---|
42 | // box, which contains new position of the object |
---|
43 | // and to which a ray aims at. |
---|
44 | void Init(const AxisAlignedBox3 &origBox, |
---|
45 | const AxisAlignedBox3 &shadBox); |
---|
46 | |
---|
47 | // This function returns true if a ray starting |
---|
48 | // in the 'origBox' and intersecting 'shadBox' |
---|
49 | // can intersect the box as input of this function |
---|
50 | bool TestIsInsideShaft(const AxisAlignedBox3 &testBox); |
---|
51 | |
---|
52 | // returns number of separating planes |
---|
53 | int CntPlanes() const { return cntPlanes;} |
---|
54 | }; |
---|
55 | |
---|
56 | // Testing code |
---|
57 | void TestSepAxis(); |
---|
58 | |
---|
59 | } |
---|
60 | #endif |
---|