• Advertisement
Sign in to follow this  

Collision geometry in FBX (or in general)

Recommended Posts

I've finally gotten the the place where I have to define collision shapes for my 3d models. Currently I only need convex hulls, but I suspect I will need capsules, cylenders, boxes ect...
I'm using FBX SDK for importing and converting to my internal format.

Currently I'm thinking about a naming convention, so If the name of the node begins with _Special_ConvexHull then this geometry will be the convex hull for the physics and not a renderable mesh.
Hulls are fine, but what about a capsule how do I define a capsule? I do not think that there is a such thing as analytic capsule cylinder in FBX? Maybe the *imaginary artist* could create a capsule that is just a triangle mesh and later I would somehow restore the capsule by the defined points(links please, I do not know how to do it :P)?

What is you solution for that thing?

 

Share this post


Link to post
Share on other sites
Advertisement

You could just calculate the capsule, aabb, bounding sphere or whatever from the vertices after loading the file. I'd think, thats better than giving your artist unnecessary work.

Share this post


Link to post
Share on other sites

Yeah, one of my question is:

how do you compute an object (or even axis) aligned bounding capsule or whatever by a set ot verts?

Share this post


Link to post
Share on other sites

FBX doesn't support collision shapes out of the box. One common approach would be to flag collision primitives using a special mesh name. E.g. a collision sphere starts with CLSP_*, a capsule CLCA, etc. Unreal uses something like this and you can read about it here:

 https://docs.unrealengine.com/latest/INT/Engine/Content/FBX/index.html

Alternatively you can write a small import dialog and the user needs to select whether a mesh is a collision mesh or render mesh or both. You basically assign the content of the model FBX file into different sets like render mesh, collision mesh, animation, etc. I think you can also write your custom FBX node attribute types, but I haven't done this so I cannot really comment on this. It is very easy to write some custom node types in Maya and export this e.g. into a simple JSON file. You would then reference the associated nodes/bones by name and save the physics/collision file along with the model. You can even have a dedicated model JSON which references the model FBX and animation FBX and also custom data like hitboxes, physics, etc. This can then be compiled into a more optimal runtime format if needed.

To answer your last question I usually compute the best fit OBB and then fit a capsule or sphere into this. This is very easy. There are many approaches to compute the best fit OBB, but for tool side computations a simple brute force approach usually works very well in practice.

HTH,

-Dirk 

Edited by DonDickieD

Share this post


Link to post
Share on other sites
8 hours ago, ongamex92 said:

how do you compute an object (or even axis) aligned bounding capsule or whatever by a set ot verts?

AABB is trivial to compute.  Iterate over all the points. Maintain values for the biggest X, lowest X, biggest Y, lowest Y, biggest Z, lowest Z.  As you iterate, if the point's position is bigger/smaller than the existing extreme, make that the new extreme.

Oriented bounding shapes are a little more work. You need to start by computing the convex hull. I'll leave the hunting on 3D convex hull generation up to you since there are many well-documented algorithms. Some are tight-fitting with a potentially high number of faces, others are more loose allowing for simpler tests. There are algorithms that use the convex hull and turn it in to an oriented bounding box, or a capsule, or a snowman of multiple spheres, or other shapes you choose.

 

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  

  • Advertisement