68 lines
No EOL
2 KiB
Java
68 lines
No EOL
2 KiB
Java
package sg;
|
|
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
|
|
import sg.env.Environment;
|
|
|
|
import com.jme.app.SimpleGame;
|
|
import com.jme.bounding.BoundingBox;
|
|
import com.jme.scene.shape.Sphere;
|
|
import com.jme.scene.state.TextureState;
|
|
import com.jme.image.Texture;
|
|
import com.jme.math.Vector3f;
|
|
import com.jme.util.TextureManager;
|
|
//import com.jmex.physics.DynamicPhysicsNode;
|
|
//import com.jmex.physics.StaticPhysicsNode;
|
|
//import com.jmex.physics.geometry.PhysicsBox;
|
|
//import com.jmex.physics.util.SimplePhysicsGame;
|
|
|
|
public class SpaceGame extends SimpleGame {
|
|
//private StaticPhysicsNode staticNode;
|
|
//private DynamicPhysicsNode dynamicNode;
|
|
private Environment environment;
|
|
|
|
public static void main(String[] args) {
|
|
Logger.getLogger( "" ).setLevel( Level.WARNING );
|
|
SpaceGame game = new SpaceGame();
|
|
game.setDialogBehaviour(SimpleGame.ALWAYS_SHOW_PROPS_DIALOG);
|
|
game.start();
|
|
}
|
|
|
|
protected void simpleInitGame() {
|
|
display.setTitle("SpaceGame");
|
|
|
|
//physics
|
|
//staticNode = getPhysicsSpace().createStaticNode();
|
|
//rootNode.attachChild(staticNode);
|
|
//dynamicNode = getPhysicsSpace().createDynamicNode();
|
|
//rootNode.attachChild(dynamicNode);
|
|
|
|
//environment
|
|
environment = new Environment();
|
|
rootNode.attachChild(environment);
|
|
|
|
//light
|
|
//TODO
|
|
|
|
//sphere
|
|
Sphere s = new Sphere("Sphere", 30, 30, 25);
|
|
s.setLocalTranslation(new Vector3f(0,0,-40));
|
|
s.setModelBound(new BoundingBox());
|
|
s.updateModelBound();
|
|
Texture texture = TextureManager.loadTexture(
|
|
SpaceGame.class.getClassLoader().getResource(
|
|
"jmetest/data/images/Monkey.jpg"),
|
|
Texture.MinificationFilter.Trilinear,
|
|
Texture.MagnificationFilter.Bilinear);
|
|
TextureState ts = display.getRenderer().createTextureState();
|
|
ts.setEnabled(true);
|
|
ts.setTexture(texture);
|
|
s.setRenderState(ts);
|
|
rootNode.attachChild(s);
|
|
}
|
|
|
|
public void simpleUpdate(){
|
|
environment.setLocalTranslation(cam.getLocation());
|
|
}
|
|
} |