00001 // Copyright (C) 2008-2012 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 __I_DYNAMIC_MESH_BUFFER_H_INCLUDED__ 00006 #define __I_DYNAMIC_MESH_BUFFER_H_INCLUDED__ 00007 00008 #include "IMeshBuffer.h" 00009 #include "IVertexBuffer.h" 00010 #include "IIndexBuffer.h" 00011 00012 namespace irr 00013 { 00014 namespace scene 00015 { 00016 00018 class IDynamicMeshBuffer : public IMeshBuffer 00019 { 00020 public: 00021 virtual IVertexBuffer &getVertexBuffer() const =0; 00022 virtual IIndexBuffer &getIndexBuffer() const =0; 00023 00024 virtual void setVertexBuffer(IVertexBuffer *vertexBuffer) =0; 00025 virtual void setIndexBuffer(IIndexBuffer *indexBuffer) =0; 00026 00028 00029 virtual video::SMaterial& getMaterial() =0; 00030 00032 00033 virtual const video::SMaterial& getMaterial() const =0; 00034 00036 00037 virtual const core::aabbox3df& getBoundingBox() const =0; 00038 00040 00042 virtual void setBoundingBox(const core::aabbox3df& box) =0; 00043 00045 virtual void recalculateBoundingBox() =0; 00046 00048 00053 virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) 00054 { 00055 00056 } 00057 00059 00061 virtual void append(const IMeshBuffer* const other) 00062 { 00063 00064 } 00065 00066 // ------------------- To be removed? ------------------- // 00067 00069 virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const 00070 { 00071 return getVertexBuffer().getHardwareMappingHint(); 00072 } 00073 00075 virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const 00076 { 00077 return getIndexBuffer().getHardwareMappingHint(); 00078 } 00079 00081 virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX ) 00082 { 00083 if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX) 00084 getVertexBuffer().setHardwareMappingHint(NewMappingHint); 00085 if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX) 00086 getIndexBuffer().setHardwareMappingHint(NewMappingHint); 00087 } 00088 00090 virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX) 00091 { 00092 if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX) 00093 getVertexBuffer().setDirty(); 00094 if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX) 00095 getIndexBuffer().setDirty(); 00096 } 00097 00098 virtual u32 getChangedID_Vertex() const 00099 { 00100 return getVertexBuffer().getChangedID(); 00101 } 00102 00103 virtual u32 getChangedID_Index() const 00104 { 00105 return getIndexBuffer().getChangedID(); 00106 } 00107 00108 // ------------------- Old interface ------------------- // 00109 00111 00112 virtual video::E_VERTEX_TYPE getVertexType() const 00113 { 00114 return getVertexBuffer().getType(); 00115 } 00116 00118 00120 virtual const void* getVertices() const 00121 { 00122 return getVertexBuffer().getData(); 00123 } 00124 00126 00128 virtual void* getVertices() 00129 { 00130 return getVertexBuffer().getData(); 00131 } 00132 00134 00135 virtual u32 getVertexCount() const 00136 { 00137 return getVertexBuffer().size(); 00138 } 00139 00141 00142 virtual video::E_INDEX_TYPE getIndexType() const 00143 { 00144 return getIndexBuffer().getType(); 00145 } 00146 00148 00149 virtual const u16* getIndices() const 00150 { 00151 return (u16*)getIndexBuffer().getData(); 00152 } 00153 00155 00156 virtual u16* getIndices() 00157 { 00158 return (u16*)getIndexBuffer().getData(); 00159 } 00160 00162 00163 virtual u32 getIndexCount() const 00164 { 00165 return getIndexBuffer().size(); 00166 } 00167 00169 virtual const core::vector3df& getPosition(u32 i) const 00170 { 00171 return getVertexBuffer()[i].Pos; 00172 } 00173 00175 virtual core::vector3df& getPosition(u32 i) 00176 { 00177 return getVertexBuffer()[i].Pos; 00178 } 00179 00181 virtual const core::vector2df& getTCoords(u32 i) const 00182 { 00183 return getVertexBuffer()[i].TCoords; 00184 } 00185 00187 virtual core::vector2df& getTCoords(u32 i) 00188 { 00189 return getVertexBuffer()[i].TCoords; 00190 } 00191 00193 virtual const core::vector3df& getNormal(u32 i) const 00194 { 00195 return getVertexBuffer()[i].Normal; 00196 } 00197 00199 virtual core::vector3df& getNormal(u32 i) 00200 { 00201 return getVertexBuffer()[i].Normal; 00202 } 00203 }; 00204 00205 00206 } // end namespace scene 00207 } // end namespace irr 00208 00209 #endif 00210 00211