Models::Model Class Reference
#include <model.h>
Detailed Description
A Model represents the template for a renderable object, consisting of a hierarchy of ModelNodes which represent transformations and shapes. Models should generally be created through the ModelServer, which guarantees that a given Model is only loaded once into memory. To render a Model, at least one ModelInstance must be created from the Model. Usually one ModelInstance is created per game object. Generally speaking, all per-instance data lives in the ModelInstance objects, while all constant data lives in the Model object.(C) 2007 Radon Labs GmbH
Public Types | |
enum | State |
resource states (DO NOT CHANGE ORDER!) | |
Public Member Functions | |
Model () | |
constructor | |
virtual | ~Model () |
destructor | |
virtual void | Unload () |
unload the resource, or cancel the pending load | |
void | LoadResources () |
load node resources (meshes, textures, shaders, ...) | |
void | UnloadResources () |
unload node resources | |
State | GetResourceState () const |
get the overall resource loading state (Initial -> Pending -> Loaded/Failed/Cancelled) | |
void | SetBoundingBox (const Math::bbox &b) |
set the model's local bounding box | |
const Math::bbox & | GetBoundingBox () const |
get the model's local bounding box | |
bool | HasNode (const Util::Atom< Util::String > &name) const |
check if a ModelNode exists | |
const Ptr< ModelNode > & | LookupNode (const Util::Atom< Util::String > &name) const |
lookup a ModelNode in the Model | |
void | AttachNode (const Ptr< ModelNode > &node) |
attach a model node to the Model | |
void | RemoveNode (const Ptr< ModelNode > &node) |
remove a model node from the Model | |
const Util::Array < Ptr< ModelNode > > & | GetNodes () const |
access to model nodes | |
Ptr< ModelInstance > | CreateInstance () |
create a ModelInstance of the Model | |
const Util::Array < Ptr< ModelInstance > > & | GetInstances () const |
get all attached model instances | |
bool | LoadFromAttrs (const Attr::AttributeContainer &attrs) |
load model attributes from attribute set | |
bool | SaveToAttrs (Attr::AttributeContainer &attrs) |
save model attributes to attribute set | |
const Attr::AttributeContainer & | GetAttrs () const |
read access to model attributes | |
bool | HasAttr (const Attr::AttrId &attrId) const |
check if model attribute exists | |
void | SetAttr (const Attr::Attribute &attr) |
set generic model attribute | |
const Attr::Attribute & | GetAttr (const Attr::AttrId &attrId) const |
get generic model attribute | |
void | SetBool (const Attr::BoolAttrId &attrId, bool val) |
set bool value | |
bool | GetBool (const Attr::BoolAttrId &attrId) const |
get bool value | |
void | SetFloat (const Attr::FloatAttrId &attrId, float val) |
set float value | |
float | GetFloat (const Attr::FloatAttrId &attrId) const |
get float value | |
void | SetInt (const Attr::IntAttrId &attrId, int val) |
set int value | |
int | GetInt (const Attr::IntAttrId &attrId) const |
get int value | |
void | SetString (const Attr::StringAttrId &attrId, const Util::String &val) |
set string value | |
const Util::String & | GetString (const Attr::StringAttrId &attrId) const |
get string value | |
void | SetFloat4 (const Attr::Float4AttrId &attrId, const Math::float4 &val) |
set float4 value | |
Math::float4 | GetFloat4 (const Attr::Float4AttrId &attrId) const |
get float4 value | |
void | SetMatrix44 (const Attr::Matrix44AttrId &attrId, const Math::matrix44 &val) |
set matrix44 value | |
const Math::matrix44 & | GetMatrix44 (const Attr::Matrix44AttrId &attrId) const |
get matrix44 value | |
void | SetGuid (const Attr::GuidAttrId &attrId, const Util::Guid &guid) |
set guid value | |
const Util::Guid & | GetGuid (const Attr::GuidAttrId &attrId) const |
get guid value | |
void | SetBlob (const Attr::BlobAttrId &attrId, const Util::Blob &blob) |
set blob value | |
const Util::Blob & | GetBlob (const Attr::BlobAttrId &attrId) const |
get blob value | |
void | SetAsyncEnabled (bool b) |
request synchronous/asynchronous resource loading | |
bool | IsAsyncEnabled () const |
return true if asynchronous resource loading is enabled | |
void | SetResourceId (const ResourceId &id) |
set the resource identifier | |
const ResourceId & | GetResourceId () const |
get the resource identifier | |
void | SetLoader (const Ptr< ResourceLoader > &loader) |
set optional resource loader | |
const Ptr < ResourceLoader > & | GetLoader () const |
get optional resource loader | |
void | SetSaver (const Ptr< ResourceSaver > &saver) |
set optional resource saver | |
const Ptr < ResourceSaver > & | GetSaver () const |
get optional resource saver | |
SizeT | GetUseCount () const |
get current use count | |
virtual State | Load () |
load the resource | |
State | GetState () const |
get current state | |
bool | IsLoaded () const |
return true if current state is Loaded | |
bool | IsPending () const |
return true if current state is Pending | |
bool | LoadFailed () const |
return true if current state is Failed | |
virtual bool | Save () |
save the resource | |
int | GetRefCount () const |
get the current refcount | |
void | AddRef () |
increment refcount by one | |
void | Release () |
decrement refcount and destroy object if refcount is zero | |
bool | IsInstanceOf (const Rtti &rtti) const |
return true if this object is instance of given class | |
bool | IsInstanceOf (const Util::String &className) const |
return true if this object is instance of given class by string | |
bool | IsInstanceOf (const Util::FourCC &classFourCC) const |
return true if this object is instance of given class by fourcc | |
bool | IsA (const Rtti &rtti) const |
return true if this object is instance of given class, or a derived class | |
bool | IsA (const Util::String &rttiName) const |
return true if this object is instance of given class, or a derived class, by string | |
bool | IsA (const Util::FourCC &rttiFourCC) const |
return true if this object is instance of given class, or a derived class, by fourcc | |
const Util::String & | GetClassName () const |
get the class name | |
Util::FourCC | GetClassFourCC () const |
get the class FourCC code | |
Static Public Member Functions | |
static void | DumpRefCountingLeaks () |
dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!) | |
Protected Member Functions | |
void | SetState (State s) |
set current state | |
void | IncrUseCount () |
increment use count | |
void | DecrUseCount () |
decrement use count |
Member Function Documentation
void Models::Model::LoadResources | ( | ) |
load node resources (meshes, textures, shaders, ...)
This method asks all model nodes to load their resources. Note that actual resource loading may be asynchronous and placeholder resources may be in place right after this method returns.
void Models::Model::UnloadResources | ( | ) |
unload node resources
This method asks all model nodes to unload their resources.
Resource::State Models::Model::GetResourceState | ( | ) | const |
get the overall resource loading state (Initial -> Pending -> Loaded/Failed/Cancelled)
Checks all model nodes and returns a cumulative resource loading state.
Resource::State Resources::Resource::Load | ( | ) | [virtual, inherited] |
load the resource
This loads the resource through the attached resource loader. Depending on the resource loader, the resource may happen synchronously or asynchronously. If the resource is loaded asynchronously, the IsPending() method will return true as long as the load is in progress, and IsLoaded() will become true when the loading process has finished. If the load has failed, IsPending() will switch to false and IsLoaded() will not be true.
bool Resources::Resource::Save | ( | ) | [virtual, inherited] |
save the resource
This will save the resource. A resource saver must be attached to the resource and the resource must be loaded for the method to succeed. Saving will always be performed synchronously.
int Core::RefCounted::GetRefCount | ( | ) | const [inline, inherited] |
get the current refcount
Return the current refcount of the object.
void Core::RefCounted::AddRef | ( | ) | [inline, inherited] |
increment refcount by one
Increment the refcount of the object.
void Core::RefCounted::Release | ( | ) | [inline, inherited] |
decrement refcount and destroy object if refcount is zero
Decrement the refcount and destroy object if refcount is zero.
const Util::String & Core::RefCounted::GetClassName | ( | ) | const [inline, inherited] |
get the class name
Get the class name of the object.
Util::FourCC Core::RefCounted::GetClassFourCC | ( | ) | const [inline, inherited] |
get the class FourCC code
Get the class FourCC of the object.
void Core::RefCounted::DumpRefCountingLeaks | ( | ) | [static, inherited] |
dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!)
This method should be called as the very last before an application exits.