CMeshSceneNode.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_MESH_SCENE_NODE_H_INCLUDED__
  5. #define __C_MESH_SCENE_NODE_H_INCLUDED__
  6. #include "IMeshSceneNode.h"
  7. #include "IMesh.h"
  8. namespace irr
  9. {
  10. namespace scene
  11. {
  12. class CMeshSceneNode : public IMeshSceneNode
  13. {
  14. public:
  15. //! constructor
  16. CMeshSceneNode(IMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id,
  17. const core::vector3df& position = core::vector3df(0,0,0),
  18. const core::vector3df& rotation = core::vector3df(0,0,0),
  19. const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f));
  20. //! destructor
  21. virtual ~CMeshSceneNode();
  22. //! frame
  23. virtual void OnRegisterSceneNode();
  24. //! renders the node.
  25. virtual void render();
  26. //! returns the axis aligned bounding box of this node
  27. virtual const core::aabbox3d<f32>& getBoundingBox() const;
  28. //! returns the material based on the zero based index i. To get the amount
  29. //! of materials used by this scene node, use getMaterialCount().
  30. //! This function is needed for inserting the node into the scene hirachy on a
  31. //! optimal position for minimizing renderstate changes, but can also be used
  32. //! to directly modify the material of a scene node.
  33. virtual video::SMaterial& getMaterial(u32 i);
  34. //! returns amount of materials used by this scene node.
  35. virtual u32 getMaterialCount() const;
  36. //! Writes attributes of the scene node.
  37. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const;
  38. //! Reads attributes of the scene node.
  39. virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);
  40. //! Returns type of the scene node
  41. virtual ESCENE_NODE_TYPE getType() const { return ESNT_MESH; }
  42. //! Sets a new mesh
  43. virtual void setMesh(IMesh* mesh);
  44. //! Returns the current mesh
  45. virtual IMesh* getMesh(void) { return Mesh; }
  46. //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style.
  47. /* In this way it is possible to change the materials a mesh causing all mesh scene nodes
  48. referencing this mesh to change too. */
  49. virtual void setReadOnlyMaterials(bool readonly);
  50. //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style
  51. virtual bool isReadOnlyMaterials() const;
  52. //! Creates a clone of this scene node and its children.
  53. virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0);
  54. //! Removes a child from this scene node.
  55. //! Implemented here, to be able to remove the shadow properly, if there is one,
  56. //! or to remove attached childs.
  57. virtual bool removeChild(ISceneNode* child);
  58. protected:
  59. void copyMaterials();
  60. core::array<video::SMaterial> Materials;
  61. core::aabbox3d<f32> Box;
  62. video::SMaterial ReadOnlyMaterial;
  63. IMesh* Mesh;
  64. s32 PassCount;
  65. bool ReadOnlyMaterials;
  66. };
  67. } // end namespace scene
  68. } // end namespace irr
  69. #endif