Search in sources :

Example 26 with Quaternion

use of com.jme3.math.Quaternion in project jmonkeyengine by jMonkeyEngine.

the class TestLightNode method simpleUpdate.

@Override
public void simpleUpdate(float tpf) {
    //        cam.setLocation(new Vector3f(5.0347548f, 6.6481347f, 3.74853f));
    //        cam.setRotation(new Quaternion(-0.19183293f, 0.80776674f, -0.37974006f, -0.40805697f));
    angle += tpf;
    angle %= FastMath.TWO_PI;
    movingNode.setLocalTranslation(new Vector3f(FastMath.cos(angle) * 3f, 2, FastMath.sin(angle) * 3f));
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 27 with Quaternion

use of com.jme3.math.Quaternion in project jmonkeyengine by jMonkeyEngine.

the class TestShadowBug method simpleInitApp.

@Override
public void simpleInitApp() {
    flyCam.setMoveSpeed(100f);
    rootNode.attachChild(makeFloor());
    Node characters = new Node("Characters");
    characters.setShadowMode(ShadowMode.Cast);
    rootNode.attachChild(characters);
    Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
    golem.scale(0.5f);
    golem.setLocalTranslation(200.0f, -6f, 200f);
    golem.setShadowMode(ShadowMode.CastAndReceive);
    characters.attachChild(golem);
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(-1f, -1f, 1f));
    sun.setColor(ColorRGBA.White.mult(1.3f));
    rootNode.addLight(sun);
    characters.addLight(sun);
    SpotLight spot = new SpotLight();
    // distance
    spot.setSpotRange(13f);
    // inner light cone (central beam)
    spot.setSpotInnerAngle(15f * FastMath.DEG_TO_RAD);
    // outer light cone (edge of the light)
    spot.setSpotOuterAngle(20f * FastMath.DEG_TO_RAD);
    // light color
    spot.setColor(ColorRGBA.White.mult(1.3f));
    spot.setPosition(new Vector3f(192.0f, -1f, 192f));
    spot.setDirection(new Vector3f(1, -0.5f, 1));
    rootNode.addLight(spot);
    PointLight lamp_light = new PointLight();
    lamp_light.setColor(ColorRGBA.Yellow);
    lamp_light.setRadius(20f);
    lamp_light.setPosition(new Vector3f(210.0f, 0f, 210f));
    rootNode.addLight(lamp_light);
    SpotLightShadowRenderer slsr = new SpotLightShadowRenderer(assetManager, 512);
    slsr.setLight(spot);
    slsr.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
    slsr.setShadowIntensity(0.6f);
    slsr.setFlushQueues(false);
    viewPort.addProcessor(slsr);
    PointLightShadowRenderer plsr = new PointLightShadowRenderer(assetManager, 512);
    plsr.setLight(lamp_light);
    plsr.setShadowIntensity(0.6f);
    plsr.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
    plsr.setFlushQueues(false);
    viewPort.addProcessor(plsr);
    viewPort.getCamera().setLocation(new Vector3f(192.0f, 10f, 192f));
    float[] angles = new float[] { 3.14f / 2, 3.14f / 2, 0 };
    viewPort.getCamera().setRotation(new Quaternion(angles));
}
Also used : Spatial(com.jme3.scene.Spatial) Quaternion(com.jme3.math.Quaternion) Node(com.jme3.scene.Node) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) PointLightShadowRenderer(com.jme3.shadow.PointLightShadowRenderer) PointLight(com.jme3.light.PointLight) SpotLightShadowRenderer(com.jme3.shadow.SpotLightShadowRenderer) SpotLight(com.jme3.light.SpotLight)

Example 28 with Quaternion

use of com.jme3.math.Quaternion in project jmonkeyengine by jMonkeyEngine.

the class TestShadowsPerf method simpleInitApp.

