D3DXLoadMeshFromX buffer format

Started by
2 comments, last by zander76 20 years, 8 months ago
Hello Everybody I am trying to use the x fileformat but i would like to render in opengl. So here is what i am trying to do but i have had little success and i have been searching for a while and can''t find any docs or tutorials related to this. First load the file using D3DxLoadMeshFromX. Then get the vertex data and indicies and put them in my own internal format. Does anybody have any tutorials for how D3DXLoadMesh stores the verticies and how i can get at them. Thanks, Ben
Advertisement
The data is simply stored in a vertex buffer.

http://msdn.microsoft.com/library/en-us/directx9_c/directx/graphics/reference/d3dx/interfaces/id3dxmesh/GetVertexBuffer.asp?frame=true

Do the same thing with the index buffer and there you go .
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Thanks for your help but i am still missing something. I am trying to create a array of floats ( x, y, z ) for the vertexs and the same for the indecies. Here is what i have so far.

LPD3DXMESH mMeshBuffer;

hr = D3DXLoadMeshFromX(
fileName,
D3DXMESH_SYSTEMMEM,
device,
NULL,
NULL,
NULL,
&mMeshBuffer // The mesh buffer
);

if (FAILED(hr)) {
mApp->getAppWindow()->messageBox((char*)DXGetErrorString8(hr), "Mesh loading error");
}

LPDIRECT3DVERTEXBUFFER8 test;
mMeshBuffer->GetVertexBuffer( &test );

BYTE* bufferreader;
D3DVERTEXBUFFER_DESC bufferDesc;

hr = test->Lock( 0, 0, &bufferreader, D3DLOCK_READONLY );

if (FAILED(hr)) {
mApp->getAppWindow()->messageBox("Could not lock buffer", "Mesh loading error");
}

// bufferreader;

test->Unlock( );

Am i on the write track.
Thanks Ben
Ok.. I think a have a better question. How do i determine how many vertex are there and how do i convert from BYTE to float.

int count = getVertexCount();

for (int i = 0; i <= count; i = i + 3) {
array = (float) vertexBuffer;<br> array[i+1] = (float) vertexBuffer[i+1];<br> array[i+2] = (float) vertexBuffer[i+2];<br>}<br><br>unlock<br><br>Any ideas how to accomplish this. Thanks again for your help.<br><br> </i>

This topic is closed to new replies.

Advertisement