Jump to content
  • Advertisement
Sign in to follow this  
Aragon

X File handling (2questions)

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

hi all! i have 2 questions about xfile manipulating when having them loaded.... // here a short look what i have (thats all ok) ............ //init (ok) LPD3DXMESH g_pMesh[500] ; ............ //Loading (ok) D3DXLoadMeshFromX( filename, D3DXMESH_MANAGED, g_pd3dDevice, NULL, NULL, NULL, NULL, &g_pMesh[nr] ) )) ............ //Draw whole mesh (ok) g_pMesh[20]->DrawSubset(0); ------------------------------- question 1; ----------- how can i accsess the vertices of one of the meshes to make some changes ingame ( changing position and u/v of some vertices ) ?? question 2; ----------- how can i divide a mesh into subsets ? //my goal g_pMesh[20]->DrawSubset(1); //body g_pMesh[20]->DrawSubset(2); //head g_pMesh[20]->DrawSubset(3); //left arm g_pMesh[20]->DrawSubset(4); //right arm g_pMesh[20]->DrawSubset(5); //left leg g_pMesh[20]->DrawSubset(5); //right leg ... i know the vertices count of every object (...head 262...) and they are sortet ... need something like that ...g_pMesh[20]->SetSubset(5, 1344,1430); much thx for all help

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
1. Call GetVertexBuffer from your D3DXMesh object, then lock it with LockVertexBuffer. This returns a pointer which you can move through the vertices with and modify them. Don't forget to UnlockVertexBuffer when you're finished. The same thing applies to the Index buffer if you need to mod that.

2. Call GetAttribute table to get it. Lock it with LockAttributeBuffer. Same as above, you get a pointer to an D3DXATTRIBUTERANGE structure which you can modify/delete/add etc.

Share this post


Link to post
Share on other sites
Quote:
Original post by Aragon
how can i accsess the vertices of one of the meshes to make some changes
ingame ( changing position and u/v of some vertices ) ??

Mesh->GetVertexBuffer(), then Buffer->Lock() function. Take special care to use a matching structure for the FVF of the mesh. You'll want to do a little research on the FVF stuff before locking and modifying the buffer.

If you would rather do it on the fly, look into vertex shaders. Shaders give you tons of control over all aspects of vertices, each and every frame.

Quote:
Original post by Aragon
how can i divide a mesh into subsets ?

Set each section of polys as a seperate material in the modeler. If you need to identify the subsets in game, the only way I'm sure will work is to give each subset a different texture, and have the name of the subset in the texture filename. You can always change the texture IDs or paths in-game after identifying each subset. So you can still use a single texture for the whole model. So have like TEXTURE_Head.png, TEXTURE_LeftArm.png, etc. Then once you use those to grab the index of each body part, change those parts to use the real texture.

Hope I helped at least a bit.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!