• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Adaline

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

23 posts in this topic

Hello

 

An example maybe :

Usually a human being is forming a T with his arms in model space.

Then I compute the bounding volume using this pose.

But if the arms within an animation are towards the up direction they'll get out of the bounding volume and they would be frustum-culled even if they are visible ...

 

How can I avoid this please ? (sorry for the poor explanation, but it's quite hard for me to explain that in English)

 

Thanks

0

Share this post


Link to post
Share on other sites

Thank you for your answers.

Finally I think I will explicitly define an extra geometry in the asset defining the bounding volume. (only for animated meshes)

The modeler will have to create it, bounding all poses the mesh can have.

Edited by Tournicoti
0

Share this post


Link to post
Share on other sites

Calculate the bounding volume after the geometry data has been formed and manipulated, if you're basing the bounding volume on the 'at rest' pose or what ever your first keyframe is then you're going to be losing accuracy in the space filled by the volume.

1

Share this post


Link to post
Share on other sites

Calculate a bounding box for each joint in the body in the orientation of that joint, based only on the vertices that are skinned to that joint.

Then at runtime, project the joint-oriented bounding boxes into worldspace, taking the min and max of each of those bounding boxes.

 

There's no real reason to have an artist make the bounding volumes.

1

Share this post


Link to post
Share on other sites

Calculate the bounding volume after the geometry data has been formed and manipulated, if you're basing the bounding volume on the 'at rest' pose or what ever your first keyframe is then you're going to be losing accuracy in the space filled by the volume.

In fact I calculate the AABB in model-space, then I convert it to OBB to transform it in world space, then I calculate the final AABB

 

Calculate a bounding box for each joint in the body in the orientation of that joint, based only on the vertices that are skinned to that joint.

Then at runtime, project the joint-oriented bounding boxes into worldspace, taking the min and max of each of those bounding boxes.

 

There's no real reason to have an artist make the bounding volumes.

Thank you, this is probably the best way, but before implementing this I prefer use simpler methods. (i.e. the artist provides the model space's AABB). But your method is the best, and will try it latersmile.png

Edited by Tournicoti
0

Share this post


Link to post
Share on other sites

Another way:

 

Compute the bounding box of all of the skinning bones (that aren't scaled to zero).  Inflate the resulting box by a precomputed amount (scaled according to the maximum scale applied to any skinning bone).

 

Advantage:  Cheaper in CPU cost to compute (compared to the bounding box per bone method); also no per-bone extra data

 

Disadvantage:  Less optimal fit.

1

Share this post


Link to post
Share on other sites

 

Calculate the bounding volume after the geometry data has been formed and manipulated, if you're basing the bounding volume on the 'at rest' pose or what ever your first keyframe is then you're going to be losing accuracy in the space filled by the volume.

In fact I calculate the AABB in model-space, then I convert it to OBB to transform it in world space, then I calculate the final AABB

 

Why are you calculating two AABB's?

 

The AABB in model space should be the same volumetricly as the OBB, albeit the OBB is translated and rotated to be aligned to the facing of the object, the AABB in world space from the OBB will have large areas of 'empty' space, thereby negating the advantage of calculating an OBB. If your intent is to only ever use Axis Alligned, then calculating an AABB straight up would save you a tonne of time and could be done by calculating the max x,y,z post the scale, translate and rotate for any step in the animation.

 

Just to add something, the image below is what i expect that your concern is.

 

[attachment=18722:boundingboxexample.png]

 

Left hand image is the model at the da Vinci Pose (the T pose), the right hand is the model with its arms up.

 

Your concern, as i understand it, is that your binding box (the black boxes) is not changing from frame to frame.

Am i on the right track?

Edited by Stragen
1

Share this post


Link to post
Share on other sites

Thank you for your answers smile.png

 


Why are you calculating two AABB's?

 

The AABB in model space is precomputed. It is an "axis-aligned OBB" in model-space ready for world transformation.

 

At runtime : model-space OBB  -> world transform -> world-space OBB -> world-space AABB

 

EDIT : But maybe you mean that I can just transform in world space the 2 vertices (min & max) of the AABB and compute the new AABB according to the 2 transformed vertices instead of the 8 transformed vertices of the OBB?

Edited by Tournicoti
0

Share this post


Link to post
Share on other sites

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.

1

Share this post


Link to post
Share on other sites
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.

1

Share this post


Link to post
Share on other sites

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

Edited by Tournicoti
0

Share this post


Link to post
Share on other sites

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.

Edited by Kryzon
2

Share this post


Link to post
Share on other sites

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 )

0

Share this post


Link to post
Share on other sites

 

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.

0

Share this post


Link to post
Share on other sites

 

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.

1

Share this post


Link to post
Share on other sites

 

 

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 ...

Edited by Tournicoti
0

Share this post


Link to post
Share on other sites

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.

2

Share this post


Link to post
Share on other sites

 This means that it is highly unlikely that you would hit a case where you export just 2 keyframes for a 360 degree rotation.

 

You're probably right, this is just an example (notice that I never modelled anything but my friend does (using Blender) )

Anyway, I think the problem is still the same ...unsure.png

Edited by Tournicoti
0

Share this post


Link to post
Share on other sites

More and more, I'm thinking about this idea to provide a bounding box that encapsulate all the animations is not as bad as said ... 

Edited by Tournicoti
0

Share this post


Link to post
Share on other sites

More and more, I'm thinking about this idea to provide a bounding box that encapsulate all the animations is not as bad as said ... 
Please proove me I'm wrong (with pleasure  )

As Buckshag mentions in the following...

 

The method using keyframes would only work if you do not blend or combine motions or do not do any procedural things.

...If you use blending or additive animations (which you most likely will), then only taking the bounds of each pure keyframe and collecting only the bigger dimensions cannot account for all possible scenarios. The addition of two extreme frames may result in something that pierces the pre-calculated bounds.

However, the odds of this making the entity pop in or out of view in the middle of the game are very low, especially because you can increase the bounding box by a fixed amount and be conservative.

 

Unity seems to use the simple keyframe calculation at import: http://docs.unity3d.com/Documentation/Components/class-SkinnedMeshRenderer.html. Note their explanations on how additive animations can alter the result.

 

You can also consider using a bounding sphere instead, which is a more conservative volume.

Edited by Kryzon
1

Share this post


Link to post
Share on other sites

Sorry, I was using the word 'keyframe' instead of animation node : I will not use keyframe animation, but skeletal animation.

 

I will not interpolate geometry (only scalings, rotations and positions of two animation nodes)

Using Assimp, this is the object aiNodeAnim

Edited by Tournicoti
0

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  
Followers 0