My Project
Public Member Functions | Public Attributes | List of all members
ParaEngine::CTerrainTile Class Reference

a tile in the latticed terrain class More...

#include <TerrainTile.h>

Inheritance diagram for ParaEngine::CTerrainTile:
ParaEngine::IAttributeFields ParaEngine::IObject ParaEngine::CRefCounted ParaEngine::CTerrainTileRoot

Public Member Functions

 CTerrainTile ()
 2009.8.26: if defined, we will attach mesh object to the most suitable terrain tile if not defined, we will always attach mesh object to the leaf terrain tile. More...
 
 CTerrainTile (float x, float y, float r)
 
 ATTRIBUTE_DEFINE_CLASS (CTerrainTile)
 
virtual IAttributeFieldsGetChildAttributeObject (const std::string &sName)
 get attribute by child object. More...
 
virtual int GetChildAttributeObjectCount (int nColumnIndex=0)
 get the number of child objects (row count) in the given column. More...
 
virtual int GetChildAttributeColumnCount ()
 we support multi-dimensional child object. More...
 
virtual IAttributeFieldsGetChildAttributeObject (int nRowIndex, int nColumnIndex=0)
 
virtual void Cleanup ()
 
void GetPosition (Vector3 *pV)
 get object position in the world space
 
bool TestCollisionSphere (const Vector3 *pvCenter, FLOAT radius)
 
bool TestCollisionObject (CBaseObject *pObj)
 desc: test if the object collide with this object in the world view. More...
 
float GetSphereCollisionDepth (Vector3 *pvCenter, FLOAT radius, bool bSolveDepth=false)
 
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 be zero. More...
 
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. More...
 
int GetChildTileIndexByRect (FLOAT fAbsoluteX, FLOAT fAbsoluteY, FLOAT fWidth, FLOAT fHeight)
 return the indice of child tiles which contain or intersect with a rectangular. More...
 
CTerrainTileCreateSubTile (int nIndex)
 nIndex: which tile to get. If the tile is blank, we will create it. More...
 
CBaseObjectSearchObject (const char *pSearchString, int search_mode=0, int reserved=0)
 find a object by its name. More...
 
CBaseObjectGetObject (const string &sName)
 get the object by its name. More...
 
void DestroyObjectByName (const char *sName)
 destroy an object by its name. More...
 
CBaseObjectGetLocalObject (const Vector3 &vPos, float fEpsilon=0.01f)
 get the first local object,whose position is very close to vPos. More...
 
CBaseObjectGetLocalObject (const Vector3 &vPos, const std::string &sName, float fEpsilon=0.01f)
 
void AddVisitor (IGameObject *pObj, bool bCheckDuplicate=false)
 add a new visitor to the terrain tile. More...
 
bool RemoveVisitor (IGameObject *pObj)
 delete a visitor to the terrain tile. More...
 
- Public Member Functions inherited from ParaEngine::IAttributeFields
virtual int GetAttributeClassID ()
 attribute class ID should be identical, unless one knows how overriding rules work. More...
 
virtual const char * GetAttributeClassName ()
 a static string, describing the attribute class object's name
 
virtual const char * GetAttributeClassDescription ()
 a static string, describing the attribute class object
 
virtual int InstallFields (CAttributeClass *pClass, bool bOverride)
 this class should be implemented if one wants to add new attribute. More...
 
 ATTRIBUTE_METHOD1 (IAttributeFields, GetName_s, const char **)
 
 ATTRIBUTE_METHOD1 (IAttributeFields, SetName_s, const char *)
 
 ATTRIBUTE_METHOD (IAttributeFields, PrintObject_s)
 
 ATTRIBUTE_METHOD (IAttributeFields, AddRef_s)
 
 ATTRIBUTE_METHOD1 (IAttributeFields, GetRefCount_s, int *)
 
 ATTRIBUTE_METHOD1 (IAttributeFields, SetTime_s, int)
 
 ATTRIBUTE_METHOD1 (IAttributeFields, GetTime_s, int *)
 
 ATTRIBUTE_METHOD (IAttributeFields, Release_s)
 
virtual const std::string & GetIdentifier ()
 
virtual void SetIdentifier (const std::string &sID)
 
virtual bool IsModified ()
 whether some of the fields are modified.It is up to the implementation class to provide this functionality if necessary. More...
 
virtual void SetModified (bool bModified)
 set whether any field has been modified. More...
 
virtual bool ValidateFields ()
 validate all fields and return true if validation passed. More...
 
virtual string GetValidationMessage ()
 get the recent validation message due to the most recent call to ValidateFields()
 
virtual bool ResetField (int nFieldID)
 Reset the field to its initial or default value. More...
 
virtual bool InvokeEditor (int nFieldID, const std::string &sParameters)
 Invoke an (external) editor for a given field. More...
 
virtual bool AddChildAttributeObject (IAttributeFields *pChild, int nRowIndex=-1, int nColumnIndex=0)
 add child object. More...
 
virtual void * QueryObjectByName (const std::string &sObjectType)
 convert to object of a given type. More...
 
virtual void * QueryObject (int nObjectType)
 convert to object of a given type. More...
 
