Example usage for javax.media.j3d Material setShininess

List of usage examples for javax.media.j3d Material setShininess

Introduction

In this page you can find the example usage for javax.media.j3d Material setShininess.

Prototype

public void setShininess(float shininess) 

Source Link

Document

Sets this material's shininess.

Usage

From source file:Licht.java

/**
 * Wurfeldarstellung/*from   w  w  w. j  a  v  a  2s. c o  m*/
 * 
 * @return Appearance
 */
private Appearance makeAppearance() {
    Appearance a = new Appearance();
    Material mat = new Material();
    mat.setShininess(50.0f);
    mat.setDiffuseColor(new Color3f(1.0f, 0.0f, 0.0f));
    mat.setSpecularColor(new Color3f(0.0f, 0.0f, 0.0f));
    a.setMaterial(mat);
    return a;
}

From source file:LitSphereApp.java

Appearance createAppearance() {

    Appearance appear = new Appearance();
    Material material = new Material();
    //      material.setDiffuseColor(0.0f, 0.0f, 1.0f);
    material.setShininess(50.0f);
    // make modifications to default material properties
    appear.setMaterial(material);/*from   w  w w . j  av  a  2s  .c  om*/

    //      ColoringAttributes colorAtt = new ColoringAttributes();
    //      colorAtt.setShadeModel(ColoringAttributes.SHADE_FLAT);
    //      appear.setColoringAttributes(colorAtt);

    return appear;
}

From source file:BasicConstruct.java

/**
 * Adds a box to the universe/*  ww  w  . ja v a  2  s.co m*/
 * 
 * @param x
 *            The x dimension of the box
 * @param y
 *            The y dimension of the box
 * @param z
 *            The z dimension of the box
 */
public void addBox(float x, float y, float z, Color3f diffuse, Color3f spec) {
    // Add a box with the given dimension

    // First setup an appearance for the box
    Appearance app = new Appearance();
    Material mat = new Material();
    mat.setDiffuseColor(diffuse);
    mat.setSpecularColor(spec);
    mat.setShininess(5.0f);

    app.setMaterial(mat);
    Box box = new Box(x, y, z, app);

    // Create a TransformGroup and make it the parent of the box
    TransformGroup tg = new TransformGroup();
    tg.addChild(box);

    // Then add it to the rootBranchGroup
    rootBranchGroup.addChild(tg);

    tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

    MouseRotate myMouseRotate = new MouseRotate();
    myMouseRotate.setTransformGroup(tg);
    myMouseRotate.setSchedulingBounds(new BoundingSphere());
    rootBranchGroup.addChild(myMouseRotate);

    MouseTranslate myMouseTranslate = new MouseTranslate();
    myMouseTranslate.setTransformGroup(tg);
    myMouseTranslate.setSchedulingBounds(new BoundingSphere());
    rootBranchGroup.addChild(myMouseTranslate);

    MouseZoom myMouseZoom = new MouseZoom();
    myMouseZoom.setTransformGroup(tg);
    myMouseZoom.setSchedulingBounds(new BoundingSphere());
    rootBranchGroup.addChild(myMouseZoom);
}

From source file:SpotLightApp.java

Appearance createMatAppear(Color3f dColor, Color3f sColor, float shine) {

    Appearance appear = new Appearance();
    Material material = new Material();
    material.setDiffuseColor(dColor);/*w  ww  .  ja  v a 2  s  .  c om*/
    material.setSpecularColor(sColor);
    material.setShininess(shine);
    appear.setMaterial(material);

    return appear;
}

From source file:LightScopeApp.java

Appearance createMaterialAppearance(Color3f color) {
    Appearance appear = new Appearance();
    Material material = new Material();
    material.setDiffuseColor(color);//from w w  w. ja  v  a  2 s  . co m
    material.setShininess(50.0f);
    appear.setMaterial(material);

    return appear;
}

From source file:AlternateAppearanceScopeTest.java

