Search in sources :

Example 86 with Vector2f

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

the class TestPbrEnv method loadScene.

public void loadScene() {
    renderManager.setPreferredLightMode(TechniqueDef.LightMode.SinglePass);
    renderManager.setSinglePassLightBatchSize(3);
    obj = new Spatial[2];
    // Setup first view
    mat = new Material[2];
    mat[0] = assetManager.loadMaterial("jme3test/light/pbr/pbrMat.j3m");
    //mat[1] = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat[1] = assetManager.loadMaterial("jme3test/light/pbr/pbrMat2.j3m");
    //        mat[1].setBoolean("UseMaterialColors", true);
    //        mat[1].setColor("Ambient", ColorRGBA.White.mult(0.5f));
    //        mat[1].setColor("Diffuse", ColorRGBA.White.clone());
    obj[0] = new Geometry("sphere", new Sphere(30, 30, 2));
    obj[0].setShadowMode(ShadowMode.CastAndReceive);
    obj[1] = new Geometry("cube", new Box(1.0f, 1.0f, 1.0f));
    obj[1].setShadowMode(ShadowMode.CastAndReceive);
    TangentBinormalGenerator.generate(obj[1]);
    TangentBinormalGenerator.generate(obj[0]);
    for (int i = 0; i < 2; i++) {
        Spatial t = obj[0].clone(false);
        t.setName("Cube" + i);
        t.setLocalScale(10f);
        t.setMaterial(mat[1].clone());
        rootNode.attachChild(t);
        t.setLocalTranslation(i * 200f + 100f, 50, 800f * (i));
    }
    Box b = new Box(1000, 2, 1000);
    b.scaleTextureCoordinates(new Vector2f(20, 20));
    ground = new Geometry("soil", b);
    TangentBinormalGenerator.generate(ground);
    ground.setLocalTranslation(0, 10, 550);
    matGroundU = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    matGroundU.setColor("Color", ColorRGBA.Green);
    //        matGroundL = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    //        Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
    //        grass.setWrap(WrapMode.Repeat);
    //        matGroundL.setTexture("DiffuseMap", grass);
    matGroundL = assetManager.loadMaterial("jme3test/light/pbr/pbrMat4.j3m");
    ground.setMaterial(matGroundL);
    //ground.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(ground);
    l = new DirectionalLight();
    l.setColor(ColorRGBA.White);
    //l.setDirection(new Vector3f(0.5973172f, -0.16583486f, 0.7846725f).normalizeLocal());
    l.setDirection(new Vector3f(-0.2823181f, -0.41889593f, 0.863031f).normalizeLocal());
    rootNode.addLight(l);
    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(0.5f));
    //  rootNode.addLight(al);
    //Spatial sky = SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", SkyFactory.EnvMapType.CubeMap);
    Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Path.hdr", SkyFactory.EnvMapType.EquirectMap);
    sky.setLocalScale(350);
    rootNode.attachChild(sky);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) BoundingSphere(com.jme3.bounding.BoundingSphere) Spatial(com.jme3.scene.Spatial) Vector2f(com.jme3.math.Vector2f) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) AmbientLight(com.jme3.light.AmbientLight)

Example 87 with Vector2f

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

the class TestSSAO method simpleInitApp.

@Override
public void simpleInitApp() {
    cam.setLocation(new Vector3f(68.45442f, 8.235511f, 7.9676695f));
    cam.setRotation(new Quaternion(0.046916496f, -0.69500375f, 0.045538206f, 0.7160271f));
    flyCam.setMoveSpeed(50);
    Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Texture diff = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg");
    diff.setWrap(Texture.WrapMode.Repeat);
    Texture norm = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall_normal.jpg");
    norm.setWrap(Texture.WrapMode.Repeat);
    mat.setTexture("DiffuseMap", diff);
    mat.setTexture("NormalMap", norm);
    mat.setFloat("Shininess", 2.0f);
    AmbientLight al = new AmbientLight();
    al.setColor(new ColorRGBA(1.8f, 1.8f, 1.8f, 1.0f));
    rootNode.addLight(al);
    model = (Geometry) assetManager.loadModel("Models/Sponza/Sponza.j3o");
    model.getMesh().scaleTextureCoordinates(new Vector2f(2, 2));
    model.setMaterial(mat);
    rootNode.attachChild(model);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    SSAOFilter ssaoFilter = new SSAOFilter(2.9299974f, 32.920483f, 5.8100376f, 0.091000035f);
    ;
    ssaoFilter.setApproximateNormals(true);
    fpp.addFilter(ssaoFilter);
    SSAOUI ui = new SSAOUI(inputManager, ssaoFilter);
    viewPort.addProcessor(fpp);
}
Also used : SSAOFilter(com.jme3.post.ssao.SSAOFilter) ColorRGBA(com.jme3.math.ColorRGBA) Quaternion(com.jme3.math.Quaternion) Vector2f(com.jme3.math.Vector2f) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material) FilterPostProcessor(com.jme3.post.FilterPostProcessor) Texture(com.jme3.texture.Texture) AmbientLight(com.jme3.light.AmbientLight)

