ISceneNodeFactory.h 3.0 KB

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