Static Public Member Functions | Static Protected Attributes

SceneGraph Class Reference

#include <SceneGraph.h>

List of all members.

Static Public Member Functions

static void init ()
static void destroy ()
static void registerCommands ()
static void deleteNode (Node *node)
static WorldcreateWorld (const char *nname)
static GroupcreateGroup (const char *nname)
static GroupcreateGroup (const char *group_name, const char *filename)
static CameracreateCamera (const char *nname)
static LightcreateLight (const char *nname)
static GeometrycreateGeometry (const char *nname)
static GeometrycreateGeometry (const char *nname, VertexArray *vertex_array, bool instantiate_resources=true)
static GeometrycreateGeometry (const char *nname, const char *filename, bool instantiate_resources=true)
static NodegetNode (const char *name)
static u32 getNodeCount ()
static void getNodes (Node **node_list)
static void getNodes (const char *name, u32 max_nodes, Node **node_list, u32 *n)
static u32 getNodeCount (NodeType_t type)
static void getNodes (Node **node_list, NodeType_t type)
static void getNodes (const char *name, u32 max_nodes, Node **node_list, u32 *n, NodeType_t type)
static bool dereferenceResource (Resource *resource)
static void purgeResources (u32 max_purge_level)
static void forcePurgeResources (u32 max_purge_level)
static VertexArraycreateVertexArray (const char *nidentifier, void *new_array, u32 nstride, u32 n, PrimitiveLayout_t layout, AttributeUsage_t usage)
static VertexArraycreateVertexArray (const char *nidentifier, u32 nstride, PrimitiveLayout_t layout, AttributeUsage_t usage)
static TexturecreateTexture (const char *nidentifier, const char *filename, bool generate_mipmaps, TextureFilter_t filter, TextureWrap_t wrap)
static TexturecreateTexture (const char *nidentifier, u8 *pixels, TextureFormat_t nformat, u32 nwidth, u32 nheight, bool generate_mipmaps, TextureFilter_t filter, TextureWrap_t wrap)
static RenderTargetcreateRenderTarget (const char *nidentifier, u32 width, u32 height, u32 n_target_textures, bool depth_buffer, bool stencil_buffer, TextureFilter_t textureFilter)
static CubeMapcreateCubeMap (const char *nidentifier, const char *nleft, const char *nright, const char *nup, const char *ndown, const char *nfront, const char *nback)
static ShaderProgramcreateShaderProgram (const char *nidentifier, const char *shader_name, char *prefix)
static ResourcegetResource (const char *identifier, ResourceType_t type)
static u32 getResourceCount (ResourceType_t type)
static void getResourceList (Resource **list, ResourceType_t type)
static void printDebugInfo ()

Static Protected Attributes

static ResourceListvertexList
static ResourceListrenderTargetList
static ResourceListtextureList
static ResourceListcubeMapList
static ResourceListshaderProgramList
static NodeListnodeList

Detailed Description

Node and resource handling

Use the create- and delete-functions from this function to handle all node and resource allocations and deallocations.


Member Function Documentation

Camera * SceneGraph::createCamera ( const char *  nname ) [static]

Create Camera node

Returns:
A Camera node on success, otherwise NULL
CubeMap * SceneGraph::createCubeMap ( const char *  nidentifier,
const char *  nleft,
const char *  nright,
const char *  nup,
const char *  ndown,
const char *  nfront,
const char *  nback 
) [static]

Create a Cube map

This creates a Cube map from 6 image files

Returns:
A Cube map resource on success, otherwise NULL
Geometry * SceneGraph::createGeometry ( const char *  nname ) [static]

Create empty Geometry node

Returns:
A Geometry node on success, otherwise NULL
Geometry * SceneGraph::createGeometry ( const char *  nname,
VertexArray vertex_array,
bool  instantiate_resources = true 
) [static]

Create Geometry node

Parameters:
instantiate_resourcesfalse if the ownership of the vertex array should be yielded to this Geometry node; true if the caller should retain its reference to the vertex array
Returns:
A Geometry node on success, otherwise NULL
Geometry * SceneGraph::createGeometry ( const char *  nname,
const char *  filename,
bool  instantiate_resources = true 
) [static]

Create Geometry node from file

This creates a Geometry node from a file that contains one, and only one mesh. This bypasses the need to load simple meshes through the Group node object.

Parameters:
filenameThe file to be loaded. Supported formats are .pwn and .obj. The file loaded must contain exactly one mesh.
instantiate_resourcesfalse if the ownership of the resources should be yielded to this Geometry node; true if the caller should retain its reference to the resources loaded.
Returns:
A Group node on success, otherwise NULL
Group * SceneGraph::createGroup ( const char *  nname ) [static]

Create Group node

Returns:
A Group node on success, otherwise NULL
Group * SceneGraph::createGroup ( const char *  group_name,
const char *  filename 
) [static]