Example 88 with Vector2f

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

the class TestDepthOfField method simpleUpdate.

@Override
public void simpleUpdate(float tpf) {
    Vector3f origin = cam.getWorldCoordinates(new Vector2f(settings.getWidth() / 2, settings.getHeight() / 2), 0.0f);
    Vector3f direction = cam.getWorldCoordinates(new Vector2f(settings.getWidth() / 2, settings.getHeight() / 2), 0.3f);
    direction.subtractLocal(origin).normalizeLocal();
    Ray ray = new Ray(origin, direction);
    CollisionResults results = new CollisionResults();
    int numCollisions = terrain.collideWith(ray, results);
    if (numCollisions > 0) {
        CollisionResult hit = results.getClosestCollision();
        fpsText.setText("" + hit.getDistance());
        dofFilter.setFocusDistance(hit.getDistance() / 10.0f);
    }
}
Also used : CollisionResult(com.jme3.collision.CollisionResult) CollisionResults(com.jme3.collision.CollisionResults)

Example 89 with Vector2f

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

the class TestParallax method setupFloor.

public void setupFloor() {
    mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m");
    Node floorGeom = new Node("floorGeom");
    Quad q = new Quad(100, 100);
    q.scaleTextureCoordinates(new Vector2f(10, 10));
    Geometry g = new Geometry("geom", q);
    g.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
    floorGeom.attachChild(g);
    TangentBinormalGenerator.generate(floorGeom);
    floorGeom.setLocalTranslation(-50, 22, 60);
    //floorGeom.setLocalScale(100);
    floorGeom.setMaterial(mat);
    rootNode.attachChild(floorGeom);
}
Also used : Geometry(com.jme3.scene.Geometry) Quad(com.jme3.scene.shape.Quad) Node(com.jme3.scene.Node)

Example 90 with Vector2f

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

the class TestParallaxPBR method setupFloor.

public void setupFloor() {
    mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWallPBR.j3m");
    //mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWallPBR2.j3m");
    Node floorGeom = new Node("floorGeom");
    Quad q = new Quad(100, 100);
    q.scaleTextureCoordinates(new Vector2f(10, 10));
    Geometry g = new Geometry("geom", q);
    g.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
    floorGeom.attachChild(g);
    TangentBinormalGenerator.generate(floorGeom);
    floorGeom.setLocalTranslation(-50, 22, 60);
    //floorGeom.setLocalScale(100);
    floorGeom.setMaterial(mat);
    rootNode.attachChild(floorGeom);
}
Also used : Geometry(com.jme3.scene.Geometry) Quad(com.jme3.scene.shape.Quad) Node(com.jme3.scene.Node)

Aggregations

Vector2f (com.jme3.math.Vector2f)80 Vector3f (com.jme3.math.Vector3f)38 Geometry (com.jme3.scene.Geometry)22 Material (com.jme3.material.Material)20 Box (com.jme3.scene.shape.Box)17 ArrayList (java.util.ArrayList)14 Texture (com.jme3.texture.Texture)9 List (java.util.List)9 Node (com.jme3.scene.Node)8 Sphere (com.jme3.scene.shape.Sphere)8 FloatBuffer (java.nio.FloatBuffer)8 InputCapsule (com.jme3.export.InputCapsule)7 Spatial (com.jme3.scene.Spatial)7 DirectionalLight (com.jme3.light.DirectionalLight)6 Mesh (com.jme3.scene.Mesh)6 AmbientLight (com.jme3.light.AmbientLight)5 Quad (com.jme3.scene.shape.Quad)5 BoundingBox (com.jme3.bounding.BoundingBox)4 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)4 CollisionResult (com.jme3.collision.CollisionResult)4