virtual int GetTime ()
 get the current local time in case it is animated in milli seconds frames. More...
 
virtual void SetTime (int nTime)
 
virtual CDynamicAttributeFieldGetDynamicField (const std::string &sName)
 Get a dynamic field with a given name. More...
 
virtual CDynamicAttributeFieldGetDynamicField (int nIndex)
 Get a dynamic field with a given index. More...
 
virtual const char * GetDynamicFieldNameByIndex (int nIndex)
 get field name by index
 
virtual int GetDynamicFieldCount ()
 how many dynamic field this object currently have. More...
 
virtual int SetDynamicField (const std::string &sName, const CVariable &value)
 set a dynamic field with a given name. More...
 
virtual int AddDynamicField (const std::string &sName, ATTRIBUTE_FIELDTYPE dwType)
 add dynamic field and return field index
 
virtual void RemoveAllDynamicFields ()
 remove all dynamic fields
 
virtual int SaveDynamicFieldsToString (std::string &output)
 save only text dynamic fields to fieldname = value text strings. More...
 
virtual int LoadDynamicFieldsFromString (const std::string &input)
 load only text dynamic fields from string More...
 
CAttributeClassGetAttributeClass ()
 get the main attribute class object. More...
 
void PrintObject ()
 print the content of this object to a text file at temp/doc/[ClassName].txt. More...
 
- Public Member Functions inherited from ParaEngine::IObject
virtual void Clone (IObject *obj) const
 Clone the object's contains to a pointer. More...
 
virtual IObjectClone () const
 Clone the object's contains and return a pointer to the newly created object. More...
 
virtual bool Equals (const IObject *obj) const
 Compare the object with another object. More...
 
virtual const ITypeGetType () const
 
virtual std::string ToString () const
 
WeakPtr_typeGetWeakReference ()
 get weak reference object. More...
 
virtual int ProcessObjectEvent (const ObjectEvent &event)
 this function is only used to backward compatibility of ParaObject:AddEvent() function. More...
 
- Public Member Functions inherited from ParaEngine::CRefCounted
void addref () const
 add reference count of the object. More...
 
bool delref () const
 decrease reference count of the object. More...
 
int GetRefCount () const
 get the reference count
 
virtual int Release ()
 
CRefCountedAddToAutoReleasePool ()
 addref and releases the ownership sometime soon automatically (usually at the end of the current frame). More...
 

Public Attributes

CTerrainTilem_subtiles [MAX_NUM_SUBTILE]
 
ObjectRefArray_type m_listSolidObj
 solid objects list. Mobile objects might collide with this kind of objects
 
ObjectRefArray_type m_listFreespace
 Free space objects list, might contains a rendering hierarchy. More...
 
VisitorList_type m_listVisitors
 mobile game objects that is moving in this region
 
map< string, CBaseObject * > m_namemap
 global name mapping.
 
unordered_ref_array< IAttributeFields * > m_children
 
float m_fX
 the central position of the terrain.
 
float m_fY
 
float m_fRadius
 the radius of the entire terrain (half the length of the square terrain).
 

Additional Inherited Members

- Public Types inherited from ParaEngine::IAttributeFields
typedef ParaEngine::weak_ptr< IObject, IAttributeFieldsWeakPtr_type
 
- Public Types inherited from ParaEngine::IObject
typedef ParaEngine::weak_ptr< IObjectWeakPtr_type
 
- Static Public Member Functions inherited from ParaEngine::IAttributeFields
static HRESULT GetAttributeClassID_s (IAttributeFields *cls, int *p1)
 
static HRESULT GetAttributeClassName_s (IAttributeFields *cls, const char **p1)
 
static bool OpenWithDefaultEditor (const char *sFilename, bool bWaitOnReturn=false)
 Open a given file with the default registered editor in the game engine. More...
 
- Protected Member Functions inherited from ParaEngine::IAttributeFields
virtual CAttributeClassCreateAttributeClass ()
 initialize fields
 
virtual CDynamicAttributesSetGetDynamicAttributes (bool bCreateIfNotExist=false)
 
- Protected Attributes inherited from ParaEngine::IObject
WeakPtr_type m_weak_reference
 
- Protected Attributes inherited from ParaEngine::CRefCounted
int m_refcount
 

Detailed Description

a tile in the latticed terrain class

Constructor & Destructor Documentation

§ CTerrainTile()

CTerrainTile::CTerrainTile ( )

2009.8.26: if defined, we will attach mesh object to the most suitable terrain tile if not defined, we will always attach mesh object to the leaf terrain tile.

if we load object asynchronously, the mesh size is not known when attached to scene, it is better to undeine this macro, otherwise, Find object by view object may be inconsistent. sub tile and its locations ^ Y |______

|2 |3 |

|0 |1 | -------—>x

Member Function Documentation

§ AddVisitor()

void CTerrainTile::AddVisitor ( IGameObject pObj,
bool  bCheckDuplicate = false 
)

add a new visitor to the terrain tile.

Parameters
bCheckDuplicateif true, no duplicate is allowed.

§ CreateSubTile()

