Package com.ardor3d.scenegraph

Examples of com.ardor3d.scenegraph.Node


        _root.acceptVisitor(new UpdateModelBoundVisitor(), false);
    }

    private Node createModel() {
        final Node node = new Node("Node");

        final Box box = new Box("Box", new Vector3(), 5, 5, 5);
        box.setModelBound(new BoundingBox());
        box.setTranslation(new Vector3(-3, 0, 0));
        box.setRandomColors();
        node.attachChild(box);

        final Teapot teapot = new Teapot("Teapot");
        teapot.setScale(2.0);
        teapot.setTranslation(new Vector3(3, 0, 0));
        node.attachChild(teapot);

        final Torus torus = new Torus("Torus", 128, 128, 2, 4);
        torus.setTranslation(new Vector3(-8, 3, 0));
        node.attachChild(torus);

        return node;
    }
View Full Code Here


     *
     * @param topNode
     */
    // -----------------------------------------------------
    void addTextTestNodes(final Node topNode) {
        final Node zup = new Node("zup");
        rotate.fromAngleNormalAxis(-Math.PI / 2, Vector3.UNIT_X);
        zup.setRotation(rotate);

        final Node textMoveNode = new Node("textModeNode");

        final CullState cs = new CullState();
        cs.setCullFace(Face.Back);
        textMoveNode.setRenderState(cs);

        final Node textExampleNode = new Node("textExampleNode");
        textExampleNode.setTranslation(0, 0, 0);
        final double a = 9.0;
        final double b = 4.5;
        newBox(textExampleNode, 0, 1, 0);
        newBox(textExampleNode, -a, 1, -b);
        newBox(textExampleNode, -a, 1, b);
        newBox(textExampleNode, a, 1, b);
        newBox(textExampleNode, a, 1, -b);

        topNode.attachChild(zup);
        zup.attachChild(textMoveNode);
        textMoveNode.attachChild(textExampleNode);

        final SpatialController<BMText> fontChanger = createFontChanger();
        final SpatialController<Node> nodeMover = createNodeMover();
        textMoveNode.addController(nodeMover);

        final BMFont font = BMFontLoader.defaultFont();
        final String initialString = font.getStyleName() + "\nThe Quick Brown Fox...";
        final double fontScale = 1.0;
        if (true) {
            final BMText text = new BMText("textSpatial1", initialString, font, BMText.Align.SouthWest,
                    BMText.Justify.Right);
            text.setFontScale(fontScale);
            text.setAutoFade(AutoFade.CapScreenSize);
            text.setAutoFadeFalloff(1.0f);
            text.setAutoScale(AutoScale.CapScreenSize);
            text.setAutoRotate(true);
            textExampleNode.attachChild(text);
            text.addController(fontChanger);
        }

        if (true) {
            final BMText text = new BMText("textSpatial2", initialString, font, BMText.Align.SouthEast,
                    BMText.Justify.Left);
            text.setFontScale(fontScale);
            text.setAutoFade(AutoFade.FixedPixelSize);
            text.setAutoFadeFalloff(0.5f);
            text.setAutoFadeFixedPixelSize(15);
            text.setAutoScale(AutoScale.CapScreenSize);
            text.setAutoRotate(true);
            textExampleNode.attachChild(text);
            text.addController(fontChanger);
        }

        if (true) {
            final BMText text = new BMText("textSpatial3", initialString, font, BMText.Align.NorthEast,
                    BMText.Justify.Left);
            text.setFontScale(fontScale);
            text.setAutoFade(AutoFade.Off);
            text.setAutoScale(AutoScale.FixedScreenSize);
            text.setAutoRotate(true);
            textExampleNode.attachChild(text);
            text.addController(fontChanger);
        }

        if (true) {
            final BMText text = new BMText("textSpatial4", initialString, font, BMText.Align.NorthWest,
                    BMText.Justify.Center);
            text.setFontScale(fontScale);
            text.setAutoFade(AutoFade.DistanceRange);
            text.setAutoFadeDistanceRange(10, 100); // start fading distance to camera > 10
            text.setAutoScale(AutoScale.Off);
            text.setAutoRotate(true);
            textExampleNode.attachChild(text);
            text.addController(fontChanger);
        }
    }
View Full Code Here

        sphere = new Sphere("Sphere", 16, 16, 4);
        _root.attachChild(sphere);

        // 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.ONE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                trailMesh.setFacingMode(TrailMesh.FacingMode.Tangent);
View Full Code Here

            // TODO: what?
            // bloomRenderPass.setUseCurrentScene(true);
        }

        // Setup textfields for presenting example info.
        final Node textNodes = new Node("Text");
        final RenderPass renderPass = new RenderPass();
        renderPass.add(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();

        // Populate passmanager with passes.
        _passManager.add(rootPass);
        _passManager.add(bloomRenderPass);
View Full Code Here

     * Creates the scene objects.
     *
     * @return the node containing the objects
     */
    private Node createObjects() {
        final Node objects = new Node("objects");

        final Torus torus = new Torus("Torus", 30, 20, 8, 17);
        torus.setTranslation(new Vector3(50, -5, 20));
        TextureState ts = new TextureState();
        torus.addController(new SpatialController<Torus>() {
            private double timer = 0;
            private final Matrix3 rotation = new Matrix3();

            public void update(final double time, final Torus caller) {
                timer += time * 0.5;
                caller.setTranslation(Math.sin(timer) * 40.0, Math.sin(timer) * 40.0, Math.cos(timer) * 40.0);
                rotation.fromAngles(timer * 0.5, timer * 0.5, timer * 0.5);
                caller.setRotation(rotation);
            }
        });

        Texture t0 = TextureManager.load("images/ardor3d_white_256.jpg",
                Texture.MinificationFilter.BilinearNearestMipMap, true);
        ts.setTexture(t0, 0);
        ts.setEnabled(true);
        torus.setRenderState(ts);
        objects.attachChild(torus);

        ts = new TextureState();
        t0 = TextureManager
                .load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true);
        t0.setWrap(Texture.WrapMode.Repeat);
        ts.setTexture(t0);

        Box box = new Box("box1", new Vector3(-10, -10, -10), new Vector3(10, 10, 10));
        box.setTranslation(new Vector3(0, -7, 0));
        box.setRenderState(ts);
        objects.attachChild(box);

        box = new Box("box2", new Vector3(-5, -5, -5), new Vector3(5, 5, 5));
        box.setTranslation(new Vector3(15, 10, 0));
        box.setRenderState(ts);
        objects.attachChild(box);

        box = new Box("box3", new Vector3(-5, -5, -5), new Vector3(5, 5, 5));
        box.setTranslation(new Vector3(0, -10, 15));
        box.setRenderState(ts);
        objects.attachChild(box);

        box = new Box("box4", new Vector3(-5, -5, -5), new Vector3(5, 5, 5));
        box.setTranslation(new Vector3(20, 0, 0));
        box.setRenderState(ts);
        objects.attachChild(box);

        ts = new TextureState();
        t0 = TextureManager
                .load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true);
        t0.setWrap(Texture.WrapMode.Repeat);
        ts.setTexture(t0);

        box = new Box("box5", new Vector3(-50, -2, -50), new Vector3(50, 2, 50));
        box.setTranslation(new Vector3(0, -15, 0));
        box.setRenderState(ts);
        box.setModelBound(new BoundingBox());
        objects.attachChild(box);

        return objects;
    }
View Full Code Here

*/
public final class ExampleScene implements Scene {
    private final Node root;

    public ExampleScene() {
        root = new Node("root");
    }
View Full Code Here

        final Random r = new Random();

        r.setSeed(1337);
        for (int i = 0; i < 50; i++) {
            final Node node = new Node("delegate" + i);

            node.setTranslation(new Vector3(-15 + r.nextFloat() * 30, r.nextFloat() * 30, -15 + r.nextFloat() * 30));

            compiledNodes.attachChild(node);
        }
        _root.attachChild(compiledNodes);

        r.setSeed(1337);
        for (int i = 0; i < 50; i++) {
            final Node node = heavyNode.makeCopy(true);

            node.setTranslation(new Vector3(-15 + r.nextFloat() * 30, r.nextFloat() * 30, -15 + r.nextFloat() * 30));

            copiedNodes.attachChild(node);
        }
        _root.attachChild(copiedNodes);
        copiedNodes.getSceneHints().setCullHint(CullHint.Always);

        // 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.SPACE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                showingCompiled = !showingCompiled;
View Full Code Here

        }));
    }

    protected Node createTestNode() {
        // just a node with lots of random boxes
        final Node node = new Node();

        final Random r = new Random(1337);
        for (int i = 0; i < 150; i++) {
            final Box box = new Box("b" + i, new Vector3(0, 0, 0), new Vector3(0.1f, 0.1f, 0.1f));
            box.updateModelBound();
            box.setRandomColors();
            final MaterialState ms = new MaterialState();
            ms.setDiffuse(MaterialFace.FrontAndBack, new ColorRGBA(r.nextFloat(), r.nextFloat(), r.nextFloat(), 1));
            box.setRenderState(ms);
            box.setTranslation(new Vector3(r.nextFloat(), r.nextFloat(), r.nextFloat()));
            box.setRotation(new Quaternion(r.nextFloat(), r.nextFloat(), r.nextFloat(), 1));
            node.attachChild(box);
        }

        return node;
    }
