Sirikata
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
Sirikata::Graphics::ResourceLoader Class Reference

ResourceLoader manages the loading of resources into Ogre. More...

#include <ResourceLoader.hpp>

Collaboration diagram for Sirikata::Graphics::ResourceLoader:

List of all members.

Classes

struct  ResourceData

Public Types

typedef std::tr1::function< void()> LoadedCallback

Public Member Functions

 ResourceLoader (Context *ctx, const Duration &per_frame_time)
 Create a ResourceLoader.
 ~ResourceLoader ()
void loadMaterial (const String &name, Mesh::MeshdataPtr mesh, const Mesh::MaterialEffectInfo &mat, const Transfer::URI &uri, TextureBindingsMapPtr textureFingerprints, LoadedCallback cb)
void loadBillboardMaterial (const String &name, const String &texuri, const Transfer::URI &uri, TextureBindingsMapPtr textureFingerprints, LoadedCallback cb)
void loadSkeleton (const String &name, Mesh::MeshdataPtr mesh, const std::set< String > &animationList, LoadedCallback cb)
void loadMesh (const String &name, Mesh::MeshdataPtr mesh, const String &skeletonName, TextureBindingsMapPtr textureFingerprints, LoadedCallback cb)
void loadTexture (const String &name, LoadedCallback cb)
void unloadResource (const String &name)
void tick ()

Private Types

enum  ResourceType { ResourceTypeMaterial, ResourceTypeTexture, ResourceTypeSkeleton, ResourceTypeMesh }
typedef std::tr1::function< void()> Task
typedef std::map< String,
ResourceData
RefCountMap

Private Member Functions

void loadMaterialWork (const String &name, Mesh::MeshdataPtr mesh, const Mesh::MaterialEffectInfo &mat, const Transfer::URI &uri, TextureBindingsMapPtr textureFingerprints, LoadedCallback cb)
void loadBillboardMaterialWork (const String &name, const String &texuri, const Transfer::URI &uri, TextureBindingsMapPtr textureFingerprints, LoadedCallback cb)
void loadSkeletonWork (const String &name, Mesh::MeshdataPtr mesh, const std::set< String > &animationList, LoadedCallback cb)
void loadMeshWork (const String &name, Mesh::MeshdataPtr mesh, const String &skeletonName, TextureBindingsMapPtr textureFingerprints, LoadedCallback cb)
void loadTextureWork (const String &name, LoadedCallback cb)
void unloadResourceWork (const String &name, ResourceType type)
void incRefCount (const String &name, ResourceType type)
void decRefCount (const String &name)
void resetRenderQueues ()

Private Attributes

const Duration mPerFrameTime
TimeProfiler::StagemProfilerStage
std::queue< TaskmTasks
RefCountMap mRefCounts
bool mNeedRenderQueuesReset

Detailed Description

ResourceLoader manages the loading of resources into Ogre.

It works asynchronously and handles scheduling loading of resources so they don't consume too much time, thereby attempting to maintain good frame rates. Since it coordinates all loading of resources for a single Ogre instance, it also makes sure each resources is loaded only once by deduplicating requests (some of which can't be known to be duplicates until we reach the point of loading, e.g. because two meshes use the same texture).

ResourceLoader also keeps track of usage so it can *unload* resources when they are no longer required. This means that even if you know Ogre has loaded a resource, you should request it be loaded and unloaded at the appropriate times.

The ResourceLoader is created and driven by OgreRenderer. You shouldn't instantiate this class yourself.


Member Typedef Documentation

typedef std::tr1::function<void()> Sirikata::Graphics::ResourceLoader::LoadedCallback
typedef std::tr1::function<void()> Sirikata::Graphics::ResourceLoader::Task [private]

Member Enumeration Documentation

Enumerator:
ResourceTypeMaterial 
ResourceTypeTexture 
ResourceTypeSkeleton 
ResourceTypeMesh 

Constructor & Destructor Documentation

Sirikata::Graphics::ResourceLoader::ResourceLoader ( Context ctx,
const Duration per_frame_time 
)

Create a ResourceLoader.

Parameters:
per_frame_timemaximum amount of time to spend loading resources. This isn't a guarantee, rather a best effort. Single resource loading tasks that exceed this time can't be avoided.

References Sirikata::TimeProfiler::addStage(), mProfilerStage, and Sirikata::Context::profiler.

Sirikata::Graphics::ResourceLoader::~ResourceLoader ( )

References mProfilerStage.


Member Function Documentation

void Sirikata::Graphics::ResourceLoader::decRefCount ( const String &  name) [private]
void Sirikata::Graphics::ResourceLoader::incRefCount ( const String &  name,
ResourceType  type 
) [private]
void Sirikata::Graphics::ResourceLoader::loadBillboardMaterial ( const String &  name,
const String &  texuri,
const Transfer::URI uri,
TextureBindingsMapPtr  textureFingerprints,
LoadedCallback  cb 
)
void Sirikata::Graphics::ResourceLoader::loadBillboardMaterialWork ( const String &  name,
const String &  texuri,
const Transfer::URI uri,
TextureBindingsMapPtr  textureFingerprints,
LoadedCallback  cb 
) [private]
void Sirikata::Graphics::ResourceLoader::loadMaterial ( const String &  name,
Mesh::MeshdataPtr  mesh,
const Mesh::MaterialEffectInfo mat,
const Transfer::URI uri,
TextureBindingsMapPtr  textureFingerprints,
LoadedCallback  cb 
)
void Sirikata::Graphics::ResourceLoader::loadMaterialWork ( const String &  name,
Mesh::MeshdataPtr  mesh,
const Mesh::MaterialEffectInfo mat,
const Transfer::URI uri,
TextureBindingsMapPtr  textureFingerprints,
LoadedCallback  cb 
) [private]

Referenced by loadMaterial().

void Sirikata::Graphics::ResourceLoader::loadMesh ( const String &  name,
Mesh::MeshdataPtr  mesh,
const String &  skeletonName,
TextureBindingsMapPtr  textureFingerprints,
LoadedCallback  cb 
)
void Sirikata::Graphics::ResourceLoader::loadMeshWork ( const String &  name,
Mesh::MeshdataPtr  mesh,
const String &  skeletonName,
TextureBindingsMapPtr  textureFingerprints,
LoadedCallback  cb 
) [private]

FIXME: set bounds, bounding radius here

Referenced by loadMesh().

void Sirikata::Graphics::ResourceLoader::loadSkeleton ( const String &  name,
Mesh::MeshdataPtr  mesh,
const std::set< String > &  animationList,
LoadedCallback  cb 
)
void Sirikata::Graphics::ResourceLoader::loadSkeletonWork ( const String &  name,
Mesh::MeshdataPtr  mesh,
const std::set< String > &  animationList,
LoadedCallback  cb 
) [private]

Referenced by loadSkeleton().

void Sirikata::Graphics::ResourceLoader::loadTexture ( const String &  name,
LoadedCallback  cb 
)
void Sirikata::Graphics::ResourceLoader::loadTextureWork ( const String &  name,
LoadedCallback  cb 
) [private]

Referenced by loadTexture().

void Sirikata::Graphics::ResourceLoader::resetRenderQueues ( ) [private]

References mNeedRenderQueuesReset.

Referenced by tick().

void Sirikata::Graphics::ResourceLoader::tick ( )
void Sirikata::Graphics::ResourceLoader::unloadResource ( const String &  name)
void Sirikata::Graphics::ResourceLoader::unloadResourceWork ( const String &  name,
ResourceType  type 
) [private]

Member Data Documentation

Referenced by tick().

Referenced by decRefCount(), and incRefCount().


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