Package javax.vecmath

Examples of javax.vecmath.Color3f


    BranchGroup bg = new BranchGroup();
    int stripVertexCounts[] = {ligne.size()};
    LineStripArray ligneArray = new LineStripArray(ligne.size(), LineArray.COORDINATES | LineArray.COLOR_3, stripVertexCounts);
    for (int i=0; i<ligne.size(); i++){
      ligneArray.setCoordinate(i, new Point3d(ligne.get(i).y, ligne.get(i).z + 0.2, ligne.get(i).x));
      ligneArray.setColor(i, new Color3f(Color.blue));
    }
    bg.addChild(new Shape3D(ligneArray));
    simpleU.addBranchGraph(bg);
  }
View Full Code Here


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

        if(bleu){
          Material material = new Material();
            material.setDiffuseColor(new Color3f(1.0f, 0.0f, 0.0f));
            materialAppear.setMaterial(material);
        } else {
          Material material = new Material();
            material.setDiffuseColor(new Color3f(0.0f, 0.0f, 1.0f));
            materialAppear.setMaterial(material);
        }
       
       
        ColoringAttributes ca = new ColoringAttributes();
View Full Code Here

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

        Material material = new Material();
        material.setDiffuseColor(new Color3f(0.2f, 0.2f, 0.2f));
        materialAppear.setMaterial(material);
       
        ColoringAttributes ca = new ColoringAttributes();
        ca.setColor(0.5f, 0.5f, 0.5f);
        materialAppear.setColoringAttributes(ca);
