Added chase camera and some cleanup
This commit is contained in:
parent
8eced25964
commit
176ee29753
2 changed files with 33 additions and 11 deletions
|
|
@ -1,6 +1,10 @@
|
||||||
package se.cookery;
|
package se.cookery;
|
||||||
|
|
||||||
|
import com.jme3.app.FlyCamAppState;
|
||||||
import com.jme3.app.SimpleApplication;
|
import com.jme3.app.SimpleApplication;
|
||||||
|
import com.jme3.input.ChaseCamera;
|
||||||
|
import com.jme3.input.MouseInput;
|
||||||
|
import com.jme3.input.controls.MouseButtonTrigger;
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
|
|
@ -17,9 +21,9 @@ public class CookeryClient extends SimpleApplication {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simpleInitApp() {
|
public void simpleInitApp() {
|
||||||
flyCam.setMoveSpeed(15);
|
// -----------------------------------------
|
||||||
cam.setLocation(new Vector3f(0,20,-10));
|
// Setup Terrain
|
||||||
cam.lookAt(new Vector3f(0f,0f,0f), Vector3f.UNIT_Z);
|
// -----------------------------------------
|
||||||
|
|
||||||
Block block = new GrassLandWorldGenerator().generateBlock(0, 0);
|
Block block = new GrassLandWorldGenerator().generateBlock(0, 0);
|
||||||
|
|
||||||
|
|
@ -27,22 +31,42 @@ public class CookeryClient extends SimpleApplication {
|
||||||
terrain.setMaterial(MaterialUtil.createMaterial(assetManager, ColorRGBA.Green));
|
terrain.setMaterial(MaterialUtil.createMaterial(assetManager, ColorRGBA.Green));
|
||||||
rootNode.attachChild(terrain);
|
rootNode.attachChild(terrain);
|
||||||
|
|
||||||
// Geometry box = GeometryUtil.createBox(assetManager, 1f, 1f, 1f, ColorRGBA.Red);
|
// -----------------------------------------
|
||||||
// box.setLocalTranslation(box.getModelBound().getCenter());
|
// Setup Player
|
||||||
// rootNode.attachChild(box);
|
// -----------------------------------------
|
||||||
|
|
||||||
Player player = new Player(assetManager);
|
Player player = new Player(assetManager);
|
||||||
rootNode.attachChild(player.getGfxNode());
|
rootNode.attachChild(player.getGfxNode());
|
||||||
|
|
||||||
|
// -----------------------------------------
|
||||||
|
// Setup Camera
|
||||||
|
// -----------------------------------------
|
||||||
|
|
||||||
|
// flyCam.setMoveSpeed(15);
|
||||||
|
// cam.setLocation(new Vector3f(0,10,-20));
|
||||||
|
// cam.lookAt(new Vector3f(0f,0f,0f), Vector3f.UNIT_Z);
|
||||||
|
|
||||||
|
flyCam.setEnabled(false);
|
||||||
|
// stateManager.detach(stateManager.getState(FlyCamAppState.class));
|
||||||
|
ChaseCamera chaseCam = new ChaseCamera(cam, player.getGfxNode(), inputManager);
|
||||||
|
chaseCam.setDefaultDistance(10);
|
||||||
|
chaseCam.setRotationSpeed(2);
|
||||||
|
chaseCam.setLookAtOffset(Vector3f.UNIT_Y);
|
||||||
|
chaseCam.setToggleRotationTrigger(new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
|
||||||
|
|
||||||
|
// -----------------------------------------
|
||||||
|
// Setup Shaders
|
||||||
|
// -----------------------------------------
|
||||||
|
|
||||||
// Wireframe mode
|
// Wireframe mode
|
||||||
// viewPort.addProcessor(new WireFrameProcessor(assetManager));
|
// viewPort.addProcessor(new WireFrameProcessor(assetManager));
|
||||||
|
|
||||||
|
// Cartoon shader
|
||||||
|
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
|
||||||
CartoonEdgeFilter toon = new CartoonEdgeFilter();
|
CartoonEdgeFilter toon = new CartoonEdgeFilter();
|
||||||
toon.setEdgeWidth(0.5f);
|
toon.setEdgeWidth(0.5f);
|
||||||
toon.setEdgeIntensity(1.0f);
|
toon.setEdgeIntensity(1.0f);
|
||||||
toon.setNormalThreshold(0.8f);
|
toon.setNormalThreshold(0.8f);
|
||||||
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
|
|
||||||
fpp.addFilter(toon);
|
fpp.addFilter(toon);
|
||||||
viewPort.addProcessor(fpp);
|
viewPort.addProcessor(fpp);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,10 @@
|
||||||
package se.cookery.gfx.character;
|
package se.cookery.gfx.character;
|
||||||
|
|
||||||
import com.jme3.asset.AssetManager;
|
import com.jme3.asset.AssetManager;
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.scene.shape.Box;
|
|
||||||
import se.cookery.gfx.util.GeometryUtil;
|
import se.cookery.gfx.util.GeometryUtil;
|
||||||
|
|
||||||
public class Player {
|
public class Player {
|
||||||
|
|
@ -14,7 +12,7 @@ public class Player {
|
||||||
|
|
||||||
public Player(AssetManager assetManager) {
|
public Player(AssetManager assetManager) {
|
||||||
Geometry box = GeometryUtil.createBox(assetManager, 0.5f,0.7f,0.5f, ColorRGBA.Red);
|
Geometry box = GeometryUtil.createBox(assetManager, 0.5f,0.7f,0.5f, ColorRGBA.Red);
|
||||||
box.setLocalTranslation(0.5f, 0.7f, 0.5f);
|
box.setLocalTranslation(0.5f, 0.35f, 0.5f);
|
||||||
playerNode.attachChild(box);
|
playerNode.attachChild(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue