My Project
|
the asset manager class in ParaEngine. More...
#include <ParaWorldAsset.h>
Public Types | |
typedef boost::signals2::signal< void()> | DeviceEvent_Callback_t |
![]() | |
typedef ParaEngine::weak_ptr< IObject, IAttributeFields > | WeakPtr_type |
![]() | |
typedef ParaEngine::weak_ptr< IObject > | WeakPtr_type |
Public Member Functions | |
ATTRIBUTE_DEFINE_CLASS (CParaWorldAsset) | |
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 int | InstallFields (CAttributeClass *pClass, bool bOverride) |
this class should be implemented if one wants to add new attribute. More... | |
ATTRIBUTE_METHOD1 (CParaWorldAsset, IsAsyncLoading_s, bool *) | |
ATTRIBUTE_METHOD1 (CParaWorldAsset, SetAsyncLoading_s, bool) | |
ATTRIBUTE_METHOD1 (CParaWorldAsset, IsAssetManifestEnabled_s, bool *) | |
ATTRIBUTE_METHOD1 (CParaWorldAsset, EnableAssetManifest_s, bool) | |
ATTRIBUTE_METHOD1 (CParaWorldAsset, IsUseLocalFileFirst_s, bool *) | |
ATTRIBUTE_METHOD1 (CParaWorldAsset, SetUseLocalFileFirst_s, bool) | |
ATTRIBUTE_METHOD (CParaWorldAsset, DeleteTempDiskTextures_s) | |
TextureAssetManager & | GetTextureManager () |
CVertexBufferPoolManager & | GetVertexBufferPoolManager () |
TextureEntity * | GetTexture (const string &sIdentifier) |
TextureEntity * | GetDefaultTexture (int nTextureID) |
TextureEntity * | LoadTexture (const string &sIdentifier, const string &sTextureFileName, TextureEntity::_SurfaceType nSurfaceType=TextureEntity::StaticTexture) |
SpriteFontAssetManager & | GetFontManager () |
SpriteFontEntity * | GetFont (const string &sIdentifier) |
SpriteFontEntity * | LoadGDIFont (const string &sIdentifier, const string &pstrFont, DWORD dwSize, bool bIsBold=true) |
DatabaseAssetManager & | GetDatabaseManager () |
DatabaseEntity * | GetDatabase (const string &sIdentifier) |
DatabaseEntity * | LoadDatabase (const string &sIdentifier, const string &fileName) |
MeshEntityManager & | GetMeshManager () |
MeshEntity * | GetMesh (const string &sIdentifier) |
MeshEntity * | LoadMesh (const string &sIdentifier, const string &sMeshFileName) |
ParaXEntityManager & | GetParaXManager () |
ParaXEntity * | GetParaX (const string &sIdentifier) |
ParaXEntity * | LoadParaX (const string &sIdentifier, const string &fileName) |
ParaXEntity * | LoadParaXByID (int nAssetID) |
the asset are feched from the current model asset database. More... | |
CSequenceManager & | GetSequenceManager () |
SequenceEntity * | LoadSequence (const string &sName) |
EffectManager & | GetEffectManager () |
CEffectFile * | LoadEffectFile (const string &sIdentifier, const string &sEffectFile) |
DynamicVertexBufferEntity * | GetDynamicBuffer (DynamicVBAssetType nBufferType) |
BufferPickingManager & | GetBufferPickingManager () |
CBufferPicking * | GetBufferPick (const string &sIdentifier) |
CBufferPicking * | LoadBufferPick (const string &sIdentifier) |
bool | RefreshAsset (const char *filename) |
refresh asset if it is already loaded. More... | |
void | RenderFrameMove (float fElapsedTime) |
called before every render frame More... | |
void | LoadAsset () |
initialize all assets created so far to accelerate loading during game play. More... | |
void | UnloadAsset () |
uninitialize all assets created so far to save some memory | |
bool | UnloadAssetByKeyName (const string &keyname) |
unload a given asset by key name. More... | |
void | GarbageCollectAll () |
Garbage Collect(free resources of) all unused entity. More... | |
void | Cleanup () |
HRESULT | InitDeviceObjects () |
Desc: Initialize scene objects that has not yet been initialized. More... | |
HRESULT | RestoreDeviceObjects () |
HRESULT | InvalidateDeviceObjects () |
HRESULT | DeleteDeviceObjects () |
HRESULT | RendererRecreated () |
callback of listening the event that renderer was recreated on Android/WP8 all opengl related id has already become invalid at this time, no need to release them, just recreate them all in this function. | |
bool | DoAssetSearch (string &AssetFile, const char *searchDir) |
given a source asset, it will first see if the asset already exist. More... | |
void | CreateAttributeModel () |
expose attribute model for all asset manager types | |
bool | IsAsyncLoading () const |
whether to enable async loading for all subsequently loaded assets, such as texture, etc. More... | |
void | SetAsyncLoading (bool val) |
bool | IsAssetManifestEnabled () const |
whether to enable asset manifest files | |
void | EnableAssetManifest (bool val) |
bool | IsUseLocalFileFirst () const |
if true, asset manifest's GetFile() will return null, if a local disk or zip file is found even there is an entry in the assetmanifest. More... | |
void | SetUseLocalFileFirst (bool val) |
![]() | |
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 | |
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... | |
Static Public Member Functions | |
static CParaWorldAsset * | GetSingleton () |
![]() | |
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... | |
Protected Attributes | |
bool | m_bUseAssetSearch |
this will be set to true when the manager class is created if there is a fill called temp/assetmap.txt if this is true, all mesh and paraX mesh files will be checked for existence if the file does not exist, it will search if there is a mapping in the m_AssetMap, if there is no valid, it will search the disk using the file name and extensions and automatically generate a new mapping item, m_AssetMap will be read and written to disk file temp/assetmap.txt at loading and exiting time | |
map< string, string > | m_AssetMap |
this is only used when m_bUseAssetSearch is true. More... | |
![]() | |
WeakPtr_type | m_weak_reference |
![]() | |
int | m_refcount |
Additional Inherited Members | |
![]() | |
virtual CAttributeClass * | CreateAttributeClass () |
initialize fields | |
virtual CDynamicAttributesSet * | GetDynamicAttributes (bool bCreateIfNotExist=false) |
the asset manager class in ParaEngine.
it contains sub managers for mesh, animated mesh, texture, font, sprite, database, buffer, effect, flash texture, occlusion query, archives, etc. it also provides the get and load functions for all above asset types. All assets are reference counted and can be garbage collected on demand. All device related asset are automatically restored when device changes.
bool CParaWorldAsset::DoAssetSearch | ( | string & | AssetFile, |
const char * | searchDir | ||
) |
given a source asset, it will first see if the asset already exist.
if the file does not exist, it will search if there is a mapping in the m_AssetMap, if there is no valid, it will search the disk using the file name and extensions; if the file name is found somewhere else, it will automatically generate a new mapping item in m_AssetMap, m_AssetMap will be read and written to disk file assetmap.txt at loading and exiting time
AssetFile | [in|out] asset file to search for, the result file will be assigned to it as well. |
searchDir | where to search the file if it is found. |
void CParaWorldAsset::GarbageCollectAll | ( | ) |
Garbage Collect(free resources of) all unused entity.
|
virtual |
we support multi-dimensional child object.
by default objects have only one column.
Reimplemented from ParaEngine::IAttributeFields.
|
virtual |
get attribute by child object.
used to iterate across the attribute field hierarchy.
Reimplemented from ParaEngine::IAttributeFields.
|
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.
HRESULT CParaWorldAsset::InitDeviceObjects | ( | ) |
Desc: Initialize scene objects that has not yet been initialized.
Asset must be the first to be initialized. Otherwise, the global device object will not be valid
|
virtual |
this class should be implemented if one wants to add new attribute.
This function is always called internally.
Reimplemented from ParaEngine::IAttributeFields.
bool ParaEngine::CParaWorldAsset::IsAsyncLoading | ( | ) | const |
whether to enable async loading for all subsequently loaded assets, such as texture, etc.
Enabled by default.
bool ParaEngine::CParaWorldAsset::IsUseLocalFileFirst | ( | ) | const |
if true, asset manifest's GetFile() will return null, if a local disk or zip file is found even there is an entry in the assetmanifest.
void CParaWorldAsset::LoadAsset | ( | ) |
initialize all assets created so far to accelerate loading during game play.
ParaXEntity * CParaWorldAsset::LoadParaXByID | ( | int | nAssetID | ) |
the asset are feched from the current model asset database.
TextureEntity * CParaWorldAsset::LoadTexture | ( | const string & | sIdentifier, |
const string & | sTextureFileName, | ||
TextureEntity::_SurfaceType | nSurfaceType = TextureEntity::StaticTexture |
||
) |
sIdentifier | usually same as sTextureFileName |
sTextureFileName | if the file name ends with _a{0-9}{0-9}{0-9}.xxx, it will be regarded as a texture sequence. and the nSurfaceType will be ignored and forced to TextureSequence |
nSurfaceType | default to TextureEntity::StaticTexture |
bool CParaWorldAsset::RefreshAsset | ( | const char * | filename | ) |
refresh asset if it is already loaded.
it will search for all refreshable asset type, such as textures and mesh, etc. if found, it will call the Refresh() method on the asset entity and return true, or return false.
void CParaWorldAsset::RenderFrameMove | ( | float | fElapsedTime | ) |
called before every render frame
fElapsedTime | in seconds |
bool CParaWorldAsset::UnloadAssetByKeyName | ( | const string & | keyname | ) |
unload a given asset by key name.
This function is rarely used, except for some specify situation, such as Loading a new replacement file that overwrite existing asset entity. currently only texture and model files are supported.
keyname | the asset key, we will automatically determine the asset type by its extension (assuming key is filename) |
|
protected |
this is only used when m_bUseAssetSearch is true.
m_AssetMap will be read and written to disk file temp/assetmap.txt at loading and exiting time file format: on each line, it is string=string, where the second string may be none.