Lags in helloLoop.. is there a better way?

Here in this exemple of HelloLoop that i found on the website, i just made very small modification to show my probleme.

I see Lags… if i don t set the frame rate, it’s over 2000 fps (Linux / nvidia quadro)

Is there a beter way, that i will not see lags ?

with java3d by having a thread who was taking in account the calculation time and by stoping the view during calculation i don’t have this effect.

I have a nice simulator that i wrote in java3d and i would love to move to JME to add shaders/physics, water and more…

so is there a beter way to avoid lags ? is that because of float accuracy ? should I use a variable and force the rotation a the variable value ?



package jme3test.helloworld;


import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.scene.Geometry;

import com.jme3.scene.shape.Box;

/** Sample 4 - how to trigger repeating actions from the main event loop.

  • In this example, we make the player character rotate. /

    public class HelloLoop extends SimpleApplication {

    public static void main(String[] args){

    HelloLoop app = new HelloLoop();

    //AppSettings settings = new AppSettings(true);





    protected Geometry player;


    public void simpleInitApp() {

    cam.setLocation(new Vector3f(0,-60,0));

    cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1,0));


    Box b = new Box(Vector3f.ZERO, 15, 1, 1);

    player = new Geometry(“blue cube”, b);

    Material mat = new Material(assetManager, “Common/MatDefs/Misc/SolidColor.j3md”);

    mat.setColor(“m_Color”, ColorRGBA.Blue);




    This is the main event loop /


    public void simpleUpdate(float tpf) {

    // make the player rotate

    player.rotate(0, 2
    tpf, 0);




Over 2000 fps is awesome and good. Most games barely manage 40, depending on your machine.

I don’t understand what you mean by lag.

well 2000 fps is great, but the animation is not always fluid … if you look weel the piece in movement, the rotation “jerk” somethimes…

Well then, try turning on anti aliasing 8x or so. You can find it on the splash page when you start a SimpleApplication.

If that doesn’t work. then it appears something on your computer is running and stealing resources every bit, which temporarily causes your lag.

Try increasing java’s priority on your CPU? Or else use the process manager and find out anything that runs once every few seconds and uses 50-100% of your CPU.

Personally, I don’t have any of this lag you speak of, so I can’t help much more than that. Sorry.

no i checked my ressources, it never goes over 10%…

how do you increase java’s priority ?

If on Windows, open the Task Manager, go to processes, start your game, and you should see javaw.exe taking a huge % of CPU processing power. Right click it, and try out Set Priority → High. See if that helps your lag. I dunno though. Sounds like an odd problem to me.

I m working on linux, but thanks. I mean it’s not obvious, but slightly visible… :slight_smile: