Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials
SMesh.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2010 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_MESH_H_INCLUDED__
6 #define __S_MESH_H_INCLUDED__
7 
8 #include "IMesh.h"
9 #include "IMeshBuffer.h"
10 #include "aabbox3d.h"
11 #include "irrArray.h"
12 
13 namespace irr
14 {
15 namespace scene
16 {
18  struct SMesh : public IMesh
19  {
22  {
23  #ifdef _DEBUG
24  setDebugName("SMesh");
25  #endif
26  }
27 
29  virtual ~SMesh()
30  {
31  // drop buffers
32  for (u32 i=0; i<MeshBuffers.size(); ++i)
33  MeshBuffers[i]->drop();
34  }
35 
37  virtual u32 getMeshBufferCount() const
38  {
39  return MeshBuffers.size();
40  }
41 
43  virtual IMeshBuffer* getMeshBuffer(u32 nr) const
44  {
45  return MeshBuffers[nr];
46  }
47 
49 
50  virtual IMeshBuffer* getMeshBuffer( const video::SMaterial & material) const
51  {
52  for (s32 i = (s32)MeshBuffers.size()-1; i >= 0; --i)
53  {
54  if ( material == MeshBuffers[i]->getMaterial())
55  return MeshBuffers[i];
56  }
57 
58  return 0;
59  }
60 
62  virtual const core::aabbox3d<f32>& getBoundingBox() const
63  {
64  return BoundingBox;
65  }
66 
68  virtual void setBoundingBox( const core::aabbox3df& box)
69  {
70  BoundingBox = box;
71  }
72 
75  {
76  if (MeshBuffers.size())
77  {
78  BoundingBox = MeshBuffers[0]->getBoundingBox();
79  for (u32 i=1; i<MeshBuffers.size(); ++i)
80  BoundingBox.addInternalBox(MeshBuffers[i]->getBoundingBox());
81  }
82  else
83  BoundingBox.reset(0.0f, 0.0f, 0.0f);
84  }
85 
88  {
89  if (buf)
90  {
91  buf->grab();
93  }
94  }
95 
97  virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue)
98  {
99  for (u32 i=0; i<MeshBuffers.size(); ++i)
100  MeshBuffers[i]->getMaterial().setFlag(flag, newvalue);
101  }
102 
105  {
106  for (u32 i=0; i<MeshBuffers.size(); ++i)
107  MeshBuffers[i]->setHardwareMappingHint(newMappingHint, buffer);
108  }
109 
112  {
113  for (u32 i=0; i<MeshBuffers.size(); ++i)
114  MeshBuffers[i]->setDirty(buffer);
115  }
116 
119 
122  };
123 
124 
125 } // end namespace scene
126 } // end namespace irr
127 
128 #endif
129 

The Irrlicht Engine
The Irrlicht Engine Documentation © 2003-2010 by Nikolaus Gebhardt. Generated on Fri Mar 21 2014 04:40:17 by Doxygen (1.8.1.2)