Dynamic mesh deformation not displaying

Problems building or running the engine, queries about how to use features etc.
xzoowy
Gnoblar
Posts: 12
Joined: Fri Jan 14, 2005 9:43 pm

Dynamic mesh deformation not displaying

Post by xzoowy »

Hi,

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 );
						
Here is the function that reads the data from the buffers

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;
}
Here is the function that writes the data to the buffers

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();


}
I currently call those functions in the frameEnded(const Ogre::FrameEvent & evt) function of my Framelistner.
xzoowy
Gnoblar
Posts: 12
Joined: Fri Jan 14, 2005 9:43 pm

Post by xzoowy »

Problem solved, i used the wrong type of lock on my buffer in the setPosition() function.