JME Physics networking - Car behaves strange

Hey,



I implemented a car racegame. Until now a client can connect to a server.

During the game, Im synchronizing all phyisical data of the car.



The problem is, that is server is calculation the physics it self… So at game start, all cars are at the corret position, but when one player is driving, the synchronized copy of it is jumping around everywhere, because the server tries to calculate all physics data is self - which collides with the synchronized data.



how could i solve that problem?



please help me

Are you using JGN? I think that there is physics management in that.

Yeah,



I m using JGN to synchronize all dynamicPhysicNodes of the advanced vehicle. (as suspensions, bases…)

what do you mean with physics management?



i will upload screenshots soon :slight_smile:

maybe you're sending wrong datas … ?



You can use .rest() with each opponent car physics nodes or try with setCollidable() for tests …





Kine

Can't help you but … screenshots!

can be, that i'm doing something wrong…

but i didnt find the error yet… i someone wants to try it, here is the code


public class JMEVehicleController implements GraphicalController<VehicleNode>  {
   private Vector3f store;
   
   public JMEVehicleController() {
      store = new Vector3f();
   }
   
    public void applySynchronizationMessage(SynchronizeMessage message, VehicleNode vehicle) {
        SynchronizeVehicleMessage m = (SynchronizeVehicleMessage)message;
        /*
        * fields for Chassis
        */
        ((TutorialCar)vehicle.getModel()).getChassis().setLocalTranslation(new Vector3f(m.getChassisPositionX(), m.getChassisPositionY(), m.getChassisPositionZ()));
        ((TutorialCar)vehicle.getModel()).getChassis().setLocalRotation(new Quaternion(m.getChassisRotationX(), m.getChassisRotationY(), m.getChassisRotationZ(), m.getChassisRotationW()));
        ((TutorialCar)vehicle.getModel()).getChassis().setLinearVelocity(new Vector3f(m.getChassisLinearVelocityX(), m.getChassisLinearVelocityY(), m.getChassisLinearVelocityZ()));
        ((TutorialCar)vehicle.getModel()).getChassis().setAngularVelocity(new Vector3f(m.getChassisAngularVelocityX(), m.getChassisAngularVelocityY(), m.getChassisAngularVelocityZ()));
        /*
       * fields for frontSuspension
       */
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().setLocalTranslation(new Vector3f(m.getFrontSuspensionPositionX(), m.getFrontSuspensionPositionY(), m.getFrontSuspensionPositionZ()));
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().setLocalRotation(new Quaternion(m.getFrontSuspensionRotationX(), m.getFrontSuspensionRotationY(), m.getFrontSuspensionRotationZ(), m.getFrontSuspensionRotationW()));
//        ((TutorialCar)vehicle.getModel()).getChassis().setLinearVelocity(new Vector3f(m.getChassisLinearVelocityX(), m.getChassisLinearVelocityY(), m.getChassisLinearVelocityZ()));
//        ((TutorialCar)vehicle.getModel()).getChassis().setAngularVelocity(new Vector3f(m.getChassisAngularVelocityX(), m.getChassisAngularVelocityY(), m.getChassisAngularVelocityZ()));
        /*
       * fields for rearSuspension
       */
        ((TutorialCar)vehicle.getModel()).getRearSuspension().setLocalTranslation(new Vector3f(m.getRearSuspensionPositionX(), m.getRearSuspensionPositionY(), m.getRearSuspensionPositionZ()));
        ((TutorialCar)vehicle.getModel()).getRearSuspension().setLocalRotation(new Quaternion(m.getRearSuspensionRotationX(), m.getRearSuspensionRotationY(), m.getRearSuspensionRotationZ(), m.getRearSuspensionRotationW()));
//        ((TutorialCar)vehicle.getModel()).getChassis().setLinearVelocity(new Vector3f(m.getChassisLinearVelocityX(), m.getChassisLinearVelocityY(), m.getChassisLinearVelocityZ()));
//        ((TutorialCar)vehicle
        /*
       * fields for frontSuspension left  WheelNode
       */
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().setLocalTranslation(new Vector3f(m.getFrontSuspensionsLeftWheelPositionX(), m.getFrontSuspensionsLeftWheelPositionY(), m.getFrontSuspensionsLeftWheelPositionZ()));
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().setLocalRotation(new Quaternion(m.getFrontSuspensionsLeftWheelRotationX(), m.getFrontSuspensionsLeftWheelRotationY(), m.getFrontSuspensionsLeftWheelRotationZ(), m.getFrontSuspensionsLeftWheelRotationW()));
//        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().setLinearVelocity(new Vector3f(m.getFrontSuspensionsLeftWheelLinearVelocityX(), m.getFrontSuspensionsLeftWheelLinearVelocityY(), m.getFrontSuspensionsLeftWheelLinearVelocityZ()));
//        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().setAngularVelocity(new Vector3f(m.getFrontSuspensionsLeftWheelAngularVelocityX(), m.getFrontSuspensionsLeftWheelAngularVelocityY(), m.getFrontSuspensionsLeftWheelAngularVelocityZ()));
        /*
       * fields for frontSuspension right  WheelNode
       */
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().setLocalTranslation(new Vector3f(m.getFrontSuspensionsRightWheelPositionX(), m.getFrontSuspensionsRightWheelPositionY(), m.getFrontSuspensionsRightWheelPositionZ()));
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().setLocalRotation(new Quaternion(m.getFrontSuspensionsRightWheelRotationX(), m.getFrontSuspensionsRightWheelRotationY(), m.getFrontSuspensionsRightWheelRotationZ(), m.getFrontSuspensionsRightWheelRotationW()));
//        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().setLinearVelocity(new Vector3f(m.getFrontSuspensionsRightWheelLinearVelocityX(), m.getFrontSuspensionsRightWheelLinearVelocityY(), m.getFrontSuspensionsRightWheelLinearVelocityZ()));
//        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().setAngularVelocity(new Vector3f(m.getFrontSuspensionsRightWheelAngularVelocityX(), m.getFrontSuspensionsRightWheelAngularVelocityY(), m.getFrontSuspensionsRightWheelAngularVelocityZ()));
        /*
       * fields for rearSuspension left  WheelNode
       */
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().setLocalTranslation(new Vector3f(m.getRearSuspensionsLeftWheelPositionX(), m.getRearSuspensionsLeftWheelPositionY(), m.getRearSuspensionsLeftWheelPositionZ()));
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().setLocalRotation(new Quaternion(m.getRearSuspensionsLeftWheelRotationX(), m.getRearSuspensionsLeftWheelRotationY(), m.getRearSuspensionsLeftWheelRotationZ(), m.getRearSuspensionsLeftWheelRotationW()));
//        ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().setLinearVelocity(new Vector3f(m.getRearSuspensionsLeftWheelLinearVelocityX(), m.getRearSuspensionsLeftWheelLinearVelocityY(), m.getRearSuspensionsLeftWheelLinearVelocityZ()));
//        ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().setAngularVelocity(new Vector3f(m.getRearSuspensionsLeftWheelAngularVelocityX(), m.getRearSuspensionsLeftWheelAngularVelocityY(), m.getRearSuspensionsLeftWheelAngularVelocityZ()));
        /*
       * fields for rearSuspension right  WheelNode
       */
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().setLocalTranslation(new Vector3f(m.getRearSuspensionsRightWheelPositionX(), m.getRearSuspensionsRightWheelPositionY(), m.getRearSuspensionsRightWheelPositionZ()));
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().setLocalRotation(new Quaternion(m.getRearSuspensionsRightWheelRotationX(), m.getRearSuspensionsRightWheelRotationY(), m.getRearSuspensionsRightWheelRotationZ(), m.getRearSuspensionsRightWheelRotationW()));
//        ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().setLinearVelocity(new Vector3f(m.getRearSuspensionsRightWheelLinearVelocityX(), m.getRearSuspensionsRightWheelLinearVelocityY(), m.getRearSuspensionsRightWheelLinearVelocityZ()));
//        ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().setAngularVelocity(new Vector3f(m.getRearSuspensionsRightWheelAngularVelocityX(), m.getRearSuspensionsRightWheelAngularVelocityY(), m.getRearSuspensionsRightWheelAngularVelocityZ()));
        /*
       * fields for frontSuspension left  WheelPhysicsNodeP
       */
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().setLocalTranslation(new Vector3f(m.getFrontSuspensionsLeftWheelPhysicsNodePositionX(), m.getFrontSuspensionsLeftWheelPhysicsNodePositionY(), m.getFrontSuspensionsLeftWheelPhysicsNodePositionZ()));
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().setLocalRotation(new Quaternion(m.getFrontSuspensionsLeftWheelPhysicsNodeRotationX(), m.getFrontSuspensionsLeftWheelPhysicsNodeRotationY(), m.getFrontSuspensionsLeftWheelPhysicsNodeRotationZ(), m.getFrontSuspensionsLeftWheelPhysicsNodeRotationW()));
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().setLinearVelocity(new Vector3f(m.getFrontSuspensionsLeftWheelPhysicsNodeLinearVelocityX(), m.getFrontSuspensionsLeftWheelPhysicsNodeLinearVelocityY(), m.getFrontSuspensionsLeftWheelPhysicsNodeLinearVelocityZ()));
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().setAngularVelocity(new Vector3f(m.getFrontSuspensionsLeftWheelPhysicsNodeAngularVelocityX(), m.getFrontSuspensionsLeftWheelPhysicsNodeAngularVelocityY(), m.getFrontSuspensionsLeftWheelPhysicsNodeAngularVelocityZ()));
        /*
       * fields for frontSuspension right WheelPhysicsNode
       */
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().setLocalTranslation(new Vector3f(m.getFrontSuspensionsRightWheelPhysicsNodePositionX(), m.getFrontSuspensionsRightWheelPhysicsNodePositionY(), m.getFrontSuspensionsRightWheelPhysicsNodePositionZ()));
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().setLocalRotation(new Quaternion(m.getFrontSuspensionsRightWheelPhysicsNodeRotationX(), m.getFrontSuspensionsRightWheelPhysicsNodeRotationY(), m.getFrontSuspensionsRightWheelPhysicsNodeRotationZ(), m.getFrontSuspensionsRightWheelPhysicsNodeRotationW()));
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().setLinearVelocity(new Vector3f(m.getFrontSuspensionsRightWheelPhysicsNodeLinearVelocityX(), m.getFrontSuspensionsRightWheelPhysicsNodeLinearVelocityY(), m.getFrontSuspensionsRightWheelPhysicsNodeLinearVelocityZ()));
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().setAngularVelocity(new Vector3f(m.getFrontSuspensionsRightWheelPhysicsNodeAngularVelocityX(), m.getFrontSuspensionsRightWheelPhysicsNodeAngularVelocityY(), m.getFrontSuspensionsRightWheelPhysicsNodeAngularVelocityZ()));
        /*
       * fields for rearSuspension left  WheelPhysicsNode
       */
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().setLocalTranslation(new Vector3f(m.getRearSuspensionsLeftWheelPhysicsNodePositionX(), m.getRearSuspensionsLeftWheelPhysicsNodePositionY(), m.getRearSuspensionsLeftWheelPhysicsNodePositionZ()));
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().setLocalRotation(new Quaternion(m.getRearSuspensionsLeftWheelPhysicsNodeRotationX(), m.getRearSuspensionsLeftWheelPhysicsNodeRotationY(), m.getRearSuspensionsLeftWheelPhysicsNodeRotationZ(), m.getRearSuspensionsLeftWheelPhysicsNodeRotationW()));
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().setLinearVelocity(new Vector3f(m.getRearSuspensionsLeftWheelPhysicsNodeLinearVelocityX(), m.getRearSuspensionsLeftWheelPhysicsNodeLinearVelocityY(), m.getRearSuspensionsLeftWheelPhysicsNodeLinearVelocityZ()));
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().setAngularVelocity(new Vector3f(m.getRearSuspensionsLeftWheelPhysicsNodeAngularVelocityX(), m.getRearSuspensionsLeftWheelPhysicsNodeAngularVelocityY(), m.getRearSuspensionsLeftWheelPhysicsNodeAngularVelocityZ()));
        /*
       * fields for rearSuspension right  WheelPhysicsNode
       */
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().setLocalTranslation(new Vector3f(m.getRearSuspensionsRightWheelPhysicsNodePositionX(), m.getRearSuspensionsRightWheelPhysicsNodePositionY(), m.getRearSuspensionsRightWheelPhysicsNodePositionZ()));
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().setLocalRotation(new Quaternion(m.getRearSuspensionsRightWheelPhysicsNodeRotationX(), m.getRearSuspensionsRightWheelPhysicsNodeRotationY(), m.getRearSuspensionsRightWheelPhysicsNodeRotationZ(), m.getRearSuspensionsRightWheelPhysicsNodeRotationW()));
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().setLinearVelocity(new Vector3f(m.getRearSuspensionsRightWheelPhysicsNodeLinearVelocityX(), m.getRearSuspensionsRightWheelPhysicsNodeLinearVelocityY(), m.getRearSuspensionsRightWheelPhysicsNodeLinearVelocityZ()));
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().setAngularVelocity(new Vector3f(m.getRearSuspensionsRightWheelPhysicsNodeAngularVelocityX(), m.getRearSuspensionsRightWheelPhysicsNodeAngularVelocityY(), m.getRearSuspensionsRightWheelPhysicsNodeAngularVelocityZ()));
        
    }



it is ugly, but it I dont know another way.... dont be confused, i m also synchronizing normal nodes which are not physics nodes - it is just because i was desperate....

and here the createSynchronizationMessage() method…

there was just not place in the upper post  :D


    public SynchronizeMessage createSynchronizationMessage(VehicleNode vehicle) {
       SynchronizeVehicleMessage message = new SynchronizeVehicleMessage();
       /*
        * fields for Chassis
        */
      message.setChassisPositionX(((TutorialCar)vehicle.getModel()).getChassis().getLocalTranslation().x);
      message.setChassisPositionY(((TutorialCar)vehicle.getModel()).getChassis().getLocalTranslation().y);
      message.setChassisPositionZ(((TutorialCar)vehicle.getModel()).getChassis().getLocalTranslation().z);
      message.setChassisRotationX(((TutorialCar)vehicle.getModel()).getChassis().getLocalRotation().x);
      message.setChassisRotationY(((TutorialCar)vehicle.getModel()).getChassis().getLocalRotation().y);
      message.setChassisRotationZ(((TutorialCar)vehicle.getModel()).getChassis().getLocalRotation().z);
      message.setChassisRotationW(((TutorialCar)vehicle.getModel()).getChassis().getLocalRotation().w);
      ((TutorialCar)vehicle.getModel()).getChassis().getLinearVelocity(store);   
      message.setChassisLinearVelocityX(store.x);
      message.setChassisLinearVelocityY(store.y);
      message.setChassisLinearVelocityZ(store.z);
      ((TutorialCar)vehicle.getModel()).getChassis().getAngularVelocity(store);
      message.setChassisAngularVelocityX(store.x);
      message.setChassisAngularVelocityY(store.y);
      message.setChassisAngularVelocityZ(store.z);
      /*
       * fields for frontSuspension left  WheelPhysicsNodePhysicsNode
       */
      message.setFrontSuspensionsLeftWheelPhysicsNodePositionX(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getLocalTranslation().x);
      message.setFrontSuspensionsLeftWheelPhysicsNodePositionY(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getLocalTranslation().y);
      message.setFrontSuspensionsLeftWheelPhysicsNodePositionZ(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getLocalTranslation().z);
      message.setFrontSuspensionsLeftWheelPhysicsNodeRotationX(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getLocalRotation().x);
      message.setFrontSuspensionsLeftWheelPhysicsNodeRotationY(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getLocalRotation().y);
      message.setFrontSuspensionsLeftWheelPhysicsNodeRotationZ(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getLocalRotation().z);
      message.setFrontSuspensionsLeftWheelPhysicsNodeRotationW(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getLocalRotation().w);
      ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getLinearVelocity(store);   
      message.setFrontSuspensionsLeftWheelPhysicsNodeLinearVelocityX(store.x);
      message.setFrontSuspensionsLeftWheelPhysicsNodeLinearVelocityY(store.y);
      message.setFrontSuspensionsLeftWheelPhysicsNodeLinearVelocityZ(store.z);
      ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getAngularVelocity(store);
      message.setFrontSuspensionsLeftWheelPhysicsNodeAngularVelocityX(store.x);
      message.setFrontSuspensionsLeftWheelPhysicsNodeAngularVelocityY(store.y);
      message.setFrontSuspensionsLeftWheelPhysicsNodeAngularVelocityZ(store.z);
      /*
       * fields for frontSuspension right WheelPhysicsNodeNode
       */
      message.setFrontSuspensionsRightWheelPhysicsNodePositionX(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getLocalTranslation().x);
      message.setFrontSuspensionsRightWheelPhysicsNodePositionY(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getLocalTranslation().y);
      message.setFrontSuspensionsRightWheelPhysicsNodePositionZ(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getLocalTranslation().z);
      message.setFrontSuspensionsRightWheelPhysicsNodeRotationX(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getLocalRotation().x);
      message.setFrontSuspensionsRightWheelPhysicsNodeRotationY(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getLocalRotation().y);
      message.setFrontSuspensionsRightWheelPhysicsNodeRotationZ(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getLocalRotation().z);
      message.setFrontSuspensionsRightWheelPhysicsNodeRotationW(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getLocalRotation().w);
      ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getLinearVelocity(store);   
      message.setFrontSuspensionsRightWheelPhysicsNodeLinearVelocityX(store.x);
      message.setFrontSuspensionsRightWheelPhysicsNodeLinearVelocityY(store.y);
      message.setFrontSuspensionsRightWheelPhysicsNodeLinearVelocityZ(store.z);
      ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getAngularVelocity(store);
      message.setFrontSuspensionsRightWheelPhysicsNodeAngularVelocityX(store.x);
      message.setFrontSuspensionsRightWheelPhysicsNodeAngularVelocityY(store.y);
      message.setFrontSuspensionsRightWheelPhysicsNodeAngularVelocityZ(store.z);
      /*
       * fields for rearSuspension left  WheelPhysicsNodeNode
       */
      message.setRearSuspensionsLeftWheelPhysicsNodePositionX(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getLocalTranslation().x);
      message.setRearSuspensionsLeftWheelPhysicsNodePositionY(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getLocalTranslation().y);
      message.setRearSuspensionsLeftWheelPhysicsNodePositionZ(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getLocalTranslation().z);
      message.setRearSuspensionsLeftWheelPhysicsNodeRotationX(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getLocalRotation().x);
      message.setRearSuspensionsLeftWheelPhysicsNodeRotationY(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getLocalRotation().y);
      message.setRearSuspensionsLeftWheelPhysicsNodeRotationZ(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getLocalRotation().z);
      message.setRearSuspensionsLeftWheelPhysicsNodeRotationW(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getLocalRotation().w);
      ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getLinearVelocity(store);   
      message.setRearSuspensionsLeftWheelPhysicsNodeLinearVelocityX(store.x);
      message.setRearSuspensionsLeftWheelPhysicsNodeLinearVelocityY(store.y);
      message.setRearSuspensionsLeftWheelPhysicsNodeLinearVelocityZ(store.z);
      ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getAngularVelocity(store);
      message.setRearSuspensionsLeftWheelPhysicsNodeAngularVelocityX(store.x);
      message.setRearSuspensionsLeftWheelPhysicsNodeAngularVelocityY(store.y);
      message.setRearSuspensionsLeftWheelPhysicsNodeAngularVelocityZ(store.z);
      /*
       * fields for rearSuspension right WheelPhysicsNodeNode
       */
      message.setRearSuspensionsRightWheelPhysicsNodePositionX(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getLocalTranslation().x);
      message.setRearSuspensionsRightWheelPhysicsNodePositionY(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getLocalTranslation().y);
      message.setRearSuspensionsRightWheelPhysicsNodePositionZ(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getLocalTranslation().z);
      message.setRearSuspensionsRightWheelPhysicsNodeRotationX(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getLocalRotation().x);
      message.setRearSuspensionsRightWheelPhysicsNodeRotationY(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getLocalRotation().y);
      message.setRearSuspensionsRightWheelPhysicsNodeRotationZ(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getLocalRotation().z);
      message.setRearSuspensionsRightWheelPhysicsNodeRotationW(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getLocalRotation().w);
      ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getLinearVelocity(store);   
      message.setRearSuspensionsRightWheelPhysicsNodeLinearVelocityX(store.x);
      message.setRearSuspensionsRightWheelPhysicsNodeLinearVelocityY(store.y);
      message.setRearSuspensionsRightWheelPhysicsNodeLinearVelocityZ(store.z);
      ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getAngularVelocity(store);
      message.setRearSuspensionsRightWheelPhysicsNodeAngularVelocityX(store.x);
      message.setRearSuspensionsRightWheelPhysicsNodeAngularVelocityY(store.y);
      message.setRearSuspensionsRightWheelPhysicsNodeAngularVelocityZ(store.z);
      /*
       * fields for rearSuspensionsLeftBaseNode
       */
      message.setRearSuspensionsLeftBasePhysicsNodePositionX(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftBase().getLocalTranslation().x);
      message.setRearSuspensionsLeftBasePhysicsNodePositionY(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftBase().getLocalTranslation().y);
      message.setRearSuspensionsLeftBasePhysicsNodePositionZ(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftBase().getLocalTranslation().z);
      message.setRearSuspensionsLeftBasePhysicsNodeRotationX(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftBase().getLocalRotation().x);
      message.setRearSuspensionsLeftBasePhysicsNodeRotationY(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftBase().getLocalRotation().y);
      message.setRearSuspensionsLeftBasePhysicsNodeRotationZ(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftBase().getLocalRotation().z);
      message.setRearSuspensionsLeftBasePhysicsNodeRotationW(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftBase().getLocalRotation().w);
      ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftBase().getLinearVelocity(store);   
      message.setRearSuspensionsLeftBasePhysicsNodeLinearVelocityX(store.x);
      message.setRearSuspensionsLeftBasePhysicsNodeLinearVelocityY(store.y);
      message.setRearSuspensionsLeftBasePhysicsNodeLinearVelocityZ(store.z);
      ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftBase().getAngularVelocity(store);
      message.setRearSuspensionsLeftBasePhysicsNodeAngularVelocityX(store.x);
      message.setRearSuspensionsLeftBasePhysicsNodeAngularVelocityY(store.y);
      message.setRearSuspensionsLeftBasePhysicsNodeAngularVelocityZ(store.z);
      /*
       * fields for rearSuspensionsRightBaseNode
       */
      message.setRearSuspensionsRightBasePhysicsNodePositionX(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightBase().getLocalTranslation().x);
      message.setRearSuspensionsRightBasePhysicsNodePositionY(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightBase().getLocalTranslation().y);
      message.setRearSuspensionsRightBasePhysicsNodePositionZ(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightBase().getLocalTranslation().z);
      message.setRearSuspensionsRightBasePhysicsNodeRotationX(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightBase().getLocalRotation().x);
      message.setRearSuspensionsRightBasePhysicsNodeRotationY(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightBase().getLocalRotation().y);
      message.setRearSuspensionsRightBasePhysicsNodeRotationZ(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightBase().getLocalRotation().z);
      message.setRearSuspensionsRightBasePhysicsNodeRotationW(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightBase().getLocalRotation().w);
      ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightBase().getLinearVelocity(store);   
      message.setRearSuspensionsRightBasePhysicsNodeLinearVelocityX(store.x);
      message.setRearSuspensionsRightBasePhysicsNodeLinearVelocityY(store.y);
      message.setRearSuspensionsRightBasePhysicsNodeLinearVelocityZ(store.z);
      ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightBase().getAngularVelocity(store);
      message.setRearSuspensionsRightBasePhysicsNodeAngularVelocityX(store.x);
      message.setRearSuspensionsRightBasePhysicsNodeAngularVelocityY(store.y);
      message.setRearSuspensionsRightBasePhysicsNodeAngularVelocityZ(store.z);
      /*
       * fields for FrontSuspensionsLeftBaseNode
       */
      message.setFrontSuspensionsLeftBasePhysicsNodePositionX(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftBase().getLocalTranslation().x);
      message.setFrontSuspensionsLeftBasePhysicsNodePositionY(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftBase().getLocalTranslation().y);
      message.setFrontSuspensionsLeftBasePhysicsNodePositionZ(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftBase().getLocalTranslation().z);
      message.setFrontSuspensionsLeftBasePhysicsNodeRotationX(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftBase().getLocalRotation().x);
      message.setFrontSuspensionsLeftBasePhysicsNodeRotationY(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftBase().getLocalRotation().y);
      message.setFrontSuspensionsLeftBasePhysicsNodeRotationZ(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftBase().getLocalRotation().z);
      message.setFrontSuspensionsLeftBasePhysicsNodeRotationW(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftBase().getLocalRotation().w);
      ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftBase().getLinearVelocity(store);   
      message.setFrontSuspensionsLeftBasePhysicsNodeLinearVelocityX(store.x);
      message.setFrontSuspensionsLeftBasePhysicsNodeLinearVelocityY(store.y);
      message.setFrontSuspensionsLeftBasePhysicsNodeLinearVelocityZ(store.z);
      ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftBase().getAngularVelocity(store);
      message.setFrontSuspensionsLeftBasePhysicsNodeAngularVelocityX(store.x);
      message.setFrontSuspensionsLeftBasePhysicsNodeAngularVelocityY(store.y);
      message.setFrontSuspensionsLeftBasePhysicsNodeAngularVelocityZ(store.z);
      /*
       * fields for FrontSuspensionsRightBaseNode
       */
      message.setFrontSuspensionsRightBasePhysicsNodePositionX(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightBase().getLocalTranslation().x);
      message.setFrontSuspensionsRightBasePhysicsNodePositionY(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightBase().getLocalTranslation().y);
      message.setFrontSuspensionsRightBasePhysicsNodePositionZ(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightBase().getLocalTranslation().z);
      message.setFrontSuspensionsRightBasePhysicsNodeRotationX(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightBase().getLocalRotation().x);
      message.setFrontSuspensionsRightBasePhysicsNodeRotationY(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightBase().getLocalRotation().y);
      message.setFrontSuspensionsRightBasePhysicsNodeRotationZ(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightBase().getLocalRotation().z);
      message.setFrontSuspensionsRightBasePhysicsNodeRotationW(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightBase().getLocalRotation().w);
      ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightBase().getLinearVelocity(store);   
      message.setFrontSuspensionsRightBasePhysicsNodeLinearVelocityX(store.x);
      message.setFrontSuspensionsRightBasePhysicsNodeLinearVelocityY(store.y);
      message.setFrontSuspensionsRightBasePhysicsNodeLinearVelocityZ(store.z);
      ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightBase().getAngularVelocity(store);
      message.setFrontSuspensionsRightBasePhysicsNodeAngularVelocityX(store.x);
      message.setFrontSuspensionsRightBasePhysicsNodeAngularVelocityY(store.y);
      message.setFrontSuspensionsRightBasePhysicsNodeAngularVelocityZ(store.z);


        return message;
    }



I believe there is a physics synchronization manager in JGN, Darkfrog would know, though/

I won't read your code but I have quite the same constructors except that I only transmit wheels&chassis positions&speeds.



Can you precise this a bit ?



The problem is, that is server is calculation the physics it self… So at game start, all cars are at the corret position, but when one player is driving, the synchronized copy of it is jumping around everywhere, because the server tries to calculate all physics data is self - which collides with the synchronized data.



So, the synchronized car is displayed on the clients, but the chassi seems to not connected with the wheels…

They are connected, but the are flying around the car with strange moves :slight_smile:



I will add a screenshot soon.



@kine, did your code work???

if yes could you give to please… My deadline for finishing the game is next friday :frowning:










www.bolidz.googlecode.com



:wink:

thx :slight_smile:



but i get a



Not Found

The requested URL / was not found on this server.



:frowning:

got it  :smiley:

here a screenshot:







it is still not working, but i guess everything sould be correct…



package vig.game.network.controller;

import vig.game.network.messages.SynchronizeVehicleMessage;
import vig.game.scene.VehicleNode;
import vig.game.scene.vehicles.TutorialCar;

import com.captiveimagination.jgn.synchronization.GraphicalController;
import com.captiveimagination.jgn.synchronization.message.Synchronize3DMessage;
import com.captiveimagination.jgn.synchronization.message.SynchronizeCreateMessage;
import com.captiveimagination.jgn.synchronization.message.SynchronizeMessage;
import com.captiveimagination.jgn.synchronization.message.SynchronizePhysicsMessage;
import com.captiveimagination.jgn.synchronization.message.SynchronizeRemoveMessage;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.scene.Spatial;
import com.jmex.physics.DynamicPhysicsNode;

/**
 * This is a basic implementation of the GraphicalControler for the
 * jME project.
 *
 * @author Mathias Tempel
 */
public class JMEVehicleController3 implements GraphicalController<VehicleNode>  {
   private Vector3f store;
   
   public JMEVehicleController3() {
      store = new Vector3f();
   }
   
    public void applySynchronizationMessage(SynchronizeMessage message, VehicleNode vehicle) {
        SynchronizeVehicleMessage m = (SynchronizeVehicleMessage)message;
        ((TutorialCar)vehicle.getModel()).getChassis().clearDynamics();
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightBase().clearDynamics();
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftBase().clearDynamics();
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightBase().clearDynamics();
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftBase().clearDynamics();
        /*
        * fields for Chassis
        */
        ((TutorialCar)vehicle.getModel()).getChassis().setLocalTranslation(new Vector3f(m.getChassisPositionX(), m.getChassisPositionY(), m.getChassisPositionZ()));
        ((TutorialCar)vehicle.getModel()).getChassis().setLocalRotation(new Quaternion(m.getChassisRotationX(), m.getChassisRotationY(), m.getChassisRotationZ(), m.getChassisRotationW()));
        ((TutorialCar)vehicle.getModel()).getChassis().setLinearVelocity(new Vector3f(m.getChassisLinearVelocityX(), m.getChassisLinearVelocityY(), m.getChassisLinearVelocityZ()));
        ((TutorialCar)vehicle.getModel()).getChassis().setAngularVelocity(new Vector3f(m.getChassisAngularVelocityX(), m.getChassisAngularVelocityY(), m.getChassisAngularVelocityZ()));
        System.out.println("Chassi Position: " + m.getChassisPositionX()+ m.getChassisPositionY()+ m.getChassisPositionZ());
        /*
       * fields for frontSuspension left  WheelPhysicsNodeP
       */
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().setLocalTranslation(new Vector3f(m.getFrontSuspensionsLeftWheelPhysicsNodePositionX(), m.getFrontSuspensionsLeftWheelPhysicsNodePositionY(), m.getFrontSuspensionsLeftWheelPhysicsNodePositionZ()));
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().setLocalRotation(new Quaternion(m.getFrontSuspensionsLeftWheelPhysicsNodeRotationX(), m.getFrontSuspensionsLeftWheelPhysicsNodeRotationY(), m.getFrontSuspensionsLeftWheelPhysicsNodeRotationZ(), m.getFrontSuspensionsLeftWheelPhysicsNodeRotationW()));
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().setLinearVelocity(new Vector3f(m.getFrontSuspensionsLeftWheelPhysicsNodeLinearVelocityX(), m.getFrontSuspensionsLeftWheelPhysicsNodeLinearVelocityY(), m.getFrontSuspensionsLeftWheelPhysicsNodeLinearVelocityZ()));
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().setAngularVelocity(new Vector3f(m.getFrontSuspensionsLeftWheelPhysicsNodeAngularVelocityX(), m.getFrontSuspensionsLeftWheelPhysicsNodeAngularVelocityY(), m.getFrontSuspensionsLeftWheelPhysicsNodeAngularVelocityZ()));
        /*
       * fields for frontSuspension right WheelPhysicsNode
       */
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().setLocalTranslation(new Vector3f(m.getFrontSuspensionsRightWheelPhysicsNodePositionX(), m.getFrontSuspensionsRightWheelPhysicsNodePositionY(), m.getFrontSuspensionsRightWheelPhysicsNodePositionZ()));
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().setLocalRotation(new Quaternion(m.getFrontSuspensionsRightWheelPhysicsNodeRotationX(), m.getFrontSuspensionsRightWheelPhysicsNodeRotationY(), m.getFrontSuspensionsRightWheelPhysicsNodeRotationZ(), m.getFrontSuspensionsRightWheelPhysicsNodeRotationW()));
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().setLinearVelocity(new Vector3f(m.getFrontSuspensionsRightWheelPhysicsNodeLinearVelocityX(), m.getFrontSuspensionsRightWheelPhysicsNodeLinearVelocityY(), m.getFrontSuspensionsRightWheelPhysicsNodeLinearVelocityZ()));
        ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().setAngularVelocity(new Vector3f(m.getFrontSuspensionsRightWheelPhysicsNodeAngularVelocityX(), m.getFrontSuspensionsRightWheelPhysicsNodeAngularVelocityY(), m.getFrontSuspensionsRightWheelPhysicsNodeAngularVelocityZ()));
        /*
       * fields for rearSuspension left  WheelPhysicsNode
       */
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().setLocalTranslation(new Vector3f(m.getRearSuspensionsLeftWheelPhysicsNodePositionX(), m.getRearSuspensionsLeftWheelPhysicsNodePositionY(), m.getRearSuspensionsLeftWheelPhysicsNodePositionZ()));
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().setLocalRotation(new Quaternion(m.getRearSuspensionsLeftWheelPhysicsNodeRotationX(), m.getRearSuspensionsLeftWheelPhysicsNodeRotationY(), m.getRearSuspensionsLeftWheelPhysicsNodeRotationZ(), m.getRearSuspensionsLeftWheelPhysicsNodeRotationW()));
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().setLinearVelocity(new Vector3f(m.getRearSuspensionsLeftWheelPhysicsNodeLinearVelocityX(), m.getRearSuspensionsLeftWheelPhysicsNodeLinearVelocityY(), m.getRearSuspensionsLeftWheelPhysicsNodeLinearVelocityZ()));
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().setAngularVelocity(new Vector3f(m.getRearSuspensionsLeftWheelPhysicsNodeAngularVelocityX(), m.getRearSuspensionsLeftWheelPhysicsNodeAngularVelocityY(), m.getRearSuspensionsLeftWheelPhysicsNodeAngularVelocityZ()));
        /*
       * fields for rearSuspension right  WheelPhysicsNode
       */
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().setLocalTranslation(new Vector3f(m.getRearSuspensionsRightWheelPhysicsNodePositionX(), m.getRearSuspensionsRightWheelPhysicsNodePositionY(), m.getRearSuspensionsRightWheelPhysicsNodePositionZ()));
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().setLocalRotation(new Quaternion(m.getRearSuspensionsRightWheelPhysicsNodeRotationX(), m.getRearSuspensionsRightWheelPhysicsNodeRotationY(), m.getRearSuspensionsRightWheelPhysicsNodeRotationZ(), m.getRearSuspensionsRightWheelPhysicsNodeRotationW()));
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().setLinearVelocity(new Vector3f(m.getRearSuspensionsRightWheelPhysicsNodeLinearVelocityX(), m.getRearSuspensionsRightWheelPhysicsNodeLinearVelocityY(), m.getRearSuspensionsRightWheelPhysicsNodeLinearVelocityZ()));
        ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().setAngularVelocity(new Vector3f(m.getRearSuspensionsRightWheelPhysicsNodeAngularVelocityX(), m.getRearSuspensionsRightWheelPhysicsNodeAngularVelocityY(), m.getRearSuspensionsRightWheelPhysicsNodeAngularVelocityZ()));
       
    }

