   Vertex buffer from mesh data?
  Hi. I started with DirectX (again) about three weeks ago and wanted to create an engine using only the fixed function pipeline. I figured if I can master the fixed function pipeline then the programmable pipeline shouldn't be very hard later.Anyway, my question is concerning the use of meshes along with primitives. The primitives are drawn relative to a vertex buffer that I define, but what about meshes? Where is the vertex data? Whenever I perform world transformations I need to set the vertex buffer as the stream source before drawing subsets, but I don't know how to access the mesh vertex data to create the buffer.When the following snippet used in my program executes it scales both the sky mesh and the terrain primitive because I can't specify which buffer to apply the scale. I even tried switching the order in which they are drawn. It seems I have to have a vertex buffer for the mesh to apply separate world transforms. What's the best way to extract a vertex buffer from a mesh and how do I do this?Code Snippet:// ????????????? denotes missing vertex bufferg_Game.GetDevice()->SetStreamSource(0,???????????,0,sizeof(D3DVERTEX));g_Game.GetDevice()->SetTransform(D3DTS_WORLD, &(matScale));for(DWORD i = 0; i < numMaterials; i++)    // loop through each subset{    g_Game.GetDevice()->SetMaterial(&material);    if(texture != NULL)   g_Game.GetDevice()->SetTexture(0, texture);    meshSky->DrawSubset(i);}g_Game.GetDevice()->SetTexture(0,mv_pTerrainBaseMap);g_Game.GetDevice()->SetStreamSource(0,mv_pTerrainVB,0,sizeof(D3DVERTEX));g_Game.GetDevice()->SetIndices(mv_pTerrainIB);g_Game.GetDevice()->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,  0,    mv_dwTerrainVertices, 0, mv_dwTerrainPrimitives);
  I'm not using D3DX Meshes anymore myself (simply using vertex and index buffer in a custom class). But in the past I have used it, but can't remember having to set the stream source myself when using fixed pipeline. Have you tried to leave out that line and simply set transformation, material, texture and then call DrawSubset?   ;  Yes, that is why I posted to see if anyone knows how to extract the vertex data from the mesh object. I could create a buffer from the data to use in SetStreamSource(). Currently, without that line, I can't specify what to apply the transforms to, and the entire world matrix (DTS_WORLD) is transformed. The primitive and the mesh both get the matrix applied to them (which has caused visual phenomena on my screen).   ;ID3DXMesh::GetVertexBuffer.   ;  First of all, reading the DX reference is always helpful if you are looking for a specific function of a specific interface. By the way, Google is your friend and the firt hit for D3DXMesh is the reference page of the ID3DXMesh interface which is only one click away from the ID3DXBaseMesh interface containing what you need.Next, I would like to point out that it is no good idea to the lock the mesh's vertex buffer and manually transform those. You should rather seperate the rendering calls of your primitives and the meshes like so:device->setTransform(WORLD, getMyMeshesWorldTransform());for (all meshes){   renderAllMeshes();}device->setTransform(WORLD, getMyPrimitivesWorldTransform());for (all primitives){   renderAllPrimitives();};  Thanks a lot! That is exactly what I was looking for! Also, thanks for the advice to not lock the mesh data. I searched google first for help on this but I couldn't find anything using a number of search queries.Also, I've looked thouroughly through MSDN to find information about classes and types that start with LP like: LPDIRECT3DVERTEXBUFFER9 and LPDIRECT3DTEXTURE9. I just want to learn more about them and others that start with LP, but can't seem to find them on MSDN either (and having the same problem with google as well).   ;  That is just bad old Microsoft style. For each of there classes and structures they have LP's defined like so:class ICoolInterface;typedef class ICoolInterface* LPCOOLINTERFACE;Back in the good old days of 16 bit computers there had been a difference between pointers and so called "long pointers" that took more bits to store an adress. Hence the LP as prefix for "Long Pointer". But today it doesn't matter since all pointers have the same bit length. You should just make it a habbit to avoid those LPxxx typedefs and use the correct C++ syntax for declaring pointers. In my opinion that makes you code much more beautiful.   