How to compute the bounding volume for an animated (skinned) mesh ?

Started by
22 comments, last by Adaline 10 years, 4 months ago

If you are really needing to create an AABB, you will have to generate it based on the largest X,Y,Z value of the post scaled, translated, and rotated model. Its more important to do it against the post rotated model as you need the X,Y,Z based on where it lies after rotation, the result could then be scaled and translated. This will still need to be done each animation step as this is going to change where the BB is going to lie based on the location of the verticies changing each step.

You probably shouldn't bother with the generation of the maxes prior to transforming the model if you're not concerned with the OBB, so once you've transformed it calculate based on the same process that you did when calculating the 'OBB' the first time.

If you calculate the model maxes prior to the translation/scale/rotate you will get the maxes based on the model only in model space, and applying the same transformation will result in a OBB in world space.

Just to consider, below is an example of where an AABB is going to give you something that doesnt look right for the volume taken up by an object.

[attachment=18736:boundingboxexample2.png]

The blue boxes are the same size, the AABB box has been cast in red on the box on the right.

The OBB for the blue box on the right will be the same space as the blue box.

If you go to investigate collision detection later down the track, AABB's are great for quick culling for proximity, OBB's create better accuracy for your final pass.

Advertisement

In case you need very accurate AABB and do not wish to compute it at animation run time - animated AABB? You would simply bind AABB to your asset as per frame object, though this would create an (unwanted) joint between animation - mesh.

If you are really needing to create an AABB, you will have to generate it based on the largest X,Y,Z value of the post scaled, translated, and rotated model. Its more important to do it against the post rotated model as you need the X,Y,Z based on where it lies after rotation, the result could then be scaled and translated. This will still need to be done each animation step as this is going to change where the BB is going to lie based on the location of the verticies changing each step.

Animation of a mesh is an object space transformation, just as AABB is a object space axis aligned box. Further than object space transformations apply to AABB as well -with the same transformation result. The OP wants to have objects space box that encapsulates object space geometry every animation frame accurately.

Hello

Since my skinned meshes will be drawned within a single draw call, I'm not sure I need a per-bone frustum culling, because even if a small part of the mesh is visible I'll have to draw it entirely. So I think my method of asking the artist to create a bounding-box for the skinned meshes, that bounds all the animations the mesh will have, could be not so bad finally .... I can get more false positives ("to be rendered") cases sure, but this technique has the benefit to be very cheap at CPU-side level.

Thank you for your positive help, guys smile.png

Your artist could put all that time to better use.

This is an iterative operation that could be done much faster with a procedural approach. If you have several different characters that need this, the benefit would be exponential.

Once you have all the animation sequences for a character production-ready, have a tool or piece of code that builds a bounding box for each single frame and then collects the biggest one. You can then save these dimensions in a configuration file or similar for your later use.

Depending on the software being used by the artist, you can program this tool right there with the script API for the software (Maya & MEL, 3DS Max & MaxScript, Blender & Python etc.).

For special sequences like those of special moves (when the character may fly around or have broad movements) you will have to use something else as the skeleton and mesh may travel away from the node's transform, having the bounding box staying with the node and the mesh becoming independent and leaving the bounding box. For these cases you may not even use culling at all.

Once you have all the animation sequences for a character production-ready, have a tool or piece of code that builds a bounding box for each single frame and then collects the biggest one.

This is a very good idea thank you, I think I will do this. I'll add this in my tool that import the meshes. rolleyes.gif

(Even if the artist (the friend with who I have this mario-kart like racing game project) really doesn't mind to add a box in the asset in 30 seconds ...wink.png )

If you are really needing to create an AABB, you will have to generate it based on the largest X,Y,Z value of the post scaled, translated, and rotated model. Its more important to do it against the post rotated model as you need the X,Y,Z based on where it lies after rotation, the result could then be scaled and translated. This will still need to be done each animation step as this is going to change where the BB is going to lie based on the location of the verticies changing each step.

Animation of a mesh is an object space transformation, just as AABB is a object space axis aligned box. Further than object space transformations apply to AABB as well -with the same transformation result. The OP wants to have objects space box that encapsulates object space geometry every animation frame accurately.

The definition of the animation steps is just a case of being specific, you could calculate the AABB once, for example at model loading, and you could say thats it. Sure you have a BB, but it wont represent the simplified volume taken up by the model as the arms and legs of the model flail around outside of the initial BB volume.

Once you have all the animation sequences for a character production-ready, have a tool or piece of code that builds a bounding box for each single frame and then collects the biggest one.

This is a very good idea thank you, I think I will do this. I'll add this in my tool that import the meshes. rolleyes.gif

(Even if the artist (the friend with who I have this mario-kart like racing game project) really doesn't mind to add a box in the asset in 30 seconds ...wink.png )

A small correction: Collect the biggest dimensions from each frame separately.

The biggest height, the biggest width and the biggest depth may not necessarily all come from the same frame (one frame may have the biggest height, but another may have the biggest width etc.).

In the end, this "all-encompassing" bounding box is formed by the biggest dimensions that you find among all the frames.

Once you have all the animation sequences for a character production-ready, have a tool or piece of code that builds a bounding box for each single frame and then collects the biggest one.

This is a very good idea thank you, I think I will do this. I'll add this in my tool that import the meshes. rolleyes.gif

(Even if the artist (the friend with who I have this mario-kart like racing game project) really doesn't mind to add a box in the asset in 30 seconds ...wink.png )

A small correction: Collect the biggest dimensions from each frame separately.

The biggest height, the biggest width and the biggest depth may not necessarily all come from the same frame (one frame may have the biggest height, but another may have the biggest width etc.).

In the end, this "all-encompassing" bounding box is formed by the biggest dimensions that you find among all the frames.

Thanks, I understood your idea this way.

I talked about this with my friend, and he told me that it would certainly work in most cases but in some others he would have to add more key frames : for instance imagine a planet and its satellite, there would be only two key frames (0->180 and 180->360) . This wouldn't be enought to correctly compute the bounding volume : 4 key frames would be needed (0° , 90°, 180° and 270°).

Either he would have to add unecessary key frames in his animations, or .... stick with my provided bounding box idea sad.png and he prefers the latter ...

It depends a bit on how your animation system works, but what works well for static boxes is to just take the bounds of the mesh, and get maximum of width/height/depth and size the box in all dimensions with that amount. So the same as mentioned above but without using any keyframes.

Some methods of calculating bounds that I implemented:

1.) Contain all node/bone global positions

2.) Contain all (skinned) vertex positions

3.) Contain all OBB's of each node/bone

4.) Static box that moves with the position of the actor (method as described above)

The method using keyframes would only work if you do not blend or combine motions or do not do any procedural things. Or you would have to pass your full motion database through it. But this is quite overkill. Also if you choose to go with this method, you most likely will sample your animation curves when importing them from the software you exported with. For example if you load an FBX or use an exporter from Max or Maya you sample the transforms every n frames and possibly optimize that data. This means that it is highly unlikely that you would hit a case where you export just 2 keyframes for a 360 degree rotation.

This topic is closed to new replies.

Advertisement