i found out about jME some time ago and was playing around with terrain stuff and things ‘in’ SimpleGame … now i tried to move to FixedLogicGame but came around a strange error (at least it is strange for me … maybe its just i overlooked something )
ok … this is the beginning of my main class:
public class Main2 extends FixedLogicrateGame{
public static void main( String args[] ){
Main2 app = new Main2();
app.setLogicTicksPerSecond( 5 );
app.start();
}
....
now if i try to start it i get a NullPointerException while calling app.setLogicTicksPerSecond():
java.lang.NullPointerException
at com.jme.app.FixedLogicrateGame.setLogicTicksPerSecond(Unknown Source)
i tried several approaches how to fix it but i came to no solution :(
so i hope someone around here can help me
(sry if this topic was around here sometime ago ... but i haven't found something via search)
Ive tried calling setLogicTicksPerSecond AFTER the display has been created in the initSystem() method. That worked for me last time I checked (which was a while ago).
Vector3f loc = new Vector3f(0, 0, 0);
Vector3f left = new Vector3f(-1, 0, 0);
Vector3f up = new Vector3f(0, 1, 0);
Vector3f dir = new Vector3f(0, 0, -1);
To be perfectly honest with you. I have never used FixedLogicrateGame because:
it doesn’t allow me to update my input in the update(…) method.
it doesn’t allow me to update my rootNode from the update(…) method
it doesn’t allow me to update my AI routines in the update(…) method
My all time favourite is VariableTimeStep game. Which is basically BaseGame with a timer. So the float value in the update() method is infact the time it took for this method to be called again (interpolation time).
Again, alot of controllers need the time, e.g. KeyNodeForwardAction in FirstPersonHandler(…) need to know about the time. So you would need to rewrite some things that deal with time again in order to remove the time element.
I love the idea tho. It would be just like old times with the posX += 5; instead of posX += 5 * time;
it works … even if i put the setLogicTicksPerSecond() call where i had it (direct under .start() in the main method) … but i don’t see any difference expect you added some code to the methods … (which i have done too in an extending class)
btw … am i wrong or does MidPointHeightMap only work with N^2 sizes but TerrainPage just uses N^2+1 ?
I haven’t touched terrain for…4…maybe 5 months now. But I believe that was the case back then.
I mean you could always obtain the data from the MidHeightPoint thingamabob, System.copyArray onto another bigger array, and set the last value to 0 or something that suits. But thats a hack IMO.
Perhaps MidHeightPoint isn’t supposed to work with Pages? I duno…
Im not the best person to be speaking to about this matter tho. Mojo would be your man as he made the terrain system.
So you would need to rewrite some things that deal with time again in order to remove the time element.
Not at all! As the logic rate is guaranteed, you can be certain of the amount of time elapsed between subsequent calls to update(float). You can then simply pass this constant time elapsed value to the controllers and use your own code based on a fixed timestep.
Where are you placing the terrain loading? As long as nothing is before initing the display in the try/catch block, then your fine.
@eric. Perhaps you could set the interpolation of the update method to 1/TicksPerSecond instead of me having to have a variable set for the number of ticks and doing it manually.
Oh yeah, could you perhaps explain the interpolation value of the rendering method please? I dont seem to understand it very well… :?
as you can see from the code above i placed it in the initGame() method … which should be called directly after the initSystem() method and therefore after .start() and the display init
Vector3f loc = new Vector3f(0, 0, 0);
Vector3f left = new Vector3f(-1, 0, 0);
Vector3f up = new Vector3f(0, 1, 0);
Vector3f dir = new Vector3f(0, 0, -1);
input = new FirstPersonHandler(this, cam, properties.getRenderer());
}
protected void initGame() {
// my added code, without this FixedLogicRateGame runs fine, but this works in SimpleGame
try {
rootNode.attachChild(TerrainManager.loadMap("test", display));
}
catch (JDOMException ex) {
}
catch (IOException ex) {
}
}
protected void reinit() {
}
protected void cleanup() {
}
public static void main(String[] args) {
Main2 app = new Main2();
app.setDialogBehaviour( ALWAYS_SHOW_PROPS_DIALOG );
app.start();
Vector3f loc = new Vector3f(0, 0, 0);
Vector3f left = new Vector3f(-1, 0, 0);
Vector3f up = new Vector3f(0, 1, 0);
Vector3f dir = new Vector3f(0, 0, -1);
input = new FirstPersonHandler(this, cam, properties.getRenderer());
}
protected void initGame() {
// crutial part below
rootNode = new Node("Root Scene Node");
// my added code, without this FixedLogicRateGame runs fine, but this works in SimpleGame
try {
rootNode.attachChild(TerrainManager.loadMap("test", display));
}
catch (JDOMException ex) {
}
catch (IOException ex) {
}
}
protected void reinit() {
}
protected void cleanup() {
}
public static void main(String[] args) {
Main2 app = new Main2();
app.setDialogBehaviour( ALWAYS_SHOW_PROPS_DIALOG );
app.start();
hmm… sorry for bothering you … guess you have better things todo then to help a newb like me
after adding the node (and some other stuff, a timer (which wasn’t yet the best idea)) it works without crashing … but the result is more or less not what it is suppost to be … i’ll just post a screenshot maybe you (or someone else) can tell me what i did wrong …
are there any states missing? (expect the lightstate) …
the white thing you see there is suppost to be my terrain … just somehow disturbed :([/img]