Package com.jme.scene.shape

Examples of com.jme.scene.shape.Sphere


     * resize affordance
     */
    private Node createSphereNode(String name) {
        // Create the new node and sphere primitive
        Node sphereNode = new Node();
        Sphere sphere = new Sphere(name, 30, 30, radius);
        sphereNode.attachChild(sphere);

        // Set the color to black and the transparency
        RenderManager rm = ClientContextJME.getWorldManager().getRenderManager();
        sphere.setSolidColor(new ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f));
        sphereNode.setRenderState(zbuf);
        MaterialState matState = (MaterialState)rm.createRendererState(StateType.Material);
        sphereNode.setRenderState(matState);
        matState.setDiffuse(new ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f));
        matState.setAmbient(new ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f));
        matState.setShininess(128.0f);
        matState.setEmissive(new ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f));
        matState.setEnabled(true);

        BlendState alphaState = (BlendState)rm.createRendererState(StateType.Blend);
        alphaState.setBlendEnabled(true);
        alphaState.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
        alphaState.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
        alphaState.setTestEnabled(true);
        alphaState.setTestFunction(BlendState.TestFunction.GreaterThan);
        alphaState.setEnabled(true);
        sphere.setRenderState(alphaState);

        // Remove the back faces of the object so transparency works properly
        CullState cullState = (CullState)rm.createRendererState(StateType.Cull);
        cullState.setCullFace(CullState.Face.Back);
        sphereNode.setRenderState(cullState);

        // Set the bound so this node can be pickable
        sphere.setModelBound(new BoundingSphere());
        sphere.updateModelBound();
        return sphereNode;
    }
View Full Code Here


        // Draw some geometry that mimics the bounds, either a sphere or a
        // box. Add to the scene graph of this Entity.
        if (bounds instanceof BoundingSphere) {
            float radius = ((BoundingSphere) bounds).radius;
            Vector3f center = ((BoundingSphere) bounds).getCenter();
            Sphere sphere = new Sphere("Sphere", center, 30, 30, radius);
            rootNode.attachChild(sphere);
        } else if (bounds instanceof BoundingBox) {
            float xExtent = ((BoundingBox)bounds).xExtent;
            float yExtent = ((BoundingBox)bounds).yExtent;
            float zExtent = ((BoundingBox)bounds).zExtent;
View Full Code Here

        translatorClip.resume();
    }

    private void attachInnerOrb(Entity entity) {
        innerOrbNode = new Node("Inner orb node");
        innerOrb = new Sphere("Inner Orb", 8, 8, INNER_RADIUS);
        innerOrb.setModelBound(new BoundingSphere());
        innerOrb.updateModelBound();
        innerOrb.setRenderState(DEFAULT_MATERIALSTATE);
        innerOrb.setRenderState(DEFAULT_SHADESTATE);
View Full Code Here

        innerOrbNode.attachChild(innerOrb);
        orbNode.attachChild(innerOrbNode);
    }

    private void attachOuterOrb(Entity entity) {
        final Sphere outerOrb = new Sphere("Outer Orb", 16, 16, OUTER_RADIUS);
        outerOrb.setModelBound(new BoundingSphere());
        outerOrb.updateModelBound();
        ColorRGBA orbColour = new ColorRGBA(0f, 0f, 1f, 0.2f);
        MaterialState matState = (MaterialState) ClientContextJME.getWorldManager().getRenderManager().createRendererState(StateType.Material);
        matState.setDiffuse(orbColour);
        outerOrb.setRenderState(matState);

        BlendState bs = (BlendState) ClientContextJME.getWorldManager().getRenderManager().createRendererState(StateType.Blend);
        bs.setEnabled(true);
        bs.setBlendEnabled(true);
        bs.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
        bs.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
        outerOrb.setRenderState(bs);

        CullState cs = (CullState) ClientContextJME.getWorldManager().getRenderManager().createRendererState(StateType.Cull);
        cs.setEnabled(true);
        cs.setCullFace(CullState.Face.Back);
        outerOrb.setRenderState(cs);

         orbNode.attachChild(outerOrb);
    }
View Full Code Here

        // attach the light to a lightState
        lightState.attach(light);
        // create the sphere object
        sphere = new Sphere("sphere", Vector3f.ZERO, 32, 32, 5f);
        // create the materials for the sphere
        // step 1
        MaterialState materialState = display.getRenderer().createMaterialState();
        materialState.setAmbient(NO_COLOR);
