Package com.ardor3d.scenegraph

Examples of com.ardor3d.scenegraph.Node


    /**
     * 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


        sphere = new Sphere("sphere", 10, 10, 2);

        sphere.setSolidColor(ColorRGBA.WHITE);
        sphere.setModelBound(new BoundingBox());

        sphereNode = new Node("sphere node");

        torus = new PQTorus("torus", 5, 4, 2f, .5f, 128, 16);
        torus.setTranslation(new Vector3(0, 0, 0));
        torus.setSolidColor(ColorRGBA.WHITE);
        torus.setModelBound(new BoundingBox());

        torusNode = new Node("torus node");

        torus.addController(new SpatialController<PQTorus>() {
            private double currentTime;

            public void update(final double time, final PQTorus caller) {
View Full Code Here

        _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(10, 0, 50));

        final Vector3 max = new Vector3(5, 5, 5);
        final Vector3 min = new Vector3(-5, -5, -5);

        opaques = new Node("Opaques");
        transps = new Node("Transps");
        orthos = new Node("Orthos");
        transps.getSceneHints().setRenderBucketType(RenderBucketType.Skip);
        opaques.getSceneHints().setRenderBucketType(RenderBucketType.Skip);
        orthos.getSceneHints().setRenderBucketType(RenderBucketType.Skip);
        _root.attachChild(orthos);
        _root.attachChild(transps);
View Full Code Here

        _root.setRenderState(ms);

        _root.getSceneHints().setCullHint(CullHint.Never);

        // 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();
    }
View Full Code Here

        ts.setTexture(TextureManager.load("images/skybox/1.jpg", Texture.MinificationFilter.Trilinear, true));
        box1.setRenderState(ts);
        box1.getSceneHints().setPickingHint(PickingHint.Pickable, true);
        box1.setModelBound(new BoundingBox());

        final Node base = new Node();
        base.setTranslation(0, 0, 0);
        base.attachChild(box1);
        _root.attachChild(base);

        final Sphere sphere = new Sphere("sphere", Vector3.ZERO, 16, 16, 8);
        ts = new TextureState();
        ts.setTexture(TextureManager.load("images/water/dudvmap.png", Texture.MinificationFilter.Trilinear, true));
        sphere.setRenderState(ts);
        sphere.getSceneHints().setPickingHint(PickingHint.Pickable, true);
        sphere.setModelBound(new BoundingSphere());

        final Node joint = new Node();
        joint.setTranslation(0, sphere.getRadius() + 2 * box1.getYExtent(), 0);
        joint.attachChild(sphere);
        base.attachChild(joint);

        final Box box2 = new Box("box", Vector3.ZERO, 5, 15, 5);
        box2.setTranslation(0, box2.getYExtent(), 0);
        ts = new TextureState();
        ts.setTexture(TextureManager.load("images/skybox/3.jpg", Texture.MinificationFilter.Trilinear, true));
        box2.setRenderState(ts);
        box2.getSceneHints().setPickingHint(PickingHint.Pickable, true);
        box2.setModelBound(new BoundingBox());

        final Node arm = new Node();
        arm.setTranslation(0, sphere.getRadius(), 0);
        arm.attachChild(box2);
        joint.attachChild(arm);

        // auto select the joint
        _root.updateGeometricState(0);
        manager.setSpatialTarget(joint);
View Full Code Here

        _pssmPass = new ParallelSplitShadowMapPass(light, 1024, 3);
        _pssmPass.add(_root);
        _pssmPass.setUseSceneTexturing(true);
        _pssmPass.setUseObjectCullFace(true);

        final Node occluders = setupOccluders();
        _pssmPass.addOccluder(occluders);

        // Populate passmanager with passes.
        _passManager.add(rootPass);
        _passManager.add(_pssmPass);
        _passManager.add(renderPass);

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

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

        textNodes.updateGeometricState(0.0);
        updateText();

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

    /**
     * Setup occluders.
     */
    private Node setupOccluders() {
        final Node occluders = new Node("occs");
        _root.attachChild(occluders);
        for (int i = 0; i < 30; i++) {
            final double w = Math.random() * 40 + 10;
            final double y = Math.random() * 20 + 10;
            final Box b = new Box("box", new Vector3(), w, y, w);
            b.setModelBound(new BoundingBox());
            final double x = Math.random() * 1000 - 500;
            final double z = Math.random() * 1000 - 500;
            b.setTranslation(new Vector3(x, y, z));

            occluders.attachChild(b);
        }

        final Torus torusWithoutShadows = new Torus("torus", 32, 10, 15.0f, 20.0f);
        torusWithoutShadows.setModelBound(new BoundingBox());
        torusWithoutShadows.getSceneHints().setCastsShadows(false);
        torusWithoutShadows.setTranslation(0, 50, -100);
        occluders.attachChild(torusWithoutShadows);

        final Torus torus = new Torus("torus", 64, 12, 10.0f, 15.0f);
        torus.setModelBound(new BoundingBox());
        occluders.attachChild(torus);
        torus.addController(new SpatialController<Torus>() {
            double timer = 0;
            Matrix3 rotation = new Matrix3();

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

        // Attach "billboard" with an alpha test.
        occluders.attachChild(makeBillBoard());

        return occluders;
    }
View Full Code Here

        final TextureState ts = new TextureState();
        ts.setEnabled(true);
        ts.setTexture(TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.Trilinear,
                TextureStoreFormat.GuessCompressedFormat, true));

        final Node sphereBase = new Node("node");
        _root.attachChild(sphereBase);

        final Random rand = new Random(1337);
        for (int i = 0; i < 100; i++) {
            final Sphere sphere = new Sphere("Sphere", 32, 32, 2);
            sphere.setRandomColors();
            sphere.setModelBound(new BoundingBox());
            sphere.setRenderState(ts);
            sphere.setTranslation(new Vector3(rand.nextDouble() * 100.0 - 50.0, rand.nextDouble() * 100.0 - 50.0, rand
                    .nextDouble() * 100.0 - 250.0));

            sphereBase.attachChild(sphere);
        }

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                vboMode = (vboMode + 1) % 3;
                if (vboMode == 0) {
                    t.setText("[SPACE] VBO Off");
                    sphereBase.getSceneHints().setDataMode(DataMode.Arrays);
                    // run this in the opengl thread
                    GameTaskQueueManager.getManager(_canvas.getCanvasRenderer().getRenderContext()).render(
                            new Callable<Void>() {
                                public Void call() throws Exception {
                                    final DeleteVBOsVisitor viz = new DeleteVBOsVisitor(_canvas.getCanvasRenderer()
                                            .getRenderer());
                                    sphereBase.acceptVisitor(viz, false);
                                    return null;
                                }
                            });
                } else if (vboMode == 1) {
                    t.setText("[SPACE] VBO On");
                    sphereBase.getSceneHints().setDataMode(DataMode.VBO);
                } else if (vboMode == 2) {
                    t.setText("[SPACE] VBO Interleaved On");
                    sphereBase.getSceneHints().setDataMode(DataMode.VBOInterleaved);
                }
            }
        }));

        // Add fps display
View Full Code Here

        return occluders;
    }

    private Spatial makeBillBoard() {
        final Node billboard = new Node("bb");
        billboard.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);

        final Quad q1 = new Quad("font block", 150, 200);
        q1.setTranslation(0, 80, 0);
        q1.setModelBound(new BoundingBox());
        final CullState cs = new CullState();
        cs.setCullFace(CullState.Face.None);
        q1.setRenderState(cs);
        billboard.attachChild(q1);

        final TextureState ts = new TextureState();
        ts.setEnabled(true);
        ts.setTexture(TextureManager.load("fonts/OkasaSansSerif-35-medium-regular_00.png",
                Texture.MinificationFilter.Trilinear, true));
        billboard.setRenderState(ts);

        final BlendState bs = new BlendState();
        bs.setEnabled(true);
        bs.setBlendEnabled(false);
        bs.setTestEnabled(true);
        bs.setTestFunction(TestFunction.GreaterThan);
        bs.setReference(0.7f);
        billboard.setRenderState(bs);

        return billboard;
    }
View Full Code Here

        final TextureState ts = new TextureState();
        ts.setTexture(TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.Trilinear,
                TextureStoreFormat.GuessCompressedFormat, true));
        _root.setRenderState(ts);

        final Node globesNode = new Node("globes");

        Sphere sphere = new Sphere("Linear mapping", Vector3.ZERO, 65, 65, 1, TextureMode.Linear);
        globesNode.attachChild(sphere);

        sphere = new Sphere("With mapping", 65, 65, 1);
        sphere = new Sphere("Projected mapping", Vector3.ZERO, 65, 65, 1, TextureMode.Projected);
        globesNode.attachChild(sphere);

        GeoSphere geoSphere = new GeoSphere("UV geo sphere - original", true, 2.0, 3, GeoSphere.TextureMode.Original);
        globesNode.attachChild(geoSphere);

        geoSphere = new GeoSphere("UV geo sphere - projected", true, 2.0, 3, GeoSphere.TextureMode.Projected);
        globesNode.attachChild(geoSphere);

        sphere = new Sphere("Projected mapping, radius 2", Vector3.ZERO, 65, 65, 2, TextureMode.Projected);
        globesNode.attachChild(sphere);

        globesNode.setRotation(new Quaternion().fromAngleAxis(-MathUtils.HALF_PI, Vector3.UNIT_X));
        int startX = -globesNode.getChildren().size() / 2;
        for (final Spatial s : globesNode.getChildren()) {
            final Mesh m = (Mesh) s;
            m.updateModelBound();
            startX += ((BoundingSphere) m.getModelBound(null)).getRadius() * 2;
            s.setTranslation(startX, 0, 0);
        }
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.