public SphereGroup(float radius, float xSpacing, float ySpacing, int xCount, int yCount, Appearance app,
        boolean overrideflag) {
    if (app == null) {
        app = new Appearance();
        Material material = new Material();
        material.setDiffuseColor(new Color3f(0.8f, 0.8f, 0.8f));
        material.setSpecularColor(new Color3f(0.0f, 0.0f, 0.0f));
        material.setShininess(0.0f);
        app.setMaterial(material);/*from  w  w w.ja  va2 s  .  c  o  m*/
    }

    double xStart = -xSpacing * (double) (xCount - 1) / 2.0;
    double yStart = -ySpacing * (double) (yCount - 1) / 2.0;

    Sphere sphere = null;
    TransformGroup trans = null;
    Transform3D t3d = new Transform3D();
    Vector3d vec = new Vector3d();
    double x, y = yStart, z = 0.0;
    shapes = new Shape3D[xCount * yCount];
    for (int i = 0; i < yCount; i++) {
        x = xStart;
        for (int j = 0; j < xCount; j++) {
            vec.set(x, y, z);
            t3d.setTranslation(vec);
            trans = new TransformGroup(t3d);
            addChild(trans);

            sphere = new Sphere(radius, // sphere radius
                    Primitive.GENERATE_NORMALS, // generate normals
                    16, // 16 divisions radially
                    app); // it's appearance
            trans.addChild(sphere);
            x += xSpacing;
            shapes[numShapes] = sphere.getShape();
            if (overrideflag)
                shapes[numShapes].setCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_WRITE);
            numShapes++;
        }
        y += ySpacing;
    }
}

From source file:ExSpotLight.java

public SphereGroup(float radius, float xSpacing, float ySpacing, int xCount, int yCount, Appearance app) {
    if (app == null) {
        app = new Appearance();
        Material material = new Material();
        material.setDiffuseColor(new Color3f(0.8f, 0.8f, 0.8f));
        material.setSpecularColor(new Color3f(0.0f, 0.0f, 0.0f));
        material.setShininess(0.0f);
        app.setMaterial(material);/* www  .ja v  a 2  s. c  o m*/
    }

    double xStart = -xSpacing * (double) (xCount - 1) / 2.0;
    double yStart = -ySpacing * (double) (yCount - 1) / 2.0;

    Sphere sphere = null;
    TransformGroup trans = null;
    Transform3D t3d = new Transform3D();
    Vector3d vec = new Vector3d();
    double x, y = yStart, z = 0.0;
    for (int i = 0; i < yCount; i++) {
        x = xStart;
        for (int j = 0; j < xCount; j++) {
            vec.set(x, y, z);
            t3d.setTranslation(vec);
            trans = new TransformGroup(t3d);
            addChild(trans);

            sphere = new Sphere(radius, // sphere radius
                    Primitive.GENERATE_NORMALS, // generate normals
                    16, // 16 divisions radially
                    app); // it's appearance
            trans.addChild(sphere);
            x += xSpacing;
        }
        y += ySpacing;
    }
}

From source file:ExBluePrint.java

