Ive wrote a function that reads the vertex positions of a mesh then update them with new data. My problem is that the values in the buffer seems to be correctly updated, but are not displayed depending of the type of rendering i use. When using directX7 it work fine, when using OpenGL it never works(its like if my mesh was static), when using Directx9 it works until the entity is in the field of view of the camera(then the mesh remains static even if new values are updated in the vertex buffer).
Im using Ogre 0.15.0
My Graphic card is a ATI Radeon 9800 pro with the latest drivers.
Im using the HardwareBuffers in Dynamic_write_only mode with Vertex Shadow Buffer enabled.
Code: Select all
Mesh* lMesh = MeshManager::getSingleton().load(EntityMeshFilename, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, true, false, 1 );
Code: Select all
std::vector<Vector3> getPosition(VertexData* inVertexData)
{
std::vector<Vector3> lArray;
// Find the POSITION element in buffer
const VertexElement* lVertexElement = inVertexData->vertexDeclaration->findElementBySemantic(VES_POSITION);
// Find the buffer used for the elements
HardwareVertexBufferSharedPtr lBuf = inVertexData->vertexBufferBinding->getBuffer(lVertexElement->getSource());
// Lock buffer & Get Base Pointeur
unsigned char* pVertex = static_cast<unsigned char*>(lBuf->lock(HardwareBuffer::HBL_READ_ONLY));
Real* pReal;
Vector3 lPos;
// Read elements
for (size_t i = 0; i < inVertexData->vertexCount; ++i, pVertex += lBuf->getVertexSize())
{
lVertexElement->baseVertexPointerToElement(pVertex,&pReal);
lPos.x = *pReal++;
lPos.y = *pReal++;
lPos.z = *pReal++;
lArray.push_back(lPos);
}
lBuf->unlock();
return lArray;
}
Code: Select all
void setPosition(std::vector<Vector3> inData, VertexData* inVertexData)
{
// Find the POSITION element in buffer
const VertexElement* lVertexElement = inVertexData->vertexDeclaration->findElementBySemantic(VES_POSITION);
// Find the buffer used for the elements
HardwareVertexBufferSharedPtr lBuf = inVertexData->vertexBufferBinding->getBuffer(lVertexElement->getSource());
// Lock buffer & Get Base Pointeur
unsigned char* pVertex = static_cast<unsigned char*>(lBuf->lock(HardwareBuffer::HBL_READ_ONLY));
Real* pReal;
Vector3 lPos;
mWindow->setDebugText("Vertex count :" + StringConverter::toString(inVertexData->vertexCount));
std::vector<Vector3>::const_iterator ibegin = inData.begin();
// Read elements
for (size_t i = 0; i < inVertexData->vertexCount; ++i, ibegin++, pVertex += lBuf->getVertexSize())
{
lVertexElement->baseVertexPointerToElement(pVertex,&pReal);
*pReal++ = ibegin->x* 1.001;
*pReal++ = ibegin->y;
*pReal++ = ibegin->z;
}
lBuf->unlock();
}