My Project
|
a tile in the latticed terrain class More...
#include <TerrainTile.h>
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 IAttributeFields * | GetChildAttributeObject (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 IAttributeFields * | GetChildAttributeObject (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... | |
CTerrainTile * | CreateSubTile (int nIndex) |
nIndex: which tile to get. If the tile is blank, we will create it. More... | |
CBaseObject * | SearchObject (const char *pSearchString, int search_mode=0, int reserved=0) |
find a object by its name. More... | |
CBaseObject * | GetObject (const string &sName) |
get the object by its name. More... | |
void | DestroyObjectByName (const char *sName) |
destroy an object by its name. More... | |
CBaseObject * | GetLocalObject (const Vector3 &vPos, float fEpsilon=0.01f) |
get the first local object,whose position is very close to vPos. More... | |
CBaseObject * | GetLocalObject (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... | |
![]() | |
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 CDynamicAttributeField * | GetDynamicField (const std::string &sName) |
Get a dynamic field with a given name. More... | |
virtual CDynamicAttributeField * | GetDynamicField (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... | |
CAttributeClass * | GetAttributeClass () |
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... | |
![]() | |
virtual void | Clone (IObject *obj) const |
Clone the object's contains to a pointer. More... | |
virtual IObject * | Clone () 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 IType * | GetType () const |
virtual std::string | ToString () const |
WeakPtr_type & | GetWeakReference () |
get weak reference object. More... | |
virtual int | ProcessObjectEvent (const ObjectEvent &event) |
this function is only used to backward compatibility of ParaObject:AddEvent() function. More... | |
![]() | |
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 () |
CRefCounted * | AddToAutoReleasePool () |
addref and releases the ownership sometime soon automatically (usually at the end of the current frame). More... | |
Public Attributes | |
CTerrainTile * | m_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 | |
![]() | |
typedef ParaEngine::weak_ptr< IObject, IAttributeFields > | WeakPtr_type |
![]() | |
typedef ParaEngine::weak_ptr< IObject > | WeakPtr_type |
![]() | |
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... | |
![]() | |
virtual CAttributeClass * | CreateAttributeClass () |
initialize fields | |
virtual CDynamicAttributesSet * | GetDynamicAttributes (bool bCreateIfNotExist=false) |
![]() | |
WeakPtr_type | m_weak_reference |
![]() | |
int | m_refcount |
a tile in the latticed terrain class
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 |______
|0 |1 | -------—>x
void CTerrainTile::AddVisitor | ( | IGameObject * | pObj, |
bool | bCheckDuplicate = false |
||
) |
add a new visitor to the terrain tile.
bCheckDuplicate | if true, no duplicate is allowed. |
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 |______
|0 |1 | -------—>x
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.
sName | exact name of the object |
|
virtual |
we support multi-dimensional child object.
by default objects have only one column.
Reimplemented from ParaEngine::IAttributeFields.
Reimplemented in ParaEngine::CTerrainTileRoot.
|
virtual |
get attribute by child object.
used to iterate across the attribute field hierarchy.
Reimplemented from ParaEngine::IAttributeFields.
Reimplemented in ParaEngine::CTerrainTileRoot.
|
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.
int CTerrainTile::GetChildTileIndexByRect | ( | FLOAT | fAbsoluteX, |
FLOAT | fAbsoluteY, | ||
FLOAT | fWidth, | ||
FLOAT | fHeight | ||
) |
return the indice of child tiles which contain or intersect with a rectangular.
fAbsoluteX | Center point.x of the rect. |
fAbsoluteY:Center | point.y of the rect. |
fWidth | the width of the rect. |
fHeight:the | height of the rect. |
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.
vPos | world position of the local mesh object |
fEpsilon | if a mesh is close enough to vPos within this value. |
search for free space objects
CBaseObject * ParaEngine::CTerrainTile::GetLocalObject | ( | const Vector3 & | vPos, |
const std::string & | sName, | ||
float | fEpsilon = 0.01f |
||
) |
search for free space objects
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.
sName | exact name of the object |
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
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 |______
|0 |1 | -------—>x
bool CTerrainTile::RemoveVisitor | ( | IGameObject * | pObj | ) |
delete a visitor to the terrain tile.
Return true if found and removed.
CBaseObject * CTerrainTile::SearchObject | ( | const char * | pSearchString, |
int | search_mode = 0 , |
||
int | reserved = 0 |
||
) |
find a object by its name.
pSearchString | the 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_mode | The default value is 0, which means that only global characters are searched. |
reserved | currently it must be 0 |
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.
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
ObjectRefArray_type ParaEngine::CTerrainTile::m_listFreespace |
Free space objects list, might contains a rendering hierarchy.
they has nothing to do with collision detection