Package com.ardor3d.scenegraph

Examples of com.ardor3d.scenegraph.Node


    }

    private void addRover() {
        try {
            final ColladaStorage storage = new ColladaImporter().load("collada/sketchup/NASA Mars Rover.dae");
            final Node rover = storage.getScene();
            rover.setTranslation(440, 102, 160.1);
            rover.setScale(3);
            rover.setRotation(new Quaternion().fromAngleAxis(-MathUtils.HALF_PI, Vector3.UNIT_X));
            _root.attachChild(rover);
        } catch (final IOException ex) {
            ex.printStackTrace();
        }
View Full Code Here


            colladaImporter.setOptimizeMeshes(true);

            // Load the collada scene
            final String mainFile = "collada/skeleton/skeleton.walk.dae";
            final ColladaStorage storage = colladaImporter.load(mainFile);
            final Node colladaNode = storage.getScene();
            final List<SkinData> skinDatas = storage.getSkins();
            pose = skinDatas.get(0).getPose();

            createAnimation();
View Full Code Here

        skybox = buildSkyBox();
        skybox.getSceneHints().setAllPickingHints(false);
        _root.attachChild(skybox);

        // Setup labels for presenting example info.
        final Node textNodes = new Node("Text");
        _root.attachChild(textNodes);
        textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
        textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off);

        final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2;
        for (int i = 0; i < _exampleInfo.length; i++) {
            _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16);
            _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0));
            textNodes.attachChild(_exampleInfo[i]);
        }

        textNodes.updateGeometricState(0.0);
        updateText();

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                updateTerrain = !updateTerrain;
View Full Code Here

        // _pssmPass.setMinimumLightDistance(500); // XXX: Tune this
        _pssmPass.setUseSceneTexturing(false);
        _pssmPass.setUseObjectCullFace(false);
        // _pssmPass.setDrawDebug(true);

        final Node occluders = setupOccluders();
        _root.attachChild(occluders);

        // TODO: could we use the shadow variable in scenehints here??
        // Add objects that will get shadowed through overlay render
        _pssmPass.add(occluders);

        // Add terrain in as bounds receiver as well, since it's not in the overlay list
        _pssmPass.addBoundsReceiver(terrain);

        // Add our occluders that will produce shadows
        _pssmPass.addOccluder(occluders);

        // Setup labels for presenting example info.
        final Node textNodes = new Node("Text");
        _root.attachChild(textNodes);
        textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
        textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off);

        final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2;
        for (int i = 0; i < _exampleInfo.length; i++) {
            _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16);
            _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0));
            textNodes.attachChild(_exampleInfo[i]);
        }

        textNodes.updateGeometricState(0.0);
        updateText();

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                updateTerrain = !updateTerrain;
View Full Code Here

            }, false);
        } catch (final IOException ioe) {
            ioe.printStackTrace();
        }

        final Node rot = new Node("Model Rotation");

        rot.getSceneHints().setDataMode(DataMode.VBO);
        rot.attachChild(colladaNode);
        _root.attachChild(rot);

    }
View Full Code Here

        }));

    }

    private Node setupOccluders() {
        final Node occluders = new Node("Occluders");

        final Box box = new Box("Box", new Vector3(), 1, 40, 1);
        box.setModelBound(new BoundingBox());
        box.setRandomColors();

        final Random rand = new Random(1337);
        for (int x = 0; x < 8; x++) {
            for (int y = 0; y < 8; y++) {
                final Mesh sm = box.makeCopy(true);

                sm.setTranslation(500 + rand.nextDouble() * 300 - 150, 20 + rand.nextDouble() * 5.0,
                        500 + rand.nextDouble() * 300 - 150);
                occluders.attachChild(sm);
            }
        }

        return occluders;
    }
View Full Code Here

        skybox = buildSkyBox();
        skybox.getSceneHints().setAllPickingHints(false);
        _root.attachChild(skybox);

        // Setup labels for presenting example info.
        final Node textNodes = new Node("Text");
        _root.attachChild(textNodes);
        textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
        textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off);

        final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2;
        for (int i = 0; i < _exampleInfo.length; i++) {
            _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16);
            _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0));
            textNodes.attachChild(_exampleInfo[i]);
        }

        textNodes.updateGeometricState(0.0);
        updateText();

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                updateTerrain = !updateTerrain;
View Full Code Here

            colladaImporter.setOptimizeMeshes(true);

            // Load the collada scene
            final String mainFile = "collada/skeleton/skeleton.walk.dae";
            final ColladaStorage storage = colladaImporter.load(mainFile);
            final Node colladaNode = storage.getScene();

            System.out.println("Importing: " + mainFile);
            System.out.println("Took " + (System.currentTimeMillis() - time) + " ms");

            final GLSLShaderObjectsState gpuShader = new GLSLShaderObjectsState();
