Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mygame;
- import com.jme3.app.SimpleApplication;
- import com.jme3.input.KeyInput;
- import com.jme3.input.controls.AnalogListener;
- import com.jme3.input.controls.KeyTrigger;
- import com.jme3.light.DirectionalLight;
- import com.jme3.math.ColorRGBA;
- import com.jme3.math.Vector3f;
- import com.jme3.scene.Spatial;
- import com.jme3.shadow.PssmShadowRenderer;
- import java.util.logging.Level;
- /**
- * Result
- * @author +Gvrv
- */
- public class Main extends SimpleApplication
- {
- float angle;
- Spatial circle1;
- Spatial circle2;
- public static void main(String[] args)
- {
- java.util.logging.Logger.getLogger("").setLevel(Level.WARNING);
- Main app = new Main();
- app.start();
- }
- @Override
- public void simpleInitApp()
- {
- setDisplayFps(false);
- setDisplayStatView(false);
- setShowSettings(false);
- //flyCam.setEnabled(false);
- //cam.setLocation(Vector3f.ZERO);
- viewPort.setBackgroundColor(ColorRGBA.Gray);
- DirectionalLight sun = new DirectionalLight();
- sun.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
- sun.setColor(ColorRGBA.Yellow);
- rootNode.addLight(sun);
- PssmShadowRenderer shadowRenderer = new PssmShadowRenderer(assetManager, 512, 4);
- shadowRenderer.setDirection(sun.getDirection());
- viewPort.addProcessor(shadowRenderer);
- Spatial ground = assetManager.loadModel("Models/ground.j3o");
- ground.move(0, -5f, 0);
- rootNode.attachChild(ground);
- circle1 = assetManager.loadModel("Models/circle1.j3o");
- circle1.move(0, -5f, 0);
- rootNode.attachChild(circle1);
- circle2 = assetManager.loadModel("Models/circle2.j3o");
- circle2.move(0, -5f, 0);
- rootNode.attachChild(circle2);
- inputManager.addMapping("Z", new KeyTrigger(KeyInput.KEY_Z));
- inputManager.addMapping("S", new KeyTrigger(KeyInput.KEY_S));
- inputManager.addMapping("Q", new KeyTrigger(KeyInput.KEY_Q));
- inputManager.addMapping("D", new KeyTrigger(KeyInput.KEY_D));
- inputManager.addListener(analogListener, new String[]{"Z", "S", "Q", "D"});
- }
- private AnalogListener analogListener = new AnalogListener()
- {
- public void onAnalog(String name, float value, float tpf)
- {
- Vector3f v = new Vector3f(cam.getLocation());
- if (name.equals("Z"))
- {
- v.z -= tpf;
- }
- if (name.equals("S"))
- {
- v.z += tpf;
- }
- if (name.equals("Q"))
- {
- v.x -= tpf;
- }
- if (name.equals("D"))
- {
- v.x += tpf;
- }
- cam.setLocation(v);
- }
- };
- @Override
- public void simpleUpdate(float tpf)
- {
- angle += 0.1f;
- circle1.move(0, (float) (0.025f * Math.sin(angle)), 0);
- circle2.move(0, (float) (0.025f * Math.cos(angle)), 0);
- }
- }
Add Comment
Please, Sign In to add comment