Search in sources :

Example 26 with Quad

use of com.jme3.scene.shape.Quad 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 27 with Quad

use of com.jme3.scene.shape.Quad 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 28 with Quad

use of com.jme3.scene.shape.Quad 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)

Example 29 with Quad

use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.

the class DetailedProfilerState method initialize.

@Override
protected void initialize(Application app) {
    Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f));
    mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
    Geometry darkenStats = new Geometry("StatsDarken", new Quad(PANEL_WIDTH, app.getCamera().getHeight()));
    darkenStats.setMaterial(mat);
    darkenStats.setLocalTranslation(0, -app.getCamera().getHeight(), -1);
    ui.attachChild(darkenStats);
    ui.setLocalTranslation(app.getCamera().getWidth() - PANEL_WIDTH, app.getCamera().getHeight(), 0);
    font = app.getAssetManager().loadFont("Interface/Fonts/Console.fnt");
    bigFont = app.getAssetManager().loadFont("Interface/Fonts/Default.fnt");
    prof.setRenderer(app.getRenderer());
    rootLine = new StatLineView("Frame");
    rootLine.attachTo(ui);
    BitmapText frameLabel = new BitmapText(bigFont);
    frameLabel.setText("Total Frame Time: ");
    ui.attachChild(frameLabel);
    frameLabel.setLocalTranslation(new Vector3f(PANEL_WIDTH / 2 - bigFont.getLineWidth(frameLabel.getText()), -PADDING, 0));
    BitmapText cpuLabel = new BitmapText(bigFont);
    cpuLabel.setText("CPU");
    ui.attachChild(cpuLabel);
    cpuLabel.setLocalTranslation(PANEL_WIDTH / 4 - bigFont.getLineWidth(cpuLabel.getText()) / 2, -PADDING - 30, 0);
    BitmapText gpuLabel = new BitmapText(bigFont);
    gpuLabel.setText("GPU");
    ui.attachChild(gpuLabel);
    gpuLabel.setLocalTranslation(3 * PANEL_WIDTH / 4 - bigFont.getLineWidth(gpuLabel.getText()) / 2, -PADDING - 30, 0);
    frameTimeValue = new BitmapText(bigFont);
    frameCpuTimeValue = new BitmapText(bigFont);
    frameGpuTimeValue = new BitmapText(bigFont);
    selectedField = new BitmapText(font);
    selectedField.setText("Selected: ");
    selectedField.setLocalTranslation(PANEL_WIDTH / 2, -PADDING - 75, 0);
    selectedField.setColor(ColorRGBA.Yellow);
    ui.attachChild(frameTimeValue);
    ui.attachChild(frameCpuTimeValue);
    ui.attachChild(frameGpuTimeValue);
    ui.attachChild(selectedField);
    hideInsignificantField = new BitmapText(font);
    hideInsignificantField.setText("O " + INSIGNIFICANT);
    hideInsignificantField.setLocalTranslation(PADDING, -PADDING - 75, 0);
    ui.attachChild(hideInsignificantField);
    final InputManager inputManager = app.getInputManager();
    if (inputManager != null) {
        inputManager.addMapping(TOGGLE_KEY, new KeyTrigger(KeyInput.KEY_F6));
        inputManager.addMapping(CLICK_KEY, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
        inputManager.addListener(new ActionListener() {

            @Override
            public void onAction(String name, boolean isPressed, float tpf) {
                if (name.equals(TOGGLE_KEY) && isPressed) {
                    setEnabled(!isEnabled());
                }
                if (isEnabled() && name.equals(CLICK_KEY) && isPressed) {
                    handleClick(inputManager.getCursorPosition());
                }
            }
        }, TOGGLE_KEY, CLICK_KEY);
    }
}
Also used : Quad(com.jme3.scene.shape.Quad) Material(com.jme3.material.Material) BitmapText(com.jme3.font.BitmapText)

Example 30 with Quad

use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.

the class StatsAppState method loadDarken.

public void loadDarken() {
    Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f));
    mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
    darkenFps = new Geometry("StatsDarken", new Quad(200, fpsText.getLineHeight()));
    darkenFps.setMaterial(mat);
    darkenFps.setLocalTranslation(0, 0, -1);
    darkenFps.setCullHint(showFps && darkenBehind ? CullHint.Never : CullHint.Always);
    guiNode.attachChild(darkenFps);
    darkenStats = new Geometry("StatsDarken", new Quad(200, statsView.getHeight()));
    darkenStats.setMaterial(mat);
    darkenStats.setLocalTranslation(0, fpsText.getHeight(), -1);
    darkenStats.setCullHint(showStats && darkenBehind ? CullHint.Never : CullHint.Always);
    guiNode.attachChild(darkenStats);
}
Also used : Geometry(com.jme3.scene.Geometry) Quad(com.jme3.scene.shape.Quad) ColorRGBA(com.jme3.math.ColorRGBA) Material(com.jme3.material.Material)

Aggregations

Geometry (com.jme3.scene.Geometry)36 Quad (com.jme3.scene.shape.Quad)35 Material (com.jme3.material.Material)30 Vector3f (com.jme3.math.Vector3f)23 Node (com.jme3.scene.Node)11 Spatial (com.jme3.scene.Spatial)10 DirectionalLight (com.jme3.light.DirectionalLight)9 Quaternion (com.jme3.math.Quaternion)9 Texture (com.jme3.texture.Texture)9 TerrainQuad (com.jme3.terrain.geomipmap.TerrainQuad)7 ColorRGBA (com.jme3.math.ColorRGBA)6 Vector2f (com.jme3.math.Vector2f)6 AmbientLight (com.jme3.light.AmbientLight)5 Mesh (com.jme3.scene.Mesh)5 Texture2D (com.jme3.texture.Texture2D)5 Picture (com.jme3.ui.Picture)5 File (java.io.File)5 ScreenshotAppState (com.jme3.app.state.ScreenshotAppState)4 BulletAppState (com.jme3.bullet.BulletAppState)4 CapsuleCollisionShape (com.jme3.bullet.collision.shapes.CapsuleCollisionShape)4