My Project
PortalNode.h
1 #pragma once
2 #include <vector>
3 #include "TileObject.h"
4 
5 namespace ParaEngine
6 {
7  using namespace std;
8  class CZoneNode;
9  struct SceneState;
10 
15  class CPortalNode : public CTileObject
16  {
17  public:
18  CPortalNode(void);
19  virtual ~CPortalNode(void);
20 
21  virtual CBaseObject::_SceneObjectType GetType(){return CBaseObject::PortalNode;};
22  virtual string ToString(DWORD nMethod);
23 
24 
28  virtual bool TestCollisionSphere(CBaseCamera* pCamera, float fFarPlaneDistance);
31  virtual bool TestCollision(CBaseCamera* pCamera);
32 
36  virtual void GetVertices(Vector3 * pVertices, int* nNumber);
37 
39  // implementation of IAttributeFields
40 
42  virtual int GetAttributeClassID(){return ATTRIBUTE_CLASSID_CPortalNode;}
44  virtual const char* GetAttributeClassName(){static const char name[] = "CPortalNode"; return name;}
46  virtual const char* GetAttributeClassDescription(){static const char desc[] = ""; return desc;}
48  virtual int InstallFields(CAttributeClass* pClass, bool bOverride);
49 
50  ATTRIBUTE_METHOD1(CPortalNode, GetHomeZone_s, const char**) {*p1 = cls->GetHomeZone(); return S_OK;}
51  ATTRIBUTE_METHOD1(CPortalNode, SetHomeZone_s, const char*) {cls->SetHomeZone(p1); return S_OK;}
52 
53  ATTRIBUTE_METHOD1(CPortalNode, GetTargetZone_s, const char**) {*p1 = cls->GetTargetZone(); return S_OK;}
54  ATTRIBUTE_METHOD1(CPortalNode, SetTargetZone_s, const char*) {cls->SetTargetZone(p1); return S_OK;}
55 
56  ATTRIBUTE_METHOD1(CPortalNode, GetPortalPoints_s, const char**) {*p1 = cls->GetPortalPoints(); return S_OK;}
57  ATTRIBUTE_METHOD1(CPortalNode, SetPortalPoints_s, const char*) {cls->SetPortalPoints(p1); return S_OK;}
58 
59  ATTRIBUTE_METHOD(CPortalNode, AutoGenPortalPoints_s) {cls->AutoGenPortalPoints(); return S_OK;}
60  public:
64  CZoneNode * GetZone(CZoneNode * pCurZone = NULL);
65 
67  int GetZoneCount();
68 
69  /* open the portal */
70  void Open();
71  /* close the portal */
72  void Close();
73  /* check if portal is open */
74  bool IsOpen() {return m_bOpen;}
75 
78  void SetCorner( int nIndex, const Vector3& vPos);
79 
82  Vector3 & getCorner( int nIndex);
83 
86  Vector3 & getDerivedCorner( int nIndex);
87 
90  Vector3 & getDerivedDirection( void );
91 
94  Vector3 & getDerivedCP( void );
95 
98  void updateDerivedValues();
99 
100 
101  /* Calculate the local direction and radius of the portal
102  */
103  void calcDirectionAndRadius( void );
104 
106  virtual HRESULT Draw( SceneState * sceneState);
107 
113  virtual void UpdateFrameNumber(int nFrameNumber);
114 
116  void SetHomeZone(const char* sName);
117  const char* GetHomeZone();
118 
120  void SetTargetZone(const char* sName);
121  const char* GetTargetZone();
122 
126  void SetPortalPoints(const char* sVertices);
128  const char* GetPortalPoints();
129 
131  void AutoGenPortalPoints();
132  private:
133  // flag open or closed
134  bool m_bOpen;
135 
137  bool m_LocalsUpToDate;
138 
141  Vector3 m_Corners[4];
143  // NOTE: For a Quad portal, determined by the 1st 3 corners.
144  // NOTE: For AABB & SPHERE portals, we only have "inward" or "outward" cases.
145  // To indicate "outward", the Direction is UNIT_Z
146  // to indicate "inward", the Direction is NEGATIVE_UNIT_Z
147  Vector3 m_Direction;
148  // Local Center point of the portal
149  Vector3 m_LocalCP;
150 
152  // cached per frame data to speed up calculation
154  Vector3 m_DerivedCorners[4];
156  // NOTE: Only applicable for a Quad portal
157  Vector3 m_DerivedDirection;
159  Vector3 m_DerivedCP;
160 
161 
162  };
163 }
164 
an attribute class is a collection of attribute fields.
Definition: AttributeClass.h:10
It&#39;s used as parameter to Draw method of each scene object.
Definition: SceneState.h:284
virtual const char * GetAttributeClassDescription()
a static string, describing the attribute class object
Definition: PortalNode.h:46
different physics engine has different winding order.
Definition: EventBinding.h:32
virtual const char * GetAttributeClassName()
a static string, describing the attribute class object&#39;s name
Definition: PortalNode.h:44
virtual int GetAttributeClassID()
attribute class ID should be identical, unless one knows how overriding rules work.
Definition: PortalNode.h:42
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
Definition: BaseCamera.h:70
a zone in portal rendering.
Definition: ZoneNode.h:17
Tile Object have position and bounding rect and can usually be attached to quad-tree terrain tile...
Definition: TileObject.h:10
Portal rendering: portal class a portal can be connected to one or two zones.
Definition: PortalNode.h:15