IStatObj

Represents a static object that can be rendered in the scene, represented by the .CGF format. More...

#include

Inherits IMeshObj, and IStreamable.

Classes

struct SStatistics
Statistics information about this object. More...

Public Types

enum ELoadingFlags {
ELoadingFlagsPreviewMode = BIT(0), ELoadingFlagsForceBreakable = BIT(1), ELoadingFlagsIgnoreLoDs = BIT(2), ELoadingFlagsTessellate = BIT(3),
ELoadingFlagsJustGeometry = BIT(4)
}
Loading flags. More...

Public Member Functions

virtual void SetFlags (int nFlags)=0
virtual int GetFlags () const =0
Retrieve flags set on the static object.
virtual unsigned int GetVehicleOnlyPhysics ()=0
Retrieves the internal flag m_nVehicleOnlyPhysics.
virtual int GetIDMatBreakable ()=0
Retrieves the internal flag m_nIdMaterialBreakable.
virtual unsigned int GetBreakableByGame ()=0
Retrieves the internal flag m_bBreakableByGame.
virtual struct IIndexedMesh * GetIndexedMesh (bool bCreateIfNone=false)=0
virtual struct IIndexedMesh * CreateIndexedMesh ()=0
virtual int PhysicalizeFoliage (IPhysicalEntity *pTrunk, const Matrix34 &mtxWorld, struct IFoliage *&pRes, float lifeTime=0.0f, int iSource=0)=0
virtual IStatObj * UpdateVertices (strided_pointer< Vec3 > pVtx, strided_pointer< Vec3 > pNormals, int iVtx0, int nVtx, int *pVtxMap=0, float rscale=1.f)=0
virtual IStatObj * SkinVertices (strided_pointer< Vec3 > pSkelVtx, const Matrix34 &mtxSkelToMesh)=0
virtual void CopyFoliageData (IStatObj *pObjDst, bool bMove=false, IFoliage *pSrcFoliage=0, int *pVtxMap=0, primitives::box *pMovedBoxes=0, int nMovedBoxes=-1)=0
virtual void SetPhysGeom (phys_geometry *pPhysGeom, int nType=0)=0
virtual ITetrLattice * GetTetrLattice ()=0
Returns a tetrahedral lattice, if any (used for breakable objects)
virtual float GetAIVegetationRadius () const =0
virtual void SetAIVegetationRadius (float radius)=0
virtual void SetMaterial (IMaterial *pMaterial)=0
ILINE Vec3 GetBoxMin () const
ILINE Vec3 GetBoxMax () const
virtual const Vec3 GetVegCenter ()=0
virtual void SetBBoxMin (const Vec3 &vBBoxMin)=0
virtual void SetBBoxMax (const Vec3 &vBBoxMax)=0
virtual void Refresh (int nFlags)=0
virtual IStatObj * GetLodObject (int nLodLevel, bool bReturnNearest=false)=0
virtual void SetLodObject (int nLodLevel, IStatObj *pLod)=0
virtual IStatObj * GetLowestLod ()=0
virtual int FindNearesLoadedLOD (int nLodIn, bool bSearchUp=false)=0
virtual int FindHighestLOD (int nBias)=0
virtual const char * GetFilePath ()=0
virtual void SetFilePath (const char *szFileName)=0
virtual const char * GetGeoName ()=0
virtual void SetGeoName (const char *szGeoName)=0
Sets the name of the geometry.
virtual bool IsSameObject (const char *szFileName, const char *szGeomName)=0
virtual Vec3 GetHelperPos (const char *szHelperName)=0
virtual const Matrix34 & GetHelperTM (const char *szHelperName)=0
Gets the transformation matrix of a specified helper, see GetHelperPos.
virtual bool IsDefaultObject ()=0
Tell us if the object is not found.
virtual void FreeIndexedMesh ()=0
Free the geometry data.
virtual void GetMemoryUsage (class ICrySizer *pSizer) const =0
Pushes the underlying tree of objects into the given Sizer object for statistics gathering.
virtual float GetRadiusVert () const =0
Used for sprites.
virtual float GetRadiusHors () const =0
Used for sprites.
virtual bool IsPhysicsExist () const =0
Determines if the object has physics capabilities.
virtual struct IStatObj * GetIStatObj ()
virtual void Invalidate (bool bPhysics=false, float tolerance=0.05f)=0
virtual int GetSubObjectCount () const =0
Retrieve number of sub-objects.
virtual void SetSubObjectCount (int nCount)=0
Sets number of sub-objects.
virtual IStatObj::SSubObject * GetSubObject (int nIndex)=0
Retrieve sub object by index, where 0 <= nIndex < GetSubObjectCount()
virtual bool IsSubObject () const =0
Check if this object is sub object of another IStatObj.
virtual IStatObj * GetParentObject () const =0
Retrieve parent static object, only relevant when this IStatObj is Sub-object.
virtual IStatObj * GetCloneSourceObject () const =0
Retrieve the static object, from which this one was cloned (if that is the case)
virtual IStatObj::SSubObject * FindSubObject (const char *sNodeName)=0
Find sub-pbject by name.
virtual IStatObj::SSubObject * FindSubObject_CGA (const char *sNodeName)=0
Find sub-object by name (including spaces, comma and semi-colon.
virtual IStatObj::SSubObject * FindSubObject_StrStr (const char *sNodeName)=0
Find object by full name (use all the characters)
virtual bool RemoveSubObject (int nIndex)=0
Remove Sub-Object.
virtual bool CopySubObject (int nToIndex, IStatObj *pFromObj, int nFromIndex)=0
Copy Sub-Object.
virtual IStatObj::SSubObject & AddSubObject (IStatObj *pStatObj)=0
Adds a new sub object.
virtual int PhysicalizeSubobjects (IPhysicalEntity *pent, const Matrix34 *pMtx, float mass, float density=0.0f, int id0=0, strided_pointer< int > pJointsIdMap=0, const char *szPropsOverride=0, int idbodyArtic=-1)=0
Adds subobjects to pent, meshes as parts, joint helpers as breakable joints.
virtual int Physicalize (IPhysicalEntity *pent, pe_geomparams *pgp, int id=-1, const char *szPropsOverride=0)=0
virtual bool IsDeformable ()=0
virtual bool SaveToCGF (const char *sFilename, IChunkFile **pOutChunkFile=NULL, bool bHavePhysicalProxy=false)=0
virtual IStatObj * Clone (bool bCloneGeometry, bool bCloneChildren, bool bMeshesOnly)=0
Clones static geometry, Makes an exact copy of the Static object and the contained geometry.
virtual int SetDeformationMorphTarget (IStatObj *pDeformed)=0
virtual IStatObj * DeformMorph (const Vec3 &pt, float r, float strength, IRenderMesh *pWeights=0)=0
virtual IStatObj * HideFoliage ()=0
hides all non-physicalized geometry, clones the object if necessary
virtual int Serialize (TSerialize ser)=0
Serialize the StatObj's mesh into a stream.
virtual const char * GetProperties ()=0
Get object properties as loaded from CGF.
virtual void SetProperties (const char *)=0
Update object properties.
virtual bool GetPhysicalProperties (float &mass, float &density)=0
Get physical properties specified for object.
virtual IStatObj * GetLastBooleanOp (float &scale)=0
Return the last B operand for this object as A, along with its relative scale.
virtual bool RayIntersection (SRayHitInfo &hitInfo, IMaterial *pCustomMtl=0)=0
virtual bool LineSegIntersection (const Lineseg &lineSeg, Vec3 &hitPos, int &surfaceTypeId)=0
virtual void DebugDraw (const struct SGeometryDebugDrawInfo &info)=0
virtual void GetStatistics (SStatistics &stats)=0
Fill statistics about the level.
virtual hidemask GetInitialHideMask ()=0
Returns initial hide mask.
virtual void SetStreamingDependencyFilePath (const char *szFileName)=0
Set the filename of the mesh of the next state (for example damaged version).
virtual int ComputeLodFromScale (float fScale, float fLodRatioNormalized, float fEntDistance, bool bFoliage, bool bForPrecache)=0
Expose the computelod function from the engine.
virtual SMeshLodInfo ComputeGeometricMean () const =0
virtual float GetLodDistance () const =0
Return the distance for the first LOD switch. Used for brushes and vegetation.
virtual Vec3 GetDepthSortOffset () const =0
Return the additional local-space offset used when depth sorting rendered objects.
- Public Member Functions inherited from IStreamable
bool UpdateStreamingPrioriryLowLevel (float fImportance, int nRoundId, bool bFullUpdate)
virtual void StartStreaming (bool bFinishNow, IReadStream_AutoPtr *ppStream)=0
virtual int GetStreamableContentMemoryUsage (bool bJustForDebug=false)=0
virtual void ReleaseStreamableContent ()=0
virtual void GetStreamableName (string &sName)=0
virtual uint32 GetLastDrawMainFrameId ()=0
virtual bool IsUnloadable () const =0

Additional Inherited Members

- Public Attributes inherited from IStreamable
SInstancePriorityInfo m_arrUpdateStreamingPrioriryRoundInfo [2]
float fCurImportance
EFileStreamingStatus m_eStreamingStatus
uint32 m_nSelectedFrameId: 31
uint32 m_nStatsInUse: 1

Detailed Description

Represents a static object that can be rendered in the scene, represented by the .CGF format.

Member Enumeration Documentation

◆ ELoadingFlags

Loading flags.

Enumerator
ELoadingFlagsTessellate

If e_StatObjTessellation enabled.

ELoadingFlagsJustGeometry

For streaming, to avoid parsing all chunks.

Member Function Documentation

◆ CopyFoliageData()

virtual void IStatObj::CopyFoliageData ( IStatObj * pObjDst,
bool bMove = false,
IFoliage * pSrcFoliage = 0,
int * pVtxMap = 0,
primitives::box * pMovedBoxes = 0,
int nMovedBoxes = -1
)
pure virtual

Copies foliage data to another statobj

Parameters
pObjDstTarget stat obj.
bMovetrue if the data needs to be removed from the original statobj.

◆ CreateIndexedMesh()

virtual struct IIndexedMesh* IStatObj::CreateIndexedMesh ( )
pure virtual

Create an empty indexed mesh ready to be filled with data. If an indexed mesh already exists it is returned

Returns
An empty indexed mesh or the existing indexed mesh

◆ DebugDraw()

virtual void IStatObj::DebugDraw ( const struct SGeometryDebugDrawInfo & info)
pure virtual

Debug Draw this static object.

Parameters
nFlags- bit0 no culling, bit1 - not draw lines.

◆ DeformMorph()

virtual IStatObj* IStatObj::DeformMorph ( const Vec3 & pt,
float r,
float strength,
IRenderMesh * pWeights = 0
)
pure virtual

Change the weights of the deformation morphing according to point, radius, and strength. If the object is a compound object, updates the weights of its subobjects that have deformation morphs. Clones the object if necessary, otherwise updates the weights passed as a pWeights param

Note
radius==0 updates all weights of all vertices.

◆ GetFilePath()

virtual const char* IStatObj::GetFilePath ( )
pure virtual

Returns the filename of the object.

Returns
Null-terminated string which contain the filename of the object.

◆ GetGeoName()

virtual const char* IStatObj::GetGeoName ( )
pure virtual

Returns the name of the geometry.

Returns
Null terminated string which contains the name of the geometry

◆ GetHelperPos()

virtual Vec3 IStatObj::GetHelperPos ( const char * szHelperName)
pure virtual

Gets the position of a specified helper. Will return the position of the helper named in the argument. The helper should have been specified during the exporting process of the cgf file.

Parameters
szHelperNameA null terminated string holding the name of the helper.
Returns
A Vec3 object which contains the position.

◆ GetIndexedMesh()

virtual struct IIndexedMesh* IStatObj::GetIndexedMesh ( bool bCreateIfNone = false)
pure virtual

Get the object source geometry. Provide access to the faces, vertices, texture coordinates, normals and colors of the object used later for CRenderMesh construction.

◆ GetIStatObj()

virtual struct IStatObj* IStatObj::GetIStatObj ( )
inline
virtual

Return a pointer to the object.

Returns
Pointer to the current object, which is simply done like this "return this;"

◆ GetLodObject()

virtual IStatObj* IStatObj::GetLodObject ( int nLodLevel,
bool bReturnNearest = false
)
pure virtual

Get the LOD object, if present.

Parameters
nLodLevelLevel of the LOD.
bReturnNearestIf true will return nearest available LOD to nLodLevel.
Returns
Static object with the desired LOD. The value NULL will be return if there isn't any LOD object for the level requested.

◆ GetVegCenter()

virtual const Vec3 IStatObj::GetVegCenter ( )
pure virtual

Get the center of bounding box.

Returns
Vec3 object containing the bounding box center.

◆ Invalidate()

virtual void IStatObj::Invalidate ( bool bPhysics = false,
float tolerance = 0.05f
)
pure virtual

Invalidate geometry inside IStatObj, will mark hosted IIndexedMesh as invalid.

Parameters
bPhysicsIf true will also recreate physics for indexed mesh.

◆ IsSameObject()

virtual bool IStatObj::IsSameObject ( const char * szFileName,
const char * szGeomName
)
pure virtual

Compares if another object is the same.

Parameters
szFileNameFilename of the object to compare.
szGeomNameGeometry name of the object to compare (optional).
Returns
true if both object are the same, false otherwise.

◆ LineSegIntersection()

virtual bool IStatObj::LineSegIntersection ( const Lineseg & lineSeg,
Vec3 & hitPos,
int & surfaceTypeId
)
pure virtual

Intersect lineseg with static object. Works on dedi server as well. Lineseg must be in object local space. Returns the hit position and the surface type id of the point hit.

◆ Physicalize()

virtual int IStatObj::Physicalize ( IPhysicalEntity * pent,
pe_geomparams * pgp,
int id = -1,
const char * szPropsOverride = 0
)
pure virtual

Adds all phys geometries to pent, assigns ids starting from id; takes mass and density from the StatObj properties if not set in pgp. id == -1 means that compound objects will use the 0th level in the id space (i.e. slot#==phys id), and simple objects will let the physics allocate an id for compound objects calls PhysicalizeSubobjects if >=0, idbodyArtic sets it for all parts as idbody, otherwise idbody is set to each node's phys part id

Returns
Physical id of the last physicalized part

◆ PhysicalizeFoliage()

virtual int IStatObj::PhysicalizeFoliage ( IPhysicalEntity * pTrunk,
const Matrix34 & mtxWorld,
struct IFoliage *& pRes,
float lifeTime = 0.0f,
int iSource = 0
)
pure virtual

Physicalizes StatObj's foliage Creates a skinnable object instance for foliage simulation

Parameters
pTrunkExisting physical entity of the trunk (foliage gets attached to it).
mtxWorldIts world matrix.
pResDestination pointer (if the object is deleted after timeouting, it will write 0 there).
lifeTimeIdle time after which the object gets deleted.
Returns
Number of physicalized leaves

◆ RayIntersection()

virtual bool IStatObj::RayIntersection ( SRayHitInfo & hitInfo,
IMaterial * pCustomMtl = 0
)
pure virtual

Intersect ray with static object. Ray must be in object local space.

◆ Refresh()

virtual void IStatObj::Refresh ( int nFlags)
pure virtual

Reloads one or more component of the object. The possible flags are FRO_SHADERS, FRO_TEXTURES and FRO_GEOMETRY.

Parameters
nFlagsOne or more flag which indicate which element of the object to reload.

◆ SaveToCGF()

virtual bool IStatObj::SaveToCGF ( const char * sFilename,
IChunkFile ** pOutChunkFile = NULL,
bool bHavePhysicalProxy = false
)
pure virtual

Save contents of static object to the CGF file. Save object to the CGF file.

Parameters
sFilename
Filename of the CGF file. The function fails if pOutChunkFile is NULL and the path to the file does not exist on the drive. You can call CFileUtil::CreatePath() before SaveToCGF() call to create all folders that do not exist yet.
Parameters
pOutChunkFile
Optional output parameter. If it is specified then the file will not be written to the drive but instead the function returns a pointer to the IChunkFile interface with filled CGF chunks. Caller of the function is responsible to call Release method of IChunkFile to release it later.

◆ SetBBoxMax()

virtual void IStatObj::SetBBoxMax ( const Vec3 & vBBoxMax)
pure virtual

Set the minimum bounding box component.

Parameters
vBBoxMaxMinimum bounding box component.

◆ SetBBoxMin()

virtual void IStatObj::SetBBoxMin ( const Vec3 & vBBoxMin)
pure virtual

Set the minimum bounding box component.

Parameters
vBBoxMinMinimum bounding box component.

◆ SetDeformationMorphTarget()

virtual int IStatObj::SetDeformationMorphTarget ( IStatObj * pDeformed)
pure virtual

Make sure that both objects have one-to-one vertex correspondance. Sets MorphBuddy for this object's render mesh

Returns
0 if failed (due to objects having no vertex maps most likely).

◆ SetFilePath()

virtual void IStatObj::SetFilePath ( const char * szFileName)
pure virtual

Set the filename of the object.

Parameters
szFileNameNew filename of the object.

◆ SetFlags()

virtual void IStatObj::SetFlags ( int nFlags)
pure virtual

Set static object flags.

Parameters
nFlagsFlags to set, a combination of EStaticObjectFlags values.

◆ SetMaterial()

virtual void IStatObj::SetMaterial ( IMaterial * pMaterial)
pure virtual

Set default material for the geometry.

Parameters
pMaterialValid pointer to the material.

◆ SetPhysGeom()

virtual void IStatObj::SetPhysGeom ( phys_geometry * pPhysGeom,
int nType = 0
)
pure virtual

Set the physics representation. Sets and replaces the physical representation of the object.

Parameters
pPhysGeomPointer to a phys_geometry class.
nTypePass 0 to set the physic geometry or pass 1 to set the obstruct geometry.

◆ SkinVertices()

virtual IStatObj* IStatObj::SkinVertices ( strided_pointer< Vec3 > pSkelVtx,
const Matrix34 & mtxSkelToMesh
)
pure virtual

Skins vertices based on skeleton vertices (mtxSkelToMesh[pSkelVtx[i]]). Clones the object if necessary to make the modifications

Returns
modified IStatObj (a clone or this one, if it's already a clone)

◆ UpdateVertices()

virtual IStatObj* IStatObj::UpdateVertices ( strided_pointer< Vec3 > pVtx,
strided_pointer< Vec3 > pNormals,
int iVtx0,
int nVtx,
int * pVtxMap = 0,
float rscale = 1.f
)
pure virtual

Updates vertices in the range [iVtx0..iVtx0+nVtx-1], vertices are in their original order (as they are physicalized). Clones the object if necessary to make the modifications

Returns
modified IStatObj (a clone or this one, if it's already a clone)