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

# SSharedMeshBuffer.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_SHARED_MESH_BUFFER_H_INCLUDED__
    00006 #define __S_SHARED_MESH_BUFFER_H_INCLUDED__
    00007
    00008 #include "irrArray.h"
    00009 #include "IMeshBuffer.h"
    00010
    00011 namespace irr
    00012 {
    00013 namespace scene
    00014 {
    00016         struct SSharedMeshBuffer : public IMeshBuffer
    00017         {
    00019                 SSharedMeshBuffer() : IMeshBuffer(), Vertices(0), ChangedID_Vertex(1), ChangedID_Index(1), MappingHintVertex(EHM_NEVER), MappingHintIndex(EHM_NEVER)
    00020                 {
    00021                         #ifdef _DEBUG
    00022                         setDebugName("SSharedMeshBuffer");
    00023                         #endif
    00024                 }
    00025
    00027                 SSharedMeshBuffer(core::array<video::S3DVertex> *vertices) : IMeshBuffer(), Vertices(vertices)
    00028                 {
    00029                         #ifdef _DEBUG
    00030                         setDebugName("SSharedMeshBuffer");
    00031                         #endif
    00032                 }
    00033
    00035                 virtual const video::SMaterial& getMaterial() const
    00036                 {
    00037                         return Material;
    00038                 }
    00039
    00041                 virtual video::SMaterial& getMaterial()
    00042                 {
    00043                         return Material;
    00044                 }
    00045
    00047                 virtual const void* getVertices() const
    00048                 {
    00049                         if (Vertices)
    00050                                 return Vertices->const_pointer();
    00051                         else
    00052                                 return 0;
    00053                 }
    00054
    00056                 virtual void* getVertices()
    00057                 {
    00058                         if (Vertices)
    00059                                 return Vertices->pointer();
    00060                         else
    00061                                 return 0;
    00062                 }
    00063
    00065                 virtual u32 getVertexCount() const
    00066                 {
    00067                         if (Vertices)
    00068                                 return Vertices->size();
    00069                         else
    00070                                 return 0;
    00071                 }
    00072
    00074                 virtual const u16* getIndices() const
    00075                 {
    00076                         return Indices.const_pointer();
    00077                 }
    00078
    00080                 virtual u16* getIndices()
    00081                 {
    00082                         return Indices.pointer();
    00083                 }
    00084
    00086                 virtual u32 getIndexCount() const
    00087                 {
    00088                         return Indices.size();
    00089                 }
    00090
    00092                 virtual const core::aabbox3d<f32>& getBoundingBox() const
    00093                 {
    00094                         return BoundingBox;
    00095                 }
    00096
    00098                 virtual void setBoundingBox( const core::aabbox3df& box)
    00099                 {
    00100                         BoundingBox = box;
    00101                 }
    00102
    00104                 virtual video::E_VERTEX_TYPE getVertexType() const
    00105                 {
    00106                         return video::EVT_STANDARD;
    00107                 }
    00108
    00110                 virtual void recalculateBoundingBox()
    00111                 {
    00112                         if (!Vertices || Vertices->empty() || Indices.empty())
    00113                                 BoundingBox.reset(0,0,0);
    00114                         else
    00115                         {
    00116                                 BoundingBox.reset((*Vertices)[Indices[0]].Pos);
    00117                                 for (u32 i=1; i<Indices.size(); ++i)
    00118                                         BoundingBox.addInternalPoint((*Vertices)[Indices[i]].Pos);
    00119                         }
    00120                 }
    00121
    00123                 virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) {}
    00124
    00126                 virtual void append(const IMeshBuffer* const other) {}
    00127
    00128
    00130                 virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const
    00131                 {
    00132                         return MappingHintVertex;
    00133                 }
    00134
    00136                 virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const
    00137                 {
    00138                         return MappingHintIndex;
    00139                 }
    00140
    00142                 virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX )
    00143                 {
    00144                         if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_VERTEX)
    00145                                 MappingHintVertex=NewMappingHint;
    00146                         if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_INDEX)
    00147                                 MappingHintIndex=NewMappingHint;
    00148                 }
    00149
    00150
    00152                 virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
    00153                 {
    00154                         if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_VERTEX)
    00155                                 ++ChangedID_Vertex;
    00156                         if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_INDEX)
    00157                                 ++ChangedID_Index;
    00158                 }
    00159
    00161
    00162                 virtual u32 getChangedID_Vertex() const {return ChangedID_Vertex;}
    00163
    00165
    00166                 virtual u32 getChangedID_Index() const {return ChangedID_Index;}
    00167
    00169                 video::SMaterial Material;
    00170
    00172                 core::array<video::S3DVertex> *Vertices;
    00173
    00175                 core::array<u16> Indices;
    00176
    00178                 u32 ChangedID_Vertex;
    00179
    00181                 u32 ChangedID_Index;
    00182
    00184                 core::aabbox3df BoundingBox;
    00185
    00187                 E_HARDWARE_MAPPING MappingHintVertex;
    00188                 E_HARDWARE_MAPPING MappingHintIndex;
    00189
    00190         };
    00191
    00192
    00193 } // end namespace scene
    00194 } // end namespace irr
    00195
    00196 #endif
    00197

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