Search in sources :

Example 81 with Vector2f

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

the class TestPssmShadow method loadScene.

public void loadScene() {
    obj = new Spatial[2];
    mat = new Material[2];
    mat[0] = assetManager.loadMaterial("Common/Materials/RedColor.j3m");
    mat[1] = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.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 < 60; i++) {
        Spatial t = obj[FastMath.nextRandomInt(0, obj.length - 1)].clone(false);
        t.setLocalScale(FastMath.nextRandomFloat() * 10f);
        t.setMaterial(mat[FastMath.nextRandomInt(0, mat.length - 1)]);
        rootNode.attachChild(t);
        t.setLocalTranslation(FastMath.nextRandomFloat() * 200f, FastMath.nextRandomFloat() * 30f + 20, 30f * (i + 2f));
    }
    Box b = new Box(1000, 2, 1000);
    b.scaleTextureCoordinates(new Vector2f(10, 10));
    ground = new Geometry("soil", b);
    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);
    ground.setMaterial(matGroundL);
    ground.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(ground);
    l = new DirectionalLight();
    l.setDirection(new Vector3f(-1, -1, -1));
    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", false);
    sky.setLocalScale(350);
    rootNode.attachChild(sky);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) 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) Texture(com.jme3.texture.Texture) AmbientLight(com.jme3.light.AmbientLight)

Example 82 with Vector2f

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

the class TestShadowBug method makeFloor.

protected Geometry makeFloor() {
    Box box = new Box(220, .2f, 220);
    box.scaleTextureCoordinates(new Vector2f(10, 10));
    Geometry floor = new Geometry("the Floor", box);
    floor.setLocalTranslation(200, -9, 200);
    Material 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);
    floor.setMaterial(matGroundL);
    floor.setShadowMode(ShadowMode.CastAndReceive);
    return floor;
}
Also used : Geometry(com.jme3.scene.Geometry) Vector2f(com.jme3.math.Vector2f) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) Texture(com.jme3.texture.Texture)

Example 83 with Vector2f

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

the class TestSpotLight 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.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.setFloat("Shininess", 3);
    //  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)

Example 84 with Vector2f

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

the class TestJoystick method pick.

private static CollisionResults pick(Camera cam, Vector2f mouseLoc, Node node) {
    CollisionResults results = new CollisionResults();
    Ray ray = new Ray();
    Vector3f pos = new Vector3f(mouseLoc.x, mouseLoc.y, -1);
    Vector3f dir = new Vector3f(mouseLoc.x, mouseLoc.y, 1);
    dir.subtractLocal(pos).normalizeLocal();
    ray.setOrigin(pos);
    ray.setDirection(dir);
    node.collideWith(ray, results);
    return results;
}
Also used : CollisionResults(com.jme3.collision.CollisionResults) Vector3f(com.jme3.math.Vector3f) Ray(com.jme3.math.Ray)

Example 85 with Vector2f

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

the class TestJoystick method pickGamePad.

private void pickGamePad(Vector2f mouseLoc) {
    if (lastButton != null) {
        CollisionResults cresults = pick(cam, mouseLoc, gamepad);
        for (CollisionResult cr : cresults) {
            Node n = cr.getGeometry().getParent();
            if (n != null && (n instanceof ButtonView)) {
                String b = ((ButtonView) n).getName().substring("Button:".length());
                String name = lastButton.getJoystick().getName().replaceAll(" ", "\\\\ ");
                String id = lastButton.getLogicalId().replaceAll(" ", "\\\\ ");
                System.out.println(name + "." + id + "=" + b);
                return;
            }
        }
    }
}
Also used : CollisionResult(com.jme3.collision.CollisionResult) CollisionResults(com.jme3.collision.CollisionResults) 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