Package javax.media.j3d

Examples of javax.media.j3d.BranchGroup


  //Some light is added to the scene here.
  public void addLight(SimpleUniverse su)
  {

    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(0.2f,-0.1f,-1.0f);
    DirectionalLight light1 = new DirectionalLight(lightColour1, lightDir1);
    light1.setInfluencingBounds(bounds);

    bgLight.addChild(light1);


    su.addBranchGraph(bgLight);

  }
View Full Code Here


      view.setFieldOfView(0.6*Math.PI);

  }
 
  private void createSceneGraph() {
      parent = new BranchGroup();
     
      ciel = new Background(new Color3f(0.9f, 0.9f, 1.0f));
      ciel.setCapability(Background.ALLOW_COLOR_WRITE);
      ciel.setApplicationBounds(new BoundingSphere(new Point3d(0, 0, 0), 80));
      parent.addChild(ciel);
View Full Code Here

      mouvement.mul(rotation);
      simpleU.getViewingPlatform().getViewPlatformTransform().setTransform(mouvement);
  }
 
  public void dessinerLigne(List<Point> ligne){
    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

    bg.addChild(new Shape3D(ligneArray));
    simpleU.addBranchGraph(bg);
  }
 
  public void dessinerSurface(List<Point> frontiere){
    BranchGroup bg = new BranchGroup();
    Shape3D surface = new Shape3D();
   
    float[] coords = new float[(frontiere.size()+1)*3];
        int i = 0;
        for (Point p : frontiere){
          coords[i++]= (float)p.y;
          coords[i++]= (float)p.z;
          coords[i++]= (float)p.x;
        }
        Point p = frontiere.get(0);
        coords[i++]= (float)p.y;
      coords[i++]= (float)p.z;
      coords[i++]= (float)p.x;
   
        int[] stripCount = {frontiere.size()+1}// ******
       
        GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
        gi.setCoordinates(coords);
        gi.setStripCounts(stripCount);
        gi.recomputeIndices();
       

        NormalGenerator ng = new NormalGenerator();
        ng.generateNormals(gi);
        gi.recomputeIndices();

        Stripifier st = new Stripifier();
        st.stripify(gi);
        gi.recomputeIndices();

        surface.setAppearance(CreateurVoiture.createMaterialAppearance());
        surface.setGeometry(gi.getGeometryArray());
   
    bg.addChild(surface);
    simpleU.addBranchGraph(bg);
    //System.out.println(frontiere.size() +" pts traces");
  }
View Full Code Here

    simpleU.addBranchGraph(bg);
    //System.out.println(frontiere.size() +" pts traces");
  }
 
  public void creerVoiture1(float x, float y, float z){
    BranchGroup voiture1 = new BranchGroup();
    voiture1tg = new TransformGroup();
    voiture1tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
      Transform3D translation;
      translation = new Transform3D();
      translation.setTranslation(new Vector3f (0, 0, 0));
      voiture1tg.setTransform(translation);
      /*ColoringAttributes ca = new ColoringAttributes();
      ca.setColor(0.8f, 0.8f, 0.2f);
      Appearance boxAppear = new Appearance();
      boxAppear.setColoringAttributes(ca);
      Box box = new Box(x/2, y, z, boxAppear);
      //Box box = new Box();
      voiture1tg.addChild(box);
      voiture1.addChild(voiture1tg);
      voiture1.compile();
      simpleU.addBranchGraph(voiture1);*/
     
      DirectionalLight light2 = new DirectionalLight();
      light2.setDirection(new Vector3f(0.1f, -0.5f, 0.1f));
      //light.setColor(new Color3f(0.5f, 0.5f, 0.5f));
      light2.setInfluencingBounds(new BoundingSphere(new Point3d(0, 0, 0), 80));
      voiture1.addChild(light2);
     
      voiture1tg.addChild(CreateurVoiturePeugeot.creerForme(true));
      voiture1.addChild(voiture1tg);
      voiture1.compile();
      simpleU.addBranchGraph(voiture1);
  }
View Full Code Here

      voiture1.compile();
      simpleU.addBranchGraph(voiture1);
  }
 
  public void creerVoiture2(float x, float y, float z){
    BranchGroup voiture2 = new BranchGroup();
    voiture2tg = new TransformGroup();
    voiture2tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
      Transform3D translation;
      translation = new Transform3D();
      translation.setTranslation(new Vector3f (0, 0, 0));
      voiture2tg.setTransform(translation);
      /*ColoringAttributes ca = new ColoringAttributes();
      ca.setColor(0.2f, 0.2f, 0.9f);
      Appearance boxAppear = new Appearance();
      boxAppear.setColoringAttributes(ca);*/
      //Box box = new Box(x, y, z, boxAppear);
      //Box box = new Box();
     
      DirectionalLight light2 = new DirectionalLight();
      light2.setDirection(new Vector3f(0.1f, -0.5f, 0.1f));
      //light.setColor(new Color3f(0.5f, 0.5f, 0.5f));
      light2.setInfluencingBounds(new BoundingSphere(new Point3d(0, 0, 0), 80));
      voiture2.addChild(light2);
     
      voiture2tg.addChild(CreateurVoiturePeugeot.creerForme(false));
      voiture2.addChild(voiture2tg);
      voiture2.compile();
      simpleU.addBranchGraph(voiture2);
  }
View Full Code Here

    TransformGroup tgTetrahedron = new TransformGroup(tfTetrahedron);
    tgTetrahedron.addChild(tetrahedron);


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

    //Add the tetrahedron to the scene.
    theScene.addChild(tgTetrahedron);

    theScene.compile();

    //Add everything to the universe.
    su.addBranchGraph(theScene);

  }
View Full Code Here

  //Some light is added to the scene here.
  public void addLight(SimpleUniverse su)
  {

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


    Vector3f lightDir2  = new Vector3f(1.0f,0.0f,0.5f);
    DirectionalLight light2 = new DirectionalLight(lightColour1, lightDir2);
    light2.setInfluencingBounds(bounds);


    bgLight.addChild(light1);
    bgLight.addChild(light2);

    su.addBranchGraph(bgLight);
  }
View Full Code Here

    tfBSphere.setTranslation(new Vector3f(2.0f,0.0f,-10.5f));
    TransformGroup tgBSphere = new TransformGroup(tfBSphere);
    tgBSphere.addChild(tgmBSphere);

    //Generate the scenegraph.
    BranchGroup theScene = new BranchGroup();
    theScene.addChild(tgFBox);
    theScene.addChild(tgBSphere);


    //Definition of the parameters for picking. Generate the PickingBehaviour
    //and add it to the scene.
    Alpha[] alphas = new Alpha[3];

    alphas[0] = boxAlpha;
    alphas[1] = sphereShrinkAlpha;
    alphas[2] = sphereStretchAlpha;

    PickingExample pe = new PickingExample(myCanvas3D,theScene,bounds,alphas);

    theScene.addChild(pe);


    theScene.compile();

    //Add everything to the universe.
    su.addBranchGraph(theScene);

  }
View Full Code Here

  //Some light is added to the scene here.
  public void addLight(SimpleUniverse su)
  {

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


    su.addBranchGraph(bgLight);

  }
View Full Code Here

TOP

Related Classes of javax.media.j3d.BranchGroup

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.