Fixed some things
This commit is contained in:
parent
7a4d7242c5
commit
14f395d273
8 changed files with 351 additions and 182 deletions
|
|
@ -5,8 +5,8 @@ import java.util.logging.Logger;
|
|||
import sg.env.Environment;
|
||||
import sg.util.SGUtil;
|
||||
|
||||
import com.jme.input.FirstPersonHandler;
|
||||
import com.jme.input.InputHandler;
|
||||
import com.jme.input.ThirdPersonHandler;
|
||||
import com.jme.math.Vector3f;
|
||||
import com.jme.renderer.Renderer;
|
||||
import com.jme.scene.Node;
|
||||
|
|
@ -28,40 +28,47 @@ public class InGameState extends CameraGameState {
|
|||
private PhysicsSpace physicsSpace;
|
||||
/** The Speed of the physics */
|
||||
private float physicsSpeed = 1;
|
||||
|
||||
/** Render pass manager */
|
||||
//protected BasicPassManager passManager;
|
||||
|
||||
public InGameState(String name) {
|
||||
super(name);
|
||||
|
||||
|
||||
LoadingGameState loader = new LoadingGameState(2);
|
||||
GameStateManager.getInstance().attachChild(loader);
|
||||
loader.setActive(true);
|
||||
// ***************** Load the Game **********************************
|
||||
|
||||
|
||||
// Pass (render thingies)
|
||||
//passManager = new BasicPassManager();
|
||||
|
||||
//physics
|
||||
physicsSpace = PhysicsSpace.create();
|
||||
|
||||
|
||||
physicsSpace.setDirectionalGravity(new Vector3f(0f, 0f, 0f));
|
||||
StaticPhysicsNode staticNode = physicsSpace.createStaticNode();
|
||||
DynamicPhysicsNode dynamicNode = physicsSpace.createDynamicNode();
|
||||
rootNode.attachChild(dynamicNode);
|
||||
rootNode.attachChild(staticNode);
|
||||
|
||||
// environment
|
||||
environment = new Environment();
|
||||
rootNode.attachChild(environment);
|
||||
loader.increment();
|
||||
|
||||
|
||||
// ship
|
||||
Node ship = SGUtil.loadModel("sg/data/models/ships/G6.3ds");
|
||||
ship.setLocalTranslation(new Vector3f(0,0,-40));
|
||||
//ship.setLocalScale(0.01f);
|
||||
rootNode.attachChild(ship);
|
||||
loader.increment();
|
||||
|
||||
// inputs
|
||||
input = new ThirdPersonHandler(ship, cam);
|
||||
|
||||
// environment
|
||||
environment = new Environment(rootNode);
|
||||
rootNode.attachChild(environment);
|
||||
loader.increment();
|
||||
|
||||
|
||||
// inputs
|
||||
FirstPersonHandler first = new FirstPersonHandler( cam, 50, 1 );
|
||||
input = new InputHandler();
|
||||
input.addToAttachedHandlers( first );
|
||||
loader.increment();
|
||||
|
||||
// ***************** Done loading **********************************
|
||||
loader.setActive(false);
|
||||
GameStateManager.getInstance().detachChild(loader);
|
||||
|
|
@ -70,18 +77,25 @@ public class InGameState extends CameraGameState {
|
|||
|
||||
public void stateUpdate(float tpf) {
|
||||
input.update(tpf);
|
||||
|
||||
|
||||
environment.update();
|
||||
|
||||
if ( tpf > 0.2 || Float.isNaN( tpf ) ) {
|
||||
Logger.getLogger( PhysicsSpace.LOGGER_NAME ).warning( "Maximum physics update interval is 0.2 seconds - capped." );
|
||||
physicsSpace.update( 0.2f * physicsSpeed );
|
||||
}
|
||||
else physicsSpace.update( tpf * physicsSpeed );
|
||||
|
||||
if ( tpf > 0.2 || Float.isNaN( tpf ) ) {
|
||||
Logger.getLogger( PhysicsSpace.LOGGER_NAME ).warning( "Maximum physics update interval is 0.2 seconds - capped." );
|
||||
physicsSpace.update( 0.2f * physicsSpeed );
|
||||
}
|
||||
else physicsSpace.update( tpf * physicsSpeed );
|
||||
|
||||
//passManager.updatePasses(tpf);
|
||||
}
|
||||
|
||||
|
||||
public void stateRender(float tpf){
|
||||
Renderer r = DisplaySystem.getDisplaySystem().getRenderer();
|
||||
|
||||
// debug
|
||||
PhysicsDebugger.drawPhysics( physicsSpace, r );
|
||||
|
||||
/** Have the PassManager render. */
|
||||
//passManager.renderPasses(r);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue