Package javax.media.j3d

Examples of javax.media.j3d.PolygonAttributes


    public static Appearance createMaterialAppearance(Color color) {

        Appearance materialAppear = new Appearance();

        PolygonAttributes polyAttrib = new PolygonAttributes();
        polyAttrib.setCullFace(PolygonAttributes.CULL_NONE);
        materialAppear.setPolygonAttributes(polyAttrib);

        Material material = new Material();
        // Might want to look into using a Color4b at some point
        material.setAmbientColor(new Color3f(color));
View Full Code Here


    }

    public static Appearance createWireFrameAppearance(Color color) {

        Appearance materialAppear = new Appearance();
        PolygonAttributes polyAttrib = new PolygonAttributes();
        polyAttrib.setPolygonMode(PolygonAttributes.POLYGON_LINE);
        materialAppear.setPolygonAttributes(polyAttrib);
        ColoringAttributes redColoring = new ColoringAttributes();
        redColoring.setColor(1.0f, 0.0f, 0.0f);
        materialAppear.setColoringAttributes(redColoring);
View Full Code Here

    //f1.viewingPlatform.setNominalViewingTransform();

    BranchGroup objRoot = scene.getBranchgroup();

    Appearance a = new Appearance();
    a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
    TransformGroup sphereTrans = new TransformGroup();
    sphereTrans.addChild(new Sphere(1.f, Sphere.GENERATE_NORMALS,40, a));

    scene.detach();
    objRoot.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
View Full Code Here

        float[] axis = AxisMaker.makeAxis(0);
        LineArray la = new LineArray(axis.length/3, LineArray.COORDINATES);
        la.setCoordinates(0,axis);
        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);
View Full Code Here

            0,0,0, x,y,z
        };
        LineArray la = new LineArray(2, LineArray.COORDINATES);
        la.setCoordinates(0,vectorCoords);
        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);
View Full Code Here

        float[] axis = AxisMaker.makeAxis(0);
        LineArray la = new LineArray(axis.length/3, LineArray.COORDINATES);
        la.setCoordinates(0,axis);
        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);
View Full Code Here

    a.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE);
    ColoringAttributes ca = new ColoringAttributes();
    // don't use light
    if ((mode==WIREFRAME_MODE) || (mode==FILLED_MODE)) {
      int attribute = (mode==FILLED_MODE) ? PolygonAttributes.POLYGON_FILL : PolygonAttributes.POLYGON_LINE;
      PolygonAttributes pa = new PolygonAttributes(attribute, PolygonAttributes.CULL_NONE, 0);
      unlockPolygonAttributes(pa);
      pa.setPolygonOffset(polygonOffset);
      pa.setPolygonOffsetFactor(polygonOffsetFactor);
        a.setPolygonAttributes(pa);
        Color selectedColor;
      if (on) selectedColor = highlightColor;
      else selectedColor = baseColor;
      float[] colors = selectedColor.getRGBColorComponents(null);
      ca.setColor(colors[0], colors[1], colors[2]);
      a.setColoringAttributes(ca);
    }
    // use light
    if ((mode==SHADING_MODE) || (mode==FLAT_MODE)) {
      if (mode==SHADING_MODE) ca.setShadeModel(ColoringAttributes.SHADE_GOURAUD);
      if (mode==FLAT_MODE) ca.setShadeModel(ColoringAttributes.SHADE_FLAT);
      a.setColoringAttributes(ca);
      PolygonAttributes pa = new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_NONE, 0);
      unlockPolygonAttributes(pa);
      pa.setPolygonOffset(polygonOffset);
      pa.setPolygonOffsetFactor(polygonOffsetFactor);
      pa.setBackFaceNormalFlip(true);
        a.setPolygonAttributes(pa);
      Material m = new Material();
        Color selectedColor;
      if (on) selectedColor = highlightColor;
      else selectedColor = baseColor;
View Full Code Here

        @Override
        public void setPropertyValue(Integer res) {
            if(_object.getPolygonAttributes()==null){
                boolean forced2=forceCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE);
                _object.setPolygonAttributes(new PolygonAttributes());
                if(forced2) restoreCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE);
            }
            boolean forced=forceCapability(PolygonAttributes.ALLOW_MODE_WRITE);
            _object.getPolygonAttributes().setPolygonMode(res);
            if(forced) restoreCapability(PolygonAttributes.ALLOW_MODE_WRITE);
View Full Code Here

           
            float[] axis = makeAxis(0);
            LineArray la = new LineArray(axis.length/3, LineArray.COORDINATES);
            la.setCoordinates(0,axis);
            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);
            saxis.setName("X");
            g.addChild(saxis);
           
            // Y axis in green
            axis = 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);
            saxis.setName("Y");
            g.addChild(saxis);
           
            // Z axis in purple
            axis = 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);
            saxis.setName("Z");
View Full Code Here

                Color3f eColor  = new Color3f(0.0f, 0.0f, 0.0f);
                Color3f sColor  = new Color3f(1.0f, 1.0f, 1.0f);

                Appearance cya=new Appearance();
                cya.setColoringAttributes(new ColoringAttributes(new Color3f(Color.WHITE),ColoringAttributes.SHADE_GOURAUD));
                cya.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_NONE, 0));
                Material cym = new Material(aColor, eColor, new Color3f(Color.WHITE), sColor, 100.0f);
                cym.setLightingEnable(true);
                cya.setMaterial(cym);
                sd.setAppearance(cya);
View Full Code Here

TOP

Related Classes of javax.media.j3d.PolygonAttributes

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.