Package com.jme.scene

Examples of com.jme.scene.Node


        }
        logger.warning("||-- notifyViewManagerListeners EXIT --|| ");
    }

    protected void createCameraEntity(WorldManager wm) {
        Node cameraSG = createCameraGraph(wm);

        // Fetch the field-of-view and front/back clip from the view properties
        float fov = viewProperties.getFieldOfView();
        float frontClip = viewProperties.getFrontClip();
        float backClip = viewProperties.getBackClip();
View Full Code Here


    CameraComponent getCameraComponent() {
        return cameraComponent;
    }

    private Node createCameraGraph(WorldManager wm) {
        Node cameraSG = new Node("MyCamera SG");
        cameraNode = new CameraNode("MyCamera", null);
        cameraSG.attachChild(cameraNode);

        cameraNode.addGeometricUpdateListener(new GeometricUpdateListener() {

            public void geometricDataChanged(Spatial arg0) {
                notifyCameraMoved(new CellTransform(arg0.getWorldRotation(), arg0.getWorldTranslation()));
View Full Code Here

     * Load a Collada file and return the graph root
     * @param file
     * @return
     */
    public ImportedModel importModel(ImportSettings settings) throws IOException {
        Node modelNode = null;
        URL origFile = settings.getModelURL();

        HashMap<URL, String> textureFilesMapping = new HashMap();
        ImportedModel importedModel = new ImportedModel(origFile, textureFilesMapping);
        SimpleResourceLocator resourceLocator=null;
View Full Code Here

    private Node loadModel(InputStream in,
                            String name,
                            boolean applyColladaAxisAndScale,
                            ThreadSafeColladaImporter.LoaderErrorListener listener) {
        Node modelNode;
        ThreadSafeColladaImporter importer = new ThreadSafeColladaImporter(name);
        importer.setErrorListener(listener);
        importer.load(in);
        modelNode = importer.getModel();

        CullState culls = DisplaySystem.getDisplaySystem().getRenderer().createCullState();
        culls.setCullFace(CullState.Face.Back);
        modelNode.setRenderState(culls);

        if (applyColladaAxisAndScale) {
            // Adjust the scene transform to match the scale and axis specified in
            // the collada file
            float unitMeter = importer.getInstance().getUnitMeter();
            modelNode.setLocalScale(unitMeter);

            String upAxis = importer.getInstance().getUpAxis();
            if ("Z_UP".equals(upAxis)) {
                modelNode.setLocalRotation(new Quaternion(new float[] {-(float)Math.PI/2, 0f, 0f}));
            } else if ("X_UP".equals(upAxis)) {
                modelNode.setLocalRotation(new Quaternion(new float[] {0f, 0f, (float)Math.PI/2}));
            } // Y_UP is the Wonderland default
        }

        importer.cleanUp();
View Full Code Here

                in = AssetUtils.getAssetURL(deployedModel.getModelURL()).openStream();

            String baseURL = deployedModel.getModelURL();
            baseURL = baseURL.substring(0, baseURL.lastIndexOf('/'));

            Node modelBG;
            Map<String, String> deployedTextures = null;
            if (data!=null)
                deployedTextures = data.getDeployedTextures();

            ResourceLocator resourceLocator = getDeployedResourceLocator(deployedTextures, baseURL);

            if (resourceLocator!=null) {
                ResourceLocatorTool.addThreadResourceLocator(
                        ResourceLocatorTool.TYPE_TEXTURE,
                        resourceLocator);
            }

            modelBG = loadModel(in, getFilename(deployedModel.getModelURL()), false, null);
            deployedModel.applyModelTransform(modelBG);

            if (resourceLocator!=null) {
                ResourceLocatorTool.removeThreadResourceLocator(
                        ResourceLocatorTool.TYPE_TEXTURE,
                        resourceLocator);
            }

            modelBG.updateGeometricState(0, true);

            return modelBG;
        } catch (IOException ex) {
            Logger.getLogger(JmeColladaLoader.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
View Full Code Here

        Quad oldQuad = quad;
        Quad updatedQuad = getQuad();

        if (updatedQuad!=oldQuad) {
            Node tmpParent = oldQuad.getParent();
            oldQuad.removeFromParent();
            TextureState texState = (TextureState) oldQuad.getRenderState(StateType.Texture);
            Texture tex = texState.getTexture();
            TextureManager.releaseTexture(tex);
            tmpParent.attachChild(updatedQuad);
        }
    }
View Full Code Here

      dispose();
  }
       
        DirectionalLight directionalLight = (DirectionalLight)lightNode.getLight();

        rootNode = new Node("Light Viewer Node");
        RenderManager rm = ClientContextJME.getWorldManager().getRenderManager();
        RenderComponent rc = rm.createRenderComponent(rootNode);
        this.addComponent(RenderComponent.class, rc);
       
        // Set the Z-buffer state on the root node
        ZBufferState zbuf = (ZBufferState)rm.createRendererState(StateType.ZBuffer);
        zbuf.setEnabled(true);
        zbuf.setFunction(ZBufferState.TestFunction.LessThanOrEqualTo);
       
        rootNode.setRenderState(zbuf);

        // Set the wireframe state on the root node
//        WireframeState wf = (WireframeState)rm.createRendererState(StateType.Wireframe);
//        wf.setEnabled(true);
//        rootNode.setRenderState(wf);
        MaterialState ms = (MaterialState)rm.createRendererState(StateType.Material);
        ms.setAmbient(new ColorRGBA(0.25f, 0, 0.5f, 0.40f));
        ms.setDiffuse(new ColorRGBA(0.25f, 0, 0.5f, 0.40f));
        ms.setMaterialFace(MaterialState.MaterialFace.FrontAndBack);;
        //ms.setSpecular(new ColorRGBA(1f, 1, 1f, 1f));
       
        ms.setEnabled(true);
        rootNode.setRenderState(ms);
       
        BlendState bs = (BlendState)rm.createRendererState(StateType.Blend);
        bs.setEnabled(true);
        bs.setBlendEnabled(true);
        bs.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
        bs.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
        bs.setTestEnabled(true);
        bs.setTestFunction(BlendState.TestFunction.GreaterThan);
        rootNode.setRenderState(bs);

        CellTransform transform = cell.getWorldTransform();
        // Draw an arrow that mimics the light position --direction still under
        //construction.
        TextLabel2D label = new TextLabel2D(name,
                                            Color.black, Color.white, 1.0f, true, Font.getFont("SANS_SERIF"));
       
        Vector3f direction = directionalLight.getDirection();
        Vector3f position = lightNode.getLocalTranslation();
        Vector3f labelPosition = new Vector3f(position.x, position.y + 3, position.z);
       
        Arrow arrow = new Arrow("Arrow", 3, 0.5f);
        Node rotatedOnX = new Node("Rotated For Arrow");
        rotatedOnX.setLocalRotation(new Quaternion().fromAngleAxis(90*FastMath.DEG_TO_RAD, new Vector3f(1, 0, 0)));
        rotatedOnX.attachChild(arrow);
        rotatedOnX.setLocalTranslation(position);
//        arrow.setLocalTranslation(position);
        label.setLocalTranslation(labelPosition);
        arrow.lookAt(direction, new Vector3f(0,1,0));
        rootNode.attachChild(label);
        rootNode.attachChild(rotatedOnX);
View Full Code Here

        Tube t = new Tube(name, outerRadius, innerRadius, thickness, 50, 50);
        t.setSolidColor(color);

        // Create the main node and set the material state on the node so the
        // color shows up. Attach the tube to the node.
        Node n = new Node();
        RenderManager rm = ClientContextJME.getWorldManager().getRenderManager();
        MaterialState matState3 = (MaterialState)
                rm.createRendererState(RenderState.StateType.Material);
        matState3.setDiffuse(color);
        n.setRenderState(matState3);
        n.attachChild(t);

        // Set the bound on the tube and update it
        t.setModelBound(new BoundingSphere());
        t.updateModelBound();
        return n;
View Full Code Here

            indentBuffer.append('\t');
        }
        buffer.append(indentBuffer.toString());
        buffer.append(aSpatial.toString());
        buffer.append('\n');
        Node parent = aSpatial.getParent();
        if (parent != null) {
            printParents(parent, buffer, indent + 1);
        }
    }
View Full Code Here

        return newChildLocal;
    }

    private static Node createTestNode() {
        Node rootNode = new Node("Root");
        for (int i = 100; i <= 500; i +=100) {
            Node iNode = new Node(String.valueOf(i));
            rootNode.attachChild(iNode);
            for (int j = 10; j <= 50; j +=10) {
                Node jNode = new Node(String.valueOf(i+j));
                iNode.attachChild(jNode);
                for (int k = 1; k <= 5; k++) {
                    TriMesh kMesh = new TriMesh(String.valueOf(i+j+k));
                    jNode.attachChild(kMesh);
                }
            }
        }
        return rootNode;
    }
View Full Code Here

TOP

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