Search in sources :

Example 26 with Material

use of com.jme3.material.Material in project jmonkeyengine by jMonkeyEngine.

the class TestLightScattering method simpleInitApp.

@Override
public void simpleInitApp() {
    // put the camera in a bad position
    cam.setLocation(new Vector3f(55.35316f, -0.27061665f, 27.092093f));
    cam.setRotation(new Quaternion(0.010414706f, 0.9874893f, 0.13880467f, -0.07409228f));
    //        cam.setDirection(new Vector3f(0,-0.5f,1.0f));
    //        cam.setLocation(new Vector3f(0, 300, -500));
    //cam.setFrustumFar(1000);
    flyCam.setMoveSpeed(10);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Rocky/Rocky.j3m");
    Spatial scene = assetManager.loadModel("Models/Terrain/Terrain.mesh.xml");
    TangentBinormalGenerator.generate(((Geometry) ((Node) scene).getChild(0)).getMesh());
    scene.setMaterial(mat);
    scene.setShadowMode(ShadowMode.CastAndReceive);
    scene.setLocalScale(400);
    scene.setLocalTranslation(0, -10, -120);
    rootNode.attachChild(scene);
    // load sky
    rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/FullskiesBlueClear03.dds", false));
    DirectionalLight sun = new DirectionalLight();
    Vector3f lightDir = new Vector3f(-0.12f, -0.3729129f, 0.74847335f);
    sun.setDirection(lightDir);
    sun.setColor(ColorRGBA.White.clone().multLocal(2));
    scene.addLight(sun);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    int numSamples = getContext().getSettings().getSamples();
    if (numSamples > 0) {
        fpp.setNumSamples(numSamples);
    }
    Vector3f lightPos = lightDir.multLocal(-3000);
    LightScatteringFilter filter = new LightScatteringFilter(lightPos);
    LightScatteringUI ui = new LightScatteringUI(inputManager, filter);
    fpp.addFilter(filter);
    viewPort.addProcessor(fpp);
}
Also used : LightScatteringFilter(com.jme3.post.filters.LightScatteringFilter) Quaternion(com.jme3.math.Quaternion) Spatial(com.jme3.scene.Spatial) Vector3f(com.jme3.math.Vector3f) Node(com.jme3.scene.Node) DirectionalLight(com.jme3.light.DirectionalLight) Material(com.jme3.material.Material) FilterPostProcessor(com.jme3.post.FilterPostProcessor)

Example 27 with Material

use of com.jme3.material.Material in project jmonkeyengine by jMonkeyEngine.

the class TestOgreComplexAnim method simpleInitApp.

@Override
public void simpleInitApp() {
    flyCam.setMoveSpeed(10f);
    cam.setLocation(new Vector3f(6.4013605f, 7.488437f, 12.843031f));
    cam.setRotation(new Quaternion(-0.060740203f, 0.93925786f, -0.2398315f, -0.2378785f));
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal());
    dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
    rootNode.addLight(dl);
    Node model = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
    control = model.getControl(AnimControl.class);
    AnimChannel feet = control.createChannel();
    AnimChannel leftHand = control.createChannel();
    AnimChannel rightHand = control.createChannel();
    // feet will dodge
    feet.addFromRootBone("hip.right");
    feet.addFromRootBone("hip.left");
    feet.setAnim("Dodge");
    feet.setSpeed(2);
    feet.setLoopMode(LoopMode.Cycle);
    // will blend over 15 seconds to stand
    feet.setAnim("Walk", 15);
    feet.setSpeed(0.25f);
    feet.setLoopMode(LoopMode.Cycle);
    // left hand will pull
    leftHand.addFromRootBone("uparm.right");
    leftHand.setAnim("pull");
    leftHand.setSpeed(.5f);
    // will blend over 15 seconds to stand
    leftHand.setAnim("stand", 15);
    // right hand will push
    rightHand.addBone("spinehigh");
    rightHand.addFromRootBone("uparm.left");
    rightHand.setAnim("push");
    SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton", control.getSkeleton());
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.getAdditionalRenderState().setWireframe(true);
    mat.setColor("Color", ColorRGBA.Green);
    mat.getAdditionalRenderState().setDepthTest(false);
    skeletonDebug.setMaterial(mat);
    model.attachChild(skeletonDebug);
    rootNode.attachChild(model);
}
Also used : SkeletonDebugger(com.jme3.scene.debug.SkeletonDebugger) ColorRGBA(com.jme3.math.ColorRGBA) Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) Node(com.jme3.scene.Node) AnimChannel(com.jme3.animation.AnimChannel) Material(com.jme3.material.Material) AnimControl(com.jme3.animation.AnimControl)

