CollisionShape for Vehicles

Hey monkeys,

I don’t really know which collision shape to use.

I have the following scenario:
My vehicle is pretty big and accesible; you can walk in and on it. So I can’t create a HullCollisionShape.

The vehicle is - obviously - moving, so that I can’t use a MeshCollisionShape.

There are multiple such vehicles in the scene so they need to collide as well, so GImpactCollisionShape isn’t an option as well.

What can I do?
Is there a way to implement vehicles that you can access with the character?

Generally a separate physics space is used for people inside the vehicle (or the characters are just glued to the vehicle - depending on how much mobility they have).

1 Like
@zarch said: Generally a separate physics space is used for people inside the vehicle (or the characters are just glued to the vehicle - depending on how much mobility they have).

Do you say I should create collision groups for the ‘character-vehicle’ collisions and for the ‘vehicle-vehicle’ collisions?

You should create the outside as a hull (for performance), and the inside can be a mesh or what ever you want. Use 2 physics space’s as zarch suggests, and then set the inside one to AppliedPhysicsLocal.

This should help with further explanations:
http://hub.jmonkeyengine.org/forum/topic/ye-olde-hollow-collisionshape-model/

1 Like
@wezrule said: You should create the outside as a hull (for performance), and the inside can be a mesh or what ever you want. Use 2 physics space's as zarch suggests, and then set the inside one to AppliedPhysicsLocal.

This should help with further explanations:
http://hub.jmonkeyengine.org/forum/topic/ye-olde-hollow-collisionshape-model/

Thanks. I understand now.

On last question though:
Since the vehicles move I think I need to use GImpactCollisionShapes for every vehicle (to represent the player-vehicle physics space).
It says they are very expensive on performance, but usually in the player-vehicle physics space they are alone with the player.

Does jME/bullet optimize this?
I mean they only have to check wether a ship is even in the proximity of the player (and usually its just one) and only handle that collision, don’t they?

bullet has broadphase and narrow phase for that yes, but GImpactCollisionShapes should mostly be avoided at all costs (it doesn’t scale very well, with complexity of mesh and object count). You don’t need to use it, just use Hull shapes, or a Compound Shape of simplex/hulls if the result is not what you desire from the HullCollisionShape directly.

1 Like
@wezrule said: bullet has broadphase and narrow phase for that yes, but GImpactCollisionShapes should mostly be avoided at all costs (it doesn't scale very well, with complexity of mesh and object count). You don't need to use it, just use Hull shapes, or a Compound Shape of simplex/hulls if the result is not what you desire from the HullCollisionShape directly.

Hm.
The reason why I though GImpact would be a good idea was that the artist could easily create a ‘physics model’ but with a compound shape I’d need to define every child collision shape manually. Our vehicle is pretty big and has three floors and multiple rooms and objects. (Okay, the size might be a reason against GImpact as well).

I hope I can automize the creation of the compound shape somehow. I’ll look into it.

@wezrule said: You don't need to use it, just use Hull shapes, or a Compound Shape of simplex/hulls if the result is not what you desire from the HullCollisionShape directly.

I thought about this, and don’t really know what to do…
How am I supposed to model something like the rump of a ship with simple CollisionShapes?

If I use a HullShape I obviously can’t get into the ship and somehow I don’t think that modeling it with boxes and spheres turns out good…

I don’t mean to complain because there is work to do, but it’s not like ‘just use Hull Shapes or a CompoundShape’
But thanks for your help and any other suggestions.

Dont use the interior in the same physicspace. Fake it, have two seperatate one with mesh for itnernal, one with a way simpler shape fore xternal taht is moving.

@Empire Phoenix said: Dont use the interior in the same physicspace. Fake it, have two seperatate one with mesh for itnernal, one with a way simpler shape fore xternal taht is moving.

Yeah, I know that.
But @wezrule advised me not to use the GImpact even in the seperate physics space.
I just don’t know how to ‘efficiently’ do that with the simple collisionShapes.
I decided I’ll use GImpact for now and well, if I really run into performance issues I may need to change it later.

3 hull shapes for the larger bodies, and a fourth for the platform between them. All combined into a compound one.

1 Like

@Empire has it sorted. To further emphasize (From the creator of Bullet):

It is better to use a btBoxShape or btConvexHull, because gimpact is not very reliable

http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=8994

and you are not dynamically changing the collision shape, so there is wasted performance using it.

@Empire Phoenix said: 3 hull shapes for the larger bodies, and a fourth for the platform between them. All combined into a compound one.

I honestly don’t think it’s that simple.
Look at the following drawing:
Green is the HullShape, black is the actual ship. The view is a profile looked at from behind.

We have decks in the ship so the boundaries of the walls get weird.
We don’t have that much room in the ship anymore.
Also you need to take into account that those walls are tapering at the front side so its even closer.

I don’t say it isn’t doable, you could split the original mesh in more and more parts with hullshapes around it to approximate the bended wall better.

@Empire Phoenix
It’s also not just 3 walls and a deck. You also need to split the deck in multiple parts so that you can have an entrance.
And, as I said, we have multiple floors too…

So it’s not that easy… :wink:

Why an entrance? as soon as I stand on that ship, move me to the static more details shape.

@Empire Phoenix said: Why an entrance? as soon as I stand on that ship, move me to the static more details shape.

So, to summarize, you mean:

  1. One Hull shape for each ship for ship-ship collision (physics space 1)
  2. Compound Shapes for each ship for player-ship collisions (physics space 2), e.g. when player jumps on board
  3. One detailed static mesh shape for the ship that the player stands on (physics space 2)

The player is in physics space 2.
I think now we have every possible kind of shape in its best usage :wink:

But there is still one question:
I can’t use a static MeshShape to represent the ship the player stands on; it needs to move as well, doesnt it?
Otherwise it could not move the player from A to B.