NotImplementedException in MobileMeshShape

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
speciesUnknown
Posts: 20
Joined: Mon Aug 01, 2011 12:31 am

NotImplementedException in MobileMeshShape

Post by speciesUnknown »

Hi,

I'm attempting to create a tank out of a series of mobile mesh shapes (using a compound body) and I found that it was missing a few method implementations. Several methods in MobileMeshShape throw a NotImplementedException. I'm using 1.6.0.

Here is the code I am using to fill the compound body, when the tank is instanced.

Code: Select all

			CompoundBody body;
			List<CompoundShapeEntry> parts = new List<CompoundShapeEntry>();

			foreach (var i in articulations)
			{
				var data = i.Value.part.collision_shape.Data;
				MobileMeshShape mesh = new MobileMeshShape(data.Vertices, data.Indices, AffineTransform.Identity, MobileMeshSolidity.Clockwise);
				parts.Add(new CompoundShapeEntry(mesh));
			}
			body = new CompoundBody(parts);
However, I'm wondering if there is a better way to do this anyway. I'm using a modified version of the TankInput class from the demo application to drive the tank around, so, would it be possible to have one body (the body of the tank) as a dynamic body, and then attach the turret and other moving parts as kinematic objects? They need to respond to raycasts but only the body needs to actually be dynamic. (This is a common tactic for tanks in games as it stops the turret and other moving parts becoming a problem due to their kinematic-like behaviour)

What is my best option?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: NotImplementedException in MobileMeshShape

Post by Norbo »

I found that it was missing a few method implementations. Several methods in MobileMeshShape throw a NotImplementedException. I'm using 1.6.0.
Woops! I'll get that fixed in the development version (http://bepuphysics.codeplex.com/SourceC ... evelopment) in a few minutes.

The backing logic for those methods is present, but apparently all my test cases went through a different path.
However, I'm wondering if there is a better way to do this anyway.
For one thing, using a few convex hulls for the immutable portions of the hull will be far cheaper than mobile meshes. The final vertex count should still be kept under control for the convex hulls; their collision detection cost increases almost linearly with the vertex count.
would it be possible to have one body (the body of the tank) as a dynamic body, and then attach the turret and other moving parts as kinematic objects?
Yup. You'll probably want to adjust the collision rules so it doesn't undergo collision response with anything, since as a kinematic object, it has infinite inertia. Information about collision rules can be found here: http://bepuphysics.codeplex.com/wikipag ... umentation
Setting the kinematic objects' entity.CollisionInformation.CollisionRules.Personal = CollisionRule.NoSolver would probably do the trick. "NoSolver" means it will do everything in the collision detection pipeline, including generating contacts, but the solver won't try to perform collision response.

To make the kinematic entity follow the dynamic body, assuming there is no collision response whatsoever with the kinematic body, setting the position/orientation each frame will work.

There's also the more physical option of connecting a tank's dynamic turret to the main dynamic body using a constraint.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: NotImplementedException in MobileMeshShape

Post by Norbo »

The development version has been updated to address those missing methods. Thanks for that report!
speciesUnknown
Posts: 20
Joined: Mon Aug 01, 2011 12:31 am

Re: NotImplementedException in MobileMeshShape

Post by speciesUnknown »

Thanks for the fast reply, I'll check out the new build in the morning.

Having read your responses I think the best solution will be a convex hull for the dynamic part of the vehicle, with all the other fixtures as kinematic bodies with the NoSolver collision rule. Unfortunately I need to use proper meshes for these fixtures as their shapes are fairly convex (such as weapons), and some I want to have special behaviour (e.g. ERA plates). I'll have a good stab at upgrading the performance of the intersection tests against triangle meshes and report any improvements I can make.

Thanks again.
Post Reply