Newbie: Have FBX model, want to find ConvexHull points

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
vintagegames
Posts: 19
Joined: Wed Dec 16, 2009 4:36 pm

Newbie: Have FBX model, want to find ConvexHull points

Post by vintagegames »

I'm a .NET developer by day and have a .fbx model file of a hockey goaltender (from the old bubble hockey games).

I'm new to the BEPU physics thing, but have worked through the basic demos of spheres, cubes, etc. I want to create a List<Vector3> out of the .fbx model I have, so that I can accurately get physics collisions for pucks shot at the goaltender. I tried mapping my model onto a Box() obj, but obviously there should be holes in the goaltender model where pucks can fit through.

Does anyone have sample code where I can run .fbx files through and retrieve a list of ray-traced Vector3 points? Am I going in the right direction?

What do I do about the glass bubble that contains the bubble hockey game, is that a ConvexHull obj?
vintagegames
Posts: 19
Joined: Wed Dec 16, 2009 4:36 pm

Re: Newbie: Have FBX model, want to find ConvexHull points

Post by vintagegames »

Here's what the goalie looks like:
http://www.justintubbs.com/fbx/goalie.fbx
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Newbie: Have FBX model, want to find ConvexHull points

Post by Norbo »

You can use the TriangleMesh.getVerticesAndIndicesFromModel static method to get a list of Vector3s and indices. It takes a loaded Model object (which you can load using the XNA content pipeline) and extracts the mesh data.

You could then directly construct a ConvexHull from those points, though there would be a couple of issues.
#1: It's a pretty high resolution mesh to use for ConvexHull collision detection.
#2: It will create a sort of shrinkwrap around the model, getting rid of all concavity.

My suggested solution would be to create multiple, relatively simple meshes that each represent a convex part of your model, create ConvexHull objects from them after loading them in, and add them to a single CompoundBody. You could probably get away with 2-4 ConvexHulls total, depending on what level of detail you want to maintain.

Going this route, you could choose what bits of detail you want to keep (such as the concavity around the neck and supporting stick) and not worry about the more minor bits (like on this edge of his left-middle padding).

If you don't want to deal with the difficulty of creating multiple meshes, you could also combine multiple simple primitives (like boxes) into a CompoundBody to approximate the collision.

For the bubble, you could use a StaticTriangleGroup created from a mesh representing the bubble. StaticTriangleGroups are just bunches of arbitrary triangles, so they can form concave shapes like the Playground (#28) in the demo project.
vintagegames
Posts: 19
Joined: Wed Dec 16, 2009 4:36 pm

Re: Newbie: Have FBX model, want to find ConvexHull points

Post by vintagegames »

So I noticed that a StaticTriangleGroup doesn't have an EventsManager...is it considered an Entity?

I had been loading individual models for each hockey player as StaticTriangleGroup objects (out of StaticTriangleMesh objs) and then I'm finding that since they aren't an "Entity" object type, they don't have an EventsManager.

So I have to create a ConvexHull for each 3D model I want to have events for? Is that correct? So the puck (which I have modeled as a 3D object) would have to have a ConvexHull obj created in order to interact with the physics of other Entities (and StaticTriangleGroups) in the scene?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Newbie: Have FBX model, want to find ConvexHull points

Post by Norbo »

The StaticTriangleGroup is not an entity. It manages entities (the triangles of the mesh).

If you want collision events and interactions, you will indeed need an Entity. For the puck specifically, instead of a ConvexHull entity, I'd recommend just using a simple Cylinder entity. You can attach whatever triangulated graphics to it that you want.
Post Reply