   How to get vertice array from a mesh?
  I am a beginner in game programming and currently learning by making a small game in managed directx and C#.For physics, I use nvidia's PhysX engine. If i have an object that is loaded from a '.x' file and i want to make it 'rigid', i need to get all the vertices of the object in an array which I could later pass into a method of creating a convex mesh in the PhysX API's methods.I am stuck in finding the vertices from a loaded mesh. Can you please help me out? if I could just get an array of all the vertices in a loaded mesh, I could get through major portion of this game's development. Please Help...   
  Get the vertex buffer from the mesh and then lock it.  Provide the correct vertex structure (i.e. D3DXVECTOR3 xyz, D3DXVECTOR3 uv for a mesh with position and 1 texture coordinate per vertex) and then lock the buffer.  Something like this:CComPtr<IDirect3DVertexBuffer9> vertices;MyMesh->GetVertexBuffer(&vertices);MyVertexType *pV = 0;vertices->Lock(0, 0, &pV, 0);Make sure you unlock the buffer after use.  The CComPtr will release the vertex pointer automatically when it goes out of scope.  However, some people prefer not to use these ;).   ;  Thank you for your reply. Actually, I came across this solution but the problem I am facing is I am not able to determine the type of array that is returned by the lock method of vertex-buffer.In C# the following code gives error:VertexBuffer vb = pMesh.VertexBuffer;CustomVertex.PositionColored[] vertices = new CustomVertex.PositionColored[pMesh.NumberVertices];vertices = vb.Lock(0,LockType.ReadOnly);Please note that while I type this reply, I do not have the source code with me and the above code may contain few syntax errors. But in the original code, syntax is proper. Consider the above code as a psuedocode only.When I execute the above code, the type of vertice array returned by Lock method does not match the type of the assigned vertice array. What should I do now?   ;  You need to determine what components are actually in the vertex array in the mesh.  You can do this by inspecting the declaration in the mesh.  i.e. (C++):D3DVERTEXELEMENT9 declr[MAX_FVF_DECL_SIZE];MyMesh->GetDeclaration(declr);If, for example, the mesh vertices were one position coordinate and one texture coordinate, declr would have 3 usable elements.  The first would be position (declr[0].Usage), the second a texture coordinate and the third would be a "stop" block (255).If you inspect the block with a debugger you will be able to confirm what components are in your meshes and give your vertex type the appropriate components.  Once you've done that, you should be able to cast the result to the appropriate value.  It looks like you're using C# and I'm not entirely sure if a straight-up cast will do the trick for that (!), so read up on the Lock method in that context after confirming you have the correct vertex components in your CustomVertex type.;  Oh by the way, the Lock method returns an array.  You shouldn't have to pass one in, just a reference (or pointer) to one.   