1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
5
#ifndef __S_ANIMATED_MESH_H_INCLUDED__
6
#define __S_ANIMATED_MESH_H_INCLUDED__
8
#include "IAnimatedMesh.h"
18
//! Simple implementation of the IAnimatedMesh interface.
19
struct SAnimatedMesh : public IAnimatedMesh
22
SAnimatedMesh(scene::IMesh* mesh=0, scene::E_ANIMATED_MESH_TYPE type=scene::EAMT_UNKNOWN) : IAnimatedMesh(), Type(type)
25
setDebugName("SAnimatedMesh");
28
recalculateBoundingBox();
33
virtual ~SAnimatedMesh()
36
for (u32 i=0; i<Meshes.size(); ++i)
41
//! Gets the frame count of the animated mesh.
42
/** \return Amount of frames. If the amount is 1, it is a static, non animated mesh. */
43
virtual u32 getFrameCount() const
49
//! Returns the IMesh interface for a frame.
50
/** \param frame: Frame number as zero based index. The maximum frame number is
52
\param detailLevel: Level of detail. 0 is the lowest,
53
255 the highest level of detail. Most meshes will ignore the detail level.
54
\param startFrameLoop: start frame
55
\param endFrameLoop: end frame
56
\return The animated mesh based on a detail level. */
57
virtual IMesh* getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop=-1, s32 endFrameLoop=-1)
67
void addMesh(IMesh* mesh)
72
Meshes.push_back(mesh);
77
//! Returns an axis aligned bounding box of the mesh.
78
/** \return A bounding box of this mesh is returned. */
79
virtual const core::aabbox3d<f32>& getBoundingBox() const
85
//! set user axis aligned bounding box
86
virtual void setBoundingBox(const core::aabbox3df& box)
91
//! Recalculates the bounding box.
92
void recalculateBoundingBox()
99
Box = Meshes[0]->getBoundingBox();
101
for (u32 i=1; i<Meshes.size(); ++i)
102
Box.addInternalBox(Meshes[i]->getBoundingBox());
106
//! Returns the type of the animated mesh.
107
virtual E_ANIMATED_MESH_TYPE getMeshType() const
113
//! returns amount of mesh buffers.
114
virtual u32 getMeshBufferCount() const
119
return Meshes[0]->getMeshBufferCount();
123
//! returns pointer to a mesh buffer
124
virtual IMeshBuffer* getMeshBuffer(u32 nr) const
129
return Meshes[0]->getMeshBuffer(nr);
133
//! Returns pointer to a mesh buffer which fits a material
134
/** \param material: material to search for
135
\return Returns the pointer to the mesh buffer or
136
NULL if there is no such mesh buffer. */
137
virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const
142
return Meshes[0]->getMeshBuffer(material);
146
//! Set a material flag for all meshbuffers of this mesh.
147
virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue)
149
for (u32 i=0; i<Meshes.size(); ++i)
150
Meshes[i]->setMaterialFlag(flag, newvalue);
153
//! set the hardware mapping hint, for driver
154
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX )
156
for (u32 i=0; i<Meshes.size(); ++i)
157
Meshes[i]->setHardwareMappingHint(newMappingHint, buffer);
160
//! flags the meshbuffer as changed, reloads hardware buffers
161
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
163
for (u32 i=0; i<Meshes.size(); ++i)
164
Meshes[i]->setDirty(buffer);
167
//! All meshes defining the animated mesh
168
core::array<IMesh*> Meshes;
170
//! The bounding box of this mesh
171
core::aabbox3d<f32> Box;
173
//! Tyhe type fo the mesh.
174
E_ANIMATED_MESH_TYPE Type;
178
} // end namespace scene
179
} // end namespace irr