|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xith3d.resources.ResourceBag
public class ResourceBag
A ResourceBag holds references to all kinds of data to be used in Xith3D. Currently
handled resource types are:
TextureLoader)ModelLoader)ModelLoader)SoundLoader)GLSLShaderLoader)Map's Iterator.
| Constructor Summary | |
|---|---|
ResourceBag()
Creates a new ResourceBag. |
|
| Method Summary | |
|---|---|
void |
addModel(java.lang.String name,
Model model)
Adds a Model resource to the ResourceBag. |
void |
addShader(java.lang.String name,
Shader shader)
Adds a Shader resource to the ResourceBag. |
void |
addSound(java.lang.String name,
SoundContainer sound)
Adds a Sound resource to the ResourceBag. |
void |
addTexture(java.lang.String name,
Texture texture)
Adds a Texture resource to the ResourceBag. |
void |
freeOpenGLResources(Canvas3D canvas)
This method frees OpenGL resources (names) for all this NodeComponent and all
child-components. |
void |
freeOpenGLResources(CanvasPeer canvasPeer)
This method frees OpenGL resources (names) for all this NodeComponent and all
child-components. |
static ResourceBag |
getInstance()
If you want to use one ResourceBag as a singleton, use this. |
Model |
getModel(java.lang.String name)
Retrieves the given Model resource from the ResourceBag. |
Model |
getModelInstance(java.lang.String name)
Retrieves a new shared instance of the given Model resource from the ResourceBag. |
java.util.Collection<Model> |
getModels()
Returns a Collection of all Models stored in the
ResourceBag. |
Shader |
getShader(java.lang.String name)
Retrieves the given Shader resource from the ResourceBag. |
java.util.Collection<Shader> |
getShaders()
Returns a Collection of all Shaders stored in the
ResourceBag. |
SoundContainer |
getSound(java.lang.String name)
Retrieves the given Sound resource from the ResourceBag. |
java.util.Collection<SoundContainer> |
getSounds()
Returns a Collection of all Sounds stored in the
ResourceBag. |
Texture |
getTexture(java.lang.String name)
Retrieves the given Texture resource from the ResourceBag. |
java.util.Collection<Texture> |
getTextures()
Returns a Collection of all Textures stored in the
ResourceBag. |
int |
numModels()
Returns the number of Model resources stored in this ResourceBag. |
int |
numResources()
Return the total number of all resources stored in this ResourceBag. |
int |
numShaders()
Return the number of Shader resources stored in this
ResourceBag. |
int |
numSounds()
Return the number of Sound resources stored in this
ResourceBag. |
int |
numTextures()
Returns the number of Texture resources stored in this ResourceBag. |
static void |
setSingletonInstance(ResourceBag resBag)
If you want to use one ResourceBag as a singleton, first invoke this and then
use the getInstance() method to access the instance everywhere. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ResourceBag()
ResourceBag. Each supported resource type is stored in a
HashMap each.
| Method Detail |
|---|
public static void setSingletonInstance(ResourceBag resBag)
ResourceBag as a singleton, first invoke this and then
use the getInstance() method to access the instance everywhere.
resBag - the ResourceBag instance to use as the singleton instancegetInstance()public static ResourceBag getInstance()
ResourceBag as a singleton, use this. But remember to
first (once) invoke the setSingletonInstance() method.
setSingletonInstance(ResourceBag)
public void addTexture(java.lang.String name,
Texture texture)
Texture resource to the ResourceBag.
name - the name to access the resource at a later timetexture - the resource to add to the bagpublic Texture getTexture(java.lang.String name)
Texture resource from the ResourceBag.
name - the name to use as the key
Texture resource or null, if the name does not
exist in the bagpublic java.util.Collection<Texture> getTextures()
Collection of all Textures stored in the
ResourceBag.
Collection of Texturespublic int numTextures()
Texture resources stored in this ResourceBag.
Texture resources
public void addModel(java.lang.String name,
Model model)
Model resource to the ResourceBag.
name - the name to access the resource at a later timemodel - the resource to add to the bagpublic Model getModel(java.lang.String name)
Model resource from the ResourceBag.
name - the name to use as the key
Model resource or null, if the name does not exist in the bagpublic Model getModelInstance(java.lang.String name)
Model resource from the ResourceBag.
name - the name to use as the key
Model resource or null, if the name does not exist in the bag.public java.util.Collection<Model> getModels()
Collection of all Models stored in the
ResourceBag.
Collection of Modelspublic int numModels()
Model resources stored in this ResourceBag.
Model resources
public void addSound(java.lang.String name,
SoundContainer sound)
Sound resource to the ResourceBag.
name - the name to access the resource at a later timesound - the resource to add to the bagpublic SoundContainer getSound(java.lang.String name)
Sound resource from the ResourceBag.
name - the name to use as the key
Sound resource or null, if the name does not exist in the bag.public java.util.Collection<SoundContainer> getSounds()
Collection of all Sounds stored in the
ResourceBag.
Collection of Soundspublic int numSounds()
Sound resources stored in this
ResourceBag.
Sound resources
public void addShader(java.lang.String name,
Shader shader)
Shader resource to the ResourceBag.
name - the name to access the resource at a later timeshader - the resource to add to the bagpublic Shader getShader(java.lang.String name)
Shader resource from the ResourceBag.
name - the name to use as the key
Shader resource or null, if the name does not exist in the bag.public java.util.Collection<Shader> getShaders()
Collection of all Shaders stored in the
ResourceBag.
Collection of Shaderspublic int numShaders()
Shader resources stored in this
ResourceBag.
Shader resourcespublic int numResources()
ResourceBag.
public void freeOpenGLResources(CanvasPeer canvasPeer)
NodeComponent and all
child-components.
canvasPeer - the CanvasPeer for which to free the resourcesNodeComponent,
CanvasPeerpublic final void freeOpenGLResources(Canvas3D canvas)
NodeComponent and all
child-components.
canvas - the Canvas3D for which to free the resourcesNodeComponent,
Canvas3D
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||