Loading...
Searching...
No Matches
SSharedMeshBuffer.h
Go to the documentation of this file.
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __S_SHARED_MESH_BUFFER_H_INCLUDED__
#define __S_SHARED_MESH_BUFFER_H_INCLUDED__
#include "irrArray.h"
#include "IMeshBuffer.h"
namespace irr
{
namespace scene
{
struct SSharedMeshBuffer : public IMeshBuffer
{
SSharedMeshBuffer() : IMeshBuffer(), Vertices(0), ChangedID_Vertex(1), ChangedID_Index(1), MappingHintVertex(EHM_NEVER), MappingHintIndex(EHM_NEVER)
{
#ifdef _DEBUG
setDebugName("SSharedMeshBuffer");
#endif
}
SSharedMeshBuffer(core::array<video::S3DVertex> *vertices) : IMeshBuffer(), Vertices(vertices)
{
#ifdef _DEBUG
setDebugName("SSharedMeshBuffer");
#endif
}
virtual const video::SMaterial& getMaterial() const
{
return Material;
}
virtual video::SMaterial& getMaterial()
{
return Material;
}
virtual const void* getVertices() const
{
if (Vertices)
return Vertices->const_pointer();
else
return 0;
}
virtual void* getVertices()
{
if (Vertices)
return Vertices->pointer();
else
return 0;
}
virtual u32 getVertexCount() const
{
if (Vertices)
return Vertices->size();
else
return 0;
}
virtual const u16* getIndices() const
{
return Indices.const_pointer();
}
virtual u16* getIndices()
{
return Indices.pointer();
}
virtual u32 getIndexCount() const
{
return Indices.size();
}
virtual video::E_INDEX_TYPE getIndexType() const
{
return video::EIT_16BIT;
}
virtual const core::aabbox3d<f32>& getBoundingBox() const
{
return BoundingBox;
}
virtual void setBoundingBox( const core::aabbox3df& box)
{
BoundingBox = box;
}
virtual video::E_VERTEX_TYPE getVertexType() const
{
return video::EVT_STANDARD;
}
virtual void recalculateBoundingBox()
{
if (!Vertices || Vertices->empty() || Indices.empty())
BoundingBox.reset(0,0,0);
else
{
BoundingBox.reset((*Vertices)[Indices[0]].Pos);
for (u32 i=1; i<Indices.size(); ++i)
BoundingBox.addInternalPoint((*Vertices)[Indices[i]].Pos);
}
}
virtual const core::vector3df& getPosition(u32 i) const
{
_IRR_DEBUG_BREAK_IF(!Vertices);
return (*Vertices)[Indices[i]].Pos;
}
virtual core::vector3df& getPosition(u32 i)
{
_IRR_DEBUG_BREAK_IF(!Vertices);
return (*Vertices)[Indices[i]].Pos;
}
virtual const core::vector3df& getNormal(u32 i) const
{
_IRR_DEBUG_BREAK_IF(!Vertices);
return (*Vertices)[Indices[i]].Normal;
}
virtual core::vector3df& getNormal(u32 i)
{
_IRR_DEBUG_BREAK_IF(!Vertices);
return (*Vertices)[Indices[i]].Normal;
}
virtual const core::vector2df& getTCoords(u32 i) const
{
_IRR_DEBUG_BREAK_IF(!Vertices);
return (*Vertices)[Indices[i]].TCoords;
}
virtual core::vector2df& getTCoords(u32 i)
{
_IRR_DEBUG_BREAK_IF(!Vertices);
return (*Vertices)[Indices[i]].TCoords;
}
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) {}
virtual void append(const IMeshBuffer* const other) {}
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const
{
return MappingHintVertex;
}
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const
{
return MappingHintIndex;
}
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX )
{
if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_VERTEX)
MappingHintVertex=NewMappingHint;
if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_INDEX)
MappingHintIndex=NewMappingHint;
}
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
{
if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_VERTEX)
++ChangedID_Vertex;
if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_INDEX)
++ChangedID_Index;
}
virtual u32 getChangedID_Vertex() const {return ChangedID_Vertex;}
virtual u32 getChangedID_Index() const {return ChangedID_Index;}
video::SMaterial Material;
core::array<video::S3DVertex> *Vertices;
core::array<u16> Indices;
u32 ChangedID_Vertex;
u32 ChangedID_Index;
core::aabbox3df BoundingBox;
E_HARDWARE_MAPPING MappingHintVertex;
E_HARDWARE_MAPPING MappingHintIndex;
};
} // end namespace scene
} // end namespace irr
#endif
IMeshBuffer.h
irr::IReferenceCounted::setDebugName
void setDebugName(const c8 *newName)
Sets the debug name of the object.
Definition IReferenceCounted.h:153
irr::core::aabbox3d
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.h:22
irr::core::array
Self reallocating template array (like stl vector) with additional features.
Definition irrArray.h:23
irr::scene::IMeshBuffer
Struct for holding a mesh with a single material.
Definition IMeshBuffer.h:40
irr::video::SMaterial
Struct for holding parameters for a material renderer.
Definition SMaterial.h:227
irrArray.h
_IRR_DEBUG_BREAK_IF
#define _IRR_DEBUG_BREAK_IF(_CONDITION_)
define a break macro for debugging.
Definition irrTypes.h:178
irr::core::vector3df
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
irr::core::vector2df
vector2d< f32 > vector2df
Typedef for f32 2d vector.
Definition vector2d.h:323
irr::core::aabbox3df
aabbox3d< f32 > aabbox3df
Typedef for a f32 3d bounding box.
Definition aabbox3d.h:324
irr::scene
All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees a...
Definition CDynamicMeshBuffer.h:16
irr::scene::E_BUFFER_TYPE
E_BUFFER_TYPE
Definition EHardwareBufferFlags.h:29
irr::scene::EBT_VERTEX_AND_INDEX
@ EBT_VERTEX_AND_INDEX
Change both vertex and index mapping to the same value.
Definition EHardwareBufferFlags.h:37
irr::scene::EBT_INDEX
@ EBT_INDEX
Change the index mapping.
Definition EHardwareBufferFlags.h:35
irr::scene::EBT_VERTEX
@ EBT_VERTEX
Change the vertex mapping.
Definition EHardwareBufferFlags.h:33
irr::scene::E_HARDWARE_MAPPING
E_HARDWARE_MAPPING
Definition EHardwareBufferFlags.h:14
irr::scene::EHM_NEVER
@ EHM_NEVER
Don't store on the hardware.
Definition EHardwareBufferFlags.h:16
irr::video::E_VERTEX_TYPE
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition S3DVertex.h:19
irr::video::EVT_STANDARD
@ EVT_STANDARD
Standard vertex type used by the Irrlicht engine, video::S3DVertex.
Definition S3DVertex.h:21
irr::video::E_INDEX_TYPE
E_INDEX_TYPE
Definition SVertexIndex.h:16
irr::video::EIT_16BIT
@ EIT_16BIT
Definition SVertexIndex.h:17
irr
Everything in the Irrlicht Engine can be found in this namespace.
Definition aabbox3d.h:13
irr::u32
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58
irr::u16
unsigned short u16
16 bit unsigned variable.
Definition irrTypes.h:40
irr::scene::SSharedMeshBuffer::MappingHintIndex
E_HARDWARE_MAPPING MappingHintIndex
Definition SSharedMeshBuffer.h:234
irr::scene::SSharedMeshBuffer::ChangedID_Vertex
u32 ChangedID_Vertex
ID used for hardware buffer management.
Definition SSharedMeshBuffer.h:224
irr::scene::SSharedMeshBuffer::getIndices
virtual const u16 * getIndices() const
returns pointer to Indices
Definition SSharedMeshBuffer.h:74
irr::scene::SSharedMeshBuffer::getChangedID_Index
virtual u32 getChangedID_Index() const
Get the currently used ID for identification of changes.
Definition SSharedMeshBuffer.h:212
irr::scene::SSharedMeshBuffer::setHardwareMappingHint
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
set the hardware mapping hint, for driver
Definition SSharedMeshBuffer.h:189
irr::scene::SSharedMeshBuffer::recalculateBoundingBox
virtual void recalculateBoundingBox()
recalculates the bounding box. should be called if the mesh changed.
Definition SSharedMeshBuffer.h:116
irr::scene::SSharedMeshBuffer::Indices
core::array< u16 > Indices
Array of Indices.
Definition SSharedMeshBuffer.h:221
irr::scene::SSharedMeshBuffer::Material
video::SMaterial Material
Material of this meshBuffer.
Definition SSharedMeshBuffer.h:215
irr::scene::SSharedMeshBuffer::getVertices
virtual void * getVertices()
returns pointer to vertices
Definition SSharedMeshBuffer.h:56
irr::scene::SSharedMeshBuffer::getHardwareMappingHint_Vertex
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const
get the current hardware mapping hint
Definition SSharedMeshBuffer.h:177
irr::scene::SSharedMeshBuffer::getHardwareMappingHint_Index
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const
get the current hardware mapping hint
Definition SSharedMeshBuffer.h:183
irr::scene::SSharedMeshBuffer::getNormal
virtual core::vector3df & getNormal(u32 i)
returns normal of vertex i
Definition SSharedMeshBuffer.h:150
irr::scene::SSharedMeshBuffer::setBoundingBox
virtual void setBoundingBox(const core::aabbox3df &box)
set user axis aligned bounding box
Definition SSharedMeshBuffer.h:104
irr::scene::SSharedMeshBuffer::getTCoords
virtual const core::vector2df & getTCoords(u32 i) const
returns texture coord of vertex i
Definition SSharedMeshBuffer.h:157
irr::scene::SSharedMeshBuffer::getVertices
virtual const void * getVertices() const
returns pointer to vertices
Definition SSharedMeshBuffer.h:47
irr::scene::SSharedMeshBuffer::getTCoords
virtual core::vector2df & getTCoords(u32 i)
returns texture coord of vertex i
Definition SSharedMeshBuffer.h:164
irr::scene::SSharedMeshBuffer::getPosition
virtual core::vector3df & getPosition(u32 i)
returns position of vertex i
Definition SSharedMeshBuffer.h:136
irr::scene::SSharedMeshBuffer::ChangedID_Index
u32 ChangedID_Index
ID used for hardware buffer management.
Definition SSharedMeshBuffer.h:227
irr::scene::SSharedMeshBuffer::getIndexCount
virtual u32 getIndexCount() const
returns amount of indices
Definition SSharedMeshBuffer.h:86
irr::scene::SSharedMeshBuffer::getIndices
virtual u16 * getIndices()
returns pointer to Indices
Definition SSharedMeshBuffer.h:80
irr::scene::SSharedMeshBuffer::BoundingBox
core::aabbox3df BoundingBox
Bounding box.
Definition SSharedMeshBuffer.h:230
irr::scene::SSharedMeshBuffer::SSharedMeshBuffer
SSharedMeshBuffer()
constructor
Definition SSharedMeshBuffer.h:19
irr::scene::SSharedMeshBuffer::getMaterial
virtual video::SMaterial & getMaterial()
returns the material of this meshbuffer
Definition SSharedMeshBuffer.h:41
irr::scene::SSharedMeshBuffer::MappingHintVertex
E_HARDWARE_MAPPING MappingHintVertex
hardware mapping hint
Definition SSharedMeshBuffer.h:233
irr::scene::SSharedMeshBuffer::getPosition
virtual const core::vector3df & getPosition(u32 i) const
returns position of vertex i
Definition SSharedMeshBuffer.h:129
irr::scene::SSharedMeshBuffer::append
virtual void append(const IMeshBuffer *const other)
append the meshbuffer to the current buffer
Definition SSharedMeshBuffer.h:174
irr::scene::SSharedMeshBuffer::getVertexCount
virtual u32 getVertexCount() const
returns amount of vertices
Definition SSharedMeshBuffer.h:65
irr::scene::SSharedMeshBuffer::Vertices
core::array< video::S3DVertex > * Vertices
Shared Array of vertices.
Definition SSharedMeshBuffer.h:218
irr::scene::SSharedMeshBuffer::setDirty
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
flags the mesh as changed, reloads hardware buffers
Definition SSharedMeshBuffer.h:198
irr::scene::SSharedMeshBuffer::getNormal
virtual const core::vector3df & getNormal(u32 i) const
returns normal of vertex i
Definition SSharedMeshBuffer.h:143
irr::scene::SSharedMeshBuffer::SSharedMeshBuffer
SSharedMeshBuffer(core::array< video::S3DVertex > *vertices)
constructor
Definition SSharedMeshBuffer.h:27
irr::scene::SSharedMeshBuffer::getMaterial
virtual const video::SMaterial & getMaterial() const
returns the material of this meshbuffer
Definition SSharedMeshBuffer.h:35
irr::scene::SSharedMeshBuffer::getBoundingBox
virtual const core::aabbox3d< f32 > & getBoundingBox() const
returns an axis aligned bounding box
Definition SSharedMeshBuffer.h:98
irr::scene::SSharedMeshBuffer::getChangedID_Vertex
virtual u32 getChangedID_Vertex() const
Get the currently used ID for identification of changes.
Definition SSharedMeshBuffer.h:208
irr::scene::SSharedMeshBuffer::getVertexType
virtual video::E_VERTEX_TYPE getVertexType() const
returns which type of vertex data is stored.
Definition SSharedMeshBuffer.h:110
irr::scene::SSharedMeshBuffer::append
virtual void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices)
append the vertices and indices to the current buffer
Definition SSharedMeshBuffer.h:171
irr::scene::SSharedMeshBuffer::getIndexType
virtual video::E_INDEX_TYPE getIndexType() const
Get type of index data which is stored in this meshbuffer.
Definition SSharedMeshBuffer.h:92
- Irrlicht Engine Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on for Irrlicht 3D Engine by Doxygen 1.15.0