diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8/include/SMesh.h | 280 |
1 files changed, 140 insertions, 140 deletions
diff --git a/libraries/irrlicht-1.8/include/SMesh.h b/libraries/irrlicht-1.8/include/SMesh.h index 77a695d..efac56e 100644 --- a/libraries/irrlicht-1.8/include/SMesh.h +++ b/libraries/irrlicht-1.8/include/SMesh.h | |||
@@ -1,140 +1,140 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | 1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | 4 | ||
5 | #ifndef __S_MESH_H_INCLUDED__ | 5 | #ifndef __S_MESH_H_INCLUDED__ |
6 | #define __S_MESH_H_INCLUDED__ | 6 | #define __S_MESH_H_INCLUDED__ |
7 | 7 | ||
8 | #include "IMesh.h" | 8 | #include "IMesh.h" |
9 | #include "IMeshBuffer.h" | 9 | #include "IMeshBuffer.h" |
10 | #include "aabbox3d.h" | 10 | #include "aabbox3d.h" |
11 | #include "irrArray.h" | 11 | #include "irrArray.h" |
12 | 12 | ||
13 | namespace irr | 13 | namespace irr |
14 | { | 14 | { |
15 | namespace scene | 15 | namespace scene |
16 | { | 16 | { |
17 | //! Simple implementation of the IMesh interface. | 17 | //! Simple implementation of the IMesh interface. |
18 | struct SMesh : public IMesh | 18 | struct SMesh : public IMesh |
19 | { | 19 | { |
20 | //! constructor | 20 | //! constructor |
21 | SMesh() | 21 | SMesh() |
22 | { | 22 | { |
23 | #ifdef _DEBUG | 23 | #ifdef _DEBUG |
24 | setDebugName("SMesh"); | 24 | setDebugName("SMesh"); |
25 | #endif | 25 | #endif |
26 | } | 26 | } |
27 | 27 | ||
28 | //! destructor | 28 | //! destructor |
29 | virtual ~SMesh() | 29 | virtual ~SMesh() |
30 | { | 30 | { |
31 | // drop buffers | 31 | // drop buffers |
32 | for (u32 i=0; i<MeshBuffers.size(); ++i) | 32 | for (u32 i=0; i<MeshBuffers.size(); ++i) |
33 | MeshBuffers[i]->drop(); | 33 | MeshBuffers[i]->drop(); |
34 | } | 34 | } |
35 | 35 | ||
36 | //! clean mesh | 36 | //! clean mesh |
37 | virtual void clear() | 37 | virtual void clear() |
38 | { | 38 | { |
39 | for (u32 i=0; i<MeshBuffers.size(); ++i) | 39 | for (u32 i=0; i<MeshBuffers.size(); ++i) |
40 | MeshBuffers[i]->drop(); | 40 | MeshBuffers[i]->drop(); |
41 | MeshBuffers.clear(); | 41 | MeshBuffers.clear(); |
42 | BoundingBox.reset ( 0.f, 0.f, 0.f ); | 42 | BoundingBox.reset ( 0.f, 0.f, 0.f ); |
43 | } | 43 | } |
44 | 44 | ||
45 | 45 | ||
46 | //! returns amount of mesh buffers. | 46 | //! returns amount of mesh buffers. |
47 | virtual u32 getMeshBufferCount() const | 47 | virtual u32 getMeshBufferCount() const |
48 | { | 48 | { |
49 | return MeshBuffers.size(); | 49 | return MeshBuffers.size(); |
50 | } | 50 | } |
51 | 51 | ||
52 | //! returns pointer to a mesh buffer | 52 | //! returns pointer to a mesh buffer |
53 | virtual IMeshBuffer* getMeshBuffer(u32 nr) const | 53 | virtual IMeshBuffer* getMeshBuffer(u32 nr) const |
54 | { | 54 | { |
55 | return MeshBuffers[nr]; | 55 | return MeshBuffers[nr]; |
56 | } | 56 | } |
57 | 57 | ||
58 | //! returns a meshbuffer which fits a material | 58 | //! returns a meshbuffer which fits a material |
59 | /** reverse search */ | 59 | /** reverse search */ |
60 | virtual IMeshBuffer* getMeshBuffer( const video::SMaterial & material) const | 60 | virtual IMeshBuffer* getMeshBuffer( const video::SMaterial & material) const |
61 | { | 61 | { |
62 | for (s32 i = (s32)MeshBuffers.size()-1; i >= 0; --i) | 62 | for (s32 i = (s32)MeshBuffers.size()-1; i >= 0; --i) |
63 | { | 63 | { |
64 | if ( material == MeshBuffers[i]->getMaterial()) | 64 | if ( material == MeshBuffers[i]->getMaterial()) |
65 | return MeshBuffers[i]; | 65 | return MeshBuffers[i]; |
66 | } | 66 | } |
67 | 67 | ||
68 | return 0; | 68 | return 0; |
69 | } | 69 | } |
70 | 70 | ||
71 | //! returns an axis aligned bounding box | 71 | //! returns an axis aligned bounding box |
72 | virtual const core::aabbox3d<f32>& getBoundingBox() const | 72 | virtual const core::aabbox3d<f32>& getBoundingBox() const |
73 | { | 73 | { |
74 | return BoundingBox; | 74 | return BoundingBox; |
75 | } | 75 | } |
76 | 76 | ||
77 | //! set user axis aligned bounding box | 77 | //! set user axis aligned bounding box |
78 | virtual void setBoundingBox( const core::aabbox3df& box) | 78 | virtual void setBoundingBox( const core::aabbox3df& box) |
79 | { | 79 | { |
80 | BoundingBox = box; | 80 | BoundingBox = box; |
81 | } | 81 | } |
82 | 82 | ||
83 | //! recalculates the bounding box | 83 | //! recalculates the bounding box |
84 | void recalculateBoundingBox() | 84 | void recalculateBoundingBox() |
85 | { | 85 | { |
86 | if (MeshBuffers.size()) | 86 | if (MeshBuffers.size()) |
87 | { | 87 | { |
88 | BoundingBox = MeshBuffers[0]->getBoundingBox(); | 88 | BoundingBox = MeshBuffers[0]->getBoundingBox(); |
89 | for (u32 i=1; i<MeshBuffers.size(); ++i) | 89 | for (u32 i=1; i<MeshBuffers.size(); ++i) |
90 | BoundingBox.addInternalBox(MeshBuffers[i]->getBoundingBox()); | 90 | BoundingBox.addInternalBox(MeshBuffers[i]->getBoundingBox()); |
91 | } | 91 | } |
92 | else | 92 | else |
93 | BoundingBox.reset(0.0f, 0.0f, 0.0f); | 93 | BoundingBox.reset(0.0f, 0.0f, 0.0f); |
94 | } | 94 | } |
95 | 95 | ||
96 | //! adds a MeshBuffer | 96 | //! adds a MeshBuffer |
97 | /** The bounding box is not updated automatically. */ | 97 | /** The bounding box is not updated automatically. */ |
98 | void addMeshBuffer(IMeshBuffer* buf) | 98 | void addMeshBuffer(IMeshBuffer* buf) |
99 | { | 99 | { |
100 | if (buf) | 100 | if (buf) |
101 | { | 101 | { |
102 | buf->grab(); | 102 | buf->grab(); |
103 | MeshBuffers.push_back(buf); | 103 | MeshBuffers.push_back(buf); |
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | //! sets a flag of all contained materials to a new value | 107 | //! sets a flag of all contained materials to a new value |
108 | virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) | 108 | virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) |
109 | { | 109 | { |
110 | for (u32 i=0; i<MeshBuffers.size(); ++i) | 110 | for (u32 i=0; i<MeshBuffers.size(); ++i) |
111 | MeshBuffers[i]->getMaterial().setFlag(flag, newvalue); | 111 | MeshBuffers[i]->getMaterial().setFlag(flag, newvalue); |
112 | } | 112 | } |
113 | 113 | ||
114 | //! set the hardware mapping hint, for driver | 114 | //! set the hardware mapping hint, for driver |
115 | virtual void setHardwareMappingHint( E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX ) | 115 | virtual void setHardwareMappingHint( E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX ) |
116 | { | 116 | { |
117 | for (u32 i=0; i<MeshBuffers.size(); ++i) | 117 | for (u32 i=0; i<MeshBuffers.size(); ++i) |
118 | MeshBuffers[i]->setHardwareMappingHint(newMappingHint, buffer); | 118 | MeshBuffers[i]->setHardwareMappingHint(newMappingHint, buffer); |
119 | } | 119 | } |
120 | 120 | ||
121 | //! flags the meshbuffer as changed, reloads hardware buffers | 121 | //! flags the meshbuffer as changed, reloads hardware buffers |
122 | virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) | 122 | virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) |
123 | { | 123 | { |
124 | for (u32 i=0; i<MeshBuffers.size(); ++i) | 124 | for (u32 i=0; i<MeshBuffers.size(); ++i) |
125 | MeshBuffers[i]->setDirty(buffer); | 125 | MeshBuffers[i]->setDirty(buffer); |
126 | } | 126 | } |
127 | 127 | ||
128 | //! The meshbuffers of this mesh | 128 | //! The meshbuffers of this mesh |
129 | core::array<IMeshBuffer*> MeshBuffers; | 129 | core::array<IMeshBuffer*> MeshBuffers; |
130 | 130 | ||
131 | //! The bounding box of this mesh | 131 | //! The bounding box of this mesh |
132 | core::aabbox3d<f32> BoundingBox; | 132 | core::aabbox3d<f32> BoundingBox; |
133 | }; | 133 | }; |
134 | 134 | ||
135 | 135 | ||
136 | } // end namespace scene | 136 | } // end namespace scene |
137 | } // end namespace irr | 137 | } // end namespace irr |
138 | 138 | ||
139 | #endif | 139 | #endif |
140 | 140 | ||