View Full Code Here

            terrain = new TerrainBuilder(terrainDataProvider, terrainCamera).setShowDebugPanels(true).build();
        } catch (final Exception ex1) {
            ex1.printStackTrace();
        }

        final Node reflectedNode = new Node("reflectNode");
        reflectedNode.attachChild(terrain);
        skybox = buildSkyBox();
        skybox.getSceneHints().setAllPickingHints(false);
        reflectedNode.attachChild(skybox);

        final Camera cam = _canvas.getCanvasRenderer().getCamera();

        // Create a new WaterNode with refraction enabled.
        waterNode = new WaterNode(cam, 2, false, true);
        // Setup textures to use for the water.
        waterNode.setNormalMapTextureString("images/water/normalmap3.dds");
        waterNode.setDudvMapTextureString("images/water/dudvmap.png");
        waterNode.setFallbackMapTextureString("images/water/water2.png");
        waterNode.useFadeToFogColor(true);

        waterNode.setSpeedReflection(0.02);
        waterNode.setSpeedReflection(-0.01);

        // setting to default value just to show
        waterNode.setWaterPlane(new Plane(new Vector3(0.0, 1.0, 0.0), 40.0));

        // Create a quad to use as geometry for the water.
        waterQuad = new Quad("waterQuad", 1, 1);
        // Hack the quad normals to point up in the y-axis. Since we are manipulating the vertices as
        // we move this is more convenient than rotating the quad.
        final FloatBuffer normBuf = waterQuad.getMeshData().getNormalBuffer();
        normBuf.clear();
        normBuf.put(0).put(1).put(0);
        normBuf.put(0).put(1).put(0);
        normBuf.put(0).put(1).put(0);
        normBuf.put(0).put(1).put(0);
        waterNode.attachChild(waterQuad);

        waterNode.addReflectedScene(reflectedNode);
        waterNode.setSkybox(skybox);

        _root.attachChild(reflectedNode);
        _root.attachChild(waterNode);

        // Setup cam above water and terrain
        final Camera camera = _canvas.getCanvasRenderer().getCamera();
        final double height = Math.max(terrain.getHeightAt(camera.getLocation().getX(), camera.getLocation().getZ()),
                waterNode.getWaterHeight())
                + heightOffset;
        if (camera.getLocation().getY() < height) {
            camera.setLocation(new Vector3(camera.getLocation().getX(), height, camera.getLocation().getZ()));
        }

        // Setup labels for presenting example info.
        final Node textNodes = new Node("Text");
        _root.attachChild(textNodes);
        textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
        textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off);

        final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() - 20;
        for (int i = 0; i < _exampleInfo.length; i++) {
            _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16);
            _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0));
            textNodes.attachChild(_exampleInfo[i]);
        }

        textNodes.updateGeometricState(0.0);
        updateText();

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                updateTerrain = !updateTerrain;
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _controlHandle.setMoveSpeed(5);
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _controlHandle.setMoveSpeed(50);
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _controlHandle.setMoveSpeed(400);
                updateText();
            }
        }));

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                groundCamera = !groundCamera;
                updateText();
            }
        }));

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                sphere.getSceneHints().setCullHint(
                        sphere.getSceneHints().getCullHint() == CullHint.Always ? CullHint.Dynamic : CullHint.Always);
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.V), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                showUI = !showUI;
                if (showUI) {
                    textNodes.getSceneHints().setCullHint(CullHint.Never);
                    debugQuadsNode.getSceneHints().setCullHint(CullHint.Never);
                } else {
                    textNodes.getSceneHints().setCullHint(CullHint.Always);
                    debugQuadsNode.getSceneHints().setCullHint(CullHint.Always);
                }
                updateText();
            }
        }));
View Full Code Here

    /**
     * Creates the debug quads.
     */
    private void createDebugQuads() {
        debugQuadsNode = new Node("quadNode");
        debugQuadsNode.getSceneHints().setCullHint(CullHint.Never);

        final double quadSize = _canvas.getCanvasRenderer().getCamera().getWidth() / 10;

        Quad debugQuad = new Quad("reflectionQuad", quadSize, quadSize);
View Full Code Here

TOP

Related Classes of com.ardor3d.scenegraph.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.