• Advertisement

Archived

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

D3DXLoadMeshFromX buffer format

This topic is 5311 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

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

Share this post


Link to post
Share on other sites
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 .

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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[i];
array[i+1] = (float) vertexBuffer[i+1];
array[i+2] = (float) vertexBuffer[i+2];
}

unlock

Any ideas how to accomplish this. Thanks again for your help.

Share this post


Link to post
Share on other sites

  • Advertisement