setLinearRotation like method for rotating the ground?

So if I use setLinearVelocity on a ground with mass set to zero, objects like boxes on that ground will be constantly moved with that velocity probably because of friction effects (like on a conveyer). Now I want to achieve the exact same effect but with the ground rotating. That means for example if I put some boxes on a big square and let that square rotate aorund its center, only its “surface moves” so the littel boxes move in circles on that ground square. Please give me some hints on how to make this? Thanks!

Use local physics, it applies the physics to the local translation of a spatial instead of the world translation. Look at TestLocalPhysics, it rotates the rootNode constantly using setLocalRotation() while the physics simulation calculates “normal” physics but applies it to the child local translation. You will need multiple physics spaces (multiple BulletAppStates) for multiple such platforms though.

Sorry but I don’t think I get it I’m still a beginner. In the example below the box moves off the platform (or ground). Now if I rotate the ground, the box should actually rotate like the box also moves when setting velocity on the ground, but it doesn’t. “setApplyPhysicsLocal(true)” doesn’t seem to make a difference either? Maybe you could give a short example or edit mine?



[java]package hello;



import com.jme3.bullet.BulletAppState;

import com.jme3.app.SimpleApplication;

import com.jme3.bullet.PhysicsSpace;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.scene.shape.Box;

import com.jme3.bullet.control.RigidBodyControl;

import com.jme3.scene.Geometry;



public class TestLocalPhysics extends SimpleApplication {



private BulletAppState bulletAppState;

private Geometry ground, box;



public static void main(String[] args) {

TestLocalPhysics app = new TestLocalPhysics();

app.start();

}



@Override

public void simpleInitApp() {

cam.setLocation(new Vector3f(20, 20, 0));

cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);

flyCam.setMoveSpeed(50);



bulletAppState = new BulletAppState();

stateManager.attach(bulletAppState);

bulletAppState.getPhysicsSpace().enableDebug(assetManager);



rootNode.attachChild(ground = createGround());

rootNode.attachChild(box = createBox());



}



private Geometry createGround() {

Box box = new Box(Vector3f.ZERO, 5f, 0.1f, 5f);

Geometry boxGeo = new Geometry(“boxGeo”, box);

Material boxMat = new Material(assetManager,

“Common/MatDefs/Misc/Unshaded.j3md”);

boxMat.setColor(“Color”, ColorRGBA.Brown);

boxGeo.setMaterial(boxMat);

boxGeo.setLocalTranslation(0, -0.1f, 0);

RigidBodyControl control = new RigidBodyControl(0.0f);

boxGeo.addControl(control);

// control.setApplyPhysicsLocal(true);

control.setLinearVelocity(Vector3f.UNIT_X.negate());

getPhysicsSpace().add(control);

return boxGeo;

}



private Geometry createBox() {

Box box = new Box(Vector3f.ZERO, 0.5f, 0.5f, 0.5f);

Geometry boxGeo = new Geometry(“boxGeo”, box);

Material boxMat = new Material(assetManager,

“Common/MatDefs/Misc/Unshaded.j3md”);

boxMat.setColor(“Color”, ColorRGBA.Gray);

boxGeo.setMaterial(boxMat);

boxGeo.setLocalTranslation(3f, 0.5f, 0);

RigidBodyControl control = new RigidBodyControl(1.0f);

boxGeo.addControl(control);

getPhysicsSpace().add(control);

return boxGeo;

}



@Override

public void simpleUpdate(float tpf) {

// rootNode.rotate(tpf, 0, 0);

// ground.rotate(0, tpf, 0);

}



private PhysicsSpace getPhysicsSpace() {

return bulletAppState.getPhysicsSpace();

}

}[/java]

After some trying around I could get the effect I needed by adding this line, yehh :slight_smile: Your answer did definitely help me though…

[java]ground.getControl(RigidBodyControl.class).setAngularVelocity(Vector3f.UNIT_Y.mult(0.31f));[/java]