Fixed lights
This commit is contained in:
parent
14f395d273
commit
0935259b6c
2 changed files with 26 additions and 19 deletions
14
src/sg/env/Environment.java
vendored
14
src/sg/env/Environment.java
vendored
|
|
@ -3,10 +3,7 @@ package sg.env;
|
|||
import sg.util.SGUtil;
|
||||
|
||||
import com.jme.image.Texture;
|
||||
import com.jme.light.DirectionalLight;
|
||||
import com.jme.light.LightNode;
|
||||
import com.jme.math.Vector3f;
|
||||
import com.jme.renderer.ColorRGBA;
|
||||
import com.jme.scene.Node;
|
||||
import com.jme.scene.Skybox;
|
||||
import com.jme.scene.state.TextureState;
|
||||
|
|
@ -22,7 +19,7 @@ public class Environment extends Node {
|
|||
* */
|
||||
private Node localNode;
|
||||
|
||||
public Environment(Node rootNode){
|
||||
public Environment(Node parentNode){
|
||||
buildLocalNode();
|
||||
}
|
||||
|
||||
|
|
@ -44,15 +41,8 @@ public class Environment extends Node {
|
|||
space.updateRenderState();
|
||||
localNode.attachChild(space);
|
||||
|
||||
// Lights
|
||||
DirectionalLight dr = new DirectionalLight();
|
||||
dr.setEnabled(true);
|
||||
dr.setDiffuse(ColorRGBA.white);
|
||||
dr.setAmbient(ColorRGBA.gray);
|
||||
dr.setDirection(new Vector3f(0.0f, 0.0f, 0.0f));
|
||||
|
||||
// Lights
|
||||
LightNode lightNode = new LightNode("space_light_node");
|
||||
lightNode.setLight(dr);
|
||||
|
||||
// Setup the lens flare textures.
|
||||
TextureState[] tex = new TextureState[4];
|
||||
|
|
|
|||
|
|
@ -7,9 +7,12 @@ import sg.util.SGUtil;
|
|||
|
||||
import com.jme.input.FirstPersonHandler;
|
||||
import com.jme.input.InputHandler;
|
||||
import com.jme.light.PointLight;
|
||||
import com.jme.math.Vector3f;
|
||||
import com.jme.renderer.ColorRGBA;
|
||||
import com.jme.renderer.Renderer;
|
||||
import com.jme.scene.Node;
|
||||
import com.jme.scene.state.LightState;
|
||||
import com.jme.system.DisplaySystem;
|
||||
import com.jmex.game.state.CameraGameState;
|
||||
import com.jmex.game.state.GameStateManager;
|
||||
|
|
@ -51,23 +54,37 @@ public class InGameState extends CameraGameState {
|
|||
rootNode.attachChild(dynamicNode);
|
||||
rootNode.attachChild(staticNode);
|
||||
|
||||
// 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();
|
||||
|
||||
// environment
|
||||
environment = new Environment(rootNode);
|
||||
rootNode.attachChild(environment);
|
||||
loader.increment();
|
||||
|
||||
// ship
|
||||
Node ship = SGUtil.loadModel("sg/data/models/ships/G6.3ds");
|
||||
ship.setLocalTranslation(new Vector3f( 0, 0, 40));
|
||||
rootNode.attachChild(ship);
|
||||
loader.increment();
|
||||
|
||||
// inputs
|
||||
FirstPersonHandler first = new FirstPersonHandler( cam, 50, 1 );
|
||||
input = new InputHandler();
|
||||
input.addToAttachedHandlers( first );
|
||||
loader.increment();
|
||||
|
||||
// lights
|
||||
/** Set up a basic, default light. */
|
||||
PointLight light = new PointLight();
|
||||
light.setDiffuse( new ColorRGBA( 0.75f, 0.75f, 0.75f, 0.75f ) );
|
||||
light.setAmbient( new ColorRGBA( 0.5f, 0.5f, 0.5f, 1.0f ) );
|
||||
light.setLocation( new Vector3f( 100, 100, 100 ) );
|
||||
light.setEnabled( true );
|
||||
|
||||
/** Attach the light to a lightState and the lightState to rootNode. */
|
||||
LightState lightState = DisplaySystem.getDisplaySystem().getRenderer().createLightState();
|
||||
lightState.setEnabled( true );
|
||||
lightState.attach( light );
|
||||
rootNode.setRenderState( lightState );
|
||||
rootNode.updateRenderState();
|
||||
|
||||
// ***************** Done loading **********************************
|
||||
loader.setActive(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue