Package com.jme.scene

Examples of com.jme.scene.Node


public class Grid extends Node {

    public Grid(Vector3f center, Vector3f rotation, float spacing, float marker, float size, boolean zBuffer) {
        super("grid");

        Node lines = new Node("lines");
        this.attachChild(lines);
        ArrayList<Vector3f> markerVertices = new ArrayList<Vector3f>();
        ArrayList<Vector3f> regularVertices = new ArrayList<Vector3f>();
        for (int i = 0; i * spacing <= size; i++) {
            if (i % marker > 0) {
                // Normal line
                regularVertices.add(new Vector3f(-size, 0, i * spacing));
                regularVertices.add(new Vector3f(size, 0, i * spacing));
                regularVertices.add(new Vector3f(-size, 0, -i * spacing));
                regularVertices.add(new Vector3f(size, 0, -i * spacing));
                regularVertices.add(new Vector3f(i * spacing, 0, -size));
                regularVertices.add(new Vector3f(i * spacing, 0, size));
                regularVertices.add(new Vector3f(-i * spacing, 0, -size));
                regularVertices.add(new Vector3f(-i * spacing, 0, size));
            } else {
                // Marker line
                markerVertices.add(new Vector3f(-size, 0, i * spacing));
                markerVertices.add(new Vector3f(size, 0, i * spacing));
                markerVertices.add(new Vector3f(-size, 0, -i * spacing));
                markerVertices.add(new Vector3f(size, 0, -i * spacing));
                markerVertices.add(new Vector3f(i * spacing, 0, -size));
                markerVertices.add(new Vector3f(i * spacing, 0, size));
                markerVertices.add(new Vector3f(-i * spacing, 0, -size));
                markerVertices.add(new Vector3f(-i * spacing, 0, size));
            }
        }
        Geometry regularGrid = new Line("regularLine", regularVertices.toArray(new Vector3f[] {}), null, null, null);
        regularGrid.getDefaultColor().set(new ColorRGBA(1, 1, 1, 0.05f));
        regularGrid.setModelBound(new BoundingBox());
        regularGrid.updateModelBound();
        lines.attachChild(regularGrid);
        Geometry markerGrid = new Line("markerLine", markerVertices.toArray(new Vector3f[] {}), null, null, null);
        markerGrid.getDefaultColor().set(new ColorRGBA(1, 1, 1, 0.1f));
        markerGrid.setModelBound(new BoundingBox());
        markerGrid.updateModelBound();
        lines.attachChild(markerGrid);
        if (rotation != null) lines.getLocalRotation().fromAngles(rotation.x, rotation.y, rotation.z);

        Node axis = new Node("axis");
        this.attachChild(axis);
        Vector3f xAxis = new Vector3f(size + (marker * spacing), 0, 0); // red
        Vector3f yAxis = new Vector3f(0, size + (marker * spacing), 0); // green
        Vector3f zAxis = new Vector3f(0, 0, size + (marker * spacing)); // blue
        Vector3f zero = new Vector3f();
        ColorRGBA red = new ColorRGBA(1, 0, 0, 0.8f);
        ColorRGBA green = new ColorRGBA(0, 1, 0, 0.8f);
        ColorRGBA blue = new ColorRGBA(0, 0, 1, 0.8f);
        Line lx = new Line("xAxis", new Vector3f[] { zero, xAxis }, null, new ColorRGBA[] { red, red }, null);
        Line ly = new Line("yAxis", new Vector3f[] { zero, yAxis }, null, new ColorRGBA[] { green, green }, null);
        Line lz = new Line("zAxis", new Vector3f[] { zero, zAxis }, null, new ColorRGBA[] { blue, blue }, null);
        lx.setModelBound(new BoundingBox());
        lx.updateModelBound();
        ly.setModelBound(new BoundingBox());
        ly.updateModelBound();
        lz.setModelBound(new BoundingBox());
        lz.updateModelBound();
        axis.attachChild(lx);
        axis.attachChild(ly);
        axis.attachChild(lz);

        TextureState ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();

        this.setTextureCombineMode(TextureCombineMode.Off);
        this.setRenderState(ts);
View Full Code Here


     */
    @Override
    protected void simpleInitGame() {
        //Definice sipek pro orientaci v prostoru

        axisRoot=new Node("axnode");
        axisRoot.setLocalTranslation(0, 0, 0);
        planeXY=new Box("planeXY",new Vector3f(0.05f,0,0.05f),0.1f,0.0001f,0.1f);

        axisXArrow=new Arrow("ax",0.1f,0.01f);
        axisXArrow.setLocalTranslation(new Vector3f(0.05f,0,0));
View Full Code Here

        MaxToJme converter = new MaxToJme();
        URL objFile = getClass().getResource("/models/test01.3ds");
        ByteArrayOutputStream BO = new ByteArrayOutputStream();
        try {
            converter.convert(objFile.openStream(), BO);
            Node obj = (Node) BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
            obj.setName("OBJ");
            n = obj;
            rootNode.attachChild(obj);
        } catch (IOException e) {
            e.printStackTrace();
        }
View Full Code Here

        AseToJme converter = new AseToJme();
        URL objFile = getClass().getResource("/models/test/cube-1m.ase");
        ByteArrayOutputStream BO = new ByteArrayOutputStream();
        try {
            converter.convert(objFile.openStream(), BO);
            Node obj = (Node) BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
            obj.setName("OBJ");
            rootNode.attachChild(obj);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
View Full Code Here

            e.printStackTrace();
        }
    }
   
    private void loadJME(){
        Node node;
        try {
            URL u = getClass().getResource("/models/ship.jme");
            node = (Node) BinaryImporter.getInstance().load(u);
            n = node;
            rootNode.attachChild(node);
View Full Code Here

        // Turn of animations for the simple avatar
        attributes.setAnimateBody(false);
        attributes.setAnimateFace(false);
        // Load the avatar using the new collada loading manager
        Node node = null;
        try {
            URL url = new URL(baseURL + avatarURL);
            DeployedModel dm = LoaderManager.getLoaderManager().getLoaderFromDeployment(url);
            node = dm.getModelLoader().loadDeployedModel(dm, null);
            node.setLocalScale(0.22f);
        } catch (MalformedURLException excp) {
            logger.log(Level.WARNING, "Unable to for .dep URL", excp);
            return null;
        } catch (IOException excp) {
            logger.log(Level.WARNING, "Error loading avatar model", excp);
View Full Code Here

                MouseDraggedEvent3D dragEvent = (MouseDraggedEvent3D) me3d;
                Vector3f dragVectorWorld = dragEvent.getDragVectorWorld(dragStartWorld, dragStartScreen,
                                                                        new Vector3f());

                // Convert from world to parent coordinates.
                Node viewNode = ((View2DEntity)view.getParent()).getNode();
                Vector3f curWorld = dragStartWorld.add(dragVectorWorld, new Vector3f());
                Vector3f curLocal = viewNode.worldToLocal(curWorld, new Vector3f());
                dragVectorLocal = curLocal.subtract(dragStartLocal);
            }
            return action;

        case MouseEvent.MOUSE_RELEASED:
View Full Code Here

                MouseDraggedEvent3D dragEvent = (MouseDraggedEvent3D) me3d;
                Vector3f dragVectorWorld = dragEvent.getDragVectorWorld(dragStartWorld, dragStartScreen,
                                                                        new Vector3f());

                // Convert from world to local coordinates.
                Node viewNode = view.getNode();
                Vector3f curWorld = dragStartWorld.add(dragVectorWorld, new Vector3f());
                Vector3f curLocal = viewNode.worldToLocal(curWorld, new Vector3f());
                dragVectorLocal = curLocal.subtract(dragStartLocal);
            }
            return action;

        case MouseEvent.MOUSE_RELEASED:
View Full Code Here

    }//GEN-LAST:event_lightingEnabledCBActionPerformed

    private void printSceneGraphBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printSceneGraphBActionPerformed
        Entity entity = ((CellRendererJME)editor.getCell().getCellRenderer(RendererType.RENDERER_JME)).getEntity();
        RenderComponent rc = entity.getComponent(RenderComponent.class);
        Node root = rc.getSceneRoot();
        print(root, 0);
//        TreeScan.findNode(root, new ProcessNodeInterface() {
//
//            public boolean processNode(Spatial node) {
//                System.err.println(node+"  "+node.getLocalScale());
View Full Code Here

                MouseDraggedEvent3D.getDragVectorWorld(hookInfo.eventX, hookInfo.eventY,
                                                       dragStartWorld, dragStartScreen,
                                                       new Vector3f());

            // Convert from world to parent coordinates.
            Node viewNode = ((View2DEntity)view.getParent()).getNode();
            Vector3f curWorld = dragStartWorld.add(dragVectorWorld, new Vector3f());
            Vector3f curLocal = viewNode.worldToLocal(curWorld, new Vector3f());
            dragVectorLocal = curLocal.subtract(dragStartLocal);

            //System.err.println("dragVectorLocal = " + dragVectorLocal);
            App2D.invokeLater(new Runnable() {
                public void run () {
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.