Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

CubeReturns

Issues with Locking VertexBuffers (MDX C#)

This topic is 5218 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve spent all day trying to get skeletal animation working, but to no avail. I''ve found 7 documents and all have a different approach, and most are in languages I don''t understand. I found one here on GameDev, and that''s the one I''m following. Though it''s in C++, I''ve managed to translate it to C#. But I''m stuck on this one step: C++:
				// Lock the meshes'' vertex buffers

				void *SrcPtr, *DestPtr;
				pMesh->MeshData.pMesh->LockVertexBuffer(D3DLOCK_READONLY, (void**)&SrcPtr);
				pMesh->pSkinMesh->LockVertexBuffer(0, (void**)&DestPtr);

				// Update the skinned mesh using provided transformations

				pMesh->pSkinInfo->UpdateSkinnedMesh(m_pBoneMatrices, NULL, SrcPtr, DestPtr);

				// Unlock the meshes vertex buffers

				pMesh->pSkinMesh->UnlockVertexBuffer();
				pMesh->MeshData.pMesh->UnlockVertexBuffer();
Seems simple enough, right? There are multiple ways to get the vertexbuffers locked in C#. You can use Mesh.LockVertexBuffer, or Mesh.VertexBuffer.Lock, and both of those have overloads. Some overloads return a GraphicsStream object, which I have no use for, I need an array to pass to the UpdateSkinnedMesh function.
					Mesh SrcMesh = cm.MeshData.Mesh;
					Mesh DestMesh = cm.SkinnedMesh;
					D3D.CustomVertex.PositionTextured[] Src = new D3D.CustomVertex.PositionTextured[200];
					Src = (D3D.CustomVertex.PositionTextured[]) SrcMesh.VertexBuffer.Lock(0,LockFlags.ReadOnly);

					Array Dest = DestMesh.LockVertexBuffer(DestMesh.VertexFormat.GetType(),LockFlags.None,new int[]{DestMesh.NumberVertices});

					cm.SkinInformation.UpdateSkinnedMesh(BoneMatrices,null,Src,out Dest) ;

					cm.SkinnedMesh.UnlockVertexBuffer();
					cm.MeshData.Mesh.UnlockVertexBuffer();

This is currently my code, though I''ve changed over and over which method and overload to use and all. Basically I get one of two errors : Object contains non-Primitive or non-Blittable data, or Value cannot be null. I''m starting to think there''s just a bug in MDX or something, because I just can''t find what the problem is. It appears on the first Lock, by the way. Any ideas? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!