CTerrainTile * CTerrainTile::CreateSubTile ( int  nIndex)

nIndex: which tile to get. If the tile is blank, we will create it.

create the tile at position nIndexs

sub tile and its locations.

^ Y |______

|2 |3 |

|0 |1 | -------—>x

§ DestroyObjectByName()

void CTerrainTile::DestroyObjectByName ( const char *  sName)

destroy an object by its name.

If there are multiple object with the same name, they will all be deleted.

Parameters
sNameexact name of the object

§ GetChildAttributeColumnCount()

int ParaEngine::CTerrainTile::GetChildAttributeColumnCount ( )
virtual

we support multi-dimensional child object.

by default objects have only one column.

Reimplemented from ParaEngine::IAttributeFields.

Reimplemented in ParaEngine::CTerrainTileRoot.

§ GetChildAttributeObject()

IAttributeFields * ParaEngine::CTerrainTile::GetChildAttributeObject ( const std::string &  sName)
virtual

get attribute by child object.

used to iterate across the attribute field hierarchy.

Reimplemented from ParaEngine::IAttributeFields.

Reimplemented in ParaEngine::CTerrainTileRoot.

§ GetChildAttributeObjectCount()

int ParaEngine::CTerrainTile::GetChildAttributeObjectCount ( int  nColumnIndex = 0)
virtual

get the number of child objects (row count) in the given column.

please note different columns can have different row count.

Reimplemented from ParaEngine::IAttributeFields.

Reimplemented in ParaEngine::CTerrainTileRoot.

§ GetChildTileIndexByRect()

int CTerrainTile::GetChildTileIndexByRect ( FLOAT  fAbsoluteX,
FLOAT  fAbsoluteY,
FLOAT  fWidth,
FLOAT  fHeight 
)

return the indice of child tiles which contain or intersect with a rectangular.

Parameters
fAbsoluteXCenter point.x of the rect.
fAbsoluteY:Centerpoint.y of the rect.
fWidththe width of the rect.
fHeight:theheight of the rect.
Returns
: a bit mask telling which child tile intersects with the rect. if (return value & (1<<nIndex))>0, then child tile of nIndex is hit by the rect

§ GetLocalObject() [1/2]

CBaseObject * CTerrainTile::GetLocalObject ( const Vector3 vPos,
float  fEpsilon = 0.01f 
)

get the first local object,whose position is very close to vPos.

This function will search for the first (local mesh) object throughout the hierachy of the scene. this function is kind of slow, please do not call on a per frame basis. Use GetObjectByViewBox() to get an object faster.

Parameters
vPosworld position of the local mesh object
fEpsilonif a mesh is close enough to vPos within this value.
Returns
: NULL if not found

search for free space objects

§ GetLocalObject() [2/2]

CBaseObject * ParaEngine::CTerrainTile::GetLocalObject ( const Vector3 vPos,
const std::string &  sName,
float  fEpsilon = 0.01f 
)

search for free space objects

§ GetObject()

CBaseObject * CTerrainTile::GetObject ( const string &  sName)

get the object by its name.

If there have been several objects with the same name, the most recently attached object is returned.

Parameters
sNameexact name of the object

§ GetObjectCollisionDepth()

float CTerrainTile::GetObjectCollisionDepth ( CBaseObject pObj)

desc: test if the circle in the y=0 plane collide with this object in the world view Note: radius can be zero.

We assume that test is done in the y=0 plane only

§ GetSubTileIndexByPoint()

int CTerrainTile::GetSubTileIndexByPoint ( FLOAT  fAbsoluteX,
FLOAT  fAbsoluteY 
)

desc: get the sub tile index which best tells the position of point given sub tile and its locations.

^ Y |______

|2 |3 |

|0 |1 | -------—>x

§ RemoveVisitor()

bool CTerrainTile::RemoveVisitor ( IGameObject pObj)

delete a visitor to the terrain tile.

Return true if found and removed.

§ SearchObject()

CBaseObject * CTerrainTile::SearchObject ( const char *  pSearchString,
int  search_mode = 0,
int  reserved = 0 
)

find a object by its name.

Parameters
pSearchStringthe name of the object to be searched. The name may end with "*" in which case "*" will match any character(s). e.g "Li*" will match both "LiXizhi" and "LiTC".In case there is multiple objects, the first found object is returned. "Li" will only match "Li"
search_modeThe default value is 0, which means that only global characters are searched.
reservedcurrently it must be 0

§ TestCollisionObject()

bool CTerrainTile::TestCollisionObject ( CBaseObject pObj)

desc: test if the object collide with this object in the world view.

Currently the pObj is regarded as a spheracal/circular object. mostly it's a biped object. And this object can have shape of any type.

§ TestCollisionSphere()

bool CTerrainTile::TestCollisionSphere ( const Vector3 pvCenter,
FLOAT  radius 
)

Note: I only tested x,z, I care not about the y component, which is related to object's height

Member Data Documentation

§ m_listFreespace

ObjectRefArray_type ParaEngine::CTerrainTile::m_listFreespace

Free space objects list, might contains a rendering hierarchy.

they has nothing to do with collision detection


The documentation for this class was generated from the following files: