Examples of Shape3D


Examples of javax.media.j3d.Shape3D

        Stripifier st = new Stripifier();
        st.stripify(gi);
        gi.recomputeIndices();

        Shape3D shape3D = new Shape3D();
        shape3D.setAppearance(createMaterialAppearance(color));
        shape3D.setGeometry(gi.getGeometryArray());

        return shape3D;
    }
View Full Code Here

Examples of javax.media.j3d.Shape3D

                | LineArray.COLOR_4, new int[] { numPoints });

        la.setCoordinates(0, data);
        Color4b[] colors = createColorArray(numPoints, color);
        la.setColors(0, colors);
        return new Shape3D(la);
    }
View Full Code Here

Examples of javax.media.j3d.Shape3D

        Appearance a = new Appearance();
    a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
    ColoringAttributes ca = new ColoringAttributes();
    ca.setColor(0.0f,0.0f,1.0f);
    a.setColoringAttributes(ca);
    Shape3D saxis = new Shape3D(la, a);
    axisGroup.addChild(saxis);
       
        // Y axis in green
        axis = AxisMaker.makeAxis(1);
        la = new LineArray(axis.length/3, LineArray.COORDINATES);
        la.setCoordinates(0,axis);
        a = new Appearance();
    a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
    ca = new ColoringAttributes();
    ca.setColor(0.0f,1.0f,0.0f);
    a.setColoringAttributes(ca);
    saxis = new Shape3D(la, a);
    axisGroup.addChild(saxis);
       
        // Z axis in purple
        axis = AxisMaker.makeAxis(2);
        la = new LineArray(axis.length/3, LineArray.COORDINATES);
        la.setCoordinates(0,axis);
        a = new Appearance();
    a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
    ca = new ColoringAttributes();
    ca.setColor(1.0f,0.0f,1.0f);
    a.setColoringAttributes(ca);
    saxis = new Shape3D(la, a);
    axisGroup.addChild(saxis);
       
    mainSwitch = new Switch(Switch.CHILD_MASK);
   
    mainSwitch.addChild(branchgroup);
View Full Code Here

Examples of javax.media.j3d.Shape3D

        Appearance a = new Appearance();
    a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
    ColoringAttributes ca = new ColoringAttributes();
    ca.setColor(1.0f,1.0f,0.0f);
    a.setColoringAttributes(ca);
    lightVector = new Shape3D(la, a);
        rootGroup.addChild(lightVector);
        attach();
    }
View Full Code Here

Examples of javax.media.j3d.Shape3D

        Appearance a = new Appearance();
    a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
    ColoringAttributes ca = new ColoringAttributes();
    ca.setColor(0.0f,0.0f,1.0f);
    a.setColoringAttributes(ca);
    Shape3D saxis = new Shape3D(la, a);
    axisGroup.addChild(saxis);
       
        // Y axis in green
        axis = AxisMaker.makeAxis(1);
        la = new LineArray(axis.length/3, LineArray.COORDINATES);
        la.setCoordinates(0,axis);
        a = new Appearance();
    a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
    ca = new ColoringAttributes();
    ca.setColor(0.0f,1.0f,0.0f);
    a.setColoringAttributes(ca);
    saxis = new Shape3D(la, a);
    axisGroup.addChild(saxis);
       
        // Z axis in purple
        axis = AxisMaker.makeAxis(2);
        la = new LineArray(axis.length/3, LineArray.COORDINATES);
        la.setCoordinates(0,axis);
        a = new Appearance();
    a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
    ca = new ColoringAttributes();
    ca.setColor(1.0f,0.0f,1.0f);
    a.setColoringAttributes(ca);
    saxis = new Shape3D(la, a);
    axisGroup.addChild(saxis);
       
    mainSwitch = new Switch(Switch.CHILD_MASK);
   
    mainSwitch.addChild(branchgroup);
View Full Code Here

Examples of javax.media.j3d.Shape3D

      iqa.setCoordinateIndices(0,index);
      iqa.setNormalIndices(0,index);
     
        anonymousNodeNumber++;
        name = NodeResourcesManager.getNodeName("Cube") + ((anonymousNodeNumber == 1) ? "" : String.valueOf(anonymousNodeNumber));
        return new Shape3D(iqa);
    }
View Full Code Here

Examples of javax.media.j3d.Shape3D

        float[] coords = GeodeMaker.createGeode(10);
      TriangleArray ta = new TriangleArray(coords.length / 3, GeometryArray.COORDINATES | GeometryArray.NORMALS);
      ta.setCoordinates(0,coords);
      ta.setNormals(0,coords);
     
      Shape3D s = new Shape3D(ta);
        anonymousNodeNumber++;
        name = NodeResourcesManager.getNodeName("Sphere") + ((anonymousNodeNumber == 1) ? "" : String.valueOf(anonymousNodeNumber));
        return s;
    }
View Full Code Here

Examples of javax.media.j3d.Shape3D

    // Setup color buffer
    ta.setColorRefBuffer(new J3DBuffer(nioColors));
      ta.setCapability(TriangleArray.ALLOW_COLOR_WRITE);
      ta.setCapabilityIsFrequent(TriangleArray.ALLOW_COLOR_WRITE);
     
      Shape3D shape3d = new Shape3D(ta);
     
    // The appearance of a shape has many interesting features.
      // In particular, in case one wants to display lines (edges) over the shape,
      // it is possible to set a polygon offset to the triangles. This offset is in fact
      // a distance in the Z-buffer => an offset of 1 for example on the triangles,
      // will place them behind the edges. @see PolygonAttributes.setPolygonOffset,
      // and the code in syn3d.nodes.java3d.Shape3DJava3D
      // Here the shape is created without an appearance and it is managed
      // by ShapeNodeJava3D. See this class for more information
        shape3d.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
        shape3d.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);

        // The shape will be pickable, which means the user can click on the shape in 3D
        // space from the 2D window
        PickTool.setCapabilities(shape3d,PickTool.INTERSECT_FULL);
        shape3d.setCapability(Shape3D.ALLOW_PICKABLE_READ);
        shape3d.setCapability(Shape3D.ALLOW_PICKABLE_WRITE);
    shape3d.setPickable(true);

        // Create a node in the JTree for this shape
    new ShapeNodeJava3D(this, shape3d);

    // Syn3D picking code uses the user data of a Java3D object to find back a node
        // that handles the picking. Let's declare this object as the handler instead of
    // ShapeNodeJava3D
    shape3d.setUserData(this);
   
    // scale the shape to have a reasonable size
    // and translate it to the origin
    Bounds bounds = transformGroup.getBounds();
    if (bounds instanceof BoundingSphere) {
View Full Code Here

Examples of javax.media.j3d.Shape3D

  // This method is called directly by the plugin on key press, as an example how to do it
  public void showResult(int num) {

    // Get the shape back from the children list. Ignore case when there is no file loaded
    if (children.size()<1) return;
    Shape3D shape3d = (Shape3D)((ShapeNodeJava3D)children.get(0)).get3DObject();
   
    // Find the color buffer
    FloatBuffer colors = (FloatBuffer)(((TriangleArray)shape3d.getGeometry()).getColorRefBuffer().getBuffer());
   
    // helper variables
    int d = num+3;
    if (d>=names.length) return; // ignore keypressed events for unknown variables
    currentVariable = d;
View Full Code Here

Examples of javax.media.j3d.Shape3D

        return super.canRemoveSceneGraphObject(obj,oldObj);
    }
   
    @Override
    public void removeSceneGraphObject(SceneGraphObject obj, SceneGraphObject oldObj){
        Shape3D s=(Shape3D)getGraphObject();
        if(obj instanceof Geometry){
            boolean forced=forceCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
            s.removeGeometry((Geometry)obj);
            if(forced) restoreCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
            return;
        }
        else if (obj instanceof Appearance){
            if(oldObj==null || !(oldObj instanceof Appearance)){
                throw new RuntimeException("removeSceneGraphObject invalid argument old="+oldObj.getClass());
            }
            boolean forced=forceCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
            s.setAppearance((Appearance)oldObj);
            if(forced) restoreCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
            return;
        }
        throw new RuntimeException("removeSceneGraphObject invalid argument ="+obj.getClass());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.