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

SMesh.h

Go to the documentation of this file.
00001 // Copyright (C) 2002-2010 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_MESH_H_INCLUDED__
00006 #define __S_MESH_H_INCLUDED__
00007 
00008 #include "IMesh.h"
00009 #include "IMeshBuffer.h"
00010 #include "aabbox3d.h"
00011 #include "irrArray.h"
00012 
00013 namespace irr
00014 {
00015 namespace scene
00016 {
00018         struct SMesh : public IMesh
00019         {
00021                 SMesh()
00022                 {
00023                         #ifdef _DEBUG
00024                         setDebugName("SMesh");
00025                         #endif
00026                 }
00027 
00029                 virtual ~SMesh()
00030                 {
00031                         // drop buffers
00032                         for (u32 i=0; i<MeshBuffers.size(); ++i)
00033                                 MeshBuffers[i]->drop();
00034                 }
00035 
00037                 virtual u32 getMeshBufferCount() const
00038                 {
00039                         return MeshBuffers.size();
00040                 }
00041 
00043                 virtual IMeshBuffer* getMeshBuffer(u32 nr) const
00044                 {
00045                         return MeshBuffers[nr];
00046                 }
00047 
00049 
00050                 virtual IMeshBuffer* getMeshBuffer( const video::SMaterial & material) const
00051                 {
00052                         for (s32 i = (s32)MeshBuffers.size()-1; i >= 0; --i)
00053                         {
00054                                 if ( material == MeshBuffers[i]->getMaterial())
00055                                         return MeshBuffers[i];
00056                         }
00057 
00058                         return 0;
00059                 }
00060 
00062                 virtual const core::aabbox3d<f32>& getBoundingBox() const
00063                 {
00064                         return BoundingBox;
00065                 }
00066 
00068                 virtual void setBoundingBox( const core::aabbox3df& box)
00069                 {
00070                         BoundingBox = box;
00071                 }
00072 
00074                 void recalculateBoundingBox()
00075                 {
00076                         if (MeshBuffers.size())
00077                         {
00078                                 BoundingBox = MeshBuffers[0]->getBoundingBox();
00079                                 for (u32 i=1; i<MeshBuffers.size(); ++i)
00080                                         BoundingBox.addInternalBox(MeshBuffers[i]->getBoundingBox());
00081                         }
00082                         else
00083                                 BoundingBox.reset(0.0f, 0.0f, 0.0f);
00084                 }
00085 
00087                 void addMeshBuffer(IMeshBuffer* buf)
00088                 {
00089                         if (buf)
00090                         {
00091                                 buf->grab();
00092                                 MeshBuffers.push_back(buf);
00093                         }
00094                 }
00095 
00097                 virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue)
00098                 {
00099                         for (u32 i=0; i<MeshBuffers.size(); ++i)
00100                                 MeshBuffers[i]->getMaterial().setFlag(flag, newvalue);
00101                 }
00102 
00104                 virtual void setHardwareMappingHint( E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX )
00105                 {
00106                         for (u32 i=0; i<MeshBuffers.size(); ++i)
00107                                 MeshBuffers[i]->setHardwareMappingHint(newMappingHint, buffer);
00108                 }
00109 
00111                 virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
00112                 {
00113                         for (u32 i=0; i<MeshBuffers.size(); ++i)
00114                                 MeshBuffers[i]->setDirty(buffer);
00115                 }
00116 
00118                 core::array<IMeshBuffer*> MeshBuffers;
00119 
00121                 core::aabbox3d<f32> BoundingBox;
00122         };
00123 
00124 
00125 } // end namespace scene
00126 } // end namespace irr
00127 
00128 #endif
00129 

The Irrlicht Engine
The Irrlicht Engine Documentation © 2003-2010 by Nikolaus Gebhardt. Generated on Sun Oct 24 12:41:58 2010 by Doxygen (1.6.2)