private Group buildGadget() {
    if (debug)/*from  w ww.  j a v  a2  s .c o m*/
        System.err.println("  gadget...");
    //
    //  Create two appearances:
    //    wireframeApp: draw as blue wireframe
    //    shadedApp: draw as metalic shaded polygons
    //

    //  Wireframe:
    //    no Material - defaults to coloring attributes color
    //    polygons as lines, with backfaces
    //    thick lines
    Appearance wireframeApp = new Appearance();

    ColoringAttributes wireframeCatt = new ColoringAttributes();
    wireframeCatt.setColor(0.0f, 0.2559f, 0.4213f);
    wireframeCatt.setShadeModel(ColoringAttributes.SHADE_FLAT);
    wireframeApp.setColoringAttributes(wireframeCatt);

    PolygonAttributes wireframePatt = new PolygonAttributes();
    wireframePatt.setPolygonMode(PolygonAttributes.POLYGON_LINE);
    wireframePatt.setCullFace(PolygonAttributes.CULL_NONE);
    wireframeApp.setPolygonAttributes(wireframePatt);

    LineAttributes wireframeLatt = new LineAttributes();
    wireframeLatt.setLineWidth(2.0f);
    wireframeApp.setLineAttributes(wireframeLatt);

    //  Shaded:
    //    silver material
    Appearance shadedApp = new Appearance();

    Material shadedMat = new Material();
    shadedMat.setAmbientColor(0.30f, 0.30f, 0.30f);
    shadedMat.setDiffuseColor(0.30f, 0.30f, 0.50f);
    shadedMat.setSpecularColor(0.60f, 0.60f, 0.80f);
    shadedMat.setShininess(0.10f);
    shadedApp.setMaterial(shadedMat);

    ColoringAttributes shadedCatt = new ColoringAttributes();
    shadedCatt.setShadeModel(ColoringAttributes.SHADE_GOURAUD);
    shadedApp.setColoringAttributes(shadedCatt);

    //
    //  Create a switch group to hold two versions of the
    //  shape: one wireframe, and one shaded
    //
    Transform3D tr = new Transform3D();
    tr.set(new Vector3f(-1.0f, 0.2f, 0.0f));
    TransformGroup gadget = new TransformGroup(tr);
    shadingSwitch = new Switch();
    shadingSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);
    Group wireframe = new Group();
    Group shaded = new Group();
    shadingSwitch.addChild(wireframe);
    shadingSwitch.addChild(shaded);
    shadingSwitch.setWhichChild(1); // shaded
    gadget.addChild(shadingSwitch);

    //
    //  Build a gear (wireframe and shaded)
    //
    tr = new Transform3D();
    tr.rotY(Math.PI / 2.0);
    TransformGroup tg = new TransformGroup(tr);
    SpurGear gear = new SpurGearThinBody(24, // tooth count
            1.6f, // pitch circle radius
            0.3f, // shaft radius
            0.08f, // addendum
            0.05f, // dedendum
            0.3f, // gear thickness
            0.28f, // tooth tip thickness
            wireframeApp);// appearance
    tg.addChild(gear);
    wireframe.addChild(tg);

    tg = new TransformGroup(tr);
    gear = new SpurGearThinBody(24, // tooth count
            1.6f, // pitch circle radius
            0.3f, // shaft radius
            0.08f, // addendum
            0.05f, // dedendum
            0.3f, // gear thickness
            0.28f, // tooth tip thickness
            shadedApp); // appearance
    tg.addChild(gear);
    shaded.addChild(tg);

    //
    //  Build another gear (wireframe and shaded)
    //
    tr.rotY(Math.PI / 2.0);
    Vector3f trans = new Vector3f(-0.5f, 0.0f, 0.0f);
    tr.setTranslation(trans);
    tg = new TransformGroup(tr);
    gear = new SpurGearThinBody(30, // tooth count
            2.0f, // pitch circle radius
            0.3f, // shaft radius
            0.08f, // addendum
            0.05f, // dedendum
            0.3f, // gear thickness
            0.28f, // tooth tip thickness
            wireframeApp);// appearance
    tg.addChild(gear);
    wireframe.addChild(tg);

    tg = new TransformGroup(tr);
    gear = new SpurGearThinBody(30, // tooth count
            2.0f, // pitch circle radius
            0.3f, // shaft radius
            0.08f, // addendum
            0.05f, // dedendum
            0.3f, // gear thickness
            0.28f, // tooth tip thickness
            shadedApp); // appearance
    tg.addChild(gear);
    shaded.addChild(tg);

    //
    //  Build a cylindrical shaft (wireframe and shaded)
    //
    tr.rotZ(-Math.PI / 2.0);
    trans = new Vector3f(1.0f, 0.0f, 0.0f);
    tr.setTranslation(trans);
    tg = new TransformGroup(tr);
    Cylinder cyl = new Cylinder(0.3f, // radius
            4.0f, // length
            Primitive.GENERATE_NORMALS, // format
            16, // radial resolution
            1, // length-wise resolution
            wireframeApp);// appearance
    tg.addChild(cyl);
    wireframe.addChild(tg);

    tg = new TransformGroup(tr);
    cyl = new Cylinder(0.3f, // radius
            4.0f, // length
            Primitive.GENERATE_NORMALS, // format
            16, // radial resolution
            1, // length-wise resolution
            shadedApp); // appearance
    tg.addChild(cyl);
    shaded.addChild(tg);

    //
    //  Build shaft teeth (wireframe and shaded)
    //
    tr.rotY(Math.PI / 2.0);
    trans = new Vector3f(2.05f, 0.0f, 0.0f);
    tr.setTranslation(trans);
    tg = new TransformGroup(tr);
    gear = new SpurGear(12, // tooth count
            0.5f, // pitch circle radius
            0.3f, // shaft radius
            0.05f, // addendum
            0.05f, // dedendum
            1.5f, // gear thickness
            0.8f, // tooth tip thickness
            wireframeApp);// appearance
    tg.addChild(gear);
    wireframe.addChild(tg);

    tg = new TransformGroup(tr);
    gear = new SpurGear(12, // tooth count
            0.5f, // pitch circle radius
            0.3f, // shaft radius
            0.05f, // addendum
            0.05f, // dedendum
            1.5f, // gear thickness
            0.8f, // tooth tip thickness
            shadedApp); // appearance
    tg.addChild(gear);
    shaded.addChild(tg);

    return gadget;
}