physics in my model

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
sazon
Posts: 15
Joined: Thu Jun 23, 2011 6:07 pm

physics in my model

Post by sazon »

Hi I have a model that I want physical applications, but so far I've only worked with the basics boxes, spheres, etc.. And the drawing with the BruteModelDrawer that comes in the Demo.

But as I do to work with models that I have made in ​​FBX, some are completely rigid, and others have a skeleton, I guess it has to be different for each case.

Just started using BEPU.

Thanks.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: physics in my model

Post by Norbo »

It's highly recommended that you stick to simple convex shapes when at all possible. If concavity is needed, using a CompoundBody of multiple simple convex shapes works well. They will be faster than detailed mesh versions of the shapes.

If a simulation really needs a rigid mobile mesh, the engine provides a MobileMesh entity type. Try to keep the triangle count as low as possible for better performance. Using a separate mesh for collision and graphics is recommended.

If you just want a static mesh that can't move that acts as the environment, the StaticMesh will do the job. It is faster than the MobileMesh in cases where it can be used.

For a mesh with a skeleton, usually each individual part (upper arm, lower arm, upper torso, etc.) is a relatively simple shape (preferably a simple convex). Those pieces are then either positioned according to an animation or held together by constraints for a ragdoll. An example of a ragdoll can be found in the ragdoll demo: http://bepuphysics.codeplex.com/wikipag ... umentation
sazon
Posts: 15
Joined: Thu Jun 23, 2011 6:07 pm

Re: physics in my model

Post by sazon »

ok thanks, but i have a error.

in

Code: Select all

TriangleMesh.GetVerticesAndIndicesFromModel(model, out vertices, out indices);
An exception occurs: FormatException-> Unsupported vertex type in mesh.

I can do?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: physics in my model

Post by Norbo »

That error means the model you're trying to load contains information that the convenience method doesn't know how to parse. That convenience method is not a fundamental part of the physics engine- you can make your own vertex data extractor that works with whatever data you'd like to load. Either that, or use a model that it can figure out.

Note that the WP7 version of that method is more constrained in the formats it supports due to a bug in the XNA framework. If you're on WP7, the vertices must be one of the XNA built-in vertex types to function. But again, making your own extractor avoids this issue entirely.
sazon
Posts: 15
Joined: Thu Jun 23, 2011 6:07 pm

Re: physics in my model

Post by sazon »

I use it for WP7
you have any idea to do that, I guess there are more people with the same problem as me.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: physics in my model

Post by Norbo »

The XNA site (http://create.msdn.com/en-US) has some samples that involve extracting vertex data at built time, like the Triangle Picking sample. That's what I would recommend for WP7.
sazon
Posts: 15
Joined: Thu Jun 23, 2011 6:07 pm

Re: physics in my model

Post by sazon »

another question, why is AffineTransform? in

var mesh = new StaticMesh(vertices, indices, new AffineTransform(new Vector3(0, 0, 10)));
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: physics in my model

Post by Norbo »

The AffineTransform transforms the vertices in the mesh. An AffineTransform is a linear transform and translation. Linear transforms include scaling, rotation, or shearing. It's similar to just providing a 4x4 matrix that includes scaling/rotation/shearing/translation, but avoids the superfluous fourth row of elements.
sazon
Posts: 15
Joined: Thu Jun 23, 2011 6:07 pm

Re: physics in my model

Post by sazon »

thanks for the explanation.

already try the example set me said, but like I still can not get it right, I'm not clear what I am seeking, for example. What I want is to get the indices and vertices of the model from the processor or the processor model has some sort of readable form BEPU
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: physics in my model

Post by Norbo »

To create a mesh, a set of vertices (Vector3 array) and indices (int array) are needed and you can get them from anywhere. This sample shows how to use a content processor to get vertex data, start to finish: http://create.msdn.com/en-US/education/ ... g_triangle

For other approaches, I'd recommend searching the XNA forums.
Post Reply