Package com.xith3d.scenegraph

Examples of com.xith3d.scenegraph.Appearance


    Locale locale = new Locale();
    universe.addLocale(locale);

    BranchGroup objRoot = new BranchGroup();

    Appearance a = new Appearance();
    a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
    Shape3D sph = new Shape3D(TestUtils.createSphere(1.0f, 20), a);
    TransformGroup sphereTrans = new TransformGroup();
    sphereTrans.addChild(sph);

    objRoot.addChild(sphereTrans);
View Full Code Here


    }

    protected void setAppearanceForHighlight(boolean on) {
        if (shape==null) return;
       
    Appearance a=new Appearance();
    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;
        a.setPolygonAttributes(new PolygonAttributes(attribute, PolygonAttributes.CULL_NONE, 0));
        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);
        a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_NONE, 0));
        Material m = new Material();
        Color selectedColor;
      if (on) selectedColor = highlightColor;
      else selectedColor = baseColor;
       
      float[] colors = selectedColor.getRGBColorComponents(null);
      m.setAmbientColor(colors[0], colors[1], colors[2]);
     
      // Squash specular toward white => keep only hue
      float[] hsb = Color.RGBtoHSB(selectedColor.getRed(), selectedColor.getGreen(), selectedColor.getBlue(), null);
      Color.getHSBColor(hsb[0],hsb[1]/10,1.0f).getRGBColorComponents(colors);
      m.setSpecularColor(colors[0], colors[1], colors[2]);

      // diffuse is same hue and saturation but darker
      Color.getHSBColor(hsb[0],hsb[1],hsb[2]/2).getRGBColorComponents(colors);
      m.setDiffuseColor(colors[0], colors[1], colors[2]);
     
      // no emissive color
      m.setEmissiveColor(0f,0f,0f);
     
/*      m.setAmbientColor(1.0f,0.0f,0.0f);
          m.setSpecularColor(1.0f,0.9f,0.9f);
          m.setDiffuseColor(0.8f,0.0f,0.0f);
          m.setEmissiveColor(0f,0f,0f);*/
       
          m.setLightingEnable(true);
          a.setMaterial(m);
    }
        shape.setAppearance(a);
    }
View Full Code Here

    v.addLocale(l);
    BranchGroup bg=new BranchGroup();
    bg.setName("bg1");
    l.addBranchGraph(bg);
   
    Appearance a = new Appearance();
    a.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
    Shape3D sph = new Shape3D(TestUtils.createSphere(1.0f, 20), a);
    sph.setName("s1");
    TransformGroup sphereTrans = new TransformGroup();
    sphereTrans.addChild(sph);
    sphereTrans.setName("t1");
View Full Code Here

       
        // X axis in blue
        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);
    saxis.setName("X axis");
        rootGroup.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);
    saxis.setName("Y axis");
        rootGroup.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);
    saxis.setName("Z axis");
        rootGroup.addChild(saxis);
       
        frame = null; // lazy creation
View Full Code Here

        float[] vectorCoords = new float[] {
            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);
    lightVector.setName("Light vector");
        rootGroup.addChild(lightVector);
    }
View Full Code Here

TOP

Related Classes of com.xith3d.scenegraph.Appearance

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.