ParaScripting::ParaAssetObject Class Reference
[ParaAsset]

List of all members.

Detailed Description

it represents an asset entity.


Public Member Functions

 ParaAssetObject (AssetEntity *pEntity)
bool IsValid ()
 check if the object is valid
bool equals (const ParaAssetObject obj) const
 whether the two objects are equal
bool Reload ()
 reload the asset from file.
void UnloadAsset ()
 unload the asset from video and system memory.
void LoadAsset ()
 Preload the asset to video and system memory, even though there is no scene object using the object in the previous frames.
void Refresh ()
 currently, this function only takes effects on texture entity refresh this entity with a local file.
void Refresh1 (const char *sFilename)
void Release ()
 call this function to safely release this asset.
int GetRefCount ()
 get the reference count
void GarbageCollectMe ()
 if its reference count is zero, unload this asset object.
string GetKeyName ()
 get the key name.
const char * GetKeyName_ ()
 this function shall never be called from the scripting interface.
string GetFileName ()
 get the file name.
const char * GetFileName_ ()
 this function shall never be called from the scripting interface.
int GetType ()
 get the asset type: enum AssetType { base=0, texture=1, mesh=2, multianimation=3, spritevertex, font, sound, mdx, parax, database, effectfile, dllplugin, };
int SetHandle (int nHandle)
 set an integer handle to this asset.
int GetHandle ()
 Get the integer handle to this asset.
ParaParamBlock GetParamBlock ()
 get the parameter block.
bool Begin ()
 only applies to effect entity: begin effect
bool BeginPass (int nPass)
 only applies to effect entity: begin effect pass
bool EndPass ()
 only applies to effect entity: end effect pass
bool End ()
 only applies to effect entity: end effect
bool CommitChanges ()
 this apply to changes.
void SetTextureFPS (float FPS)
 For animated textures.
void EnableTextureAutoAnimation (bool bEnable)
 For animated textures.
void SetCurrentFrameNumber (int nFrame)
 For animated textures.
int GetCurrentFrameNumber ()
 For animated textures.
int GetFrameCount ()
 For animated textures.
int GetWidth ()
 get the texture width
int GetHeight ()
 get the texture height
void SetSize (int nWidth, int nHeight)
 set the texture info (size) of the asset
object GetBoundingBox (const object &box)
 get the bounding box (AABB) of the mesh or parax entity in object space.
int GetNumReplaceableTextures ()
 get the total number of replaceable textures, which is the largest replaceable texture ID.
ParaAssetObject GetDefaultReplaceableTexture (int ReplaceableTextureID)
 get the default replaceable texture by its ID.

Public Attributes

AssetEntity * m_pAsset


Member Function Documentation

bool ParaAssetObject::Reload (  ) 

reload the asset from file.

Please note that for scene nodes which are currently using the asset entities, they are not automatically updated. For example, the physics which depends on a mesh entity, will not be automatically updated, once the mesh entity is reloaded. This function is almost solely used for debugging.

Returns:
: return true if the mesh is updated.

void ParaAssetObject::UnloadAsset (  ) 

unload the asset from video and system memory.

This is usually used for animated or one time texture entity. Please note, asset is unloaded, but can still be used by other scene objects.The use of an unloaded object will cause the object to be loaded again.

void ParaAssetObject::Refresh (  ) 

currently, this function only takes effects on texture entity refresh this entity with a local file.

Parameters:
sFilename,: if NULL or empty, the old file will be used.

void ParaAssetObject::Release (  ) 

call this function to safely release this asset.

If there is no further reference to this object, it will actually delete itself (with "delete this"). So never keep a pointer to this class after you have released it. A macro like SAFE_RELEASE() is advised to be used.

void ParaAssetObject::GarbageCollectMe (  ) 

if its reference count is zero, unload this asset object.

any reference holder of this object can call this function to free its resources, if they believe that it will not be needed for quite some time in future.

string ParaAssetObject::GetKeyName (  ) 

get the key name.

this is usually the file name of the entity. return "" if it is not valid.

const char * ParaAssetObject::GetKeyName_ (  ) 

this function shall never be called from the scripting interface.

Solely used for managed exporting.

string ParaAssetObject::GetFileName (  ) 

get the file name.

this is always the file name of the entity. return "" if it is not valid.