Example 28 with Material

use of com.jme3.material.Material in project jmonkeyengine by jMonkeyEngine.

the class TestSkeletonControlRefresh method setupFloor.

public void setupFloor() {
    Quad q = new Quad(20, 20);
    q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(10));
    Geometry geom = new Geometry("floor", q);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.White);
    geom.setMaterial(mat);
    geom.rotate(-FastMath.HALF_PI, 0, 0);
    geom.center();
    geom.move(0, -0.3f, 0);
    geom.setShadowMode(RenderQueue.ShadowMode.Receive);
    rootNode.attachChild(geom);
}
Also used : Geometry(com.jme3.scene.Geometry) Quad(com.jme3.scene.shape.Quad) Material(com.jme3.material.Material)

Example 29 with Material

use of com.jme3.material.Material in project jmonkeyengine by jMonkeyEngine.

the class TestBillboard method simpleInitApp.

public void simpleInitApp() {
    flyCam.setMoveSpeed(10);
    Quad q = new Quad(2, 2);
    Geometry g = new Geometry("Quad", q);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.Blue);
    g.setMaterial(mat);
    Quad q2 = new Quad(1, 1);
    Geometry g3 = new Geometry("Quad2", q2);
    Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat2.setColor("Color", ColorRGBA.Yellow);
    g3.setMaterial(mat2);
    g3.setLocalTranslation(.5f, .5f, .01f);
    Box b = new Box(.25f, .5f, .25f);
    Geometry g2 = new Geometry("Box", b);
    g2.setLocalTranslation(0, 0, 3);
    g2.setMaterial(mat);
    Node bb = new Node("billboard");
    BillboardControl control = new BillboardControl();
    bb.addControl(control);
    bb.attachChild(g);
    bb.attachChild(g3);
    n = new Node("parent");
    n.attachChild(g2);
    n.attachChild(bb);
    rootNode.attachChild(n);
    n2 = new Node("parentParent");
    n2.setLocalTranslation(Vector3f.UNIT_X.mult(5));
    n2.attachChild(n);
    rootNode.attachChild(n2);
//        rootNode.attachChild(bb);
//        rootNode.attachChild(g2);
}
Also used : Geometry(com.jme3.scene.Geometry) Quad(com.jme3.scene.shape.Quad) BillboardControl(com.jme3.scene.control.BillboardControl) Node(com.jme3.scene.Node) Material(com.jme3.material.Material) Box(com.jme3.scene.shape.Box)

Example 30 with Material

use of com.jme3.material.Material in project jmonkeyengine by jMonkeyEngine.

the class TestBox method simpleInitApp.

@Override
public void simpleInitApp() {
    Box b = new Box(1, 1, 1);
    Geometry geom = new Geometry("Box", b);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
    geom.setMaterial(mat);
    rootNode.attachChild(geom);
}
Also used : Geometry(com.jme3.scene.Geometry) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material)

Aggregations

Material (com.jme3.material.Material)285 Geometry (com.jme3.scene.Geometry)165 Vector3f (com.jme3.math.Vector3f)110 Box (com.jme3.scene.shape.Box)79 Texture (com.jme3.texture.Texture)69 DirectionalLight (com.jme3.light.DirectionalLight)49 Sphere (com.jme3.scene.shape.Sphere)43 Node (com.jme3.scene.Node)39 ColorRGBA (com.jme3.math.ColorRGBA)38 Spatial (com.jme3.scene.Spatial)35 Quaternion (com.jme3.math.Quaternion)31 Quad (com.jme3.scene.shape.Quad)26 Texture2D (com.jme3.texture.Texture2D)21 KeyTrigger (com.jme3.input.controls.KeyTrigger)20 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)19 ArrayList (java.util.ArrayList)19 TerrainQuad (com.jme3.terrain.geomipmap.TerrainQuad)18 TextureKey (com.jme3.asset.TextureKey)17 ParticleEmitter (com.jme3.effect.ParticleEmitter)17 AmbientLight (com.jme3.light.AmbientLight)16