View Full Code Here

  public void createSceneGraph(SimpleUniverse su)
  {


    Appearance yellowApp = new Appearance();
    setToMyDefaultAppearance(yellowApp,new Color3f(0.5f,0.5f,0.0f));


    //The four vertices of the tetrahedron.
    Point3f[] tetrahedronCoordinates =
      {
View Full Code Here

  {

    BranchGroup bgLight = new BranchGroup();

    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), Double.MAX_VALUE);
    Color3f lightColour1 = new Color3f(1.0f,1.0f,1.0f);
    Vector3f lightDir1  = new Vector3f(-1.0f,0.0f,-0.5f);
    DirectionalLight light1 = new DirectionalLight(lightColour1, lightDir1);
    light1.setInfluencingBounds(bounds);

View Full Code Here

  public void createSceneGraph(SimpleUniverse su)
  {


//*** Generate a red cube including its transformation group ***
    Color3f ambientColourFBox = new Color3f(0.5f,0.0f,0.0f);
    Color3f emissiveColourFBox = new Color3f(0.0f,0.0f,0.0f);
    Color3f diffuseColourFBox = new Color3f(0.5f,0.0f,0.0f);
    Color3f specularColourFBox = new Color3f(0.8f,0.0f,0.0f);
    float shininessFBox = 10.0f;

    Appearance fBoxApp = new Appearance();

    fBoxApp.setMaterial(new Material(ambientColourFBox,emissiveColourFBox,
                          diffuseColourFBox,specularColourFBox,shininessFBox));

    Box fBox = new Box(0.2f,0.2f,0.2f,fBoxApp);

    //The UserData are needed in order to identify the cube when it is picked.
    fBox.setUserData("box");

    TransformGroup tgmBox = new TransformGroup();
    tgmBox.addChild(fBox);

    Transform3D rotationAxis = new Transform3D();


    //The following lines define what the cube should do when picked.
    Alpha boxAlpha = new Alpha(1,2000);

    //The starting time is first postponed until "infinity".
    boxAlpha.setStartTime(Long.MAX_VALUE);

    RotationInterpolator boxRotation = new RotationInterpolator(boxAlpha,tgmBox,
                                             rotationAxis,0.0f,(float) Math.PI*2);

    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE);
    boxRotation.setSchedulingBounds(bounds);

    //The movement is added to the transformation group.
    tgmBox.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tgmBox.addChild(boxRotation);


    //A transformation group for positioning the cube.
    Transform3D tfFBox = new Transform3D();
    tfFBox.rotY(Math.PI/6);
    Transform3D rotationX = new Transform3D();
    rotationX.rotX(-Math.PI/5);
    tfFBox.mul(rotationX);
    TransformGroup tgFBox = new TransformGroup(tfFBox);
    tgFBox.addChild(tgmBox);


//*** The same for the sphere.
    Color3f ambientColourBSphere = new Color3f(0.0f,0.6f,0.0f);
    Color3f emissiveColourBSphere = new Color3f(0.0f,0.0f,0.0f);
    Color3f diffuseColourBSphere = new Color3f(0.0f,0.6f,0.0f);
    Color3f specularColourBSphere = new Color3f(0.0f,0.6f,0.0f);
    float shininessBSphere = 2.0f;

    Appearance bSphereApp = new Appearance();

    bSphereApp.setMaterial(new Material(ambientColourBSphere,
View Full Code Here

    BranchGroup bgLight = new BranchGroup();

    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), Double.MAX_VALUE);

    //Directional light.
    Color3f lightColour1 = new Color3f(1.0f,1.0f,1.0f);
    Vector3f lightDir1  = new Vector3f(-1.0f,0.0f,-0.5f);
    DirectionalLight light1 = new DirectionalLight(lightColour1, lightDir1);
    light1.setInfluencingBounds(bounds);

    bgLight.addChild(light1);


    //Ambient light.
    Color3f lightColourAmb = new Color3f(0.5f, 0.5f, 0.5f);
    AmbientLight lightAmb = new AmbientLight(lightColourAmb);
    lightAmb.setInfluencingBounds(bounds);
    bgLight.addChild(lightAmb);

View Full Code Here

  {

//*** Generate a cube. ***

    //Generate an (unrealistic) Appearance for the cube.
    Color3f ambientColourBox = new Color3f(1.0f,0.0f,0.0f);
    Color3f emissiveColourBox = new Color3f(0.0f,0.0f,0.0f);
    Color3f diffuseColourBox = new Color3f(0.0f,1.0f,0.0f);
    Color3f specularColourBox = new Color3f(0.0f,0.0f,1.0f);
    float shininessBox = 10.0f;

    Appearance boxApp = new Appearance();


    boxApp.setMaterial(new Material(ambientColourBox,emissiveColourBox,
                          diffuseColourBox,specularColourBox,shininessBox));




    Box myBox = new Box(0.2f,0.2f,0.2f,boxApp);

    //Rotate and shift the cube slightly.
    Transform3D tfBox = new Transform3D();
    tfBox.rotY(Math.PI/6);
    tfBox.rotX(Math.PI/9);
    Transform3D shift = new Transform3D();
    shift.setTranslation(new Vector3f(-0.6f,-0.2f,0.1f));
    tfBox.mul(shift);
    TransformGroup tgBox = new TransformGroup(tfBox);
    tgBox.addChild(myBox);




//*** Generate a sphere. ***

    //Generate an (unrealistic) Appearance for the sphere.
    Color3f ambientColourSphere = new Color3f(1.0f,0.0f,0.0f);
    Color3f emissiveColourSphere = new Color3f(0.3f,0.0f,0.0f);
    Color3f diffuseColourSphere = new Color3f(0.0f,1.0f,0.0f);
    Color3f specularColourSphere = new Color3f(0.0f,0.0f,1.0f);
    float shininessSphere = 20.0f;

    Appearance sphereApp = new Appearance();

    sphereApp.setMaterial(new Material(ambientColourSphere,emissiveColourSphere,
                           diffuseColourSphere,specularColourSphere,shininessSphere));



    Sphere mySphere = new Sphere(0.3f,Sphere.GENERATE_NORMALS,100,sphereApp);
    Transform3D tfSphere = new Transform3D();
    tfSphere.setTranslation(new Vector3f(0.0f,0.0f,-1.0f));

    TransformGroup tgSphere = new TransformGroup(tfSphere);
    tgSphere.addChild(mySphere);




    //*** Generate (the root of) the scenegraph. ***
    BranchGroup theScene = new BranchGroup();


    //Add the cube and the sphere to the scene.
    theScene.addChild(tgBox);
    theScene.addChild(tgSphere);


    //Generate a white background.
    Background bg = new Background(new Color3f(1.0f,1.0f,1.0f));
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE);
    bg.setApplicationBounds(bounds);
    theScene.addChild(bg);


View Full Code Here

    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), Double.MAX_VALUE);


    //Directional light to be rotated.
    Color3f lightColour = new Color3f(1.0f, 1.0f, 1.0f);
    Vector3f lightDir  = new Vector3f(0.0f, 0.0f, -1.0f);
    DirectionalLight light = new DirectionalLight(lightColour, lightDir);
    light.setInfluencingBounds(bounds);

    //The transformation group for the directional light including the rotation.
    TransformGroup tfmLight = new TransformGroup();
    tfmLight.addChild(light);

    //The Alpha for the rotation.
    Alpha alphaLight = new Alpha(-1,4000);
    //The rotation.
    RotationInterpolator rot = new RotationInterpolator(alphaLight,tfmLight,
                                                        new Transform3D(),
                                                         0.0f,(float) Math.PI*2);
    rot.setSchedulingBounds(bounds);

    tfmLight.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tfmLight.addChild(rot);

    bgLight.addChild(tfmLight);




    //Ambient light.
    Color3f ambientLightColour = new Color3f(0.5f, 0.5f, 0.5f);
    AmbientLight ambLight = new AmbientLight(ambientLightColour);
    ambLight.setInfluencingBounds(bounds);
    bgLight.addChild(ambLight);


