IMeshSceneNode.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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_MESH_SCENE_NODE_H_INCLUDED
  5. #define IRR_I_MESH_SCENE_NODE_H_INCLUDED
  6. #include "ISceneNode.h"
  7. namespace irr
  8. {
  9. namespace scene
  10. {
  11. class IShadowVolumeSceneNode;
  12. class IMesh;
  13. //! Option for nodes how to register themeselves at the SceneManager
  14. enum ENodeRegistration
  15. {
  16. //! Each node registers once and renders all it's mesh-buffers
  17. ENR_DEFAULT,
  18. //! Register a new node per mesh-buffer at the SceneManager
  19. //! It allows the SceneManager to sort in each render stage per buffer instead of per node.
  20. //! This can be useful when having several transparent buffers in a mesh.
  21. //! Depending on the scene (and hardware) this can have a positive or negative effect on performance.
  22. //! It can avoid texture-switches, but adds nodes to sort and more matrix transformations are set.
  23. ENR_PER_MESH_BUFFER
  24. };
  25. //! A scene node displaying a static mesh
  26. class IMeshSceneNode : public ISceneNode
  27. {
  28. public:
  29. //! Constructor
  30. /** Use setMesh() to set the mesh to display.
  31. */
  32. IMeshSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
  33. const core::vector3df& position = core::vector3df(0,0,0),
  34. const core::vector3df& rotation = core::vector3df(0,0,0),
  35. const core::vector3df& scale = core::vector3df(1,1,1))
  36. : ISceneNode(parent, mgr, id, position, rotation, scale)
  37. , NodeRegistration(ENR_DEFAULT)
  38. {}
  39. //! Sets a new mesh to display or update mesh when it changed
  40. /** \param mesh Mesh to display. */
  41. virtual void setMesh(IMesh* mesh) = 0;
  42. //! Get the currently defined mesh for display.
  43. /** \return Pointer to mesh which is displayed by this node. */
  44. virtual IMesh* getMesh(void) = 0;
  45. /** The shadow can be rendered using the ZPass or the zfail
  46. method. ZPass is a little bit faster because the shadow volume
  47. creation is easier, but with this method there occur ugly
  48. looking artifacts when the camera is inside the shadow volume.
  49. These error do not occur with the ZFail method, but it can
  50. have trouble with clipping to the far-plane (it usually works
  51. well in OpenGL and fails with other drivers).
  52. \param shadowMesh: Optional custom mesh for shadow volume.
  53. \param id: Id of the shadow scene node. This id can be used to
  54. identify the node later.
  55. \param zfailmethod: If set to true, the shadow will use the
  56. zfail method, if not, zpass is used.
  57. \param infinity: Value used by the shadow volume algorithm to
  58. scale the shadow volume. For zfail shadow volumes on some drivers
  59. only support finite shadows, so camera zfar must be larger than
  60. shadow back cap,which is depending on the infinity parameter).
  61. Infinity value also scales by the scaling factors of the model.
  62. If shadows don't show up with zfail then try reducing infinity.
  63. If shadows are cut-off then try increasing infinity.
  64. \return Pointer to the created shadow scene node. This pointer
  65. should not be dropped. See IReferenceCounted::drop() for more
  66. information. */
  67. virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(const IMesh* shadowMesh=0,
  68. s32 id=-1, bool zfailmethod=true, f32 infinity=1000.0f) = 0;
  69. //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style.
  70. /** In this way it is possible to change the materials of a mesh
  71. causing all mesh scene nodes referencing this mesh to change, too.
  72. \param readonly Flag if the materials shall be read-only. */
  73. virtual void setReadOnlyMaterials(bool readonly) = 0;
  74. //! Check if the scene node should not copy the materials of the mesh but use them in a read only style
  75. /** This flag can be set by setReadOnlyMaterials().
  76. \return Whether the materials are read-only. */
  77. virtual bool isReadOnlyMaterials() const = 0;
  78. //! Set how the node registers itself to the SceneManager
  79. /** Note: Derived classes can ignore this flag, so think of it as a hint. */
  80. virtual void setNodeRegistration(ENodeRegistration nodeRegistration)
  81. {
  82. NodeRegistration = nodeRegistration;
  83. }
  84. //! How does a node register itself to the SceneManager
  85. /** Note: Derived classes may ignore this flag */
  86. virtual ENodeRegistration getNodeRegistration() const
  87. {
  88. return NodeRegistration;
  89. }
  90. protected:
  91. ENodeRegistration NodeRegistration;
  92. };
  93. } // end namespace scene
  94. } // end namespace irr
  95. #endif