Package com.ardor3d.scenegraph.shape

Examples of com.ardor3d.scenegraph.shape.Sphere


    protected void initExample() {

        _canvas.setTitle("RenderEffects Example");

        // Create a new sphere that rotates
        final Sphere sphere = new Sphere("Sphere", new Vector3(0, 0, 0), 32, 32, 5);
        sphere.setModelBound(new BoundingBox());
        sphere.setTranslation(new Vector3(0, 0, -15));
        sphere.addController(new SpatialController<Spatial>() {
            private final Vector3 _axis = new Vector3(1, 1, 0.5f).normalizeLocal();
            private final Matrix3 _rotate = new Matrix3();
            private double _angle = 0;

            public void update(final double time, final Spatial caller) {
                // update our rotation
                _angle = _angle + (_timer.getTimePerFrame() * 25);
                if (_angle > 180) {
                    _angle = -180;
                }

                _rotate.fromAngleNormalAxis(_angle * MathUtils.DEG_TO_RAD, _axis);
                sphere.setRotation(_rotate);
            }
        });
        _root.attachChild(sphere);

        // Add a texture to the sphere.
        final TextureState ts = new TextureState();
        ts.setTexture(TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.Trilinear, true));
        sphere.setRenderState(ts);

        // Setup our manager
        effectManager = new EffectManager(_settings, TextureStoreFormat.RGBA8);
        effectManager.setSceneCamera(_canvas.getCanvasRenderer().getCamera());

