Code: Select all
const Ogre::v1::VertexElement* vertexPositions = submesh->vertexData[0]->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);
Ogre::v1::HardwareVertexBufferSharedPtr vertexBuffer = submesh->vertexData[0]->vertexBufferBinding->getBuffer(vertexPositions->getSource());
unsigned char* ogreVertices = static_cast<unsigned char*>(vertexBuffer->lock(Ogre::v1::HardwareBuffer::HBL_READ_ONLY));
for (int i = 0; i < nVertices; ++i, ogreVertices += vertexBuffer->getVertexSize()) {
float* vertex = NULL;
vertexPositions->baseVertexPointerToElement(ogreVertices, &vertex);
Vector3d vertexPosition = position + rotate(orientation, scale*Vector3d(vertex[0], vertex[1], vertex[2]));
triangleMesh->vertices[offset + 3*i] = vertexPosition.getX();
triangleMesh->vertices[offset + 3*i + 1] = vertexPosition.getY();
triangleMesh->vertices[offset + 3*i + 2] = vertexPosition.getZ();
}
vertexBuffer->unlock();
That's bizarre since I'm just exploring the mesh vertices, which shouldn't differ between rendersystems.
Am I doing that wrong? Is there any alternate way to retrieve those data?
Thanks in advance.