コード例 #1
0
ファイル: Scene3D.java プロジェクト: TeMPOraL/Sparkle
 private void setSceneAppearance() {
   AmbientLight lightA = new AmbientLight();
   lightA.setColor(new Color3f(255, 0, 100));
   _contents.addChild(lightA);
   Background background = new Background();
   background.setColor(EnvSettings.BACKGROUND_COLOR);
   _bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 0.1);
   background.setApplicationBounds(_bounds);
   _contents.addChild(background);
 }
コード例 #2
0
ファイル: KainCorak.java プロジェクト: danurwenda/JB4
  public void prepareCorak(
      String projectPath, CorakLSystem cor, CorakDataObject obj, boolean encloseOBJ) {

    this.projectPath = projectPath;

    // initiate our "turtle" -> Canting
    canting = new Canting(cor, obj);

    // start creating shapes based on Cor
    timer = System.currentTimeMillis();
    canting.generate(encloseOBJ);

    BoundingSphere lightingBounds = new BoundingSphere(new Point3d(0, 0, 0), FARTHEST);
    camLamp = new PointLight();
    camLamp.setCapability(PointLight.ALLOW_POSITION_READ);
    camLamp.setCapability(PointLight.ALLOW_POSITION_WRITE);
    camLamp.setColor(new Color3f(1.0f, 1.0f, 1.0f));
    camLamp.setInfluencingBounds(lightingBounds);

    ambient = new AmbientLight();
    ambient.setColor(new Color3f(1.0f, 1.0f, 1.0f));
    ambient.setInfluencingBounds(lightingBounds);

    canting.getBatikBG().addChild(camLamp);
    canting.getBatikBG().addChild(ambient);

    // attach generated shapes to root TransformGroup
    Enumeration kaintgchildren = kainTG.getAllChildren();
    while (kaintgchildren.hasMoreElements()) {
      Node child = (Node) kaintgchildren.nextElement();
      if (child instanceof Measurer) {
        ((Measurer) child).removeAllChildren();
      } else {
        kainTG.removeChild(child);
      }
    }
    //        canting.getBatikBG().compile();
    kainTG.addChild(canting.getBatikBG());

    timer = System.currentTimeMillis() - timer;
    // System.out.println("Timer= " + timer);

    bs = (BoundingSphere) canting.getBatikBG().getBounds();
  }
コード例 #3
0
  //
  //  Build scene
  //
  public Group buildScene() {
    // Turn off the example headlight
    setHeadlightEnable(false);

    // Build the scene group
    Group scene = new Group();

    // Build foreground geometry into two groups.  We'll
    // create three directional lights below, one each with
    // scope to cover the first geometry group only, the
    // second geometry group only, or both geometry groups.
    content1 =
        new SphereGroup(
            0.25f, // radius of spheres
            1.5f, // x spacing
            0.75f, // y spacing
            3, // number of spheres in X
            5, // number of spheres in Y
            null); // appearance
    scene.addChild(content1);

    content2 =
        new SphereGroup(
            0.25f, // radius of spheres
            1.5f, // x spacing
            0.75f, // y spacing
            2, // number of spheres in X
            5, // number of spheres in Y
            null); // appearance
    scene.addChild(content2);

    // BEGIN EXAMPLE TOPIC
    // Create influencing bounds
    BoundingSphere worldBounds =
        new BoundingSphere(
            new Point3d(0.0, 0.0, 0.0), // Center
            1000.0); // Extent

    // Add three directional lights whose scopes are set
    // to cover one, the other, or both of the shape groups
    // above.  Also set the lights' color and aim direction.

    // Light #1 with content1 scope
    light1 = new DirectionalLight();
    light1.setEnable(light1OnOff);
    light1.setColor(Red);
    light1.setDirection(new Vector3f(1.0f, 0.0f, -1.0f));
    light1.setInfluencingBounds(worldBounds);
    light1.addScope(content1);
    light1.setCapability(Light.ALLOW_STATE_WRITE);
    scene.addChild(light1);

    // Light #2 with content2 scope
    light2 = new DirectionalLight();
    light2.setEnable(light2OnOff);
    light2.setColor(Blue);
    light2.setDirection(new Vector3f(1.0f, 0.0f, -1.0f));
    light2.setInfluencingBounds(worldBounds);
    light2.addScope(content2);
    light2.setCapability(Light.ALLOW_STATE_WRITE);
    scene.addChild(light2);

    // Light #3 with universal scope (the default)
    light3 = new DirectionalLight();
    light3.setEnable(light3OnOff);
    light3.setColor(White);
    light3.setDirection(new Vector3f(1.0f, 0.0f, -1.0f));
    light3.setInfluencingBounds(worldBounds);
    light3.setCapability(Light.ALLOW_STATE_WRITE);
    scene.addChild(light3);

    // Add an ambient light to dimly illuminate the rest of
    // the shapes in the scene to help illustrate that the
    // directional lights are being scoped... otherwise it looks
    // like we're just removing shapes from the scene
    AmbientLight ambient = new AmbientLight();
    ambient.setEnable(true);
    ambient.setColor(White);
    ambient.setInfluencingBounds(worldBounds);
    scene.addChild(ambient);
    // END EXAMPLE TOPIC

    return scene;
  }