Thx for all of the previous help that I've received form these forums I was wondering if u can assist me on my next issue that i've been attempting to solve for a couple weeks now
I'm having issues with threading. I have two threads the main one which I plan to do physics and ai on and the other one for rendering; however for some odd reason the update of the main thread is a lot faster than the openGL one and despite various attempts I can't seem to make the update speed of both the same. I've Tried the updateLocks and some jME code around standardGame to no prevail…Any suggestions
I wasn't attempting to Lock the thread per say however i've realized that the when I update the physics in the main thread as opposed to the openGL Thread the object either doesn't appear on screen or appears on screen for a short while(or if I constrain the physics update to a key it shows until i press the key) before disappearing. in the openGL thread it falls slowly downward.
as it stands
package util;
import java.util.logging.Level;
import com.jme.util.NanoTimer;
import com.jme.util.Timer;
import com.jmex.game.StandardGame.GameType;
public class Manager {
/**High resolution timer. remember that tpf is .getTimePerFrame();*/
private final Timer timer = (gameSingleton.game.getGameType() == GameType.GRAPHICAL)? Timer.getTimer(): new NanoTimer();;
public Manager(){
gameSingleton.get().getPhysics().build(); //Build octrees (may take a while)
System.out.println("Collision-Scene Built Sucesffully!!");
run();
System.out.println("Thread is ending");
}
private void run() {
try {
while (gameSingleton.game.isStarted()&&!gameSingleton.get().getDisplay.isClosing()){
mainUpdate(-1);
Thread.yield();
}
} catch (Throwable t) {
gameSingleton.getLogger.logp(Level.SEVERE, this.getClass().toString(), "start()", "Exception in game loop", t);
}
}
public void mainUpdate(float tpf){
gameSingleton.get().mainUpdate(tpf);
ObjectManager.get().mainUpdate(tpf);
}
}