View Full Code Here

        // Need to setup fog cause the water use it for various calculations.
        setupFog();

        // Collect everything we want reflected in the water under a node.
        final Node reflectedNode = new Node("reflectNode");
        reflectedNode.attachChild(createObjects());
        buildSkyBox();
        reflectedNode.attachChild(skybox);
        _root.attachChild(reflectedNode);

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

        // Create a new WaterNode with refraction enabled.
        waterNode = new WaterNode(cam, 4, true, true);
        waterNode.setClipBias(0.5f);
        waterNode.setWaterMaxAmplitude(5.0f);
        // 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.setFoamMapTextureString("images/water/oceanfoam.png");

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

        // Create a ProjectedGrid to use as geometry for the water.
        projectedGrid = new ProjectedGrid("ProjectedGrid", cam, 100, 70, 0.01f, new WaterHeightGenerator(), _timer);
        // or implement your own waves like this(or in a separate class)...
        // projectedGrid = new ProjectedGrid( "ProjectedGrid", cam, 50, 50,
        // 0.01f, new HeightGenerator() {
        // public float getHeight( float x, float z, float time ) {
        // return
        // FastMath.sin(x*0.05f+time*2.0f)+FastMath.cos(z*0.1f+time*4.0f)*2;
        // }
        // } );
        projectedGrid.setNrUpdateThreads(Runtime.getRuntime().availableProcessors());

        waterNode.attachChild(projectedGrid);

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

        _root.attachChild(waterNode);

        // Setup textfields 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();

        // Register keyboard triggers for manipulating example
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
View Full Code Here

     * Creates the scene objects.
     *
     * @return the node containing the objects
     */
    private Node createObjects() {
        final Node objects = new Node("objects");

        final Torus torus = new Torus("Torus", 50, 50, 8, 17);
        torus.setTranslation(new Vector3(50, -5, 20));
        TextureState ts = new TextureState();
        torus.addController(new SpatialController<Torus>() {
            private double timer = 0;
            private final Matrix3 rotation = new Matrix3();

            public void update(final double time, final Torus caller) {
                timer += time * 0.5;
                caller.setTranslation(Math.sin(timer) * 40.0, Math.sin(timer) * 40.0, Math.cos(timer) * 40.0);
                rotation.fromAngles(timer * 0.5, timer * 0.5, timer * 0.5);
                caller.setRotation(rotation);
            }
        });

        Texture t0 = TextureManager.load("images/ardor3d_white_256.jpg",
                Texture.MinificationFilter.BilinearNearestMipMap, true);
        ts.setTexture(t0, 0);
        ts.setEnabled(true);
        torus.setRenderState(ts);
        objects.attachChild(torus);

        ts = new TextureState();
        t0 = TextureManager
                .load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true);
        t0.setWrap(Texture.WrapMode.Repeat);
        ts.setTexture(t0);

        Box box = new Box("box1", new Vector3(-10, -10, -10), new Vector3(10, 10, 10));
        box.setTranslation(new Vector3(0, -7, 0));
        box.setRenderState(ts);
        objects.attachChild(box);

        box = new Box("box2", new Vector3(-5, -5, -5), new Vector3(5, 5, 5));
        box.setTranslation(new Vector3(15, 10, 0));
        box.setRenderState(ts);
        objects.attachChild(box);

        box = new Box("box3", new Vector3(-5, -5, -5), new Vector3(5, 5, 5));
        box.setTranslation(new Vector3(0, -10, 15));
        box.setRenderState(ts);
        objects.attachChild(box);

        box = new Box("box4", new Vector3(-5, -5, -5), new Vector3(5, 5, 5));
        box.setTranslation(new Vector3(20, 0, 0));
        box.setRenderState(ts);
        objects.attachChild(box);

        ts = new TextureState();
        t0 = TextureManager
                .load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.BilinearNearestMipMap, true);
        t0.setWrap(Texture.WrapMode.Repeat);
        ts.setTexture(t0);

        box = new Box("box5", new Vector3(-50, -2, -50), new Vector3(50, 2, 50));
        box.setTranslation(new Vector3(0, -15, 0));
        box.setRenderState(ts);
        box.setModelBound(new BoundingBox());
        objects.attachChild(box);

        return objects;
    }
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.