Search in sources :

Example 51 with Geometry

use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.

the class TestEnvironmentMapping method simpleInitApp.

@Override
public void simpleInitApp() {
    final Node buggy = (Node) assetManager.loadModel("Models/Buggy/Buggy.j3o");
    TextureKey key = new TextureKey("Textures/Sky/Bright/BrightSky.dds", true);
    key.setGenerateMips(true);
    key.setTextureTypeHint(Texture.Type.CubeMap);
    final Texture tex = assetManager.loadTexture(key);
    for (Spatial geom : buggy.getChildren()) {
        if (geom instanceof Geometry) {
            Material m = ((Geometry) geom).getMaterial();
            m.setTexture("EnvMap", tex);
            m.setVector3("FresnelParams", new Vector3f(0.05f, 0.18f, 0.11f));
        }
    }
    flyCam.setEnabled(false);
    ChaseCamera chaseCam = new ChaseCamera(cam, inputManager);
    chaseCam.setLookAtOffset(new Vector3f(0, 0.5f, -1.0f));
    buggy.addControl(chaseCam);
    rootNode.attachChild(buggy);
    rootNode.attachChild(SkyFactory.createSky(assetManager, tex, false));
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    BloomFilter bf = new BloomFilter(BloomFilter.GlowMode.Objects);
    bf.setBloomIntensity(2.3f);
    bf.setExposurePower(0.6f);
    fpp.addFilter(bf);
    DirectionalLight l = new DirectionalLight();
    l.setDirection(new Vector3f(0, -1, -1));
    rootNode.addLight(l);
    viewPort.addProcessor(fpp);
}
Also used : Geometry(com.jme3.scene.Geometry) TextureKey(com.jme3.asset.TextureKey) Spatial(com.jme3.scene.Spatial) Node(com.jme3.scene.Node) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) ChaseCamera(com.jme3.input.ChaseCamera) Material(com.jme3.material.Material) FilterPostProcessor(com.jme3.post.FilterPostProcessor) Texture(com.jme3.texture.Texture) BloomFilter(com.jme3.post.filters.BloomFilter)

Example 52 with Geometry

use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.

the class TestLightNode method simpleInitApp.

@Override
public void simpleInitApp() {
    Torus torus = new Torus(10, 6, 1, 3);
    //        Torus torus = new Torus(50, 30, 1, 3);
    Geometry g = new Geometry("Torus Geom", torus);
    g.rotate(-FastMath.HALF_PI, 0, 0);
    g.center();
    //        g.move(0, 1, 0);
    Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat.setFloat("Shininess", 32f);
    mat.setBoolean("UseMaterialColors", true);
    mat.setColor("Ambient", ColorRGBA.Black);
    mat.setColor("Diffuse", ColorRGBA.White);
    mat.setColor("Specular", ColorRGBA.White);
    //        mat.setBoolean("VertexLighting", true);
    //        mat.setBoolean("LowQuality", true);
    g.setMaterial(mat);
    rootNode.attachChild(g);
    Geometry lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    movingNode = new Node("lightParentNode");
    movingNode.attachChild(lightMdl);
    rootNode.attachChild(movingNode);
    PointLight pl = new PointLight();
    pl.setColor(ColorRGBA.Green);
    pl.setRadius(4f);
    rootNode.addLight(pl);
    LightNode lightNode = new LightNode("pointLight", pl);
    movingNode.attachChild(lightNode);
    DirectionalLight dl = new DirectionalLight();
    dl.setColor(ColorRGBA.Red);
    dl.setDirection(new Vector3f(0, 1, 0));
    rootNode.addLight(dl);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) LightNode(com.jme3.scene.LightNode) Torus(com.jme3.scene.shape.Torus) Node(com.jme3.scene.Node) LightNode(com.jme3.scene.LightNode) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material) PointLight(com.jme3.light.PointLight)

Example 53 with Geometry

use of com.jme3.scene.Geometry 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 54 with Geometry

use of com.jme3.scene.Geometry 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 55 with Geometry

use of com.jme3.scene.Geometry in project jmonkeyengine by jMonkeyEngine.

the class TestSpotLightShadows method setupFloor.

public void setupFloor() {
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.setBoolean("UseMaterialColors", true);
    mat.setColor("Diffuse", ColorRGBA.White.clone());
    mat.setColor("Ambient", ColorRGBA.White.clone());
    // mat.setColor("Specular", ColorRGBA.White.clone());
    // mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.setFloat("Shininess", 0);
    //  mat.setBoolean("VertexLighting", true);
    Box floor = new Box(50, 1f, 50);
    TangentBinormalGenerator.generate(floor);
    floor.scaleTextureCoordinates(new Vector2f(5, 5));
    Geometry floorGeom = new Geometry("Floor", floor);
    floorGeom.setMaterial(mat);
    floorGeom.setShadowMode(ShadowMode.Receive);
    rootNode.attachChild(floorGeom);
}
Also used : Geometry(com.jme3.scene.Geometry) Material(com.jme3.material.Material) Box(com.jme3.scene.shape.Box)

Aggregations

Geometry (com.jme3.scene.Geometry)246 Material (com.jme3.material.Material)175 Vector3f (com.jme3.math.Vector3f)116 Box (com.jme3.scene.shape.Box)92 DirectionalLight (com.jme3.light.DirectionalLight)56 Node (com.jme3.scene.Node)54 Sphere (com.jme3.scene.shape.Sphere)49 Spatial (com.jme3.scene.Spatial)41 Quaternion (com.jme3.math.Quaternion)39 Quad (com.jme3.scene.shape.Quad)33 Texture (com.jme3.texture.Texture)30 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)26 Mesh (com.jme3.scene.Mesh)25 KeyTrigger (com.jme3.input.controls.KeyTrigger)24 AmbientLight (com.jme3.light.AmbientLight)24 ColorRGBA (com.jme3.math.ColorRGBA)21 FilterPostProcessor (com.jme3.post.FilterPostProcessor)21 PointLight (com.jme3.light.PointLight)20 Vector2f (com.jme3.math.Vector2f)17 FloatBuffer (java.nio.FloatBuffer)17