🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Collision geometry in FBX (or in general)

Started by
4 comments, last by frob 6 years, 12 months ago

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?

 

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.

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?

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 

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.

 

This topic is closed to new replies.

Advertisement