Sign in to follow this  
_Camus_

D3DXComputeBoundingBox And Animated Mesh

Recommended Posts

_Camus_    138
Hi, i have a problem to load a Skinned Mesh and generate his own bounding box, also i didnt found any info about... So i got an idea, load the skinned mesh as a static mesh but not draw it, in that case i have the bounding box of the phantom static mesh over the skinned mesh, buuuuuut it seems that there is some strange trick, the bound appears outside my mesh, translated: http://img59.imageshack.us/img59/4281/bounding1ss8.jpg That its the mesh loaded only static with the bounding box, now i load both, static and skinned mesh, but i only draw the skinned and the bound of the static: http://img59.imageshack.us/img59/9333/bounding2vf7.jpg As you can see, in both cases, the bound appears off, i check3d the world matrix, and its ok, even i load some other static mesh and the bound its in the right place, only appears outside the mesh if this is skinned or animated, i repeat even if i load as a static one. I hope can you help me please, thanks a lot, and sorry my bizzare english xD [Edited by - _Camus_ on May 16, 2008 3:50:09 AM]

Share this post


Link to post
Share on other sites
Evil Steve    2017
What are you passing in to D3DXComputeBoundingBox()? My guess is that you're not passing in the final skinned vertex positions (Most likely you're passing in the bind pose), so you're getting gibberish back.

Share this post


Link to post
Share on other sites
_Camus_    138
Thanks for reply.

Ok, lets see, i have a lot of things here,

I Have a LDP3DXFRAME, then a container with the mesh data:


BYTE* pVertices=NULL;

Model->MO->frame_root->pMeshContainer->MeshData.pMesh->LockVertexBuffer(D3DLOCK_READONLY, (LPVOID*)&pVertices);

D3DXComputeBoundingBox((D3DXVECTOR3*)pVertices,
Model->MO->frame_root->pMeshContainer->MeshData.pMesh->GetNumVertices(),
D3DXGetFVFVertexSize(Model->MO->frame_root->pMeshContainer->MeshData.pMesh->GetFVF()),
&Model->min,
&Model->max);

Model->MO->frame_root->pMeshContainer->MeshData.pMesh->UnlockVertexBuffer();

If the mesh do not have skin this half-work, appears the bound off,
if the mesh do have skin the program stops =(. For compute the bound
of the static mesh:

BYTE* pVertices=NULL;

Model->Mesh->LockVertexBuffer(D3DLOCK_READONLY, (LPVOID*)&pVertices);

D3DXComputeBoundingBox((D3DXVECTOR3*)pVertices,
Model->Mesh->GetNumVertices(),
D3DXGetFVFVertexSize(Model->Mesh->GetFVF()),
&Model->min,
&Model->max);

Model->Mesh->UnlockVertexBuffer();

This works fine with every non-animated-non-skined mesh, again, if
its skinned or animated the bound appears out :'(, with some other
non animated mesh works perfect.

About the pointer Model of these two, have the same name but are diferent
kind of objet.

Share this post


Link to post
Share on other sites
Buckeye    10747
You should read Evil Steve's reply.

You create a bounding box of a mesh when it's not animated.

If you want the bounding box to bound the animated mesh while it's animated, you have to recalculate the bounding box for the animated vertices, which may not be an easy task.

A bounding box surrounds the vertices that you pass to the D3DXComputeBoundingBox function. It's a calculation of the maximum and minimum coordinates of the vertices. When the mesh is animated, the mesh vertices move in object space so the maximum and minimum coordinates change but the bounding box you created has not changed.

That's why the bounding box doesn't "match" the animated mesh.

Share this post


Link to post
Share on other sites
_Camus_    138
Oh thx xD!

Sounds like a lot of issues generate a bounding box for
each frame on move, even more complex a bounding for each
bone, i think a waste of time and resources for a simple
game without physics, or that kind of.

Thanks a lot, then i go back and reconsider to load a boundingbox
of the skinned mesh loaded as static.

The other problem its the traslation of the bounding, i need to
put the mesh inside by myself? coz this thing put that thing out
:(

thanks for reply and translate my poor english

Share this post


Link to post
Share on other sites
Buckeye    10747
Yes, Camus, you'll have to either move the bounding box to the mesh ( or the other way 'round ) yourself.

Remember:

Back to what Evil Steve said - when you create the skinned mesh, it is positioned in what is called a ragdoll, bind or reference pose. It is not the pose the mesh will have when it's animated because each vertex position is multiplied by matrices associated with bone positions.

Those animated bone positions will probably not be close to the bind pose positions.

Share this post


Link to post
Share on other sites
_Camus_    138
Thank!! y fix3d my problem, and i'll explain wtf :

1- The bounding box always was OK!! the problem was
the BOx that i draw for represent the bounding box.

2- I was made several stupid things xD like get de
bounding again each frame!! LOL, now i only transform
the box xD,

3- For the animated model, i only load as a static mesh for
get de bounding, i dont need yet to know the bounding of
each keyframe, with the static its ok, and the collisions
using AABB are tot perfect.

thank a lot, right now i am working on vertex/face collision
only for fun, if that works i'll implement for real.

Cheers Budds

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this