const char * ParaAssetObject::GetFileName_ (  ) 

this function shall never be called from the scripting interface.

Solely used for managed exporting.

int ParaAssetObject::GetType (  ) 

get the asset type: enum AssetType { base=0, texture=1, mesh=2, multianimation=3, spritevertex, font, sound, mdx, parax, database, effectfile, dllplugin, };

Returns:
-1 is returned, if the asset is invalid.

int ParaScripting::ParaAssetObject::SetHandle ( int  nHandle  ) 

set an integer handle to this asset.

This is usually used by effect file asset. We can later assign mesh's primary technique handler using this value. please note that handles are not automatically created for most custom asset, one needs to manually create one. call this function multiple times with different handle, will associate the same asset with multiple handles.

Parameters:
nHandle,: TODO: if nHandle is -1, the system will automatically allocate a free handle for it and returned.
Returns:
: handle of this asset after successful set.

int ParaScripting::ParaAssetObject::GetHandle (  ) 

Get the integer handle to this asset.

if there are multiple handles, the first (smallest) handle is returned. if handle is not available. it will return -1 (INVALID handle).

ParaScripting::ParaParamBlock ParaScripting::ParaAssetObject::GetParamBlock (  ) 

get the parameter block.

currently only effect and mesh entity file asset has effect param block. Currently the effect parameters can be set via ParaParamBlock interface from the scripting interface. we offer three levels of effect parameters: per effect file, per asset file, per mesh object. Effect parameters are also applied in that order. e.g. per effect file affects all object rendering with the effect file; per asset file affects all objects that use the mesh asset file; per mesh object affects only the mesh object.

bool ParaScripting::ParaAssetObject::CommitChanges (  ) 

this apply to changes.

void ParaAssetObject::SetTextureFPS ( float  FPS  ) 

For animated textures.

set the FPS for animation textures. this provides a short cut to animated textures

Parameters:
nFPS frames per seconds. default value is 15 FPS

void ParaAssetObject::EnableTextureAutoAnimation ( bool  bEnable  ) 

For animated textures.

whether to enable texture animation. this provides a short cut to animated textures

Parameters:
bEnable default value is true. Set this to false, if one wants to manually animate the texture, such as controlling from the scripting interface.

void ParaAssetObject::SetCurrentFrameNumber ( int  nFrame  ) 

For animated textures.

set the current frame number. this provides a short cut to animated textures

Parameters:
nFrame 

int ParaAssetObject::GetCurrentFrameNumber (  ) 

For animated textures.

Get the current frame number. this provides a short cut to animated textures

Returns:
frame number is returned

int ParaAssetObject::GetFrameCount (  ) 

For animated textures.

Get the total frames in the animated texture. this provides a short cut to animated textures

Returns:
frame number is returned

int ParaScripting::ParaAssetObject::GetWidth (  ) 

get the texture width

Returns:

int ParaScripting::ParaAssetObject::GetHeight (  ) 

get the texture height

Returns:

object ParaScripting::ParaAssetObject::GetBoundingBox ( const object &  box  ) 

get the bounding box (AABB) of the mesh or parax entity in object space.

This function returns nothing if asset is not mesh or character entity.

Parameters:
box,: [in|out] a script table to receive the output. in the format: {min_x, min_y, min_z, max_x, max_y, max_z}

int ParaAssetObject::GetNumReplaceableTextures (  ) 

get the total number of replaceable textures, which is the largest replaceable texture ID.

but it does not mean that all ID contains valid replaceable textures. This function can be used to quickly decide whether the model contains replaceable textures. Generally we allow 32 replaceable textures per model.

Returns:
0 may be returned if no replaceable texture is used by the model.

ParaAssetObject ParaAssetObject::GetDefaultReplaceableTexture ( int  ReplaceableTextureID  ) 

get the default replaceable texture by its ID.

The default replaceable texture is the main texture exported from the 3dsmax exporter.

Parameters:
ReplaceableTextureID usually [0-32) generally speaking, replaceable ID 0 is used for general purpose replaceable texture, ID 1 is for user defined. ID 2 is for custom skins.
Returns:
this may return invalid asset, if replaceable texture is not set before or ID is invalid.


Generated on Mon Dec 1 14:34:44 2008 for NPL Scripting Reference for ParaEngine by  doxygen 1.5.2