View Full Code Here

  {

    BranchGroup theScene = new BranchGroup();

    //Generate a sphere.
    Color3f ambientColourBSphere = new Color3f(0.0f,0.0f,0.0f);
    Color3f emissiveColourBSphere = new Color3f(0.0f,0.0f,0.0f);
    Color3f diffuseColourBSphere = new Color3f(0.9f,0.9f,0.9f);
    Color3f specularColourBSphere = new Color3f(0.9f,0.9f,0.9f);
    float shininessBSphere = 128.0f;

    Appearance bSphereApp = new Appearance();

    bSphereApp.setMaterial(new Material(ambientColourBSphere,
                                        emissiveColourBSphere,
                                        diffuseColourBSphere,
                                        specularColourBSphere,
                                        shininessBSphere));

    Sphere bSphere = new Sphere(0.1f,bSphereApp);


    //Assign the sphere to a SharedGroup to use it multiple
    //times in the scene.
    SharedGroup sgSphere = new SharedGroup();
    sgSphere.addChild(bSphere);



    //Generate a two-dimensional array of rows*columns spheres.
    //rowStep and columnStep define the distance between the spheres.
    int rows = 40;
    float rowStep = 0.25f;
    int columns = 20;
    float columnStep = 0.3f;

    TransformGroup[][] tgArray = new TransformGroup[rows][columns];
    Transform3D[][] tfArray = new Transform3D[rows][columns];

    for (int i=0; i<rows; i++)
    {
      for (int j=0; j<columns; j++)
      {
        tfArray[i][j] = new Transform3D();
        tfArray[i][j].setTranslation(new Vector3f(i*columnStep-2.0f,j*0.1f-0.5f,-j*rowStep));
        tgArray[i][j] = new TransformGroup(tfArray[i][j]);
        tgArray[i][j].addChild(new Link(sgSphere));
        theScene.addChild(tgArray[i][j]);
      }
    }




    //Generate a background in the colour of the fog.
    Color3f fogColour = new Color3f(0.5f,0.5f,0.5f);
    Background bg = new Background(fogColour);
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE);
    bg.setApplicationBounds(bounds);
    theScene.addChild(bg);

View Full Code Here

TOP

Related Classes of javax.vecmath.Color3f

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.