Example usage for javax.media.j3d Material setDiffuseColor

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

Introduction

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

Prototype

public void setDiffuseColor(Color3f color) 

Source Link

Document

Sets this material's diffuse color.

Usage

From source file:Licht.java

/**
 * Wurfeldarstellung/*from w  w w  . j  a  v a 2  s.  com*/
 * 
 * @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:BasicConstruct.java

/**
 * Adds a box to the universe/*from  w  ww  .  j  av  a2s .  c o 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);
    material.setSpecularColor(sColor);//from   ww w  . j  ava  2s  .c om
    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);
    material.setShininess(50.0f);/*  ww  w . j  a v  a 2s .co m*/
    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);//from www  . ja  v  a 2  s.  c o  m
        app.setMaterial(material);
    }

    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:GeomInfoApp.java

Appearance createMaterialAppearance() {

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

    Material material = new Material();
    material.setDiffuseColor(new Color3f(1.0f, 0.0f, 0.0f));
    materialAppear.setMaterial(material);

    return materialAppear;
}

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);//w w  w.  ja  v  a 2  s .co m
        app.setMaterial(material);
    }

    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;
    }
}