My Project
TerrainTile.h
1 #pragma once
2 #include "util/ParaMemPool.h"
3 #include "unordered_ref_array.h"
4 #include "IGameObject.h"
5 #include "AttributeModelProxy.h"
6 
7 #include <list>
8 #include <map>
9 
10 namespace ParaEngine
11 {
12 class CBaseObject;
13 class CBipedObject;
14 class IGameObject;
15 typedef unordered_ref_array<CBaseObject*> ObjectRefArray_type;
16 
17 typedef FixedSizedAllocator<IGameObject::WeakPtr_type> DL_Allocator_IGameWeakPtr;
18 typedef std::list<IGameObject::WeakPtr_type, DL_Allocator_IGameWeakPtr> VisitorList_type;
19 
22 {
23 public:
24  CTerrainTile();
25  CTerrainTile(float x, float y, float r);
26  virtual ~CTerrainTile(void);
27  ATTRIBUTE_DEFINE_CLASS(CTerrainTile);
29  virtual IAttributeFields* GetChildAttributeObject(const std::string& sName);
31  virtual int GetChildAttributeObjectCount(int nColumnIndex = 0);
33  virtual int GetChildAttributeColumnCount();
34  virtual IAttributeFields* GetChildAttributeObject(int nRowIndex, int nColumnIndex = 0);
35 
36 public:
37  virtual void Cleanup();
39  #define MAX_NUM_SUBTILE 4
40  CTerrainTile* m_subtiles[MAX_NUM_SUBTILE];
41 
43  ObjectRefArray_type m_listSolidObj;
46  ObjectRefArray_type m_listFreespace;
48  VisitorList_type m_listVisitors;
50  map<string, CBaseObject*> m_namemap;
52 
54  float m_fX, m_fY;
56  float m_fRadius;
57 public:
59  void GetPosition(Vector3 *pV);
60  bool TestCollisionSphere(const Vector3* pvCenter, FLOAT radius);
61  bool TestCollisionObject(CBaseObject* pObj);
62  float GetSphereCollisionDepth(Vector3* pvCenter, FLOAT radius, bool bSolveDepth = false);
64 
65  int GetSubTileIndexByPoint(FLOAT fAbsoluteX, FLOAT fAbsoluteY);
75  int GetChildTileIndexByRect(FLOAT fAbsoluteX, FLOAT fAbsoluteY, FLOAT fWidth, FLOAT fHeight);
76  CTerrainTile* CreateSubTile(int nIndex);
86  CBaseObject* SearchObject(const char* pSearchString, int search_mode=0, int reserved = 0);
91  CBaseObject* GetObject(const string& sName);
92 
96  void DestroyObjectByName(const char* sName);
97 
105  CBaseObject* GetLocalObject(const Vector3& vPos, float fEpsilon=0.01f);
106  CBaseObject* GetLocalObject(const Vector3& vPos, const std::string& sName, float fEpsilon=0.01f);
107 
110  void AddVisitor(IGameObject* pObj, bool bCheckDuplicate= false);
112  bool RemoveVisitor(IGameObject* pObj);
113 };
114 
115 }
bool RemoveVisitor(IGameObject *pObj)
delete a visitor to the terrain tile.
Definition: TerrainTile.cpp:68
Definition: combase.h:159
float m_fX
the central position of the terrain.
Definition: TerrainTile.h:54
CTerrainTile()
2009.8.26: if defined, we will attach mesh object to the most suitable terrain tile if not defined...
Definition: TerrainTile.cpp:30
CBaseObject * GetLocalObject(const Vector3 &vPos, float fEpsilon=0.01f)
get the first local object,whose position is very close to vPos.
Definition: TerrainTile.cpp:389
void AddVisitor(IGameObject *pObj, bool bCheckDuplicate=false)
add a new visitor to the terrain tile.
Definition: TerrainTile.cpp:49
void GetPosition(Vector3 *pV)
get object position in the world space
Definition: TerrainTile.cpp:152
different physics engine has different winding order.
Definition: EventBinding.h:32
int GetSubTileIndexByPoint(FLOAT fAbsoluteX, FLOAT fAbsoluteY)
desc: get the sub tile index which best tells the position of point given sub tile and its locations...
Definition: TerrainTile.cpp:230
CTerrainTile * CreateSubTile(int nIndex)
nIndex: which tile to get. If the tile is blank, we will create it.
Definition: TerrainTile.cpp:307
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
bool TestCollisionObject(CBaseObject *pObj)
desc: test if the object collide with this object in the world view.
Definition: TerrainTile.cpp:213
bool TestCollisionSphere(const Vector3 *pvCenter, FLOAT radius)
Definition: TerrainTile.cpp:159
virtual IAttributeFields * GetChildAttributeObject(const std::string &sName)
get attribute by child object.
Definition: TerrainTile.cpp:428
CBaseObject * SearchObject(const char *pSearchString, int search_mode=0, int reserved=0)
find a object by its name.
Definition: TerrainTile.cpp:128
CBaseObject * GetObject(const string &sName)
get the object by its name.
Definition: TerrainTile.cpp:120
VisitorList_type m_listVisitors
mobile game objects that is moving in this region
Definition: TerrainTile.h:48
this is an interface class for game objects, such as NPC, OPC and players.
Definition: IGameObject.h:15
float m_fRadius
the radius of the entire terrain (half the length of the square terrain).
Definition: TerrainTile.h:56
a tile in the latticed terrain class
Definition: TerrainTile.h:21
map< string, CBaseObject * > m_namemap
global name mapping.
Definition: TerrainTile.h:50
A common interface for all classes implementing IAttributeFields By implementing this class&#39;s virtual...
Definition: IAttributeFields.h:59
virtual int GetChildAttributeColumnCount()
we support multi-dimensional child object.
Definition: TerrainTile.cpp:467
int GetChildTileIndexByRect(FLOAT fAbsoluteX, FLOAT fAbsoluteY, FLOAT fWidth, FLOAT fHeight)
return the indice of child tiles which contain or intersect with a rectangular.
Definition: TerrainTile.cpp:247
virtual int GetChildAttributeObjectCount(int nColumnIndex=0)
get the number of child objects (row count) in the given column.
Definition: TerrainTile.cpp:456
Defines the base class of all scene elements:CBaseObject for Parallel World Engine.
Definition: BaseObject.h:230
float GetObjectCollisionDepth(CBaseObject *pObj)
desc: test if the circle in the y=0 plane collide with this object in the world view Note: radius can...
Definition: TerrainTile.cpp:200
void DestroyObjectByName(const char *sName)
destroy an object by its name.
Definition: TerrainTile.cpp:104
ObjectRefArray_type m_listSolidObj
solid objects list. Mobile objects might collide with this kind of objects
Definition: TerrainTile.h:43
ObjectRefArray_type m_listFreespace
Free space objects list, might contains a rendering hierarchy.
Definition: TerrainTile.h:46