My Project
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ParaScripting::ParaAssetObject Class Reference

it represents an asset entity. More...

#include <ParaScriptingCommon.h>

Public Member Functions

 ParaAssetObject (AssetEntity *pEntity)
 
AssetEntityGetAssetEntity ()
 
TextureEntityGetTextureEntity ()
 
bool IsValid ()
 check if the object is valid
 
bool IsLoaded ()
 most assets are loaded asynchronously. More...
 
bool equals (const ParaAssetObject obj) const
 whether the two objects are equal
 
bool Reload ()
 reload the asset from file. More...
 
void UnloadAsset ()
 unload the asset from video and system memory. More...
 
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. More...
 
void Refresh1 (const char *sFilename)
 
void Release ()
 call this function to safely release this asset. More...
 
int GetRefCount ()
 get the reference count
 
void GarbageCollectMe ()
 if its reference count is zero, unload this asset object. More...
 
string GetKeyName ()
 get the key name. More...
 
const char * GetKeyName_ ()
 this function shall never be called from the scripting interface. More...
 
string GetFileName ()
 get the file name. More...
 
const char * GetFileName_ ()
 this function shall never be called from the scripting interface. More...
 
int GetType ()
 get the asset type: enum AssetType { base=0, texture=1, mesh=2, multianimation=3, spritevertex, font, sound, mdx, parax, database, effectfile, dllplugin, }; More...
 
int SetHandle (int nHandle)
 set an integer handle to this asset. More...
 
int GetHandle ()
 Get the integer handle to this asset. More...
 
ParaAttributeObject GetAttributeObject ()
 get the attribute object associated with the current asset object, such as getting the poly count, etc
 
ParaParamBlock GetParamBlock ()
 get the parameter block. More...
 
bool Begin ()
 only applies to effect entity: begin effect
 
bool BeginPass (int nPass)
 only applies to effect entity: begin effect pass
 
void SetTexture (int nIndex, const char *filename)
 only used for effect file asset. More...
 
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. More...
 
void SetTextureFPS (float FPS)
 For animated textures. More...
 
void EnableTextureAutoAnimation (bool bEnable)
 For animated textures. More...
 
void SetCurrentFrameNumber (int nFrame)
 For animated textures. More...
 
int GetCurrentFrameNumber ()
 For animated textures. More...
 
int GetFrameCount ()
 For animated textures. More...
 
int GetWidth ()
 get the texture width More...
 
int GetHeight ()
 get the texture height More...
 
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. More...
 
int GetNumReplaceableTextures ()
 get the total number of replaceable textures, which is the largest replaceable texture ID. More...
 
ParaAssetObject GetDefaultReplaceableTexture (int ReplaceableTextureID)
 get the default replaceable texture by its ID. More...
 
void SetCallback (int callbackType, const char *func)
 

Static Public Member Functions

static TextureEntityGetTexture (const object &texture)
 static helper functions: More...
 
static TextureEntityGetTextureWithParams (const object &texture)
 

Public Attributes

AssetEntitym_pAsset
 

Detailed Description

it represents an asset entity.

Member Function Documentation

§ CommitChanges()

bool ParaScripting::ParaAssetObject::CommitChanges ( )

this apply to changes.

§ EnableTextureAutoAnimation()

void ParaAssetObject::EnableTextureAutoAnimation ( bool  bEnable)

For animated textures.

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

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

§ GarbageCollectMe()

void ParaScripting::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.

§ GetBoundingBox()

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}

§ GetCurrentFrameNumber()

int ParaAssetObject::GetCurrentFrameNumber ( )

For animated textures.

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

Returns
frame number is returned

§ GetDefaultReplaceableTexture()

ParaAssetObject ParaScripting::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
ReplaceableTextureIDusually [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.

§ GetFileName()

string ParaScripting::ParaAssetObject::GetFileName ( )

get the file name.

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

§ GetFileName_()

const char * ParaScripting::ParaAssetObject::GetFileName_ ( )

this function shall never be called from the scripting interface.

Solely used for managed exporting.

§ GetFrameCount()

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

§ GetHandle()

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).

§ GetHeight()

int ParaScripting::ParaAssetObject::GetHeight ( )

get the texture height

Returns

§ GetKeyName()

string ParaScripting::ParaAssetObject::GetKeyName ( )

get the key name.

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

§ GetKeyName_()

const char * ParaScripting::ParaAssetObject::GetKeyName_ ( )

this function shall never be called from the scripting interface.

Solely used for managed exporting.

§ GetNumReplaceableTextures()

int ParaScripting::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.

§ GetParamBlock()

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.

§ GetTexture()

TextureEntity * ParaScripting::ParaAssetObject::GetTexture ( const object texture)
static

static helper functions:

Parameters
textureit can be string or a ParaAssetObject

§ GetType()

int ParaScripting::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.

§ GetWidth()

int ParaScripting::ParaAssetObject::GetWidth ( )

get the texture width

Returns

§ IsLoaded()

bool ParaScripting::ParaAssetObject::IsLoaded ( )

most assets are loaded asynchronously.

This allows us to check if an asset is loaded. For example, we can LoadAsset() for a number of assets that need preloading. and then use a timer to check if they are initialized and remove from the uninialized list.

§ Refresh()

void ParaScripting::ParaAssetObject::Refresh ( )

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

Parameters
sFilenameif NULL or empty, the old file will be used.

§ Release()

void ParaScripting::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.

§ Reload()

bool ParaScripting::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.

§ SetCurrentFrameNumber()

void ParaAssetObject::SetCurrentFrameNumber ( int  nFrame)

For animated textures.

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

Parameters
nFrame

§ SetHandle()

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
nHandleTODO: if nHandle is -1, the system will automatically allocate a free handle for it and returned.
Returns
: handle of this asset after successful set.

§ SetTexture()

void ParaScripting::ParaAssetObject::SetTexture ( int  nIndex,
const char *  filename 
)

only used for effect file asset.

Parameters
nIndextexture stage
filenameif "", it will set to NULL

§ SetTextureFPS()

void ParaAssetObject::SetTextureFPS ( float  FPS)

For animated textures.

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

Parameters
nFPSframes per seconds. default value is 15 FPS

§ UnloadAsset()

void ParaScripting::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.


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