Local-Inertia

Hi,

can someone explain me, how the local inertia of a compoundCollisionShape works, because I developed an editor to put a compoundCollisionShape around a Node. But now I have to change the local inertia to the right position and e.g. an arrow has had a crazy behavior since then.

It has to be computed based on the collision shape and RigidBody configuration (weight etc). Theres a method for that but you don’t need to use it if you just generate the collision shape with the existing classes. It will be created and set automatically. What kind of “editor” is that? The hull and mesh collision shape constructors already can use mesh data and also set their inertia properly. Just as the compound collision shapes generated by the CollisionShapeFactory are.

I am planning a game which has a world completely build out of “physics-objects”. But I do not want to use only bricks, like e.g. Minecraft does. I want to use nodes created via Blender and so the performance is a big problem. To make performance “as a first step” better, I created an editor, in which you can load such a Node and put a compoundCollisionShape around it. That allows me to create a tower out of bottels or a Micado out of arrows. But now I have to set the local-inertia manually and that is my problem.

Minecraft doesn’t use physics for its blocks.



If you try and do that then performance will be terrible both because of the number of separate items (meshes) and because of the amount of physics processing required.

Yeah, what @zarch said. Our manual contains a lot of info that would have saved you from going this way in the first place. Its always a good idea to do the tuorials and take an evening or two to read the whole manual to get a better overview no matter what your programming skills are.

yeah, there were a topics about voxel engine:

http://hub.jmonkeyengine.org/groups/free-announcements/forum/topic/simple-voxel-engine-starter-kit/



there are many voxel kinds. not only box looking one



if you also want to make some objects component made, maybe batchNode is good solution, depends if its animated

I do not want to create a “brick-world”. I use the graphics of Gothic 1 and 2. So I have to load the Nodes from Blender and without that Editor I can only create a CollisionShape from every Vertex of the Nodes and that makes such a game unplayable. So is there a good way to set the local-inertia manually?

CollisionShape from every Vertex of the Nodes and that makes such a game unplayable

dont know exactly what you mean.

i understand you know there are many CollisionShapes, for some objects you can make BoxCollisionShape, player is usually SphereCollisionShape, not only vertex based(which is slow, true).

Phycics convention is same in all engines.
@javafriend said:
I do not want to create a "brick-world". I use the graphics of Gothic 1 and 2. So I have to load the Nodes from Blender and without that Editor I can only create a CollisionShape from every Vertex of the Nodes and that makes such a game unplayable. So is there a good way to set the local-inertia manually?

Thats not true, you can just batch a mesh and create a hull shape or create a hull shape from single points.. Theres really no need to do what you want, you somehow go down the wrong avenue.

For example you have a barrel imported from Blender. But you want to make it roll around in your Game. So you need a CollisionShape for that barrel. You can use only one cylinder or a CollisonShape created automatically by the JME. Created automatically by the JME is a simple way to create the needed CollsionShape but it needs a lot of effort. Using only one cylinder will not look good. So I create with that editor a CollisionShape e.g. out of three cylinders. In this case you have a good performance and the Collision-Detection looks great. And for that CollisionShapes I have to Set the local-inertia manually and that is my problem.

Again, please read the tutorials, what you say isn’t true. For your problem you can create a simple SDK plugin to add any collision shape just like the mesh and hull shapes can be added now. The CollisionShapeFactory even has a method to wrap trees of geometry according to their bounding boxes. And in no case you have to mess with local inertia as the shape would be a compound shape anyway and the inertia for that is calculated when you add it to the RigidBody.

I dont want to let the Engine create a CollisionShape for every Geometry etc. I want to decide which parts of the Nodes are important for the CollisionDetection. So I have the problem with the local-inertia.

No you don’t. As said, you can construct your own compound shapes combined of any kind of other collision shape, you can create a hull shape of an arbitrary set of points or a mesh shape from a batch-combined version of your meshes and you can even save that in a j3o file. In all of those cases you DO NOT need to use localInertia.

Ok, how would you solve that problem:

You have an arrow consisting of a shawt and an arrowhead.

The shawt is made of wood and the arrowhead is made of iron.

Now the problem is, that the local-inertia moves a bit to the arrowhead,

because it has a bigger density as the shawt out of wood.

So how can I move the local-inertia manually to the right position,

that the arrow moves well and not strange.

You attach the single collision shapes to a compound collision shape with the appropriate offset so that the location of the compound shape defines the desired center of mass. Then you add that to a RigidBody and it will define its localInertia automatically.

1 Like

Ok, thanks a lot.

That means that you have only the possibility to move the CollisionShape to the “Central Point”.

In the moment I will do it that way.

Its a relative thing… You just need to think different ^^ The center of mass is always at the logical center (0/0/0) of the collision shape in bullet. And please do read the manual.