This commit is contained in:
parent
80718cf937
commit
c5209c215b
3 changed files with 68 additions and 31 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
#Game Settings written by com.jme.app.BaseGame$BaseGameSettings at Sun Mar 08 18:20:37 CET 2009
|
#Game Settings written by com.jme.app.BaseGame$BaseGameSettings at Sun Mar 08 18:41:50 CET 2009
|
||||||
#Sun Mar 08 18:20:37 CET 2009
|
#Sun Mar 08 18:41:50 CET 2009
|
||||||
FREQ=60
|
FREQ=60
|
||||||
WIDTH=1440
|
|
||||||
RENDERER=LWJGL
|
RENDERER=LWJGL
|
||||||
|
WIDTH=1440
|
||||||
HEIGHT=900
|
HEIGHT=900
|
||||||
DEPTH=32
|
DEPTH=32
|
||||||
FULLSCREEN=true
|
FULLSCREEN=true
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,70 @@
|
||||||
package sg;
|
package sg;
|
||||||
|
|
||||||
public class SpaceGame {
|
import com.jme.app.SimpleGame;
|
||||||
|
import com.jme.scene.Skybox;
|
||||||
|
import com.jme.image.Texture;
|
||||||
|
import com.jme.util.TextureManager;
|
||||||
|
|
||||||
|
|
||||||
|
public class SpaceGame extends SimpleGame {
|
||||||
|
private Skybox skybox;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param args
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO Auto-generated method stub
|
SpaceGame app = new SpaceGame();
|
||||||
|
app.setConfigShowMode(ConfigShowMode.AlwaysShow);
|
||||||
|
app.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void simpleInitGame() {
|
||||||
|
display.setTitle("SpaceGame");
|
||||||
|
buildSkyBox();
|
||||||
|
rootNode.attachChild(skybox);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void simpleUpdate(){
|
||||||
|
skybox.setLocalTranslation(cam.getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildSkyBox() {
|
||||||
|
skybox = new Skybox("skybox", 500, 500, 500);
|
||||||
|
Texture north = TextureManager.loadTexture(
|
||||||
|
SpaceGame.class.getClassLoader().getResource(
|
||||||
|
"sg/data/skybox/advanced/front.png"),
|
||||||
|
Texture.MinificationFilter.BilinearNearestMipMap,
|
||||||
|
Texture.MagnificationFilter.Bilinear);
|
||||||
|
Texture south = TextureManager.loadTexture(
|
||||||
|
SpaceGame.class.getClassLoader().getResource(
|
||||||
|
"sg/data/skybox/advanced/rest.png"),
|
||||||
|
Texture.MinificationFilter.BilinearNearestMipMap,
|
||||||
|
Texture.MagnificationFilter.Bilinear);
|
||||||
|
Texture east = TextureManager.loadTexture(
|
||||||
|
SpaceGame.class.getClassLoader().getResource(
|
||||||
|
"sg/data/skybox/advanced/rest.png"),
|
||||||
|
Texture.MinificationFilter.BilinearNearestMipMap,
|
||||||
|
Texture.MagnificationFilter.Bilinear);
|
||||||
|
Texture west = TextureManager.loadTexture(
|
||||||
|
SpaceGame.class.getClassLoader().getResource(
|
||||||
|
"sg/data/skybox/advanced/rest.png"),
|
||||||
|
Texture.MinificationFilter.BilinearNearestMipMap,
|
||||||
|
Texture.MagnificationFilter.Bilinear);
|
||||||
|
Texture up = TextureManager.loadTexture(
|
||||||
|
SpaceGame.class.getClassLoader().getResource(
|
||||||
|
"sg/data/skybox/advanced/rest.png"),
|
||||||
|
Texture.MinificationFilter.BilinearNearestMipMap,
|
||||||
|
Texture.MagnificationFilter.Bilinear);
|
||||||
|
Texture down = TextureManager.loadTexture(
|
||||||
|
SpaceGame.class.getClassLoader().getResource(
|
||||||
|
"sg/data/skybox/advanced/rest.png"),
|
||||||
|
Texture.MinificationFilter.BilinearNearestMipMap,
|
||||||
|
Texture.MagnificationFilter.Bilinear);
|
||||||
|
skybox.setTexture(Skybox.Face.North, north);
|
||||||
|
skybox.setTexture(Skybox.Face.West, west);
|
||||||
|
skybox.setTexture(Skybox.Face.South, south);
|
||||||
|
skybox.setTexture(Skybox.Face.East, east);
|
||||||
|
skybox.setTexture(Skybox.Face.Up, up);
|
||||||
|
skybox.setTexture(Skybox.Face.Down, down);
|
||||||
|
skybox.preloadTextures();
|
||||||
|
skybox.updateRenderState();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -44,35 +44,15 @@ public class Lesson1 extends SimpleGame {
|
||||||
s.setRenderState(ts);
|
s.setRenderState(ts);
|
||||||
|
|
||||||
rootNode.attachChild(s);
|
rootNode.attachChild(s);
|
||||||
graphNode.attachChild(new Box("box",null, 0f,0f,0f));
|
|
||||||
|
|
||||||
buildSkyBox();
|
buildSkyBox();
|
||||||
rootNode.attachChild(this.skybox);
|
rootNode.attachChild(this.skybox);
|
||||||
|
|
||||||
buildLighting();
|
|
||||||
rootNode.setRenderState(lightState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void simpleUpdate(){
|
public void simpleUpdate(){
|
||||||
skybox.setLocalTranslation(cam.getLocation());
|
skybox.setLocalTranslation(cam.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildLighting() {
|
|
||||||
/** Set up a basic, default light. */
|
|
||||||
PointLight pl = new PointLight();
|
|
||||||
pl.setDiffuse(new ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f));
|
|
||||||
pl.setAmbient(new ColorRGBA(0.5f, 0.0f, 0.0f, 1.0f));
|
|
||||||
//create a point light at position 10,0,0
|
|
||||||
pl.setLocation(new Vector3f(10,0,0));
|
|
||||||
pl.setEnabled(true);
|
|
||||||
|
|
||||||
/** Attach the light to a lightState and the lightState to rootNode. */
|
|
||||||
LightState lightState = display.getRenderer().createLightState();
|
|
||||||
lightState.setEnabled(true);
|
|
||||||
lightState.attach(pl);
|
|
||||||
//scene.setRenderState(lightState);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildSkyBox() {
|
private void buildSkyBox() {
|
||||||
skybox = new Skybox("skybox", 500, 500, 500);
|
skybox = new Skybox("skybox", 500, 500, 500);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue