Fixed some things
This commit is contained in:
parent
7a4d7242c5
commit
14f395d273
8 changed files with 351 additions and 182 deletions
|
|
@ -131,9 +131,9 @@ public class SpaceGame2 extends BaseGame {
|
|||
logger.info("Free memory: "+(freeMem>>10)+" kb");
|
||||
logger.info("Max memory: "+(maxMem>>10)+" kb");
|
||||
}
|
||||
|
||||
if ( KeyBindingManager.getKeyBindingManager().isValidCommand( "exit",
|
||||
false ) ) {
|
||||
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
src/sg/data/textures/sunmap.jpg
Normal file
BIN
src/sg/data/textures/sunmap.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 275 KiB |
5
src/sg/env/Environment.java
vendored
5
src/sg/env/Environment.java
vendored
|
|
@ -7,7 +7,6 @@ import com.jme.light.DirectionalLight;
|
|||
import com.jme.light.LightNode;
|
||||
import com.jme.math.Vector3f;
|
||||
import com.jme.renderer.ColorRGBA;
|
||||
import com.jme.renderer.Renderer;
|
||||
import com.jme.scene.Node;
|
||||
import com.jme.scene.Skybox;
|
||||
import com.jme.scene.state.TextureState;
|
||||
|
|
@ -23,7 +22,7 @@ public class Environment extends Node {
|
|||
* */
|
||||
private Node localNode;
|
||||
|
||||
public Environment(){
|
||||
public Environment(Node rootNode){
|
||||
buildLocalNode();
|
||||
}
|
||||
|
||||
|
|
@ -51,8 +50,6 @@ public class Environment extends Node {
|
|||
dr.setDiffuse(ColorRGBA.white);
|
||||
dr.setAmbient(ColorRGBA.gray);
|
||||
dr.setDirection(new Vector3f(0.0f, 0.0f, 0.0f));
|
||||
dr.setShadowCaster(true);
|
||||
this.setRenderQueueMode(Renderer.QUEUE_OPAQUE);
|
||||
|
||||
LightNode lightNode = new LightNode("space_light_node");
|
||||
lightNode.setLight(dr);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
package sg.input;
|
||||
|
||||
import com.jme.renderer.Camera;
|
||||
import com.jme.scene.Node;
|
||||
|
||||
|
||||
public class FirstPersonHandler extends GlobalInputHandler{
|
||||
|
||||
public FirstPersonHandler(Node ship, Camera cam){
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,6 +28,8 @@ 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);
|
||||
|
|
@ -37,6 +39,9 @@ public class InGameState extends CameraGameState {
|
|||
loader.setActive(true);
|
||||
// ***************** Load the Game **********************************
|
||||
|
||||
// Pass (render thingies)
|
||||
//passManager = new BasicPassManager();
|
||||
|
||||
//physics
|
||||
physicsSpace = PhysicsSpace.create();
|
||||
|
||||
|
|
@ -46,11 +51,6 @@ public class InGameState extends CameraGameState {
|
|||
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));
|
||||
|
|
@ -58,8 +58,15 @@ public class InGameState extends CameraGameState {
|
|||
rootNode.attachChild(ship);
|
||||
loader.increment();
|
||||
|
||||
// environment
|
||||
environment = new Environment(rootNode);
|
||||
rootNode.attachChild(environment);
|
||||
loader.increment();
|
||||
|
||||
// inputs
|
||||
input = new ThirdPersonHandler(ship, cam);
|
||||
FirstPersonHandler first = new FirstPersonHandler( cam, 50, 1 );
|
||||
input = new InputHandler();
|
||||
input.addToAttachedHandlers( first );
|
||||
loader.increment();
|
||||
|
||||
// ***************** Done loading **********************************
|
||||
|
|
@ -78,10 +85,17 @@ public class InGameState extends CameraGameState {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,151 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2003-2009 jMonkeyEngine
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package sg.test;
|
||||
|
||||
import com.jme.app.SimpleGame;
|
||||
import com.jme.bounding.BoundingBox;
|
||||
import com.jme.image.Image;
|
||||
import com.jme.image.Texture;
|
||||
import com.jme.light.LightNode;
|
||||
import com.jme.light.PointLight;
|
||||
import com.jme.math.Vector3f;
|
||||
import com.jme.renderer.ColorRGBA;
|
||||
import com.jme.scene.Spatial.LightCombineMode;
|
||||
import com.jme.scene.shape.Box;
|
||||
import com.jme.scene.state.TextureState;
|
||||
import com.jme.util.TextureManager;
|
||||
import com.jmex.effects.LensFlare;
|
||||
import com.jmex.effects.LensFlareFactory;
|
||||
|
||||
/**
|
||||
* <code>TestLensFlare</code> Test of the lens flare effect in jME. Notice
|
||||
* that currently it doesn't do occlusion culling.
|
||||
*
|
||||
* @author Joshua Slack
|
||||
* @version $Id: TestLensFlare.java,v 1.17 2007/09/21 15:46:34 nca Exp $
|
||||
*/
|
||||
public class TestLensFlare extends SimpleGame {
|
||||
|
||||
private LightNode lightNode;
|
||||
LensFlare flare;
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestLensFlare app = new TestLensFlare();
|
||||
app.setConfigShowMode(ConfigShowMode.AlwaysShow);
|
||||
app.start();
|
||||
}
|
||||
|
||||
protected void simpleInitGame() {
|
||||
|
||||
display.setTitle("Lens Flare!");
|
||||
cam.setLocation(new Vector3f(0.0f, 0.0f, 200.0f));
|
||||
cam.update();
|
||||
lightState.detachAll();
|
||||
|
||||
PointLight dr = new PointLight();
|
||||
dr.setEnabled(true);
|
||||
dr.setDiffuse(ColorRGBA.white.clone());
|
||||
dr.setAmbient(ColorRGBA.gray.clone());
|
||||
dr.setLocation(new Vector3f(0f, 0f, 0f));
|
||||
|
||||
lightState.attach(dr);
|
||||
lightState.setTwoSidedLighting(true);
|
||||
|
||||
lightNode = new LightNode("light");
|
||||
lightNode.setLight(dr);
|
||||
|
||||
Vector3f min2 = new Vector3f(-0.5f, -0.5f, -0.5f);
|
||||
Vector3f max2 = new Vector3f(0.5f, 0.5f, 0.5f);
|
||||
Box lightBox = new Box("box", min2, max2);
|
||||
lightBox.setModelBound(new BoundingBox());
|
||||
lightBox.updateModelBound();
|
||||
lightNode.attachChild(lightBox);
|
||||
lightNode.setLocalTranslation(new Vector3f(-14f, 14f, -14f));
|
||||
|
||||
Box box2 = new Box("blocker", new Vector3f(-5, -5, -5), new Vector3f(5,
|
||||
5, 5));
|
||||
box2.setModelBound(new BoundingBox());
|
||||
box2.updateModelBound();
|
||||
box2.setLocalTranslation(new Vector3f(100, 0, 0));
|
||||
rootNode.attachChild(box2);
|
||||
|
||||
// clear the lights from this lightbox so the lightbox itself doesn't
|
||||
// get affected by light:
|
||||
lightBox.setLightCombineMode(LightCombineMode.Off);
|
||||
|
||||
// Setup the lensflare textures.
|
||||
TextureState[] tex = new TextureState[4];
|
||||
tex[0] = display.getRenderer().createTextureState();
|
||||
tex[0].setTexture(TextureManager.loadTexture(LensFlare.class
|
||||
.getClassLoader()
|
||||
.getResource("jmetest/data/texture/flare1.png"),
|
||||
Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear, Image.Format.RGBA8,
|
||||
0.0f, true));
|
||||
tex[0].setEnabled(true);
|
||||
|
||||
tex[1] = display.getRenderer().createTextureState();
|
||||
tex[1].setTexture(TextureManager.loadTexture(LensFlare.class
|
||||
.getClassLoader()
|
||||
.getResource("jmetest/data/texture/flare2.png"),
|
||||
Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear));
|
||||
tex[1].setEnabled(true);
|
||||
|
||||
tex[2] = display.getRenderer().createTextureState();
|
||||
tex[2].setTexture(TextureManager.loadTexture(LensFlare.class
|
||||
.getClassLoader()
|
||||
.getResource("jmetest/data/texture/flare3.png"),
|
||||
Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear));
|
||||
tex[2].setEnabled(true);
|
||||
|
||||
tex[3] = display.getRenderer().createTextureState();
|
||||
tex[3].setTexture(TextureManager.loadTexture(LensFlare.class
|
||||
.getClassLoader()
|
||||
.getResource("jmetest/data/texture/flare4.png"),
|
||||
Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear));
|
||||
tex[3].setEnabled(true);
|
||||
|
||||
flare = LensFlareFactory.createBasicLensFlare("flare", tex);
|
||||
flare.setRootNode(rootNode);
|
||||
//lightNode.attachChild(flare);
|
||||
Box box = new Box("my box", new Vector3f(0, 0, 0), 10, 10, 10);
|
||||
box.setModelBound(new BoundingBox());
|
||||
box.updateModelBound();
|
||||
rootNode.attachChild(box);
|
||||
rootNode.attachChild(lightNode);
|
||||
|
||||
// notice that it comes at the end
|
||||
lightNode.attachChild(flare);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
305
src/sg/test/TestMotionBlur.java
Normal file
305
src/sg/test/TestMotionBlur.java
Normal file
|
|
@ -0,0 +1,305 @@
|
|||
/*
|
||||
* Copyright (c) 2003-2009 jMonkeyEngine
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package sg.test;
|
||||
|
||||
import com.jme.app.SimplePassGame;
|
||||
import com.jme.bounding.BoundingBox;
|
||||
import com.jme.image.Texture;
|
||||
import com.jme.input.KeyBindingManager;
|
||||
import com.jme.input.KeyInput;
|
||||
import com.jme.light.PointLight;
|
||||
import com.jme.math.FastMath;
|
||||
import com.jme.math.Vector3f;
|
||||
import com.jme.renderer.ColorRGBA;
|
||||
import com.jme.renderer.Renderer;
|
||||
import com.jme.renderer.pass.RenderPass;
|
||||
import com.jme.scene.Node;
|
||||
import com.jme.scene.Spatial;
|
||||
import com.jme.scene.Text;
|
||||
import com.jme.scene.shape.Box;
|
||||
import com.jme.scene.shape.Quad;
|
||||
import com.jme.scene.shape.Sphere;
|
||||
import com.jme.scene.shape.Torus;
|
||||
import com.jme.scene.state.TextureState;
|
||||
import com.jme.util.TextureManager;
|
||||
import com.jmex.effects.glsl.MotionBlurRenderPass;
|
||||
|
||||
/**
|
||||
* Motion blur effect pass test.
|
||||
*
|
||||
* @author Rikard Herlitz (MrCoder)
|
||||
*/
|
||||
public class TestMotionBlur extends SimplePassGame {
|
||||
private MotionBlurRenderPass motionBlurRenderPass;
|
||||
private int screenshotIndex = 0;
|
||||
private Node debugQuadsNode;
|
||||
|
||||
private Spatial torus;
|
||||
private Spatial sphere;
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestMotionBlur app = new TestMotionBlur();
|
||||
app.setConfigShowMode(ConfigShowMode.AlwaysShow);
|
||||
app.start();
|
||||
}
|
||||
|
||||
protected void cleanup() {
|
||||
super.cleanup();
|
||||
if (motionBlurRenderPass != null)
|
||||
motionBlurRenderPass.cleanup();
|
||||
}
|
||||
|
||||
protected void simpleInitGame() {
|
||||
display.setTitle("MotionBlur Test");
|
||||
|
||||
// Setup camera
|
||||
cam.setFrustumPerspective(45.0f, (float) display.getWidth()
|
||||
/ (float) display.getHeight(), 1, 5000);
|
||||
cam.setLocation(new Vector3f(200, 150, 200));
|
||||
cam.lookAt(new Vector3f(0, 0, 0), Vector3f.UNIT_Y);
|
||||
cam.update();
|
||||
|
||||
setupKeyBindings();
|
||||
|
||||
// Setup lights
|
||||
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));
|
||||
light.setLocation(new Vector3f(0, 30, 0));
|
||||
light.setEnabled(true);
|
||||
lightState.attach(light);
|
||||
|
||||
// Add dummy objects to rootNode
|
||||
rootNode.attachChild(createObjects());
|
||||
|
||||
// Setup renderpasses
|
||||
RenderPass rootPass = new RenderPass();
|
||||
rootPass.add(rootNode);
|
||||
pManager.add(rootPass);
|
||||
|
||||
motionBlurRenderPass = new MotionBlurRenderPass(cam);
|
||||
|
||||
if (!motionBlurRenderPass.isSupported()) {
|
||||
Text t = Text.createDefaultTextLabel("Text", "GLSL Not supported on this computer.");
|
||||
t.setRenderQueueMode(Renderer.QUEUE_ORTHO);
|
||||
t.setLightCombineMode(Spatial.LightCombineMode.Off);
|
||||
t.setLocalTranslation(new Vector3f(0, 20, 0));
|
||||
statNode.attachChild(t);
|
||||
} else {
|
||||
motionBlurRenderPass.add(rootNode);
|
||||
motionBlurRenderPass.addMotionBlurSpatial(sphere);
|
||||
motionBlurRenderPass.addMotionBlurSpatial(torus);
|
||||
motionBlurRenderPass.setUseCurrentScene(true);
|
||||
pManager.add(motionBlurRenderPass);
|
||||
}
|
||||
|
||||
createDebugQuads();
|
||||
statNode.attachChild(debugQuadsNode);
|
||||
|
||||
RenderPass statPass = new RenderPass();
|
||||
statPass.add(statNode);
|
||||
pManager.add(statPass);
|
||||
}
|
||||
|
||||
protected void simpleUpdate() {
|
||||
if (!motionBlurRenderPass.isFreeze()) {
|
||||
float time = (FastMath.sin(timer.getTimeInSeconds() * 0.5f) + 1.0f) * 10.0f;
|
||||
torus.getLocalRotation().fromAngles(time * 2f, time * 2.0f,
|
||||
time * 1.0f);
|
||||
torus.getLocalTranslation().x = FastMath.sin(time * 1.0f) * 100.0f;
|
||||
torus.getLocalTranslation().z = FastMath.cos(time * 1.0f) * 100.0f;
|
||||
|
||||
float scale = (FastMath.sin(timer.getTimeInSeconds() * 10.0f) + 2.0f) * 0.5f;
|
||||
sphere.getLocalScale().set(scale, scale, scale);
|
||||
sphere.getLocalTranslation().z = FastMath.sin(time * 1.0f) * 200.0f;
|
||||
}
|
||||
|
||||
if (KeyBindingManager.getKeyBindingManager().isValidCommand("1", false)) {
|
||||
motionBlurRenderPass.setEnabled(!motionBlurRenderPass.isEnabled());
|
||||
}
|
||||
|
||||
if (KeyBindingManager.getKeyBindingManager().isValidCommand("2", false)) {
|
||||
motionBlurRenderPass.setBlurStrength(motionBlurRenderPass
|
||||
.getBlurStrength() * 0.5f);
|
||||
}
|
||||
if (KeyBindingManager.getKeyBindingManager().isValidCommand("3", false)) {
|
||||
motionBlurRenderPass.setBlurStrength(motionBlurRenderPass
|
||||
.getBlurStrength() * 2.0f);
|
||||
}
|
||||
|
||||
if (KeyBindingManager.getKeyBindingManager().isValidCommand("f", false)) {
|
||||
motionBlurRenderPass.setFreeze(!motionBlurRenderPass.isFreeze());
|
||||
}
|
||||
|
||||
if (KeyBindingManager.getKeyBindingManager().isValidCommand("g", false)) {
|
||||
motionBlurRenderPass.reloadShader();
|
||||
}
|
||||
|
||||
if (KeyBindingManager.getKeyBindingManager().isValidCommand("0", false)) {
|
||||
motionBlurRenderPass.resetParameters();
|
||||
motionBlurRenderPass.setUseCurrentScene(true);
|
||||
}
|
||||
|
||||
if (KeyBindingManager.getKeyBindingManager().isValidCommand("shot",
|
||||
false)) {
|
||||
display.getRenderer().takeScreenShot("shot" + screenshotIndex++);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupKeyBindings() {
|
||||
KeyBindingManager.getKeyBindingManager().set("1", KeyInput.KEY_1);
|
||||
KeyBindingManager.getKeyBindingManager().set("2", KeyInput.KEY_2);
|
||||
KeyBindingManager.getKeyBindingManager().set("3", KeyInput.KEY_3);
|
||||
KeyBindingManager.getKeyBindingManager().set("0", KeyInput.KEY_0);
|
||||
KeyBindingManager.getKeyBindingManager().set("g", KeyInput.KEY_G);
|
||||
KeyBindingManager.getKeyBindingManager().set("f", KeyInput.KEY_F);
|
||||
KeyBindingManager.getKeyBindingManager().set("shot", KeyInput.KEY_F4);
|
||||
|
||||
Text t = Text.createDefaultTextLabel("Text", "1: enable/disable motionblur pass");
|
||||
t.setRenderQueueMode(Renderer.QUEUE_ORTHO);
|
||||
t.setLightCombineMode(Spatial.LightCombineMode.Off);
|
||||
t.setLocalTranslation(new Vector3f(0, 20, 1));
|
||||
statNode.attachChild(t);
|
||||
|
||||
t = Text.createDefaultTextLabel("Text", "2/3: decrease/increase blur strength");
|
||||
t.setRenderQueueMode(Renderer.QUEUE_ORTHO);
|
||||
t.setLightCombineMode(Spatial.LightCombineMode.Off);
|
||||
t.setLocalTranslation(new Vector3f(0, 40, 1));
|
||||
statNode.attachChild(t);
|
||||
|
||||
t = Text.createDefaultTextLabel("Text", "f: freeze/unfreeze movement");
|
||||
t.setRenderQueueMode(Renderer.QUEUE_ORTHO);
|
||||
t.setLightCombineMode(Spatial.LightCombineMode.Off);
|
||||
t.setLocalTranslation(new Vector3f(0, 60, 1));
|
||||
statNode.attachChild(t);
|
||||
}
|
||||
|
||||
private Node createObjects() {
|
||||
Node objects = new Node("objects");
|
||||
|
||||
torus = new Torus("Torus", 50, 50, 10, 25);
|
||||
torus.setLocalTranslation(new Vector3f(50, -5, 20));
|
||||
TextureState ts = display.getRenderer().createTextureState();
|
||||
Texture t0 = TextureManager.loadTexture(
|
||||
TestMotionBlur.class.getClassLoader().getResource(
|
||||
"jmetest/data/images/Monkey.jpg"),
|
||||
Texture.MinificationFilter.Trilinear,
|
||||
Texture.MagnificationFilter.Bilinear);
|
||||
Texture t1 = TextureManager.loadTexture(
|
||||
TestMotionBlur.class.getClassLoader().getResource(
|
||||
"jmetest/data/texture/north.jpg"),
|
||||
Texture.MinificationFilter.Trilinear,
|
||||
Texture.MagnificationFilter.Bilinear);
|
||||
t1.setEnvironmentalMapMode(Texture.EnvironmentalMapMode.SphereMap);
|
||||
ts.setTexture(t0, 0);
|
||||
ts.setTexture(t1, 1);
|
||||
ts.setEnabled(true);
|
||||
torus.setRenderState(ts);
|
||||
objects.attachChild(torus);
|
||||
|
||||
ts = display.getRenderer().createTextureState();
|
||||
t0 = TextureManager.loadTexture(TestMotionBlur.class.getClassLoader()
|
||||
.getResource("jmetest/data/texture/wall.jpg"),
|
||||
Texture.MinificationFilter.Trilinear,
|
||||
Texture.MagnificationFilter.Bilinear);
|
||||
t0.setWrap(Texture.WrapMode.Repeat);
|
||||
ts.setTexture(t0);
|
||||
|
||||
ts = display.getRenderer().createTextureState();
|
||||
t0 = TextureManager.loadTexture(TestMotionBlur.class.getClassLoader()
|
||||
.getResource("jmetest/data/texture/cloud_land.jpg"),
|
||||
Texture.MinificationFilter.Trilinear,
|
||||
Texture.MagnificationFilter.Bilinear);
|
||||
t0.setWrap(Texture.WrapMode.Repeat);
|
||||
ts.setTexture(t0);
|
||||
|
||||
sphere = new Sphere("sphere", 16, 16, 10);
|
||||
sphere.setLocalTranslation(new Vector3f(0, -10, 15));
|
||||
sphere.setRenderState(ts);
|
||||
objects.attachChild(sphere);
|
||||
|
||||
Box box = new Box("floor", new Vector3f(-1000, -10, -1000),
|
||||
new Vector3f(1000, 10, 1000));
|
||||
box.setLocalTranslation(new Vector3f(0, -100, 0));
|
||||
box.setRenderState(ts);
|
||||
box.setModelBound(new BoundingBox());
|
||||
box.updateModelBound();
|
||||
objects.attachChild(box);
|
||||
|
||||
ts = display.getRenderer().createTextureState();
|
||||
t0 = TextureManager.loadTexture(TestMotionBlur.class.getClassLoader()
|
||||
.getResource("jmetest/data/texture/wall.jpg"),
|
||||
Texture.MinificationFilter.Trilinear,
|
||||
Texture.MagnificationFilter.Bilinear);
|
||||
t0.setWrap(Texture.WrapMode.Repeat);
|
||||
ts.setTexture(t0);
|
||||
|
||||
box = new Box("box1", new Vector3f(-10, -10, -10), new Vector3f(10, 10,
|
||||
10));
|
||||
box.setLocalTranslation(new Vector3f(0, -20, 0));
|
||||
box.setRenderState(ts);
|
||||
objects.attachChild(box);
|
||||
|
||||
box = new Box("box2", new Vector3f(-5, -5, -5), new Vector3f(5, 5, 5));
|
||||
box.setLocalTranslation(new Vector3f(15, 30, 0));
|
||||
box.setRenderState(ts);
|
||||
objects.attachChild(box);
|
||||
|
||||
box = new Box("box3", new Vector3f(-5, -5, -5), new Vector3f(5, 5, 5));
|
||||
box.setLocalTranslation(new Vector3f(0, -10, 45));
|
||||
box.setRenderState(ts);
|
||||
objects.attachChild(box);
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
private void createDebugQuads() {
|
||||
debugQuadsNode = new Node("quadNode");
|
||||
debugQuadsNode.setCullHint(Spatial.CullHint.Never);
|
||||
|
||||
float quadWidth = display.getWidth() / 8;
|
||||
float quadHeight = display.getWidth() / 8;
|
||||
Quad debugQuad = new Quad("reflectionQuad", quadWidth, quadHeight);
|
||||
debugQuad.setRenderQueueMode(Renderer.QUEUE_ORTHO);
|
||||
debugQuad.setCullHint(Spatial.CullHint.Never);
|
||||
debugQuad.setLightCombineMode(Spatial.LightCombineMode.Off);
|
||||
TextureState ts = display.getRenderer().createTextureState();
|
||||
ts.setTexture(motionBlurRenderPass.getMainTexture());
|
||||
debugQuad.setRenderState(ts);
|
||||
debugQuad.updateRenderState();
|
||||
debugQuad.getLocalTranslation().set(quadWidth * 0.6f,
|
||||
quadHeight * 1.0f, 1.0f);
|
||||
debugQuadsNode.attachChild(debugQuad);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,7 +7,6 @@ import java.io.IOException;
|
|||
import java.net.URISyntaxException;
|
||||
|
||||
import com.jme.bounding.BoundingBox;
|
||||
import com.jme.image.Image;
|
||||
import com.jme.image.Texture;
|
||||
import com.jme.scene.Node;
|
||||
import com.jme.scene.Spatial;
|
||||
|
|
@ -17,7 +16,6 @@ import com.jme.util.TextureManager;
|
|||
import com.jme.util.export.binary.BinaryImporter;
|
||||
import com.jme.util.resource.ResourceLocatorTool;
|
||||
import com.jme.util.resource.SimpleResourceLocator;
|
||||
import com.jmex.effects.LensFlare;
|
||||
import com.jmex.model.converters.AseToJme;
|
||||
import com.jmex.model.converters.MaxToJme;
|
||||
import com.jmex.model.converters.Md2ToJme;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue