Jmephysics and graphic problems

hi,

I try to use jmephysics any more, but my Objects "jitter" (is it the correct word? I'm not sure cause English isn't my first language). So, every Object which isn't added to the PhysicsWorld and StaticPhysicsObjects are correct shown, but every DynamicPhysicsObject is shown for a few milliseconds, and than it is repainted (so disappear from the screen, appear again, stay a few millisecond and disappear again…and so on…)…



This didn't look really nice ;). I think I set up my physics world incorrect.



I call its update method in the update-Method of BaseGame, is this okay or should I do it any other way? (How?)



I'll be glad for tips :wink:



campino

Paste some source code and we can help you further.  The update method should be getting called in the graphics update method.



darkfrog

Did someone update the jmephysics lib after the changes to

the Quaternion class, last week?



If not, that might be the reason stuff isn't working very well in physics anymore!

Your issues, compino, sound quite strange - havn't seen that yet. Please check if the tests run fine for you and compare your scene setup to that of the tests. Maybe even post some code here (short example please), as darkfrog suggests.



@tGiantLabs: last changes in Quaternion do not affect jmephysics (as the changed method is not used) and tests run fine for me, so it does not seem to be a general problem.

okay, some Code.the tests work correctly…



I spot the problem to my vehicle by myself. if I didn't call the setPhysics-Method(shown below), there is now problem, everything works. But as far as I call this Method the error appears.



So, here is the methods Code:


public void setPhysics(DynamicPhysicsObject chassis, DynamicPhysicsObject[] wheels, Vector3f frontAxis, Vector3f backAxis, float axislength){
       this.car=new Car(chassis, wheels, 1f, 1f, true, frontAxis, backAxis, axislength);
       this.car.setHandBrakeOn(true);
       this.car.addToWorld();
    }



And here were I call it:


model=new Node("Car");
       Box b=new Box("chassis", new Vector3f(0, 0, 0), 2, 0.1f, 1);
       model.attachChild(b);
      
       Cylinder[] raeder=new Cylinder[4];
      
       raeder[0]=new Cylinder("Rad0", 2, 12, 0.2f, 0.1f);
       raeder[0].setLocalTranslation(new Vector3f(-2f, 0f, -1f));
       model.attachChild(raeder[0]);
      
       raeder[1]=new Cylinder("Rad1", 2, 12, 0.2f, 0.1f);
       raeder[1].setLocalTranslation(new Vector3f(-2f, 0f, 1f));
       model.attachChild(raeder[1]);
      
       raeder[2]=new Cylinder("Rad2", 2, 12, 0.2f, 0.1f);
       raeder[2].setLocalTranslation(new Vector3f(2f, 0f, -1f));
       model.attachChild(raeder[2]);
      
       raeder[3]=new Cylinder("Rad3", 2, 12, 0.2f, 0.1f);
       raeder[3].setLocalTranslation(new Vector3f(2f, 0f, 1f));
       model.attachChild(raeder[3]);
      
       DynamicPhysicsObject chassis=new DynamicPhysicsObject(b, 10);
       DynamicPhysicsObject[] wheels=new DynamicPhysicsObject[4];
       wheels[0]=new DynamicPhysicsObject(raeder[0], 1);
       wheels[1]=new DynamicPhysicsObject(raeder[1], 1);
       wheels[2]=new DynamicPhysicsObject(raeder[2], 1);
       wheels[3]=new DynamicPhysicsObject(raeder[3], 1);
      
      
      
      
       //set the vehicles attributes (these numbers can be thought
       //of as Unit/Second).
       player = new GVehicle("Player Node", model);
       player.setAcceleration(15);
       player.setBraking(15);
       player.setTurnSpeed(2.5f);
       player.setWeight(25);
       player.setMaxSpeed(15);
       player.setMinSpeed(5);
      
       float height=tb.getHeight(100, 100);
      
       player.setLocalTranslation(new Vector3f(100,height+2, 100));
       scene.attachChild(player);
       scene.updateGeometricState(0, true);
       player.setRenderQueueMode(Renderer.QUEUE_OPAQUE);
      
       player.setPhysics(chassis, wheels, new Vector3f(-2, 0, 0), new Vector3f(+2, 0, 0), 2);
      



I hopefully hope that this is enough code ;)

campino
campino said:

I hopefully hope that this is enough code ;)

Well, the amount of code is ok - but it's the wrong one to look at :)

You say calling that setPhysics method causes the problems. As the method itself deos not change anything regarding scenegraph or physics, the Constructor of Car, the setHandBrakeOn and/or the addToWorld method seem to cause the trouble. What do they do?

They are standard jmephysics…



car is a com.jmex.physics.vehicle.Car, I am sorry for forgetting to mention this…

oh, ok - did not realize there even was a Car class in jmephysics



Hmm probably check that your wheels and chassis behave normally when added to the physics world without a car, first. But most probably they will work (without flickering) - it might be that the joints start causing problems…



…as that car stuff is pretty much code (and I did not have a look at it yet) what about taking that CarTest or BuggeDemo and modify that instead to learn where the problems are?

That's what I would suggest as well.



darkfrog