Non uniform scale (solved)

Hi



I just started using physics and i ran into a small bump. I have a sphere that  i scale


Sphere s = new Sphere("sphere", new Vector3f(0, 0, 0), 15, 15, 1);
      s.setModelBound(new BoundingSphere());
      s.setLocalScale(new Vector3f(5, 1, 5));
      s.updateModelBound();
      node.attachChild(s);
node.generatePhysicsGeometry(true);


However when i view the physicsgeom on it, it is a normal sphere and not scaled like the sphere model.
How can i fix this ?

Hellmaster.

You can't. A sphere is a sphere is a sphere…



You best bet is to use a trimesh if your sphere is really heavily deformed. Probably two spheres or a capsule can do the trick, if you just need to squeeze is a little bit.

You might also want to look at the capsule geometry if you want a 'deformed' sphere.





Edit: oh oops I guess you did say capsule irrisor…







poor Tux, he just doesn't look like he is enjoying being violated :smiley:

basixs said:

poor Tux, he just doesn't look like he is enjoying being violated :D

hehe i just cant feel sorry for him  :evil:

Ok i came across the following in physics fun

TriMesh topCylinderVisual = new Cylinder("cyl", 10, 10, 0.2f, 9, true);
        topCylinderVisual.setModelBound(new BoundingBox());
        topCylinderVisual.updateModelBound();
        topCylinderVisual.getLocalRotation().fromAngleAxis(FastMath.DEG_TO_RAD * 90, Vector3f.UNIT_Y);

        topCylinderNode = space.createDynamicNode();
        topCylinderNode.setName("top cylinder");
        PhysicsMesh topCylinderMesh = topCylinderNode.createMesh("top cylinder");
        topCylinderMesh.copyFrom(topCylinderVisual);
        topCylinderNode.attachChild(topCylinderMesh);



so i did

Sphere s = new Sphere("sphere", new Vector3f(0, 0, 0), 15, 15, 1);
      s.setModelBound(new BoundingSphere());
      s.setLocalScale(new Vector3f(5, 1, 5));
      node.attachChild(s);
      node.updateModelBound();
      PhysicsMesh pmesh = node.createMesh("pmesh");
      pmesh.copyFrom(s);
      node.attachChild(pmesh);


which appears to be working fine, only thing is i now cant see the physics bounding with the physicsDebugger so i cant really be sure the bounding is now correct.

Is this the way to go?


edit
is there a "save" way to save and load this ? when i save it now i get the message "Not implemented: currently, saving PhysicsMesh collision geometry doesn't work",  ok i can live with that and regenerate the mesh after loading. however i cant even load the jme file anymore because it either crashes with the message "Unexpected end of ZLIB input stream"or with the following NPE

Exception in thread "loader for ingame" java.lang.NullPointerException
   at com.jmex.physics.util.binarymodules.BinaryPhysicsMeshModule.load(BinaryPhysicsMeshModule.java:51)
   at com.jme.util.export.binary.BinaryClassLoader.fromName(BinaryClassLoader.java:125)
   at com.jme.util.export.binary.BinaryImporter.readObject(BinaryImporter.java:242)
   at com.jme.util.export.binary.BinaryInputCapsule.resolveIDs(BinaryInputCapsule.java:458)
   at com.jme.util.export.binary.BinaryInputCapsule.readSavableArray(BinaryInputCapsule.java:446)
   at com.jme.util.export.binary.BinaryInputCapsule.readSavableArrayList(BinaryInputCapsule.java:550)
   at com.jme.scene.Node.read(Node.java:649)
   at com.jmex.physics.PhysicsNode.read(PhysicsNode.java:633)
   at com.jme.util.export.binary.BinaryImporter.readObject(BinaryImporter.java:247)
   at com.jme.util.export.binary.BinaryInputCapsule.resolveIDs(BinaryInputCapsule.java:458)
   at com.jme.util.export.binary.BinaryInputCapsule.readSavableArray(BinaryInputCapsule.java:446)
   at com.jme.util.export.binary.BinaryInputCapsule.readSavableArrayList(BinaryInputCapsule.java:550)
   at com.jme.scene.Node.read(Node.java:649)
   at basicItems.ItemNode.read(ItemNode.java:231)
   at com.jme.util.export.binary.BinaryImporter.readObject(BinaryImporter.java:247)
   at com.jme.util.export.binary.BinaryInputCapsule.resolveIDs(BinaryInputCapsule.java:458)
   at com.jme.util.export.binary.BinaryInputCapsule.readSavableArray(BinaryInputCapsule.java:446)
   at com.jme.util.export.binary.BinaryInputCapsule.readSavableArrayList(BinaryInputCapsule.java:550)
   at com.jme.scene.Node.read(Node.java:649)
   at com.jme.util.export.binary.BinaryImporter.readObject(BinaryImporter.java:247)
   at com.jme.util.export.binary.BinaryImporter.load(BinaryImporter.java:156)
   at com.jme.util.export.binary.BinaryImporter.load(BinaryImporter.java:173)
   at com.jme.util.export.binary.BinaryImporter.load(BinaryImporter.java:168)



Hellmaster.

Yes, that's the way to go. And yes, physics meshes are not visualized in the ODE impl. Save and load does work, yet.

To save the rest of your stuff you need to remove the physics mesh first or change your local version to ignore the missing implementation instead of throwing an exception. If you get the exception while saving the file is broken and cannot be loaded any more.

Thanks got it working.



Hellmaster.