Create Group node from file

This creates a Group node with the entire scene structure of the specified file.

Parameters:
filenameThe file to be loaded. Supported formats are .pwn and .obj. For .obj files there will only be a single child Geometry node to this Group node. .pwn files, however, may contain entire scenes.
Returns:
A Group node on success, otherwise NULL
Light * SceneGraph::createLight ( const char *  nname ) [static]

Create Light node

Returns:
A Light node on success, otherwise NULL
RenderTarget * SceneGraph::createRenderTarget ( const char *  nidentifier,
u32  width,
u32  height,
u32  n_target_textures,
bool  depth_buffer,
bool  stencil_buffer,
TextureFilter_t  textureFilter 
) [static]

Create a RenderTarget resource

Note: Some platforms require width and height to be powers of 2. This automatically choses to use RGBA8 textures with bilinear filtering. You're free to hack this if you feel like it.

Returns:
A RenderTarget resource on success, otherwise NULL
ShaderProgram * SceneGraph::createShaderProgram ( const char *  nidentifier,
const char *  shader_name,
char *  prefix 
) [static]

Create a Shader program resource

Parameters:
shader_nameThe name of the shader. It's up to the Renderer to interpret this name in a way it deems appropriate. The OpenGL ES 2.0 Renderer, for instance, will look for shader files named "name.gles20.vs" and "name.gles20.fs", whereas another Renderer may have hard coded code paths for specific names. Check the documentation for the Renderers you intend to use for more information on how shaders are handled.
prefixA prefix string (if applicable) that can contain things like extra defines and such, that alter the behaviour of the shader. Not all Renderers utilize this parameter. The prefix may also be NULL.
Returns:
A Shader program resource on success, otherwise NULL
Texture * SceneGraph::createTexture ( const char *  nidentifier,
const char *  filename,
bool  generate_mipmaps,
TextureFilter_t  filter,
TextureWrap_t  wrap 
) [static]

Create a Texture resource from file

This creates a Texture resource from an image file. Which formats are supported is up to the Platform layer. The safest bet is to use .png or .bmp images, as these formats are mostly supported.

Parameters:
filenameThe filename of the image (preferably .png or .bmp)
filterThe filtering method used for magnification _and_ minification;

  • TEXTURE_FILTER_NEAREST
  • TEXTURE_FILTER_BILINEAR
  • TEXTURE_FILTER_TRILINEAR
wrapHow the texture should wrap

  • TEXTURE_WRAP_CLAMP
  • TEXTURE_WRAP_REPEAT
  • TEXTURE_WRAP_MIRRORED_REPEAT
Returns:
A Texture resource on success, otherwise NULL
Texture * SceneGraph::createTexture ( const char *  nidentifier,
u8 *  pixels,
TextureFormat_t  nformat,
u32  nwidth,
u32  nheight,
bool  generate_mipmaps,
TextureFilter_t  filter,
TextureWrap_t  wrap 
) [static]

Create a Texture resource from pixel array

Note: Some platforms require width and height to be powers of 2.

Parameters:
pixelsAn array of color/intensity values. May be NULL (if the texture is intended to be used as a render target)
nformatThe format of the incoming pixels;

  • TEXTURE_FORMAT_RGBA8
  • TEXTURE_FORMAT_RGB8
  • TEXTURE_FORMAT_GRAY8
filterThe filtering method used for magnification _and_ minification;

  • TEXTURE_FILTER_NEAREST
  • TEXTURE_FILTER_BILINEAR
  • TEXTURE_FILTER_TRILINEAR
wrapHow the texture should wrap

  • TEXTURE_WRAP_CLAMP
  • TEXTURE_WRAP_REPEAT
  • TEXTURE_WRAP_MIRRORED_REPEAT
Returns:
A Texture resource on success, otherwise NULL
VertexArray * SceneGraph::createVertexArray ( const char *  nidentifier,
void *  new_array,
u32  nstride,
u32  n,
PrimitiveLayout_t  layout,
AttributeUsage_t  usage 
) [static]

Create a Vertex Array resource

Parameters:
new_arrayArray of vertex attribute structs. It's safe to delete the incoming array after calling this function.
nstrideThe length of each struct in bytes
nNumber of structs in the array
usageHow often the contents will change;

  • USAGE_STATIC Never
  • USAGE_DYNAMIC Every few render calls
  • USAGE_STREAM: Used once and then changed
Returns:
A VertexArray resource on success, otherwise NULL
VertexArray * SceneGraph::createVertexArray ( const char *  nidentifier,
u32  nstride,
PrimitiveLayout_t  layout,
AttributeUsage_t  usage 
) [static]

Create an empty Vertex Array resource

This creates an empty Vertex Array resource. This just defines the vertex array - the actual data is provided later on using VertexArray::setArray().