View Full Code Here

        ts.setTexture(TextureManager.loadTexture(TestBoxColor.class.getResource("/textures/earth_small/earthmap1k.jpg"), Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear));
        rootNode.setRenderState(ts);

        Random random = new Random();
        for (int i = 0; i < 2000; i++) {
            Sphere sphere = new Sphere("sphere_" + i, new Vector3f(random.nextInt(500) - 250, random.nextInt(500) - 250, random.nextInt(500) - 250), 12, 12, random.nextInt(5) + 4);
            rootNode.attachChild(sphere);
        }

        rootNode.updateGeometricState(0.0f, true);
        rootNode.updateRenderState();
View Full Code Here

        axisZArrow=new Arrow("az",0.1f,0.01f);
        axisZArrow.setLocalTranslation(new Vector3f(0,0,0.05f));
        axisZArrow.rotateUpTo(new Vector3f(0,0,1));
        axisZArrow.setRenderState(materialz);

        camPosBall=new Sphere("cameraPosition",new Vector3f(0,0,0),10,10,0.02f);


        axisRoot.attachChild(axisXArrow);
        axisRoot.attachChild(axisYArrow);
        axisRoot.attachChild(axisZArrow);
View Full Code Here

        cam.setLocation(new Vector3f(0,0,-700));
        cam.setDirection(new Vector3f(0,0,1));
        cam.update();


        earthSphere=new Sphere("earth",20,20,4);
        earthSphere.setSolidColor(ColorRGBA.green);
        earthSphere.setLocalTranslation(-100,170,0);
        gEarth.setPosition(new Vector3f(-100,170,0));

        gEarth.setWeight(1f);
        gEarth.setSpeed(new Vector3f(-2f,0.1f,1f));
        gEarth.setRadius(400);
        gEarth.WritePosition();

        earthSphere1=new Sphere("earth",20,20,4);
        earthSphere1.setSolidColor(ColorRGBA.green);
        earthSphere1.setLocalTranslation(100,170,0);
        gEarth1.setPosition(new Vector3f(100,170,0));

        gEarth1.setWeight(1f);
        gEarth1.setSpeed(new Vector3f(-1f,0f,0f));
        gEarth1.setRadius(400);
        gEarth1.WritePosition();





        sunSphere=new Sphere("sun",50,50,10);
        sunSphere.setLocalTranslation(0, 0, 0);
        gSun.setPosition(new Vector3f(0,0,0));
        gSun.setRadius(100);

        gSun.setWeight(7000f);
View Full Code Here

        Random r = new Random();
        Node[] subNode = new Node[5];
        TriMesh[] triMesh = new TriMesh[5];
        subNode[0] = new Node("spheres");
        subNode[0].setRenderState(Tool.createXRayShader());
        triMesh[0] = new Sphere("sphere", new Vector3f(0, 0, 0), 10, 10, 5);
        triMesh[0].setModelBound(new BoundingSphere());
        subNode[1] = new Node("boxes");
        triMesh[1] = new Box("box", new Vector3f(0, 0, 0), 5, 5, 5);
        triMesh[1].setModelBound(new BoundingBox());
        subNode[2] = new Node("toruses");
View Full Code Here

        app.start();
    }

    @Override
    protected void simpleInitGame() {
        Sphere sphere = new Sphere("Sphere", 50, 50, 5);

        shader = DisplaySystem.getDisplaySystem().getRenderer().createGLSLShaderObjectsState();

        if(!GLSLShaderObjectsState.isSupported()) {
            Logger.getLogger("GB").log(Level.WARNING, "Shader not supported");
        } else {
            shader.load(TestAtmo.class.getClassLoader().getResource("shader/test01.vert"), TestAtmo.class.getClassLoader().getResource("shader/test01.frag"));
            shader.setUniform("v3CameraPos", DisplaySystem.getDisplaySystem().getRenderer().getCamera().getLocation().x, DisplaySystem.getDisplaySystem().getRenderer().getCamera().getLocation().y, DisplaySystem.getDisplaySystem().getRenderer().getCamera().getLocation().z);
            shader.apply();

            sphere.setRenderState(shader);
        }

        sphere.setModelBound(new BoundingSphere());
        sphere.updateModelBound();
        sphere.updateRenderState();

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

TOP

Related Classes of com.jme.scene.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.