Search in sources :

Example 36 with Material

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

the class TestSphere method simpleInitApp.

@Override
public void simpleInitApp() {
    Sphere sphMesh = new Sphere(14, 14, 1);
    Material solidColor = assetManager.loadMaterial("Common/Materials/RedColor.j3m");
    for (int y = -5; y < 5; y++) {
        for (int x = -5; x < 5; x++) {
            Geometry sphere = new Geometry("sphere", sphMesh);
            sphere.setMaterial(solidColor);
            sphere.setLocalTranslation(x * 2, 0, y * 2);
            rootNode.attachChild(sphere);
        }
    }
    cam.setLocation(new Vector3f(0, 5, 0));
    cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
}
Also used : Sphere(com.jme3.scene.shape.Sphere) Geometry(com.jme3.scene.Geometry) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material)

Example 37 with Material

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

the class TestToneMapFilter method createHDRBox.

public Geometry createHDRBox() {
    Box boxMesh = new Box(1, 1, 1);
    Geometry box = new Geometry("Box", boxMesh);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setTexture("ColorMap", assetManager.loadTexture("Textures/HdrTest/Memorial.hdr"));
    box.setMaterial(mat);
    return box;
}
Also used : Geometry(com.jme3.scene.Geometry) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material)

Example 38 with Material

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

the class TestTransparentCartoonEdge method simpleInitApp.

public void simpleInitApp() {
    renderManager.setAlphaToCoverage(true);
    cam.setLocation(new Vector3f(0.14914267f, 0.58147097f, 4.7686534f));
    cam.setRotation(new Quaternion(-0.0044764364f, 0.9767943f, 0.21314798f, 0.020512417f));
    //        cam.setLocation(new Vector3f(2.0606942f, 3.20342f, 6.7860126f));
    //        cam.setRotation(new Quaternion(-0.017481906f, 0.98241085f, -0.12393151f, -0.13857932f));
    viewPort.setBackgroundColor(ColorRGBA.DarkGray);
    Quad q = new Quad(20, 20);
    q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(5));
    Geometry geom = new Geometry("floor", q);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    geom.setMaterial(mat);
    geom.rotate(-FastMath.HALF_PI, 0, 0);
    geom.center();
    geom.setShadowMode(ShadowMode.Receive);
    rootNode.attachChild(geom);
    // create the geometry and attach it
    Spatial teaGeom = assetManager.loadModel("Models/Tree/Tree.mesh.j3o");
    teaGeom.setQueueBucket(Bucket.Transparent);
    teaGeom.setShadowMode(ShadowMode.Cast);
    makeToonish(teaGeom);
    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(2));
    rootNode.addLight(al);
    DirectionalLight dl1 = new DirectionalLight();
    dl1.setDirection(new Vector3f(1, -1, 1).normalizeLocal());
    dl1.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f));
    rootNode.addLight(dl1);
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    dl.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f));
    rootNode.addLight(dl);
    rootNode.attachChild(teaGeom);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    CartoonEdgeFilter toon = new CartoonEdgeFilter();
    toon.setEdgeWidth(0.5f);
    toon.setEdgeIntensity(1.0f);
    toon.setNormalThreshold(0.8f);
    fpp.addFilter(toon);
    viewPort.addProcessor(fpp);
}
Also used : Geometry(com.jme3.scene.Geometry) Quad(com.jme3.scene.shape.Quad) Spatial(com.jme3.scene.Spatial) DirectionalLight(com.jme3.light.DirectionalLight) Material(com.jme3.material.Material) FilterPostProcessor(com.jme3.post.FilterPostProcessor) AmbientLight(com.jme3.light.AmbientLight) CartoonEdgeFilter(com.jme3.post.filters.CartoonEdgeFilter)

Example 39 with Material

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

the class TestSimpleBumps method simpleInitApp.

@Override
public void simpleInitApp() {
    Quad quadMesh = new Quad(1, 1);
    Geometry sphere = new Geometry("Rock Ball", quadMesh);
    Material mat = assetManager.loadMaterial("Textures/BumpMapTest/SimpleBump.j3m");
    sphere.setMaterial(mat);
    TangentBinormalGenerator.generate(sphere);
    rootNode.attachChild(sphere);
    lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    rootNode.attachChild(lightMdl);
    pl = new PointLight();
    pl.setColor(ColorRGBA.White);
    pl.setPosition(new Vector3f(0f, 0f, 4f));
    rootNode.addLight(pl);
//        DirectionalLight dl = new DirectionalLight();
//        dl.setDirection(new Vector3f(1, -1, -1).normalizeLocal());
//        dl.setColor(new ColorRGBA(0.22f, 0.15f, 0.1f, 1.0f));
//        rootNode.addLight(dl);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) Quad(com.jme3.scene.shape.Quad) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material) PointLight(com.jme3.light.PointLight)

Example 40 with Material

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

the class TestTessellationShader method simpleInitApp.

@Override
public void simpleInitApp() {
    tessellationMaterial = new Material(getAssetManager(), "Materials/Tess/SimpleTess.j3md");
    tessellationMaterial.setInt("TessellationFactor", tessFactor);
    tessellationMaterial.getAdditionalRenderState().setWireframe(true);
    Quad quad = new Quad(10, 10);
    quad.clearBuffer(VertexBuffer.Type.Index);
    quad.setBuffer(VertexBuffer.Type.Index, 4, BufferUtils.createIntBuffer(0, 1, 2, 3));
    quad.setMode(Mesh.Mode.Patch);
    quad.setPatchVertexCount(4);
    Geometry geometry = new Geometry("tessTest", quad);
    geometry.setMaterial(tessellationMaterial);
    rootNode.attachChild(geometry);
    getInputManager().addMapping("TessUp", new KeyTrigger(KeyInput.KEY_O));
    getInputManager().addMapping("TessDo", new KeyTrigger(KeyInput.KEY_L));
    getInputManager().addListener(new AnalogListener() {

        @Override
        public void onAnalog(String name, float value, float tpf) {
            if (name.equals("TessUp")) {
                tessFactor++;
                enqueue(new Callable<Boolean>() {

                    @Override
                    public Boolean call() throws Exception {
                        tessellationMaterial.setInt("TessellationFactor", tessFactor);
                        return true;
                    }
                });
            }
            if (name.equals("TessDo")) {
                tessFactor--;
                enqueue(new Callable<Boolean>() {

                    @Override
                    public Boolean call() throws Exception {
                        tessellationMaterial.setInt("TessellationFactor", tessFactor);
                        return true;
                    }
                });
            }
        }
    }, "TessUp", "TessDo");
}
Also used : Geometry(com.jme3.scene.Geometry) Quad(com.jme3.scene.shape.Quad) KeyTrigger(com.jme3.input.controls.KeyTrigger) Material(com.jme3.material.Material) AnalogListener(com.jme3.input.controls.AnalogListener) Callable(java.util.concurrent.Callable)

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