Problem with meshes in a mesh hierarchy

Started by
2 comments, last by fuchiefck 18 years, 10 months ago
Hi, I'm a newbie to directx and also a newbie to this forum... I am stuck at something and hope I can find an answer with everyone's help. well, here it is: I am trying to make a "Paper doll system" with meshes (X file). What I mean is I am trying to load a model of a person, and then change its body parts or clothes with another mesh, say.. I want to replace the hair with another hair of some other shape. My mesh is already divided and named into different parts, eg Body, Head, Hair, L_UpperArm, and so forth. Currently I have the ability to catch the program when it is rendering certain parts, eg: if (strcmp(pFrame->Name, "Hair") == 0) { //don't render } This, of course will result in a model of a bald person. The next step is, I want to load another mesh of just the hair, and when the program is rendering the hair, I want to let it render the new hair instead of the old hair. So I tackled this by loading the hair mesh and storing the pMesh pointer somewhere accessible by my main class, and then when its rendering the Hair mesh container, I clone the old mesh with the new mesh: if (strcmp(pFrame->Name, "Hair") == 0) { pNewMesh->CloneMeshFVF(pNewMesh->GetOptions(), pNewMesh->GetFVF(), pd3ddevice, &pMeshContainer->MeshData.pMesh); } //continue with rendering And heres the problem, the new mesh (the new hair) appears, but its position is wrong. To my understanding, the Frame and the meshcontainer data is unchanged, the only thing changed is the pMesh pointer that it uses to render. So I thought the new mesh is still in the original mesh container, but obviously I may be wrong. also, the sometimes animation is also wrong. I tried to tackle this problem by checking if the frame matrices are setup and updated properly, but as I said before, all the frame and mesh container data still remains original, only the pMesh is changed in the Hair's mesh container. So the frame matrices remains the same. Hope someone here can provide some help, or share ur experiences if you've ever tried to do something like this. Thx btw most of my code is copied and modified from the SkinnedMesh sample of the DX9 SDK
-fuchiefck----------------------------------------------------------"Inside the world that you as a programmer or developer create, you are God" - Zerbst & Duvel
Advertisement
err... eagerly waiting for someone who can help me out here... please... any help would be greatly appreciated... thank you..

- fuchiefck
-fuchiefck----------------------------------------------------------"Inside the world that you as a programmer or developer create, you are God" - Zerbst & Duvel
hm have you set the transform?
if not this is how you do it: take the combined transform of the current frame (bone) and multiply it with your world transform for the object, and then just set this new transform.
dont think you need to copy the mesh like that neither, just render it when the transform is set.
----------Thale Cres
Thanks for your reply chot... Yes I have multiplied my matrices, like the way the SkinnedMesh Sample in the SDK does, which is the same as your suggestion. I think why my new mesh, the Hair, is out of place is because it was not placed in the center when the artist drew it, thats why theres an offset when i render it... is my assumption correct..?

thanks

-fuchiefck
-fuchiefck----------------------------------------------------------"Inside the world that you as a programmer or developer create, you are God" - Zerbst & Duvel

This topic is closed to new replies.

Advertisement