@Override
public void simpleInitApp() {
    Logger.getLogger("com.jme3").setLevel(Level.SEVERE);
    flyCam.setMoveSpeed(50);
    flyCam.setEnabled(false);
    viewPort.setBackgroundColor(ColorRGBA.DarkGray);
    cam.setLocation(new Vector3f(-53.952988f, 27.15874f, -32.875023f));
    cam.setRotation(new Quaternion(0.1564309f, 0.6910534f, -0.15713608f, 0.6879555f));
    //        cam.setLocation(new Vector3f(53.64627f, 130.56f, -11.247704f));
    //        cam.setRotation(new Quaternion(-6.5737107E-4f, 0.76819664f, -0.64021313f, -7.886125E-4f));   
    //// 
    cam.setFrustumFar(500);
    mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    Box b = new Box(800, 1, 700);
    b.scaleTextureCoordinates(new Vector2f(50, 50));
    Geometry ground = new Geometry("ground", b);
    ground.setMaterial(mat);
    rootNode.attachChild(ground);
    ground.setShadowMode(ShadowMode.Receive);
    Sphere sphMesh = new Sphere(32, 32, 1);
    sphMesh.setTextureMode(Sphere.TextureMode.Projected);
    sphMesh.updateGeometry(32, 32, 1, false, false);
    TangentBinormalGenerator.generate(sphMesh);
    sphere = new Geometry("Rock Ball", sphMesh);
    sphere.setLocalTranslation(0, 5, 0);
    sphere.setMaterial(mat);
    sphere.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(sphere);
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(0, -1, 0).normalizeLocal());
    dl.setColor(ColorRGBA.White);
    rootNode.addLight(dl);
    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(0.7f));
    rootNode.addLight(al);
    //rootNode.setShadowMode(ShadowMode.CastAndReceive);
    createballs();
    final DirectionalLightShadowRenderer pssmRenderer = new DirectionalLightShadowRenderer(assetManager, 1024, 4);
    viewPort.addProcessor(pssmRenderer);
    //        
    //        final PssmShadowFilter pssmRenderer = new PssmShadowFilter(assetManager, 1024, 4);
    //        FilterPostProcessor fpp = new FilterPostProcessor(assetManager);        
    //        fpp.addFilter(pssmRenderer);
    //        viewPort.addProcessor(fpp);
    pssmRenderer.setLight(dl);
    pssmRenderer.setLambda(0.55f);
    pssmRenderer.setShadowIntensity(0.55f);
    pssmRenderer.setShadowCompareMode(com.jme3.shadow.CompareMode.Software);
    pssmRenderer.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
    //pssmRenderer.displayDebug();
    inputManager.addListener(new ActionListener() {

        public void onAction(String name, boolean isPressed, float tpf) {
            if (name.equals("display") && isPressed) {
                //pssmRenderer.debugFrustrums();
                System.out.println("tetetetet");
            }
            if (name.equals("add") && isPressed) {
                createballs();
            }
        }
    }, "display", "add");
    inputManager.addMapping("display", new KeyTrigger(KeyInput.KEY_SPACE));
    inputManager.addMapping("add", new KeyTrigger(KeyInput.KEY_RETURN));
}
Also used : Quaternion(com.jme3.math.Quaternion) KeyTrigger(com.jme3.input.controls.KeyTrigger) Box(com.jme3.scene.shape.Box) Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) ActionListener(com.jme3.input.controls.ActionListener) Vector2f(com.jme3.math.Vector2f) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) DirectionalLightShadowRenderer(com.jme3.shadow.DirectionalLightShadowRenderer) AmbientLight(com.jme3.light.AmbientLight)

Example 29 with Quaternion

use of com.jme3.math.Quaternion in project jmonkeyengine by jMonkeyEngine.

the class TestSimpleLighting method simpleInitApp.

