My Project
PortalFrustum.h
1 #pragma once
2 #include "ShapeAABB.h"
3 #include "ShapeSphere.h"
4 #include <boost/circular_buffer.hpp>
5 #include <deque>
6 
7 namespace ParaEngine
8 {
9  class CPortalNode;
10  class CShapeFrustum;
11  class CBaseObject;
12 
14  class PCPlane : public Plane
15  {
16  public:
18  PCPlane();
20  PCPlane(const Plane & plane);
22  PCPlane(const Vector3& rkNormal, const Vector3& rkPoint);
24  PCPlane(const Vector3& rkPoint0, const Vector3& rkPoint1, const Vector3& rkPoint2);
25 
27  void SetPlane(const Plane & plane);
28 
30  ~PCPlane();
31 
35  {
36  return m_portal;
37  };
38 
42  {
43  m_portal = o;
44  };
45 
46  protected:
47 
50  };
51 
52  typedef boost::circular_buffer < PCPlane * > PCPlaneList;
53 
62  {
63  public:
64  // visibility types
65  enum Visibility
66  {
67  NONE,
68  PARTIAL,
69  FULL
70  };
71 
72  CPortalFrustum(void);
73  ~CPortalFrustum(void);
74  public:
75  // set the origin value
76  void setOrigin(const Vector3 & newOrigin);
77 
78  /* isVisible function for aabb */
79  bool isVisible( const CShapeAABB &bound) const;
80 
81  /* return true if we can see the view clipping scene object. it will use the OBB of the view clipping object. */
82  bool CanSeeObject( IViewClippingObject * pViewClippingObject) const;
85  bool CanSeeObject_PortalOnly( IViewClippingObject * pViewClippingObject) const;
86 
92  bool CanSeeObject_CompleteCull( IViewClippingObject * pViewClippingObject, int nFullCullIndex=-1) const;
93 
94  /* isVisible function for sphere */
95  bool isVisible( const CShapeSphere &bound) const;
96  /* isVisible() function for portals
97  * @param bIgnorePortalDirection: default to true. This should be set to false, if you are testing within a zone that may contain other zones.
98  * such as the root zone. however, for all convex zones that does not contain other zones, one can set this to true.
99  */
100  bool isVisible (CPortalNode * portal, bool bIgnorePortalDirection = true);
101 
102  /* more detailed check for visibility of an AABB */
103  Visibility getVisibility(const CShapeAABB & bound);
104 
105  // calculate extra culling planes from portal and camera
106  // origin and add to list of extra culling planes
107  // @param bAutoDirection: it will correct portal direction, so that it does not face away from the camera eye
108  int AddPortalCullingPlanes(CPortalNode * portal, bool bAutoDirection = true);
109 
113  bool AddCullingPlane(const Plane& plane, bool bAddToFront = true);
114 
121  int AddFrustum(CShapeFrustum * frustum, float fNearPlaneShiftDistance = 0.f);
122 
123  // remove extra culling planes created from the given portal
124  void RemovePortalCullingPlanes(CPortalNode *portal);
125 
126  // remove all extra culling planes
127  void RemoveAllExtraCullingPlanes(void);
128 
129  // get an unused PCPlane from the CullingPlane Reservoir
130  PCPlane * getUnusedCullingPlane(void);
131 
132  private:
133  Vector3 m_vOrigin;
134  PCPlaneList m_ActiveCullingPlanes;
135  PCPlaneList m_CullingPlaneReservoir;
136  };
137 }
Definition: combase.h:159
Pure interface for CBaseObject (3D scene object) It defines basic shapes and collision detection...
Definition: IViewClippingObject.h:29
different physics engine has different winding order.
Definition: EventBinding.h:32
void SetPlane(const Plane &plane)
Copy from a standard Plane.
Definition: PortalFrustum.cpp:41
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
Definition: ShapeSphere.h:6
AABB-related code.
Definition: ShapeAABB.h:11
almost the same as Plane, except that it keeps a pointer to the containing portal.
Definition: PortalFrustum.h:14
Specialized frustum shaped culling volume that has culling planes created from portals This isn&#39;t rea...
Definition: PortalFrustum.h:61
~PCPlane()
Standard destructor.
Definition: PortalFrustum.cpp:46
Defines a plane in 3D space.
Definition: ParaPlane.h:23
CPortalNode * GetPortal()
Returns the Portal that was used to create this plane.
Definition: PortalFrustum.h:34
void SetPortal(CPortalNode *o)
Sets the Portal that was used to create this plane.
Definition: PortalFrustum.h:41
Portal rendering: portal class a portal can be connected to one or two zones.
Definition: PortalNode.h:15
PCPlane()
Standard constructor.
Definition: PortalFrustum.cpp:21
a general view frustum class.
Definition: ShapeFrustum.h:9
CPortalNode * m_portal
Portal used to create this plane.
Definition: PortalFrustum.h:44