This commit is contained in:
parent
5f797d9046
commit
b02be8bcc6
1 changed files with 26 additions and 4 deletions
|
|
@ -1,9 +1,15 @@
|
|||
package sg;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.jme.app.SimpleGame;
|
||||
import com.jme.bounding.BoundingBox;
|
||||
import com.jme.renderer.ColorRGBA;
|
||||
import com.jme.scene.Skybox;
|
||||
import com.jme.scene.shape.Sphere;
|
||||
import com.jme.scene.state.LightState;
|
||||
import com.jme.scene.state.TextureState;
|
||||
import com.jme.image.Texture;
|
||||
import com.jme.light.PointLight;
|
||||
import com.jme.math.Vector3f;
|
||||
|
|
@ -15,13 +21,30 @@ public class SpaceGame extends SimpleGame {
|
|||
private LightState lightState;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpaceGame app = new SpaceGame();
|
||||
app.setConfigShowMode(ConfigShowMode.AlwaysShow);
|
||||
app.start();
|
||||
Logger.getLogger( "" ).setLevel( Level.WARNING );
|
||||
SpaceGame game = new SpaceGame();
|
||||
game.setConfigShowMode(ConfigShowMode.AlwaysShow);
|
||||
game.start();
|
||||
}
|
||||
|
||||
protected void simpleInitGame() {
|
||||
display.setTitle("SpaceGame");
|
||||
|
||||
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);
|
||||
|
||||
buildSkyBox();
|
||||
rootNode.attachChild(skybox);
|
||||
buildLighting();
|
||||
|
|
@ -75,7 +98,6 @@ public class SpaceGame extends SimpleGame {
|
|||
}
|
||||
|
||||
private void buildLighting() {
|
||||
/** Set up a basic, default light. */
|
||||
PointLight light = new PointLight();
|
||||
light.setDiffuse( new ColorRGBA( 1.0f, 1.0f, 1.0f, 1.0f ) );
|
||||
light.setAmbient( new ColorRGBA( 0.5f, 0.5f, 0.5f, 1.0f ) );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue