Example usage for javax.media.j3d Appearance Appearance

List of usage examples for javax.media.j3d Appearance Appearance

Introduction

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

Prototype

public Appearance() 

Source Link

Document

Constructs an Appearance component object using defaults for all state variables.

Usage

From source file:Erscheinungsbild.java

/**
 * Wurfeldarstellung//w w w .  jav  a  2 s.  c  om
 * 
 * @return Appearance
 */
private Appearance makeAppearance() {
    Appearance a = new Appearance();
    ColoringAttributes c = new ColoringAttributes();
    c.setColor(new Color3f(0.0f, 1.0f, 0.0f));
    a.setColoringAttributes(c);
    return a;
}

From source file:TextureMapping.java

/**
 * Wurfeldarstellung//from  ww  w .  j av a2  s .  co m
 * 
 * @return Appearance
 */
private Appearance makeAppearance() {
    Appearance a = new Appearance();
    TextureLoader loader = null;
    if (getCodeBase() != null)
        try {
            // Laden der Obj Datei als Applet mit jar
            loader = new TextureLoader(new URL("jar:" + getCodeBase() + "TextureMapping.jar!/burnstone.jpg"),
                    null);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    else
        // Laden der Obj Datei mittels jar
        loader = new TextureLoader(ClassLoader.getSystemResource("burnstone.jpg"), null);

    Texture2D texture = (Texture2D) loader.getTexture();
    a.setTexture(texture);
    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);//from  w w  w. ja  v  a  2 s . c  o m
    // make modifications to default material properties
    appear.setMaterial(material);

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

    return appear;
}

From source file:edu.uci.ics.jung.visualization3d.PluggableRenderContext.java

public PluggableRenderContext() {
    super();/*  w  w  w . ja v a2  s. c om*/
    Color3f lightGray = new Color3f(0.7f, 0.7f, 0.7f);
    Color3f black = new Color3f(0, 0, 0);
    Color3f white = new Color3f(1, 1, 1);
    Color3f gray = new Color3f(.2f, .2f, .2f);
    Color3f red = new Color3f(1, 0, 0);
    Color3f yellow = new Color3f(0, 1, 1);
    Material lightGrayMaterial = new Material(lightGray, black, lightGray, white, 100.0f);
    Material blackMaterial = new Material(lightGray, black, black, lightGray, 10.0f);
    Material whiteMaterial = new Material(white, white, white, white, 100.0f);
    Material grayMaterial = new Material(gray, black, gray, gray, 100.0f);
    Material redMaterial = new Material(red, black, red, red, 100.0f);
    Material yellowMaterial = new Material(yellow, black, yellow, yellow, 100.0f);

    final Appearance lightGrayLook = new Appearance();
    lightGrayLook.setMaterial(lightGrayMaterial);
    Appearance blackLook = new Appearance();
    blackLook.setMaterial(blackMaterial);
    Appearance whiteLook = new Appearance();
    whiteLook.setMaterial(whiteMaterial);
    Appearance grayLook = new Appearance();
    grayLook.setMaterial(grayMaterial);

    //      grayLook.setCapability(Appearance.ALLOW_MATERIAL_READ);
    //      grayLook.setCapability(Appearance.ALLOW_MATERIAL_WRITE);

    final Appearance redLook = new Appearance();
    redLook.setMaterial(redMaterial);
    final Appearance yellowLook = new Appearance();
    yellowLook.setMaterial(yellowMaterial);

    final Cylinder cylinder = new Cylinder(1, 1, Cylinder.GENERATE_NORMALS | Cylinder.ENABLE_GEOMETRY_PICKING,
            26, 26, lightGrayLook);
    final Sphere sphere = new Sphere(10, Sphere.GENERATE_NORMALS | Sphere.ENABLE_GEOMETRY_PICKING, redLook);
    final Box box = new Box(10, 10, 10, Box.GENERATE_NORMALS | Box.ENABLE_GEOMETRY_PICKING, redLook);

    this.edgeAppearanceTransformer = new ConstantTransformer(lightGrayLook);
    this.edgeShapeTransformer = new Transformer<Context<Graph<V, E>, E>, Node>() {

        public Node transform(Context<Graph<V, E>, E> ec) {
            LineArray lineArray = new LineArray(2, LineArray.COORDINATES | LineArray.COLOR_3);
            lineArray.setCoordinates(0, new Point3f[] { new Point3f(0, -.5f, 0), new Point3f(0, .5f, 0) });
            lineArray.setColor(0, new Color3f(1, 1, 1));
            lineArray.setColor(1, new Color3f(1, 1, 1));
            Shape3D shape = new Shape3D();
            shape.setGeometry(lineArray);
            return shape;
            //            return new Cylinder(1, 1, 
            //                  Cylinder.GENERATE_NORMALS |
            //                  Cylinder.ENABLE_GEOMETRY_PICKING,
            //                   26, 26, lightGrayLook);
        }
    };
    this.vertexAppearanceTransformer = new ConstantTransformer(redLook);
    this.vertexShapeTransformer = new Transformer<V, Node>() {

        public Node transform(V arg0) {
            return new Sphere(10,
                    Sphere.GENERATE_NORMALS | Sphere.ENABLE_GEOMETRY_PICKING | Sphere.ENABLE_APPEARANCE_MODIFY,
                    redLook);
        }
    };
}

From source file:Licht.java

/**
 * Wurfeldarstellung/* w  w w . j a va 2  s  .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:SpotLightApp.java

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

    Appearance appear = new Appearance();
    Material material = new Material();
    material.setDiffuseColor(dColor);/*from w  w  w.  ja v  a2  s.  c  o  m*/
    material.setSpecularColor(sColor);
    material.setShininess(shine);
    appear.setMaterial(material);

    return appear;
}

From source file:SimpleCone.java

/**
 * This builds the content branch of our scene graph. It uses the buildShape
 * function to create the actual shape, adding to to the transform group so
 * that the shape is slightly tilted to reveal its 3D shape.
 * // w w w .  j a  v a  2 s  .  c o m
 * @param shape
 *            Node that represents the geometry for the content
 * @return BranchGroup that is the root of the content branch
 */
protected BranchGroup buildContentBranch() {
    BranchGroup contentBranch = new BranchGroup();
    Transform3D rotateCube = new Transform3D();
    rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI / 4.0));
    TransformGroup rotationGroup = new TransformGroup(rotateCube);
    contentBranch.addChild(rotationGroup);
    rotationGroup.addChild(new Cone(1.0f, 2.0f, 0, new Appearance()));
    return contentBranch;
}

From source file:SimpleCylinder.java

/**
 * This builds the content branch of our scene graph. It uses the Cylinder
 * utility class to create the actual shape, adding to to the transform
 * group so that the shape is slightly tilted to reveal its 3D shape.
 * //from   w  w  w .j a  v  a  2  s.  c o m
 * @param shape
 *            Node that represents the geometry for the content
 * @return BranchGroup that is the root of the content branch
 */
protected BranchGroup buildContentBranch() {
    BranchGroup contentBranch = new BranchGroup();
    Transform3D rotateCube = new Transform3D();
    rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI / 4.0));
    TransformGroup rotationGroup = new TransformGroup(rotateCube);
    contentBranch.addChild(rotationGroup);
    //Create the shape and add it to the branch
    rotationGroup.addChild(new Cylinder(1.0f, 1.0f, new Appearance()));
    return contentBranch;
}

From source file:PictureBall.java

public PictureBall() {

    // Create the universe
    SimpleUniverse universe = new SimpleUniverse();

    // Create a structure to contain objects
    BranchGroup group = new BranchGroup();

    // Set up colors
    Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f red = new Color3f(0.7f, .15f, .15f);

    // Set up the texture map
    TextureLoader loader = new TextureLoader("K:\\3d\\Arizona.jpg", "LUMINANCE", new Container());
    Texture texture = loader.getTexture();
    texture.setBoundaryModeS(Texture.WRAP);
    texture.setBoundaryModeT(Texture.WRAP);
    texture.setBoundaryColor(new Color4f(0.0f, 1.0f, 0.0f, 0.0f));

    // Set up the texture attributes
    //could be REPLACE, BLEND or DECAL instead of MODULATE
    TextureAttributes texAttr = new TextureAttributes();
    texAttr.setTextureMode(TextureAttributes.MODULATE);
    Appearance ap = new Appearance();
    ap.setTexture(texture);/*from w  ww . j  a  v a 2 s.  co m*/
    ap.setTextureAttributes(texAttr);

    //set up the material
    ap.setMaterial(new Material(red, black, red, black, 1.0f));

    // Create a ball to demonstrate textures
    int primflags = Primitive.GENERATE_NORMALS + Primitive.GENERATE_TEXTURE_COORDS;
    Sphere sphere = new Sphere(0.5f, primflags, ap);
    group.addChild(sphere);

    // Create lights
    Color3f light1Color = new Color3f(1f, 1f, 1f);
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

    Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);
    DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
    light1.setInfluencingBounds(bounds);
    group.addChild(light1);

    AmbientLight ambientLight = new AmbientLight(new Color3f(.5f, .5f, .5f));
    ambientLight.setInfluencingBounds(bounds);
    group.addChild(ambientLight);

    // look towards the ball
    universe.getViewingPlatform().setNominalViewingTransform();

    // add the group of objects to the Universe
    universe.addBranchGraph(group);
}

From source file:PureImmediate.java

public void render() {
    if (gc == null) {
        // Set up Graphics context
        gc = canvas.getGraphicsContext3D();
        gc.setAppearance(new Appearance());

        // Set up geometry
        cube = new ColorCube(0.4).getGeometry();
    }/*  www.  jav  a2 s .  c  om*/

    // Compute angle of rotation based on alpha value
    double angle = rotAlpha.value() * 2.0 * Math.PI;
    cmt.rotY(angle);

    // Render the geometry for this frame
    gc.clear();
    gc.setModelTransform(cmt);
    gc.draw(cube);
    canvas.swap();
}