View Full Code Here


    void randomLight(final int i) {
        // Chose the color for the lights.
        final ColorRGBA lightColor = ColorRGBA.randomColor(new ColorRGBA());

        // Create a sphere to show where the light is in the demo.
        final Sphere lightSphere = new Sphere("lightSphere" + i, 9, 9, .1f);
        lightSphere.setModelBound(new BoundingSphere());
        lightSphere.getSceneHints().setLightCombineMode(LightCombineMode.Off);
        lightSphere.setDefaultColor(lightColor);

        // Create a new point light and fill out the properties
        final PointLight pointLight = new PointLight();
        pointLight.setAttenuate(true);
        pointLight.setConstant(.01f);
        pointLight.setLinear(.001f);
        pointLight.setQuadratic(.1f);
        pointLight.setEnabled(true);
        pointLight.setDiffuse(lightColor);
        pointLight.setAmbient(new ColorRGBA(.1f, .1f, .1f, .1f));

        _lightState.attach(pointLight);

        lightSphere.addController(new SpatialController<Spatial>() {

            double timeX = rand.nextDouble() * Math.PI * 8;
            double timeY = rand.nextDouble() * Math.PI * 8;
            double timeZ = rand.nextDouble() * Math.PI * 8;
            double speed = MathUtils.nextRandomDouble();
View Full Code Here

     * @param i
     *            Index of the sphere
     */
    void randomSphere(final int i) {
        // Crate a sphere and position it.
        final Sphere sphere = new Sphere("sphere" + i, 18, 18, MathUtils.nextRandomDouble() * 1.75 + 1.25);
        sphere.updateModelBound();
        sphere.setTranslation(new Vector3(rand.nextDouble() * worldsize * 2 - worldsize, rand.nextDouble() * worldsize
                * 2 - worldsize, rand.nextDouble() * worldsize * 2 - worldsize));

        _root.attachChild(sphere);
    }
View Full Code Here

    @Override
    protected void initExample() {
        _canvas.setTitle("TestSharedMesh");

        final Sphere sphere = new Sphere("Sphere", 8, 8, 1);
        sphere.setModelBound(new BoundingBox());
        sphere.getSceneHints().setDataMode(DataMode.VBO);

        final CullState cs = new CullState();
        cs.setCullFace(CullState.Face.Back);
        cs.setEnabled(true);
        _root.setRenderState(cs);

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

        sphere.setRenderState(ts);

        final Node n1 = new Node("n1");
        n1.setTranslation(new Vector3(-50, 0, -200));

        _root.attachChild(n1);

        final Random rand = new Random(1337);
        for (int i = 0; i < 500; i++) {
            final Mesh sm = sphere.makeCopy(true);

            sm.setTranslation(new Vector3(rand.nextDouble() * 100.0 - 50.0, rand.nextDouble() * 100.0 - 50.0, rand
                    .nextDouble() * 100.0 - 50.0));
            n1.attachChild(sm);
        }
View Full Code Here

    }

    protected void generateSpheres(final Node modelBase, final boolean useInstancing, final int nrOfObjects) {
        final Random rand = new Random(1337);

        final Sphere sphereroot = new Sphere("Sphere", 8, 8, 2);
        for (int i = 0; i < nrOfObjects; i++) {
            Sphere sphere;
            if (useInstancing) {
                sphere = (Sphere) sphereroot.makeInstanced();
            } else {
                sphere = (Sphere) sphereroot.makeCopy(true);
            }
            sphere.setRandomColors();
            sphere.setModelBound(new BoundingSphere());
            sphere.setTranslation(new Vector3(rand.nextDouble() * 100.0 - 50.0, rand.nextDouble() * 100.0 - 50.0, rand
                    .nextDouble() * 100.0 - 250.0));
            sphere.getSceneHints().setCullHint(CullHint.Dynamic);
            modelBase.attachChild(sphere);
        }

    }
View Full Code Here

        final Texture texture = createTexture();
        texture.setEnvironmentalMapMode(EnvironmentalMapMode.ObjectLinear);
        ts.setTexture(texture);
        _root.setRenderState(ts);

        final Sphere sp = new Sphere("sphere", 16, 16, 2);
        _root.attachChild(sp);

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

        addMesh(new Octahedron("Octahedron", 3));
        addMesh(new PQTorus("PQTorus", 5, 4, 1.5, .5, 128, 8));
        addMesh(new Pyramid("Pyramid", 2, 4));
        addMesh(new Quad("Quad", 3, 3));
        addMesh(new RoundedBox("RoundedBox", new Vector3(3, 3, 3)));
        addMesh(new Sphere("Sphere", 16, 16, 3));
        addMesh(new GeoSphere("GeoSphere", true, 3, 3, TextureMode.Original));
        addMesh(new StripBox("StripBox", new Vector3(), 3, 3, 3));
        addMesh(new Teapot("Teapot"));
        addMesh(new Torus("Torus", 16, 8, 1.0, 2.5));
        addMesh(new Tube("Tube", 2, 3, 4));
View Full Code Here

        debugDumpAtlases(packer);
    }

    private Mesh createSphere(final Node parentNode, final String textureName, final WrapMode mode) {
        // Create sphere
        final Sphere sphere = new Sphere("Sphere", 10, 10, 1);
        sphere.setModelBound(new BoundingBox());
        sphere.setTranslation(new Vector3(MathUtils.rand.nextInt(40) - 20, MathUtils.rand.nextInt(40) - 20,
                MathUtils.rand.nextInt(40) - 100));
        parentNode.attachChild(sphere);

        setupStates(sphere, textureName, mode);
View Full Code Here

                        ts.setTexture(texture, 1);
                        return null;
                    }
                });

        sp = new Sphere("sphere", 16, 16, 2);
        sp.getMeshData().copyTextureCoordinates(0, 1, 1f);
        _root.attachChild(sp);

        // add base texture to unit 0
        final TextureState ts = new TextureState();
View Full Code Here

        addMesh(new Octahedron("Octahedron", 3));
        addMesh(new PQTorus("PQTorus", 5, 4, 1.5, .5, 128, 8));
        addMesh(new Pyramid("Pyramid", 2, 4));
        addMesh(new Quad("Quad", 3, 3));
        addMesh(new RoundedBox("RoundedBox", new Vector3(3, 3, 3)));
        addMesh(new Sphere("Sphere", 16, 16, 3));
        addMesh(new GeoSphere("GeoSphere", true, 3, 3, TextureMode.Original));
        addMesh(new StripBox("StripBox", new Vector3(), 3, 3, 3));
        addMesh(new Teapot("Teapot"));
        addMesh(new Torus("Torus", 16, 8, 1.0, 2.5));
        addMesh(new Tube("Tube", 2, 3, 4));
View Full Code Here

TOP

Related Classes of com.ardor3d.scenegraph.shape.Sphere

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.