1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
5
#ifndef __I_SCENE_NODE_FACTORY_H_INCLUDED__
6
#define __I_SCENE_NODE_FACTORY_H_INCLUDED__
8
#include "IReferenceCounted.h"
9
#include "ESceneNodeTypes.h"
18
//! Interface for dynamic creation of scene nodes
19
/** To be able to add custom scene nodes to Irrlicht and to make it possible for the
20
scene manager to save and load those external scene nodes, simply implement this
21
interface and register it in you scene manager via ISceneManager::registerSceneNodeFactory.
22
Note: When implementing your own scene node factory, don't call ISceneNodeManager::grab() to
23
increase the reference counter of the scene node manager. This is not necessary because the
24
scene node manager will grab() the factory anyway, and otherwise cyclic references will
25
be created and the scene manager and all its nodes won't get deallocated.
27
class ISceneNodeFactory : public virtual IReferenceCounted
30
//! adds a scene node to the scene graph based on its type id
31
/** \param type: Type of the scene node to add.
32
\param parent: Parent scene node of the new node, can be null to add the scene node to the root.
33
\return Returns pointer to the new scene node or null if not successful.
34
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
35
virtual ISceneNode* addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent=0) = 0;
37
//! adds a scene node to the scene graph based on its type name
38
/** \param typeName: Type name of the scene node to add.
39
\param parent: Parent scene node of the new node, can be null to add the scene node to the root.
40
\return Returns pointer to the new scene node or null if not successful.
41
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
42
virtual ISceneNode* addSceneNode(const c8* typeName, ISceneNode* parent=0) = 0;
44
//! returns amount of scene node types this factory is able to create
45
virtual u32 getCreatableSceneNodeTypeCount() const = 0;
47
//! returns type of a createable scene node type
48
/** \param idx: Index of scene node type in this factory. Must be a value between 0 and
49
getCreatableSceneNodeTypeCount() */
50
virtual ESCENE_NODE_TYPE getCreateableSceneNodeType(u32 idx) const = 0;
52
//! returns type name of a createable scene node type by index
53
/** \param idx: Index of scene node type in this factory. Must be a value between 0 and
54
getCreatableSceneNodeTypeCount() */
55
virtual const c8* getCreateableSceneNodeTypeName(u32 idx) const = 0;
57
//! returns type name of a createable scene node type
58
/** \param type: Type of scene node.
59
\return: Returns name of scene node type if this factory can create the type, otherwise 0. */
60
virtual const c8* getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type) const = 0;
64
} // end namespace scene
65
} // end namespace irr