Sign in to follow this  

Bounding Box - IN - X file parsing

This topic is 4839 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 guys! I'm back on this forum again with collision problems... But now my problems begin earlier!!! I know how to parse an .X file, how to catch out X frames matrices but I don't know how to compute a bounding box around each frame! I want to load a level in my game and parsing its X file, I want to compute a bounding box around each object (frame), but I don't know how to do that! I kwon how to create a bounding box of an complete object, but I want to create lots of bb around all its parts... How to do that?! Can I extract from each frame the mesh (if exist) and from it create a bb for the same mesh?! How can I do that?! Have you got any tutorial?! Or code samples?! Thanks for help!!! Byez, [Edited by - GENTS on September 14, 2004 5:20:18 AM]

Share this post


Link to post
Share on other sites
There's a D3DX method/utility called D3DXComputeBoundingBox(). Use it right when you load your mesh, and you should be able to store a bounding box that contains it.

If you use that box again later the find the mesh's current bounding box, be sure to transform the bounding box by the same matrices you used to transform your 3D object.

I believe there are numerous SDK examples that contain this and D3DXComputeBoundingSphere().

Share this post


Link to post
Share on other sites
Use the IDirectXFile and IDirectXFileData interfaces to process the .x file data. You can load from each subset separately and calculate your BB. Use the GetNextObject and GetData members to get each frame's root mesh node and children.

Share this post


Link to post
Share on other sites
The Frugal Gourmet:

probably you've not understood my problem... I don't want a unique bb, but a bb for every frame of my X file...

enigma1:

yes, I've get the idea! Thanks... Could you post me some code or link to tutorial's page?!

THANKS!!!

I hope I'm not annoying you!!!

Share this post


Link to post
Share on other sites
To be honest, the !!!!!'s are annoying. Try to use less of them and it won't feel like you're screaming at everyone.

You can also store the bounding mesh (could be a box, could be a sphere, could be a complex mesh) in the X file and store it as a separate name. Then when you load it, you know that it's your bounding mesh.

I'm a little confused why you need a bounding mesh for each frame. Could you comment on that a little? It also depends on what you use the frames for. Are you using them as a bone heirarchy and you want to have a bounding box around the arms, legs, body, etc.? Or something else?

Thanks,
Chris

Share this post


Link to post
Share on other sites
there is an article in GameDev that comes close to what you are looking for I think. (see the implementation page too)
http://www.gamedev.net/reference/programming/features/skinmesh/page2.asp

If you can also do what Chris said precalculate the BB it will also be faster for your render computations.

source link:
http://www.gamedev.net/reference/programming/features/skinmesh/source.zip

hope it helps

Share this post


Link to post
Share on other sites
ok sorry for !!!

Supernat02:

I don't want to fill my .X file more than it is 'cause dimensions could be a problem...
So I'm trying to load a complete level, a mesh with walls, terrain, holes and some barrels... my level has no bones, so I've not bones matrices, but only frames matrices...
Now I want to create a bb around every piece of wall, one for terrain and one for every barrel, 'cause my level is closed and I'm in the inner part of it (ex: a room or a lot of rooms)...
I know how to get every frame by name or by looping through them, but I don't know how to pick out their world position, matrices and how to compute bb around every mesh of every frame...

I hope its almoust clear... Sorry for my bad english!

enigma1:

Thanks for the link; I'll look at it and I'll try to find a solution...


THANKS!

Share this post


Link to post
Share on other sites
no help in that article... my meshes aren't skinned meshes and that's is the problem...
I've not bones matrices to figure out and to create bounding box around them, so how can I do?!

Byez,

Share this post


Link to post
Share on other sites
You can use the D3DXLoadMeshFromXof function and the ID3DXFile, ID3DXFileEnumerator and ID3DXFileData interfaces to get to teh mesh object.

Open the xfile, and iterate through the hierarchy until you find a TID_D3DRMMesh template, then load that using D3DXLoadMeshFromXof and compute the bounding box using D3DXComputeBoundingBox

Share this post


Link to post
Share on other sites
The DirectX SDK has a sample (meshes\skinnedmesh) Read the code on how the .x data are processed. It reads the .x file frames as you want to do. You do not need to process the skin and bone info as he does but you should easily modify it to get the mesh vertices for each frame and build a bb around each mesh.

Share this post


Link to post
Share on other sites
ok!
I've found the way to compute all bounding boxes and to keep in an array all min and max values and in another array all different meshes...

But I've another problem now, but that's only caused by my level model...

I've a level that is a "circuit" for my cars game and that have the shape of a sort of "8"...

_ _ _
/ | | but all borders of the level are an unique mesh,
| | so if I create bb around it, I've a big one bb
\ / not useful for my scope...
-----
/ \ So, how cai I solve this new problem?!
| | Should I split my mesh in a lot of little meshes
| | or exist another way to implement collision
\_ _ _ / having an unique mesh that represent wall and
to create bb around pieces of this wall?!

THANKS FOR HELP!!!

Share this post


Link to post
Share on other sites

This topic is 4839 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.

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