My Project
|
the root of the quad-tree terrain tiles. More...
#include <TerrainTileRoot.h>
Public Types | |
enum | DIRECTION { DIR_SOUTHWEST = 0, DIR_SOUTH = 1, DIR_SOUTHEAST = 2, DIR_WEST = 3, DIR_CENTER = 4, DIR_EAST = 5, DIR_NORTHWEST = 6, DIR_NORTH = 7, DIR_NORTHEAST = 8, DIR_INVALID = 9 } |
These values are used by Terrain TILE. More... | |
![]() | |
typedef ParaEngine::weak_ptr< IObject, IAttributeFields > | WeakPtr_type |
![]() | |
typedef ParaEngine::weak_ptr< IObject > | WeakPtr_type |
Public Member Functions | |
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 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 | ResetTerrain (float fRadius, int nDepth) |
Reset Terrain. | |
CTerrainTile * | GetAdjacentTile (CTerrainTile *pTile, DIRECTION nDirection) |
get any of the 9 adjacent tile of pTile. More... | |
CTerrainTile * | GetAdjacentTile (const Vector3 &vPos, DIRECTION nDirection, float fRadius=0.f) |
get any of the 9 adjacent tiles of a given point. More... | |
CTerrainTile * | AttachLocalObject (CBaseObject *obj) |
attach object to the proper tile that tells most exactly where it is if the object is already in the tile, it will be attached twice.So it is the caller's responsibility to check for duplicate calls to this function for the same object. More... | |
CTerrainTile * | AttachGlobalObject (CBaseObject *obj) |
the object will be attached to the root tile as solid object. More... | |
bool | DetachObject (CBaseObject *pObject) |
detach the object from the tile or its sub tiles. More... | |
CTerrainTile * | GetTileByPoint (float fAbsoluteX, float fAbsoluteY) |
get existing smallest tile that contains the given point More... | |
CTerrainTile * | GetTileByRect (float fAbsoluteX, float fAbsoluteY, float fPtWidth, float fPtHeight) |
get existing smallest tile that contains the given rect More... | |
CBaseObject * | GetGlobalObject (const string &sName) |
get the global object by its name. More... | |
CBaseObject * | GetLocalObject (const string &sName, const Vector3 &vPos, DWORD dwFlag=3) |
Get an object. 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) |
CBaseObject * | GetObjectByViewBox (const CShapeAABB &viewbox) |
get an object(usually a static mesh object) by a given view box. More... | |
![]() | |
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) | |
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 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... | |
Additional Inherited Members | |
![]() | |
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... | |
![]() | |
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). | |
![]() | |
virtual CAttributeClass * | CreateAttributeClass () |
initialize fields | |
virtual CDynamicAttributesSet * | GetDynamicAttributes (bool bCreateIfNotExist=false) |
![]() | |
WeakPtr_type | m_weak_reference |
![]() | |
int | m_refcount |
the root of the quad-tree terrain tiles.
When Tile Object is attached to the scene, they are automatically attached to this quad-tree. Once attached, a strong reference of the object is kept, once detached, object will be added to the auto release pool, which will be deleted some time in the next frame if reference count is zero.
These values are used by Terrain TILE.
CTerrainTile * CTerrainTileRoot::AttachGlobalObject | ( | CBaseObject * | obj | ) |
the object will be attached to the root tile as solid object.
global objects can be retrieved very fast by its name.
CTerrainTile * CTerrainTileRoot::AttachLocalObject | ( | CBaseObject * | obj | ) |
attach object to the proper tile that tells most exactly where it is if the object is already in the tile, it will be attached twice.So it is the caller's responsibility to check for duplicate calls to this function for the same object.
bool CTerrainTileRoot::DetachObject | ( | CBaseObject * | pObject | ) |
detach the object from the tile or its sub tiles.
it will not be found. the function will return once the first matching object is found and detached
pObject | the object to be detached. |
CTerrainTile * CTerrainTileRoot::GetAdjacentTile | ( | CTerrainTile * | pTile, |
DIRECTION | nDirection | ||
) |
get any of the 9 adjacent tile of pTile.
nDirection | number 0-8, |
CTerrainTile * CTerrainTileRoot::GetAdjacentTile | ( | const Vector3 & | vPos, |
DIRECTION | nDirection, | ||
float | fRadius = 0.f |
||
) |
get any of the 9 adjacent tiles of a given point.
vPos | the position centered at which the 9 adjacent tiles are queried.Please note that only x,z component is used. y is ignored. |
nDirection | number 0-8, |
fRadius | radius of the adjacent region. If this is 0 or negative, the smallest quad tree size will be used. |
|
inlinevirtual |
attribute class ID should be identical, unless one knows how overriding rules work.
Reimplemented from ParaEngine::IAttributeFields.
|
virtual |
we support multi-dimensional child object.
by default objects have only one column.
Reimplemented from ParaEngine::CTerrainTile.
|
virtual |
get attribute by child object.
used to iterate across the attribute field hierarchy.
Reimplemented from ParaEngine::CTerrainTile.
|
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::CTerrainTile.
CBaseObject * CTerrainTileRoot::GetGlobalObject | ( | const string & | sName | ) |
get the global 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 |
CBaseObject * CTerrainTileRoot::GetLocalObject | ( | const string & | sName, |
const Vector3 & | vPos, | ||
DWORD | dwFlag = 3 |
||
) |
Get an object.
Call this function to see if object with a given identifier is already attached.
sName | name of the object, if this is "", the function always returns NULL |
vPos | the location to search for the object. |
dwFlag | : [reserved] a value specifying the search range:
|
CBaseObject * CTerrainTileRoot::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. |
CBaseObject * CTerrainTileRoot::GetObjectByViewBox | ( | const CShapeAABB & | viewbox | ) |
get an object(usually a static mesh object) by a given view box.
viewbox | One can get the view box by getting the view culling object. see example in the ParaObject:GetViewBox(). |
search for free space objects
CTerrainTile * CTerrainTileRoot::GetTileByPoint | ( | float | fAbsoluteX, |
float | fAbsoluteY | ||
) |
get existing smallest tile that contains the given point
fAbsoluteX | |
fAbsoluteY |
CTerrainTile * CTerrainTileRoot::GetTileByRect | ( | float | fAbsoluteX, |
float | fAbsoluteY, | ||
float | fPtWidth, | ||
float | fPtHeight | ||
) |
get existing smallest tile that contains the given rect
fAbsoluteX | |
fAbsoluteY | |
fPtWidth | |
fPtHeight |