arsa  2.7
SAnimatedMesh.h
Go to the documentation of this file.
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 
5 #ifndef __S_ANIMATED_MESH_H_INCLUDED__
6 #define __S_ANIMATED_MESH_H_INCLUDED__
7 
8 #include "IAnimatedMesh.h"
9 #include "IMesh.h"
10 #include "aabbox3d.h"
11 #include "irrArray.h"
12 
13 namespace irr
14 {
15 namespace scene
16 {
17 
19  struct SAnimatedMesh : public IAnimatedMesh
20  {
23  {
24  #ifdef _DEBUG
25  setDebugName("SAnimatedMesh");
26  #endif
27  addMesh(mesh);
29  }
30 
32  virtual ~SAnimatedMesh()
33  {
34  // drop meshes
35  for (u32 i=0; i<Meshes.size(); ++i)
36  Meshes[i]->drop();
37  }
38 
40 
42  {
43  return Meshes.size();
44  }
45 
47 
49  {
50  return FramesPerSecond;
51  }
52 
54 
57  {
58  FramesPerSecond=fps;
59  }
60 
62 
69  virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1) _IRR_OVERRIDE_
70  {
71  if (Meshes.empty())
72  return 0;
73 
74  return Meshes[frame];
75  }
76 
78  void addMesh(IMesh* mesh)
79  {
80  if (mesh)
81  {
82  mesh->grab();
83  Meshes.push_back(mesh);
84  }
85  }
86 
88 
90  {
91  return Box;
92  }
93 
96  {
97  Box = box;
98  }
99 
102  {
103  Box.reset(0,0,0);
104 
105  if (Meshes.empty())
106  return;
107 
108  Box = Meshes[0]->getBoundingBox();
109 
110  for (u32 i=1; i<Meshes.size(); ++i)
111  Box.addInternalBox(Meshes[i]->getBoundingBox());
112  }
113 
116  {
117  return Type;
118  }
119 
122  {
123  if (Meshes.empty())
124  return 0;
125 
126  return Meshes[0]->getMeshBufferCount();
127  }
128 
131  {
132  if (Meshes.empty())
133  return 0;
134 
135  return Meshes[0]->getMeshBuffer(nr);
136  }
137 
139 
142  virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const _IRR_OVERRIDE_
143  {
144  if (Meshes.empty())
145  return 0;
146 
147  return Meshes[0]->getMeshBuffer(material);
148  }
149 
151  virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) _IRR_OVERRIDE_
152  {
153  for (u32 i=0; i<Meshes.size(); ++i)
154  Meshes[i]->setMaterialFlag(flag, newvalue);
155  }
156 
159  {
160  for (u32 i=0; i<Meshes.size(); ++i)
161  Meshes[i]->setHardwareMappingHint(newMappingHint, buffer);
162  }
163 
166  {
167  for (u32 i=0; i<Meshes.size(); ++i)
168  Meshes[i]->setDirty(buffer);
169  }
170 
173 
176 
179 
182  };
183 
184 
185 } // end namespace scene
186 } // end namespace irr
187 
188 #endif
189 
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) _IRR_OVERRIDE_
flags the meshbuffer as changed, reloads hardware buffers
bool drop() const
Drops the object. Decrements the reference counter by one.
float f32
32 bit floating point variable.
Definition: irrTypes.h:108
E_ANIMATED_MESH_TYPE
Possible types of meshes.
Definition: IMesh.h:19
core::array< IMesh * > Meshes
All meshes defining the animated mesh.
Unknown animated mesh type.
Definition: IMesh.h:22
E_ANIMATED_MESH_TYPE Type
The type of the mesh.
Everything in the Irrlicht Engine can be found in this namespace.
Definition: CARSADPad.h:6
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
Definition: aabbox3d.h:50
virtual IMesh * getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1) _IRR_OVERRIDE_
Returns the IMesh interface for a frame.
Definition: SAnimatedMesh.h:69
Class which holds the geometry of an object.
Definition: IMesh.h:71
void addMesh(IMesh *mesh)
adds a Mesh
Definition: SAnimatedMesh.h:78
virtual u32 getMeshBufferCount() const _IRR_OVERRIDE_
returns amount of mesh buffers.
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) _IRR_OVERRIDE_
set the hardware mapping hint, for driver
virtual void setAnimationSpeed(f32 fps) _IRR_OVERRIDE_
Gets the frame count of the animated mesh.
Definition: SAnimatedMesh.h:56
virtual IMeshBuffer * getMeshBuffer(u32 nr) const _IRR_OVERRIDE_
returns pointer to a mesh buffer
signed int s32
32 bit signed variable.
Definition: irrTypes.h:70
Struct for holding a mesh with a single material.
Definition: IMeshBuffer.h:39
void addInternalBox(const aabbox3d< T > &b)
Adds another bounding box.
Definition: aabbox3d.h:82
f32 FramesPerSecond
Default animation speed of this mesh.
virtual f32 getAnimationSpeed() const _IRR_OVERRIDE_
Gets the default animation speed of the animated mesh.
Definition: SAnimatedMesh.h:48
virtual IMeshBuffer * getMeshBuffer(const video::SMaterial &material) const _IRR_OVERRIDE_
Returns pointer to a mesh buffer which fits a material.
GLfloat f
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
virtual const core::aabbox3d< f32 > & getBoundingBox() const _IRR_OVERRIDE_
Returns an axis aligned bounding box of the mesh.
Definition: SAnimatedMesh.h:89
Change both vertex and index mapping to the same value.
virtual void setBoundingBox(const core::aabbox3df &box) _IRR_OVERRIDE_
set user axis aligned bounding box
Definition: SAnimatedMesh.h:95
virtual u32 getFrameCount() const _IRR_OVERRIDE_
Gets the frame count of the animated mesh.
Definition: SAnimatedMesh.h:41
void recalculateBoundingBox()
Recalculates the bounding box.
Self reallocating template array (like stl vector) with additional features.
Definition: irrArray.h:22
void grab() const
Grabs the object. Increments the reference counter by one.
#define _IRR_OVERRIDE_
Defines an override macro, to protect virtual functions from typos and other mismatches.
Definition: irrTypes.h:216
virtual E_ANIMATED_MESH_TYPE getMeshType() const _IRR_OVERRIDE_
Returns the type of the animated mesh.
E_MATERIAL_FLAG
Material flags.
virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) _IRR_OVERRIDE_
Set a material flag for all meshbuffers of this mesh.
void setDebugName(const c8 *newName)
Sets the debug name of the object.
GLuint buffer
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1571
Simple implementation of the IAnimatedMesh interface.
Definition: SAnimatedMesh.h:19
Interface for an animated mesh.
Definition: IAnimatedMesh.h:20
SAnimatedMesh(scene::IMesh *mesh=0, scene::E_ANIMATED_MESH_TYPE type=scene::EAMT_UNKNOWN)
constructor
Definition: SAnimatedMesh.h:22
core::aabbox3d< f32 > Box
The bounding box of this mesh.
#define const
Definition: zconf.h:217
virtual ~SAnimatedMesh()
destructor
Definition: SAnimatedMesh.h:32
Struct for holding parameters for a material renderer.
Definition: SMaterial.h:304