@Override
public void simpleInitApp() {
    Geometry teapot = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
    TangentBinormalGenerator.generate(teapot.getMesh(), true);
    teapot.setLocalScale(2f);
    Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    //        mat.selectTechnique("GBuf");
    mat.setFloat("Shininess", 25);
    mat.setBoolean("UseMaterialColors", true);
    cam.setLocation(new Vector3f(0.015041917f, 0.4572918f, 5.2874837f));
    cam.setRotation(new Quaternion(-1.8875003E-4f, 0.99882424f, 0.04832061f, 0.0039016632f));
    //        mat.setTexture("ColorRamp", assetManager.loadTexture("Textures/ColorRamp/cloudy.png"));
    //
    //        mat.setBoolean("VTangent", true);
    //        mat.setBoolean("Minnaert", true);
    //        mat.setBoolean("WardIso", true);
    //        mat.setBoolean("VertexLighting", true);
    //        mat.setBoolean("LowQuality", true);
    //        mat.setBoolean("HighQuality", true);
    mat.setColor("Ambient", ColorRGBA.Black);
    mat.setColor("Diffuse", ColorRGBA.Gray);
    mat.setColor("Specular", ColorRGBA.Gray);
    teapot.setMaterial(mat);
    rootNode.attachChild(teapot);
    lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    lightMdl.getMesh().setStatic();
    rootNode.attachChild(lightMdl);
    pl = new PointLight();
    pl.setColor(ColorRGBA.White);
    pl.setRadius(4f);
    rootNode.addLight(pl);
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    dl.setColor(ColorRGBA.Green);
    rootNode.addLight(dl);
    MaterialDebugAppState debug = new MaterialDebugAppState();
    debug.registerBinding("Common/ShaderLib/BlinnPhongLighting.glsllib", teapot);
    stateManager.attach(debug);
    setPauseOnLostFocus(false);
    flyCam.setDragToRotate(true);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) Quaternion(com.jme3.math.Quaternion) MaterialDebugAppState(com.jme3.util.MaterialDebugAppState) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) Material(com.jme3.material.Material) PointLight(com.jme3.light.PointLight)

Example 30 with Quaternion

use of com.jme3.math.Quaternion in project jmonkeyengine by jMonkeyEngine.

the class TestSpotLightTerrain method simpleInitApp.

@Override
public void simpleInitApp() {
    makeTerrain();
    flyCam.setMoveSpeed(50);
    sl = new SpotLight();
    sl.setSpotRange(100);
    sl.setSpotOuterAngle(20 * FastMath.DEG_TO_RAD);
    sl.setSpotInnerAngle(15 * FastMath.DEG_TO_RAD);
    sl.setDirection(new Vector3f(-0.39820394f, -0.73094344f, 0.55421597f));
    sl.setPosition(new Vector3f(-64.61567f, -87.615425f, -202.41328f));
    rootNode.addLight(sl);
    AmbientLight ambLight = new AmbientLight();
    ambLight.setColor(ColorRGBA.Black);
    rootNode.addLight(ambLight);
    cam.setLocation(new Vector3f(-41.219646f, 0.8363f, -171.67267f));
    cam.setRotation(new Quaternion(-0.04562731f, 0.89917684f, -0.09668826f, -0.4243236f));
    sl.setDirection(cam.getDirection());
    sl.setPosition(cam.getLocation());
}
Also used : Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) SpotLight(com.jme3.light.SpotLight) AmbientLight(com.jme3.light.AmbientLight)

Aggregations

Quaternion (com.jme3.math.Quaternion)115 Vector3f (com.jme3.math.Vector3f)100 Geometry (com.jme3.scene.Geometry)42 DirectionalLight (com.jme3.light.DirectionalLight)37 Material (com.jme3.material.Material)36 Node (com.jme3.scene.Node)30 FilterPostProcessor (com.jme3.post.FilterPostProcessor)26 Spatial (com.jme3.scene.Spatial)26 KeyTrigger (com.jme3.input.controls.KeyTrigger)22 Box (com.jme3.scene.shape.Box)21 TempVars (com.jme3.util.TempVars)16 ActionListener (com.jme3.input.controls.ActionListener)15 ColorRGBA (com.jme3.math.ColorRGBA)15 Quad (com.jme3.scene.shape.Quad)15 AmbientLight (com.jme3.light.AmbientLight)14 Sphere (com.jme3.scene.shape.Sphere)11 Bone (com.jme3.animation.Bone)9 PointLight (com.jme3.light.PointLight)8 AnimControl (com.jme3.animation.AnimControl)7 SpotLight (com.jme3.light.SpotLight)7