41 #ifndef _graphicssubmesh_cpp
42 #define _graphicssubmesh_cpp
44 #include "Graphics/submesh.h"
53 InternalSubMesh(Internal)
76 return VertData->vertexCount;
90 Ogre::RenderOperation Render;
97 Ogre::MaterialManager* MatMan = Ogre::MaterialManager::getSingletonPtr();
98 if( MatMan != NULL ) {
99 Ogre::ResourcePtr Mat = MatMan->getByName( this->
InternalSubMesh->getMaterialName() );
121 Whole VertexOffset = ToFill.size();
125 const Ogre::VertexElement* PositionElem = VertData->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);
126 if( PositionElem != NULL ) {
127 ToFill.resize(NewSize);
128 Ogre::HardwareVertexBufferSharedPtr vBuffer = VertData->vertexBufferBinding->getBuffer(PositionElem->getSource());
131 unsigned char* vertex =
static_cast<unsigned char*
>(vBuffer->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
132 for(
size_t j = VertexOffset ; j < NewSize ; j++, vertex += vBuffer->getVertexSize() )
134 PositionElem->baseVertexPointerToElement(vertex, &pReal);
135 ToFill[j].X = *pReal++;
136 ToFill[j].Y = *pReal++;
137 ToFill[j].Z = *pReal++;
145 Whole VertexOffset = ToFill.size();
149 const Ogre::VertexElement* TexCoordElem = VertData->vertexDeclaration->findElementBySemantic(Ogre::VES_TEXTURE_COORDINATES);
150 if( TexCoordElem != NULL ) {
151 ToFill.resize(NewSize);
152 Ogre::HardwareVertexBufferSharedPtr vBuffer = VertData->vertexBufferBinding->getBuffer(TexCoordElem->getSource());
155 unsigned char* vertex =
static_cast<unsigned char*
>(vBuffer->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
156 for(
size_t j = VertexOffset ; j < NewSize ; j++, vertex += vBuffer->getVertexSize() )
158 TexCoordElem->baseVertexPointerToElement(vertex, &pReal);
159 ToFill[j].X = *pReal++;
160 ToFill[j].Y = *pReal++;
168 Whole VertexOffset = ToFill.size();
172 const Ogre::VertexElement* NormalElem = VertData->vertexDeclaration->findElementBySemantic(Ogre::VES_NORMAL);
173 if( NormalElem != NULL ) {
174 ToFill.resize(NewSize);
175 Ogre::HardwareVertexBufferSharedPtr vBuffer = VertData->vertexBufferBinding->getBuffer(NormalElem->getSource());
178 unsigned char* vertex =
static_cast<unsigned char*
>(vBuffer->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
179 for(
size_t j = VertexOffset ; j < NewSize ; j++, vertex += vBuffer->getVertexSize() )
181 NormalElem->baseVertexPointerToElement(vertex, &pReal);
182 ToFill[j].X = *pReal++;
183 ToFill[j].Y = *pReal++;
184 ToFill[j].Z = *pReal++;
192 Whole VertexOffset = ToFill.size();
196 const Ogre::VertexElement* TangentElem = VertData->vertexDeclaration->findElementBySemantic(Ogre::VES_TANGENT);
197 if( TangentElem != NULL ) {
198 ToFill.resize(NewSize);
199 Ogre::HardwareVertexBufferSharedPtr vBuffer = VertData->vertexBufferBinding->getBuffer(TangentElem->getSource());
202 unsigned char* vertex =
static_cast<unsigned char*
>(vBuffer->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
203 for(
size_t j = VertexOffset ; j < NewSize ; j++, vertex += vBuffer->getVertexSize() )
205 TangentElem->baseVertexPointerToElement(vertex, &pReal);
206 ToFill[j].X = *pReal++;
207 ToFill[j].Y = *pReal++;
208 ToFill[j].Z = *pReal++;
216 Whole IndexOffset = ToFill.size();
219 Ogre::HardwareIndexBufferSharedPtr iBuffer = this->
InternalSubMesh->indexData->indexBuffer;
220 Boole use32bitindexes = ( iBuffer->getType() == Ogre::HardwareIndexBuffer::IT_32BIT );
221 ToFill.resize(NewSize);
223 long* pLong =
static_cast<long*
>( iBuffer->lock( Ogre::HardwareBuffer::HBL_READ_ONLY ) );
224 if( use32bitindexes ) {
225 for(
size_t CurrIndex = IndexOffset ; CurrIndex < NewSize ; ++CurrIndex )
226 { ToFill[CurrIndex] = pLong[CurrIndex]; }
228 short* pShort =
reinterpret_cast<short*
>(pLong);
229 for(
size_t CurrIndex = IndexOffset ; CurrIndex < NewSize ; ++CurrIndex )
230 { ToFill[CurrIndex] =
static_cast<unsigned long>( pShort[CurrIndex] ); }
VertexInfo Vertices
A collection of containers storing the various properties of a Vertex.
bool Boole
Generally acts a single bit, true or false.
A convenience class for the storage of Vertex data in a Mesh/SubMesh.
Ogre::SubMesh * InternalSubMesh
A pointer to the internal SubMesh this is based on.
~SubMesh()
Class Destructor.
void AppendIndexInfo(IntVec &ToFill) const
Gets the Index information of this SubMesh and appends it to the container provided.
IntVec Indices
A container of Indexes used to assemble the Vertices for rendering.
String MaterialName
The name of the material used to render the Mesh/SubMesh.
const String & GetMaterialName() const
Gets the name of the Material being used by this SubMesh.
String MaterialGroup
The resource group in which the named Material can be found.
Whole GetVertexCount() const
Gets the number of Vertices in this SubMesh.
Boole UsesSharedVertices() const
Gets whether or not this SubMesh shares a Vertex Buffer with other SubMeshes.
void AppendVertexPositionInfo(Vector3Vec &ToFill) const
Gets the vertex position information of this SubMesh and appends it to the container provided...
Vector3Vec Tangents
A container storing the tangent of each vertex.
Whole VertexCount
The number of Vertices in the Mesh/SubMesh.
SubMesh(Ogre::SubMesh *Internal)
Internal Constructor.
void SetMaterialName(const String &MatName)
Sets the name of the Material to be used by this SubMesh.
std::vector< Vector2 > Vector2Vec
Convenience type for a container of Vector2s.
Vector2Vec UVs
A container storing the texture coordinates of each vertex.
A convenience class for the storage of rendering data in a Mesh/SubMesh.
void AppendVertexTexCoordInfo(Vector2Vec &ToFill) const
Gets the vertex texture coordinate information of this SubMesh and appends it to the container provid...
Vector3Vec Normals
A container storing the normal of each vertex.
std::vector< Integer > IntVec
Convenience type for a container of Integers.
void GetInfo(MeshInfo &ToFill) const
Gets the information used to render this SubMesh.
The bulk of the engine components go in this namspace.
Whole IndexCount
The number of Indexes in the Mesh/SubMesh.
std::vector< Vector3 > Vector3Vec
Convenience type for a container of Vector3s.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Whole OperationType
Used Internally. Describes how the Vertex data should be treated when rendering.
Vector3Vec Positions
A container storing the position of each vertex.
void AppendVertexTangentInfo(Vector3Vec &ToFill) const
Gets the vertex tangent information of this SubMesh and appends it to the container provided...
void AppendVertexInfo(VertexInfo &ToFill) const
Gets the vertex information of this SubMesh and appends it to the VertexInfo provided.
std::string String
A datatype used to a series of characters.
Ogre::SubMesh * _GetInternalSubMesh() const
Gets the internal SubMesh pointer.
Whole GetIndexCount() const
Gets the number of Indices in this SubMesh.
void AppendVertexNormalInfo(Vector3Vec &ToFill) const
Gets the vertex normal information of this SubMesh and appends it to the container provided...