How to read a vertex buffer?

Started by
3 comments, last by lucky6969b 8 years, 6 months ago
https://msdn.microsoft.com/en-us/library/windows/desktop/bb172233%28v=vs.85%29.aspx

On this web site, it talks about how to write into a vertex buffer stream.
But what about reading it back?
I am currently needing to take the mesh from the X loader to convert it into something another engine can understand.
Thanks
Jack
Advertisement
It says on that page:

If you create a vertex buffer with the D3DUSAGE_WRITEONLY flag, do not use the D3DLOCK_READONLY locking flag. Use the D3DLOCK_READONLY flag if your application will read only from the vertex buffer memory. Including this flag enables Direct3D to optimize its internal procedures to improve efficiency, given that access to the memory will be read-only.


So if you don't use D3DLOCK_WRITEONLY, you can just read from the pointer returned by the lock method.

Thanks Aardvajk, I saw your other posts. And you said we can use LockVertexBuffer, and LockIndexBuffer.

And that's good.

Here I got another question. Within the X Allocation Hierarchy,

how can I tell whether a texture is a normal, specular or diffuse map?

Here is the code snippet in CreateMeshContainer overloaded function,

and it is loading the materials and textures. I have no ways to tell the type of the texture because pMaterials only

contains diffuse, ambient and specular colors and a texture file name.

In the engine I am after, I got to put the correct file names into various member variables of a class.

So please help me out

Thanks

Jack


// if materials provided, copy them
	if (NumMaterials > 0)
	{		 
		memcpy(pMeshContainer->pMaterials, pMaterials, sizeof(D3DXMATERIAL) * NumMaterials);
		// copy ambient color
		//pMeshContainer->pMaterials->MatD3D.Ambient = pMeshContainer->pMaterials->MatD3D.Emissive =
		//	pMeshContainer->pMaterials->MatD3D.Specular = pMeshContainer->pMaterials->MatD3D.Diffuse;
                pMeshContainer->vMaterials.push_back(pMaterials[iMaterial]);

		for (int iMaterial = 0; iMaterial < NumMaterials; iMaterial++)
		{
			if (pMeshContainer->pMaterials[iMaterial].pTextureFilename != NULL)
			{
				// store the texture filename instead, 
				// we will load the texture later on the GenerateSkinnedMesh function
				// so we could append the texture path
				pMeshContainer->pMaterials[iMaterial].pTextureFilename = new char[strlen(pMaterials[iMaterial].pTextureFilename) + 1];
				strcpy(pMeshContainer->pMaterials[iMaterial].pTextureFilename, pMaterials[iMaterial].pTextureFilename);
			
			}
		}
	}

depending on where your sample code same from, odds are its just a regular texture. IE the sample code doesn't support normal/specular/diffuse maps. which would mean the data it uses doesn't contain normal/specular/diffuse maps, and the tool used to make the data didn't create normal/specular/diffuse maps.


I am currently needing to take the mesh from the X loader to convert it into something another engine can understand.

if the .x file doesn't have normal/specular/diffuse maps, and you other engine needs them, that may be difficult (IE not possible).

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

One final question is how do I extract the skinweights from a .X file (using D3DX9)? Are there any good books on this topic or web site which discusses this? Thanks Jack

This topic is closed to new replies.

Advertisement