Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials

# SAnimatedMesh.h

Go to the documentation of this file.

    00001 // Copyright (C) 2002-2009 Nikolaus Gebhardt
    00002 // This file is part of the "Irrlicht Engine".
    00003 // For conditions of distribution and use, see copyright notice in irrlicht.h
    00004
    00005 #ifndef __S_ANIMATED_MESH_H_INCLUDED__
    00006 #define __S_ANIMATED_MESH_H_INCLUDED__
    00007
    00008 #include "IAnimatedMesh.h"
    00009 #include "IMesh.h"
    00010 #include "aabbox3d.h"
    00011 #include "irrArray.h"
    00012
    00013 namespace irr
    00014 {
    00015 namespace scene
    00016 {
    00017
    00019         struct SAnimatedMesh : public IAnimatedMesh
    00020         {
    00022                 SAnimatedMesh(scene::IMesh* mesh=0, scene::E_ANIMATED_MESH_TYPE type=scene::EAMT_UNKNOWN) : IAnimatedMesh(), Type(type)
    00023                 {
    00024                         #ifdef _DEBUG
    00025                         setDebugName("SAnimatedMesh");
    00026                         #endif
    00027                         addMesh(mesh);
    00028                         recalculateBoundingBox();
    00029                 }
    00030
    00031
    00033                 virtual ~SAnimatedMesh()
    00034                 {
    00035                         // drop meshes
    00036                         for (u32 i=0; i<Meshes.size(); ++i)
    00037                                 Meshes[i]->drop();
    00038                 }
    00039
    00040
    00042
    00043                 virtual u32 getFrameCount() const
    00044                 {
    00045                         return Meshes.size();
    00046                 }
    00047
    00048
    00050
    00057                 virtual IMesh* getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop=-1, s32 endFrameLoop=-1)
    00058                 {
    00059                         if (Meshes.empty())
    00060                                 return 0;
    00061
    00062                         return Meshes[frame];
    00063                 }
    00064
    00065
    00067                 void addMesh(IMesh* mesh)
    00068                 {
    00069                         if (mesh)
    00070                         {
    00071                                 mesh->grab();
    00072                                 Meshes.push_back(mesh);
    00073                         }
    00074                 }
    00075
    00076
    00078
    00079                 virtual const core::aabbox3d<f32>& getBoundingBox() const
    00080                 {
    00081                         return Box;
    00082                 }
    00083
    00084
    00086                 virtual void setBoundingBox(const core::aabbox3df& box)
    00087                 {
    00088                         Box = box;
    00089                 }
    00090
    00092                 void recalculateBoundingBox()
    00093                 {
    00094                         Box.reset(0,0,0);
    00095
    00096                         if (Meshes.empty())
    00097                                 return;
    00098
    00099                         Box = Meshes[0]->getBoundingBox();
    00100
    00101                         for (u32 i=1; i<Meshes.size(); ++i)
    00102                                 Box.addInternalBox(Meshes[i]->getBoundingBox());
    00103                 }
    00104
    00105
    00107                 virtual E_ANIMATED_MESH_TYPE getMeshType() const
    00108                 {
    00109                         return Type;
    00110                 }
    00111
    00112
    00114                 virtual u32 getMeshBufferCount() const
    00115                 {
    00116                         if (Meshes.empty())
    00117                                 return 0;
    00118
    00119                         return Meshes[0]->getMeshBufferCount();
    00120                 }
    00121
    00122
    00124                 virtual IMeshBuffer* getMeshBuffer(u32 nr) const
    00125                 {
    00126                         if (Meshes.empty())
    00127                                 return 0;
    00128
    00129                         return Meshes[0]->getMeshBuffer(nr);
    00130                 }
    00131
    00132
    00134
    00137                 virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const
    00138                 {
    00139                         if (Meshes.empty())
    00140                                 return 0;
    00141
    00142                         return Meshes[0]->getMeshBuffer(material);
    00143                 }
    00144
    00145
    00147                 virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue)
    00148                 {
    00149                         for (u32 i=0; i<Meshes.size(); ++i)
    00150                                 Meshes[i]->setMaterialFlag(flag, newvalue);
    00151                 }
    00152
    00154                 virtual void setHardwareMappingHint( E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX )
    00155                 {
    00156                         for (u32 i=0; i<Meshes.size(); ++i)
    00157                                 Meshes[i]->setHardwareMappingHint(newMappingHint, buffer);
    00158                 }
    00159
    00161                 virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
    00162                 {
    00163                         for (u32 i=0; i<Meshes.size(); ++i)
    00164                                 Meshes[i]->setDirty(buffer);
    00165                 }
    00166
    00168                 core::array<IMesh*> Meshes;
    00169
    00171                 core::aabbox3d<f32> Box;
    00172
    00174                 E_ANIMATED_MESH_TYPE Type;
    00175         };
    00176
    00177
    00178 } // end namespace scene
    00179 } // end namespace irr
    00180
    00181 #endif
    00182

| The Irrlicht Engine Documentation © 2003-2010 by Nikolaus Gebhardt. Generated on Sun Feb 14 13:06:58 2010 by Doxygen (1.6.2)