Jbullet-jme import/export

Hi i need to import/export physicsnodes of jbullet-jme and in the last version of svn does not appears to be implemented yet.

Because this I'm implementing this feature and I can export a small scene with a sphere falling on the ground.

But when I use more objects the collisions don't work propertly…



I don't know how to export the CompoundCollisionShape, but for the others shapes I exported the id of the type, BOX, SPHERE… and it worked.



Any idea?



thank-you

Great to hear somebody is working on this hope to see some diff posts soon! :wink:

CollisionShapes are a reference to another object so CollisionShape would have to implement Savable and then you can export/import it directly in the PhysicsNode write()/read() method. Using the id is not a good idea because you basically create the "default" CollisionShape each time then, also it would not allow shared CollisionShapes to be used.

I am thinking about removing the CollisionShape.ShapeType thing completely and replacing it with a CollisionShapeBuilder or something to create CollisionShapes from jme objects like BoundingVolumes etc.



Hope this helps,

Normen

For me CollisionShape.ShapeType is good because in a visual editor i want to define the Shapes ans their sizes.



I attach my first atempt. Look this and give me some tips please.

I have problems with the position. if the physicsnode have a  local position diferent of 0, the collision are moved.

if in read() method,  i reset the local translation first and after apply it goes fine.



Also I have a question. The methods createMotionState() and applyMotionState() need the world position of the node. I'm true? Because when read() the object isn't attached to rootnode, the object aren't in the real position. and i think the objects goes crazy for this.



If you want to look test the jmetest.jbullet.TestWriteSimple  jmetest.jbullet.TestSave  jmetest.jbullet.TestLoad2



Others question: in TestSimplePhysics if i  lean the floor,  dinamic objects don't skate. Why?



GhostPhysicsNode is a kinematic physic node?



Thank you!

Paueti said:

Also I have a question. The methods createMotionState() and applyMotionState() need the world position of the node. I'm true? Because when read() the object isn't attached to rootnode, the object aren't in the real position. and i think the objects goes crazy for this.

Other question: in TestSimplePhysics if i  lean the floor,  dinamic objects don't skate. Why?

yes, the physics work with world coordinates.

how do you lean it? did you lower the friction of the objects? its quite high I think.

Did not have a look at your version yet, its a bit inconvenient scanning through a whole project folder for changes, diff files would be easier.
Paueti said:

GhostPhysicsNode is a kinematic physic node?

not exactly, kinematic nodes are not implemented yet, it will be a flag in PhysicsNode. GhostNodes do not collide and are mostly for triggering purposes etc.

diffs

Good, I see you began to step back from using the type value of the CollisionShapes.

Ok, so saving of the CompoundCollisionShape can only work if you store the list of added child shapes (which is not done currently) and then have every CollisionShape extend Savable (I'd remove the Binary… wrappers an put it directly), also CompoundCollisionShape. Then you just store the child collision shapes when exporting the compound one.

Cheers,

Normen

I started to look CompoundCollisionShape. My intention is Get the list of childs (bulletphysics shapes ), wrap into the com.jmex.jbullet.CollisionShapes  and save.

The problem are the childs of CompoundShape have location,. I see 2 options: Create com.jmex.jbullet.CollisionShapeChild (and variants box sphere…) or add location to CollisionShapes ad only use if are childs of Compound. What do you think?



A compoundshape can have a child that be other compoundshape ? And create a tree?

You would have to save the list of childs (which are also Savable) and their local locations, yes. Its important to keep the Savable structure to reload the referenced nodes correctly. I dont know if the binary system of jme2 supports lists of Savable s to be saved, if not I'd say you should create one separate class also extending Savable and then have that save the location and the other CollisionShape, not for every CollisionShape.



Edit: I think trees of compoundShapes are not supported in bullet although they might "work" as in throwing no exception.

If you want to contribute this I can set up a branch in jbullet-jme for you to commit to, this way its also easier for me/others to help out.