CDefaultSceneNodeFactory.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 __C_DEFAULT_SCENE_NODE_FACTORY_H_INCLUDED__
  5. #define __C_DEFAULT_SCENE_NODE_FACTORY_H_INCLUDED__
  6. #include "ISceneNodeFactory.h"
  7. #include "irrArray.h"
  8. #include "irrString.h"
  9. namespace irr
  10. {
  11. namespace scene
  12. {
  13. class ISceneNode;
  14. class ISceneManager;
  15. //! Interface making it possible to dynamicly create scene nodes and animators
  16. class CDefaultSceneNodeFactory : public ISceneNodeFactory
  17. {
  18. public:
  19. CDefaultSceneNodeFactory(ISceneManager* mgr);
  20. //! adds a scene node to the scene graph based on its type id
  21. /** \param type: Type of the scene node to add.
  22. \param parent: Parent scene node of the new node, can be null to add the scene node to the root.
  23. \return Returns pointer to the new scene node or null if not successful. */
  24. virtual ISceneNode* addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent=0);
  25. //! adds a scene node to the scene graph based on its type name
  26. /** \param typeName: Type name 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. virtual ISceneNode* addSceneNode(const c8* typeName, ISceneNode* parent=0);
  30. //! returns amount of scene node types this factory is able to create
  31. virtual u32 getCreatableSceneNodeTypeCount() const;
  32. //! returns type name of a createable scene node type by index
  33. /** \param idx: Index of scene node type in this factory. Must be a value between 0 and
  34. uetCreatableSceneNodeTypeCount() */
  35. virtual const c8* getCreateableSceneNodeTypeName(u32 idx) const;
  36. //! returns type of a createable scene node type
  37. /** \param idx: Index of scene node type in this factory. Must be a value between 0 and
  38. getCreatableSceneNodeTypeCount() */
  39. virtual ESCENE_NODE_TYPE getCreateableSceneNodeType(u32 idx) const;
  40. //! returns type name of a createable scene node type
  41. /** \param idx: Type of scene node.
  42. \return: Returns name of scene node type if this factory can create the type, otherwise 0. */
  43. virtual const c8* getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type) const;
  44. private:
  45. ESCENE_NODE_TYPE getTypeFromName(const c8* name) const;
  46. struct SSceneNodeTypePair
  47. {
  48. SSceneNodeTypePair(ESCENE_NODE_TYPE type, const c8* name)
  49. : Type(type), TypeName(name)
  50. {}
  51. ESCENE_NODE_TYPE Type;
  52. core::stringc TypeName;
  53. };
  54. core::array<SSceneNodeTypePair> SupportedSceneNodeTypes;
  55. ISceneManager* Manager;
  56. };
  57. } // end namespace scene
  58. } // end namespace irr
  59. #endif