Package com.jme.scene

Examples of com.jme.scene.Node


            return result;
        }
    }

    public static void main(String[] args) {
        Node testNode = createTestNode();
        testPrintNamedNodes(testNode);
        testNamedNode(testNode, "444");
        testPrintChildren(testNode);
        testPrintParents(testNode, "444");
    }
View Full Code Here


     * Load model from file
     *
     * @param origFile
     */
    ImportedModel loadModel(ImportSettings settings) throws IOException {
        Node rootBG = new Node();

        URL url = settings.getModelURL();
        if (url.getProtocol().equalsIgnoreCase("file")) {
            lastModelDir = new File(url.getFile()).getParentFile();
        }

        Node modelBG = null;

        ModelLoader modelLoader =
                LoaderManager.getLoaderManager().getLoader(url);

        LOGGER.fine("Using model loader " + modelLoader);
View Full Code Here

     */
    void loadCancelled(ImportedModel model) {
        if (editingRow >= 0 && imports.contains(model)) {
            // Restore Position of model
            final ImportedModel imp = model; //imports.get(editingRow);
            final Node tg = imp.getRootBG();
            final Vector3f rot = imp.getOrientation();
            RenderUpdater renderUpdater = new RenderUpdater() {

                public void update(Object arg0) {
                    tg.setLocalRotation(
                            calcRotationMatrix(rot.x, rot.y, rot.z));
                    tg.setLocalTranslation(imp.getTranslation());
                    ClientContextJME.getWorldManager().addToUpdateList(tg);
                }
            };
            ClientContextJME.getWorldManager().addRenderUpdater(
                    renderUpdater, null);
View Full Code Here

        Arrow a2 = new Arrow(name + " 2", length, width);
        a2.setSolidColor(color);

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

        // Create a sub-node to hold the first arrow. We must translate it up,
        // so that the end is at (0, 0, 0) in the local coordinate space of
        // the node we return
        Node subNode1 = new Node();
        subNode1.setLocalTranslation(0, length / 2, 0);
        subNode1.attachChild(a1);

        // Create a sub-node to hold the second arrow. We must rotate it 180
        // degrees (about the +y axis since arrows by default point up). We
        // also must translate it down. Attach the second arrow to this node.
        Node subNode2 = new Node();
        Quaternion q = new Quaternion().fromAngleAxis((float)Math.PI, new Vector3f(0, 0, 1));
        subNode2.setLocalRotation(q);
        subNode2.setLocalTranslation(0, -length / 2, 0);
        subNode2.attachChild(a2);

        // Attach the first arrow and the subnode to the main node
        n.attachChild(subNode1);
        n.attachChild(subNode2);
View Full Code Here

          JmeColladaLoader.LoaderErrorListener errorListener = new JmeColladaLoader.LoaderErrorListener(importedModel, LoaderManager.getLoaderManager().getLoaderListeners());

          if (models.size()==1) {
                importedModel.setModelBG(load(zipFile, models.get(0), errorListener));
            } else {
                Node modelBG = new Node();
                for(KmlParser.KmlModel model : models) {
                    modelBG.attachChild(load(zipFile, model, errorListener));
                }
                importedModel.setModelBG(modelBG);
            }
            ResourceLocatorTool.removeThreadResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, zipResource);
            WlzipManager.getWlzipManager().removeZip(zipHost, zipFile);
View Full Code Here

        BufferedInputStream in = new BufferedInputStream(zipFile.getInputStream(modelEntry));

        ThreadSafeColladaImporter importer = new ThreadSafeColladaImporter(filename);
        importer.setErrorListener(errorListener);
        importer.load(in);
        Node modelNode = importer.getModel();

        // 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 (upAxis.equals("Z_UP")) {
            modelNode.setLocalRotation(new Quaternion(new float[] {-(float)Math.PI/2, 0f, 0f}));
        } else if (upAxis.equals("X_UP")) {
            modelNode.setLocalRotation(new Quaternion(new float[] {0f, 0f, (float)Math.PI/2}));
        } // Y_UP is the Wonderland default

        importer.cleanUp();

        setupBounds(modelNode);
View Full Code Here

        Vector3f translation = sceneRoot.getWorldTranslation();
        rootNode.setLocalTranslation(translation);
        rootNode.setLocalScale(new Vector3f(LENGTH_SCALE, LENGTH_SCALE, LENGTH_SCALE));

        resizeEntity = new Entity("Sphere Entity");
        Node sphereNode = createSphereNode("Sphere Node");
        addSubEntity(resizeEntity, sphereNode);
        resizeListener = addResizeListener(resizeEntity, sphereNode);

        // Listen for changes to the cell's translation and apply the same
        // update to the root node of the affordances. We also re-set the size
View Full Code Here

     * Creates and returns a Node that contains a sphere that represents the
     * 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

     * Load and return the model. The node returned is the model BG
     *
     * @return
     */
    public Node loadModel(Entity rootEntity) {
        Node ret = new Node();

        DeployedModel dm = getDeployedModel();

        ModelLoader loader = dm.getModelLoader();
        Node model = loader.loadDeployedModel(dm, rootEntity);
        if (model != null) {
            model.setName(dm.getModelURL());
            ret.attachChild(model);
        }
        return ret;
    }
View Full Code Here

    protected Affordance(String name) {
        super(name);

        // Create the root node of the cell and the render component to attach
        // to the Entity with the node
        rootNode = new Node();
        RenderManager rm = ClientContextJME.getWorldManager().getRenderManager();
        RenderComponent rc = rm.createRenderComponent(rootNode);
        this.addComponent(RenderComponent.class, rc);
    }
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.