Parameters:
nstrideThe length of each struct
usageHow often the contents will change;

  • USAGE_STATIC Never
  • USAGE_DYNAMIC Every few render calls
  • USAGE_STREAM: Used once and then changed
Returns:
A VertexArray resource on success, otherwise NULL
World * SceneGraph::createWorld ( const char *  nname ) [static]

Create World node

Returns:
A World node on success, otherwise NULL
void SceneGraph::deleteNode ( Node node ) [static]

Common destroyer

Use this function when destroying a node, no matter what type it has. The children of this node will also be deleted recursively, so make sure that the node doesn't have any children that shouldn't be deleted.

Parameters:
nodeThe root node to be destroyed
bool SceneGraph::dereferenceResource ( Resource resource ) [static]

Common dereferencer.

Use this to dereference and potentially delete resources of any type. When a resource is dereferenced its reference counter is decreased. When there are no more references to a resource, it's actually deallocated from memory, if the purge level is set to 0.

Returns:
true if the resource was actually deleted from memory, false otherwise.
void SceneGraph::destroy (  ) [static]

SceneGraph destroyer

This is called by RC on tear down.

static void SceneGraph::forcePurgeResources ( u32  max_purge_level ) [static]

Forced purge resources.

Purge all resources with purge level that is; 0 < purgeLevel <= max_purge_level

The resources _are_ deleted even if their reference counter has not reached 0. It's important that you delete any Nodes using these resources _before_ calling this method, or your program is very likely to crash!

Node * SceneGraph::getNode ( const char *  name ) [static]

Get first node with name

This retrieves the first node with the specified name. There may be multiple nodes with the same name, and it's not specified which one of them you will recieve in that case. If you want to retrieve a node that is a child of a certain other node, then use Node::getChild(char, u32) instead.

Returns:
A Node on success, otherwise NULL
u32 SceneGraph::getNodeCount ( NodeType_t  type ) [static]

Get node count of a specific type

static void SceneGraph::getNodes ( const char *  name,
u32  max_nodes,
Node **  node_list,
u32 *  n 
) [static]

Get nodes with name

Retrieves a maximum number of nodes with a specified name. This method does not allocate any memory. It's up to the caller to provide an appropriately sized array pointer, though an upper limit can be set.

Parameters:
nameName of the nodes to be fetched
max_nodesOnly the first max_nodes number of nodes will be fetched. It's not speficied which these are if there exists more than max_nodes number of nodes with this name
node_listSend in an array big enough to hold max_nodes number of Node pointers, and this method will populate it.
nThe number of nodes found and inserted into node_list
void SceneGraph::getNodes ( Node **  node_list,
NodeType_t  type 
) [static]

Get all nodes of a specific type

Retrieves all existing nodes of a certain type. Use getNodeCount(NodeType_t) to find out how many nodes that is. This method does not allocate any memory. It's up to the caller to provide an appropriately sized array pointer.

Parameters:
node_listSend in an array big enough to hold all Node pointers, and this method will populate it.
typeThe type of node that should populate the list
void SceneGraph::getNodes ( const char *  name,
u32  max_nodes,
Node **  node_list,
u32 *  n,
NodeType_t  type 
) [static]

Get nodes with name and type

Retrieves a maximum number of nodes with a specified name and type. This method does not allocate any memory. It's up to the caller to provide an appropriately sized array pointer, though an upper limit can be set.

Parameters:
nameName of the nodes to be fetched
max_nodesOnly the first max_nodes number of nodes will be fetched. It's not speficied which these are if there exists more than max_nodes number of nodes with this name
node_listSend in an array big enough to hold max_nodes number of Node pointers, and this method will populate it.
nThe number of nodes found and inserted into node_list
typeThe type of node that should populate the list
void SceneGraph::getNodes ( Node **  node_list ) [static]

Get all nodes

Retrieves all existing nodes. Use getNodeCount() to find out how many nodes that is. This method does not allocate any memory. It's up to the caller to provide an appropriately sized array pointer.

Parameters:
node_listSend in an array big enough to hold all Node pointers, and this method will populate it.
Resource * SceneGraph::getResource ( const char *  identifier,
ResourceType_t  type 
) [static]

Fetch resource

Returns:
A Resource on success, otherwise NULL
void SceneGraph::getResourceList ( Resource **  list,
ResourceType_t  type 
) [static]

Get list of Resources

Parameters:
listAn array of appropriate size that will be populated by this method. Use getResourceCount(ResourceType_t) to get the list size.
void SceneGraph::init (  ) [static]

SceneGraph initializer

This is called by RC during setup.

void SceneGraph::printDebugInfo (  ) [static]

Debug printout

void SceneGraph::purgeResources ( u32  max_purge_level ) [static]

Purge resources.

Purge all resources with purge level that is; 0 < purgeLevel <= max_purge_level

The resources are not actually deleted unless their reference counter has hit 0.


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