    public SynchronizeMessage createSynchronizationMessage(VehicleNode vehicle) {
       SynchronizeVehicleMessage message = new SynchronizeVehicleMessage();
       /*
        * fields for Chassis
        */
      message.setChassisPositionX(((TutorialCar)vehicle.getModel()).getChassis().getLocalTranslation().x);
      message.setChassisPositionY(((TutorialCar)vehicle.getModel()).getChassis().getLocalTranslation().y);
      message.setChassisPositionZ(((TutorialCar)vehicle.getModel()).getChassis().getLocalTranslation().z);
      message.setChassisRotationX(((TutorialCar)vehicle.getModel()).getChassis().getLocalRotation().x);
      message.setChassisRotationY(((TutorialCar)vehicle.getModel()).getChassis().getLocalRotation().y);
      message.setChassisRotationZ(((TutorialCar)vehicle.getModel()).getChassis().getLocalRotation().z);
      message.setChassisRotationW(((TutorialCar)vehicle.getModel()).getChassis().getLocalRotation().w);
      ((TutorialCar)vehicle.getModel()).getChassis().getLinearVelocity(store);   
      message.setChassisLinearVelocityX(store.x);
      message.setChassisLinearVelocityY(store.y);
      message.setChassisLinearVelocityZ(store.z);
      ((TutorialCar)vehicle.getModel()).getChassis().getAngularVelocity(store);
      message.setChassisAngularVelocityX(store.x);
      message.setChassisAngularVelocityY(store.y);
      message.setChassisAngularVelocityZ(store.z);
      /*
       * fields for frontSuspension left  WheelPhysicsNodePhysicsNode
       */
      message.setFrontSuspensionsLeftWheelPhysicsNodePositionX(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getLocalTranslation().x);
      message.setFrontSuspensionsLeftWheelPhysicsNodePositionY(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getLocalTranslation().y);
      message.setFrontSuspensionsLeftWheelPhysicsNodePositionZ(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getLocalTranslation().z);
      message.setFrontSuspensionsLeftWheelPhysicsNodeRotationX(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getLocalRotation().x);
      message.setFrontSuspensionsLeftWheelPhysicsNodeRotationY(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getLocalRotation().y);
      message.setFrontSuspensionsLeftWheelPhysicsNodeRotationZ(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getLocalRotation().z);
      message.setFrontSuspensionsLeftWheelPhysicsNodeRotationW(((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getLocalRotation().w);
      ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getLinearVelocity(store);   
      message.setFrontSuspensionsLeftWheelPhysicsNodeLinearVelocityX(store.x);
      message.setFrontSuspensionsLeftWheelPhysicsNodeLinearVelocityY(store.y);
      message.setFrontSuspensionsLeftWheelPhysicsNodeLinearVelocityZ(store.z);
      ((TutorialCar)vehicle.getModel()).getFrontSuspension().getLeftWheel().getPhysicsNode().getAngularVelocity(store);
      message.setFrontSuspensionsLeftWheelPhysicsNodeAngularVelocityX(store.x);
      message.setFrontSuspensionsLeftWheelPhysicsNodeAngularVelocityY(store.y);
      message.setFrontSuspensionsLeftWheelPhysicsNodeAngularVelocityZ(store.z);
      /*
       * fields for frontSuspension right WheelPhysicsNodeNode
       */
      message.setFrontSuspensionsRightWheelPhysicsNodePositionX(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getLocalTranslation().x);
      message.setFrontSuspensionsRightWheelPhysicsNodePositionY(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getLocalTranslation().y);
      message.setFrontSuspensionsRightWheelPhysicsNodePositionZ(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getLocalTranslation().z);
      message.setFrontSuspensionsRightWheelPhysicsNodeRotationX(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getLocalRotation().x);
      message.setFrontSuspensionsRightWheelPhysicsNodeRotationY(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getLocalRotation().y);
      message.setFrontSuspensionsRightWheelPhysicsNodeRotationZ(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getLocalRotation().z);
      message.setFrontSuspensionsRightWheelPhysicsNodeRotationW(((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getLocalRotation().w);
      ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getLinearVelocity(store);   
      message.setFrontSuspensionsRightWheelPhysicsNodeLinearVelocityX(store.x);
      message.setFrontSuspensionsRightWheelPhysicsNodeLinearVelocityY(store.y);
      message.setFrontSuspensionsRightWheelPhysicsNodeLinearVelocityZ(store.z);
      ((TutorialCar)vehicle.getModel()).getFrontSuspension().getRightWheel().getPhysicsNode().getAngularVelocity(store);
      message.setFrontSuspensionsRightWheelPhysicsNodeAngularVelocityX(store.x);
      message.setFrontSuspensionsRightWheelPhysicsNodeAngularVelocityY(store.y);
      message.setFrontSuspensionsRightWheelPhysicsNodeAngularVelocityZ(store.z);
      /*
       * fields for rearSuspension left  WheelPhysicsNodeNode
       */
      message.setRearSuspensionsLeftWheelPhysicsNodePositionX(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getLocalTranslation().x);
      message.setRearSuspensionsLeftWheelPhysicsNodePositionY(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getLocalTranslation().y);
      message.setRearSuspensionsLeftWheelPhysicsNodePositionZ(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getLocalTranslation().z);
      message.setRearSuspensionsLeftWheelPhysicsNodeRotationX(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getLocalRotation().x);
      message.setRearSuspensionsLeftWheelPhysicsNodeRotationY(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getLocalRotation().y);
      message.setRearSuspensionsLeftWheelPhysicsNodeRotationZ(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getLocalRotation().z);
      message.setRearSuspensionsLeftWheelPhysicsNodeRotationW(((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getLocalRotation().w);
      ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getLinearVelocity(store);   
      message.setRearSuspensionsLeftWheelPhysicsNodeLinearVelocityX(store.x);
      message.setRearSuspensionsLeftWheelPhysicsNodeLinearVelocityY(store.y);
      message.setRearSuspensionsLeftWheelPhysicsNodeLinearVelocityZ(store.z);
      ((TutorialCar)vehicle.getModel()).getRearSuspension().getLeftWheel().getPhysicsNode().getAngularVelocity(store);
      message.setRearSuspensionsLeftWheelPhysicsNodeAngularVelocityX(store.x);
      message.setRearSuspensionsLeftWheelPhysicsNodeAngularVelocityY(store.y);
      message.setRearSuspensionsLeftWheelPhysicsNodeAngularVelocityZ(store.z);
      /*
       * fields for rearSuspension right WheelPhysicsNodeNode
       */
      message.setRearSuspensionsRightWheelPhysicsNodePositionX(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getLocalTranslation().x);
      message.setRearSuspensionsRightWheelPhysicsNodePositionY(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getLocalTranslation().y);
      message.setRearSuspensionsRightWheelPhysicsNodePositionZ(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getLocalTranslation().z);
      message.setRearSuspensionsRightWheelPhysicsNodeRotationX(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getLocalRotation().x);
      message.setRearSuspensionsRightWheelPhysicsNodeRotationY(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getLocalRotation().y);
      message.setRearSuspensionsRightWheelPhysicsNodeRotationZ(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getLocalRotation().z);
      message.setRearSuspensionsRightWheelPhysicsNodeRotationW(((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getLocalRotation().w);
      ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getLinearVelocity(store);   
      message.setRearSuspensionsRightWheelPhysicsNodeLinearVelocityX(store.x);
      message.setRearSuspensionsRightWheelPhysicsNodeLinearVelocityY(store.y);
      message.setRearSuspensionsRightWheelPhysicsNodeLinearVelocityZ(store.z);
      ((TutorialCar)vehicle.getModel()).getRearSuspension().getRightWheel().getPhysicsNode().getAngularVelocity(store);
      message.setRearSuspensionsRightWheelPhysicsNodeAngularVelocityX(store.x);
      message.setRearSuspensionsRightWheelPhysicsNodeAngularVelocityY(store.y);
      message.setRearSuspensionsRightWheelPhysicsNodeAngularVelocityZ(store.z);
      

        return message;
    }

    /**
     * This method will always return 1.0f. It is recommended to override this method
     * in games to provide better efficiency to synchronization.
     */
    public float proximity(VehicleNode vehicle, short playerId) {
        return 1.0f;
    }

    /**
     * This method will always return true. It is recommended to override this method
     * in games to provide a layer of security.
     */
    public boolean validateMessage(SynchronizeMessage message, VehicleNode vehicle) {
        return true;
    }


   public boolean validateCreate(SynchronizeCreateMessage message) {
      return true;
   }


   public boolean validateRemove(SynchronizeRemoveMessage message) {
      return true;
   }
}



@kine... where do you register the objects and where are you really creating them in the gamestate??
btw thx for the nice code :)

I don't use the same kind of managent than FlagRush



Bolides are created in Bolides.java

and for transmitting, because of I want dead reckoning and server lag adjustement, I send a bolide data, saved in a in the server and the others clients for the moment in a CarState, it is performed in a client call back added to the physics engine in networking.client 



I remember that I had a problem with local and world translation, check the differences, and verify you didn't use car.setLocal translation but car.moveto when setting the cars starting blocks



Kine

thx a lot kine.



i think i found the problem :slight_smile:

i think the physics is updated while a synchronization message is applied on the car.

so the car has inconsistent physical values - some current values and some values from the last sync message.

everything was better when i increased the update rate.

now i'm using a boolean flag, which allows the physic only to update if the there is no sync message applied…

this works ok for two players, but with more players there would probably by at least one car… so the physics engine could not work properly - how could i solve this?

I am unsure what you are doing there but if you are updating your objects form multiple threads, you need to use synchronization.



Using a boolean won't always work, even if it is declared as 'volatile', because of the way the JVM works and the optimizations that are made to the code.



The easiest way is to use the "synchronize" Java keyword, so only one thread can access the same code block. It would be something like:


network:

synchronize (scene) {
  // Update things from messages
}

yourlogic:

synchronize (scene) {
  // Update physics
}



Read more about synchronization in the web or here:

http://java.sun.com/docs/books/tutorial/essential/concurrency/sync.html