]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CMeshSceneNode.h
Add back lighting system
[irrlicht.git] / source / Irrlicht / CMeshSceneNode.h
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt\r
2 // This file is part of the "Irrlicht Engine".\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h\r
4 \r
5 #ifndef __C_MESH_SCENE_NODE_H_INCLUDED__\r
6 #define __C_MESH_SCENE_NODE_H_INCLUDED__\r
7 \r
8 #include "IMeshSceneNode.h"\r
9 #include "IMesh.h"\r
10 \r
11 namespace irr\r
12 {\r
13 namespace scene\r
14 {\r
15 \r
16         class CMeshSceneNode : public IMeshSceneNode\r
17         {\r
18         public:\r
19 \r
20                 //! constructor\r
21                 CMeshSceneNode(IMesh* mesh, ISceneNode* parent, ISceneManager* mgr,     s32 id,\r
22                         const core::vector3df& position = core::vector3df(0,0,0),\r
23                         const core::vector3df& rotation = core::vector3df(0,0,0),\r
24                         const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f));\r
25 \r
26                 //! destructor\r
27                 virtual ~CMeshSceneNode();\r
28 \r
29                 //! frame\r
30                 void OnRegisterSceneNode() override;\r
31 \r
32                 //! renders the node.\r
33                 void render() override;\r
34 \r
35                 //! returns the axis aligned bounding box of this node\r
36                 const core::aabbox3d<f32>& getBoundingBox() const override;\r
37 \r
38                 //! returns the material based on the zero based index i. To get the amount\r
39                 //! of materials used by this scene node, use getMaterialCount().\r
40                 //! This function is needed for inserting the node into the scene hierarchy on a\r
41                 //! optimal position for minimizing renderstate changes, but can also be used\r
42                 //! to directly modify the material of a scene node.\r
43                 video::SMaterial& getMaterial(u32 i) override;\r
44 \r
45                 //! returns amount of materials used by this scene node.\r
46                 u32 getMaterialCount() const override;\r
47 \r
48                 //! Returns type of the scene node\r
49                 ESCENE_NODE_TYPE getType() const override { return ESNT_MESH; }\r
50 \r
51                 //! Sets a new mesh\r
52                 void setMesh(IMesh* mesh) override;\r
53 \r
54                 //! Returns the current mesh\r
55                 IMesh* getMesh(void) override { return Mesh; }\r
56 \r
57                 //! Creates shadow volume scene node as child of this node\r
58                 //! and returns a pointer to it.\r
59                 virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(const IMesh* shadowMesh,\r
60                         s32 id, bool zfailmethod=true, f32 infinity=10000.0f) override;\r
61 \r
62                 //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style.\r
63                 /* In this way it is possible to change the materials a mesh causing all mesh scene nodes\r
64                 referencing this mesh to change too. */\r
65                 void setReadOnlyMaterials(bool readonly) override;\r
66 \r
67                 //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style\r
68                 bool isReadOnlyMaterials() const override;\r
69 \r
70                 //! Creates a clone of this scene node and its children.\r
71                 ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0) override;\r
72 \r
73                 //! Removes a child from this scene node.\r
74                 //! Implemented here, to be able to remove the shadow properly, if there is one,\r
75                 //! or to remove attached child.\r
76                 bool removeChild(ISceneNode* child) override;\r
77 \r
78         protected:\r
79 \r
80                 void copyMaterials();\r
81 \r
82                 core::array<video::SMaterial> Materials;\r
83                 core::aabbox3d<f32> Box;\r
84                 video::SMaterial ReadOnlyMaterial;\r
85 \r
86                 IMesh* Mesh;\r
87                 IShadowVolumeSceneNode* Shadow;\r
88 \r
89                 s32 PassCount;\r
90                 bool ReadOnlyMaterials;\r
91         };\r
92 \r
93 } // end namespace scene\r
94 } // end namespace irr\r
95 \r
96 #endif\r
97 \r