Example #1
0
  // -----------------------------------------------------------------
  //  Draws this panel by requesting that each Building draw itself.
  // -----------------------------------------------------------------
  public void paintComponent(Graphics page) {
    super.paintComponent(page);

    building1.draw(page);
    building2.draw(page);
    building3.draw(page);
    building4.draw(page);
    building5.draw(page);
  }
  public void draw() {
    if (!afterFirstStreaming) return;
    runNum++;

    if (afterOverviewShot) returnChanges = theCamera.apply();

    // test world Objects with screen frustum
    if (returnChanges) {
      for (int i = 0; i < objectManager.worldObjects.size(); i++) {
        if (((ObjectOfInterest) (objectManager.worldObjects.elementAt(i))).selectable)
          ((Building) (objectManager.worldObjects.elementAt(i))).testIfOnScreen();
      }
    }
    // process moving objects
    movingObjectsManager.process();
    // draw time and weather conditions
    naturalFactor.putIntoEffect();
    // korrdinatensystem
    groundPlane.draw(touring);
    clearZBuffer();
    // houses.draw();
    boxes.draw();

    pushMatrix();
    scale(buildingUniScale);
    // draw models
    for (int i = 0; i < objectManager.worldObjects.size(); i++) {
      if (((ObjectOfInterest) (objectManager.worldObjects.elementAt(i))).selectable) {
        ((Building) (objectManager.worldObjects.elementAt(i)))
            .draw(this, false /* Don't draw in gray old:touring*/);
      } else ((ObjectOfInterest) (objectManager.worldObjects.elementAt(i))).draw(this, touring);
    }
    popMatrix();

    /**
     * ****************** AFTER INTRO
     * **************************************************************************************
     */
    if (afterIntro) { //
      if (theCamera.getPos() != null) Overview.setLookPoint(theCamera.getPos()); //
      locator.draw(); //
      //
      // draw moving objects                                                                //
      movingObjectsManager.draw(); //
      //
      if (drawDebugSpheres) { //
        sphereDetail(20); //
        for (int i = 0; i < objectManager.worldObjects.size(); i++) { //
          if (((ObjectOfInterest) (objectManager.worldObjects.elementAt(i)))
              . //
              selectable) //
          ((Building) (objectManager.worldObjects.elementAt(i))).debugDraw(this); //
        } //
      } //
      //
      fill(255, 255, 255, 255); //
      noStroke(); //
      //
      // sphere list drawing for testing                                                     //
      for (int i = 0; i < spheres.size(); i++) { //
        FVector pos = ((FVector) (spheres.elementAt(i))).cloneMe(); //
        fill(255, 100, 100, 255); //
        pushMatrix(); //
        translate(pos.getX(), pos.getY(), pos.getZ()); //
        sphere(10 + 5 * i); //
        popMatrix(); //
      } //
      //
    } //
    /**
     * ************************************************************************************* END
     * AFTER INTRO **************************
     */
    naturalFactor.applySurroundings();

    if (selectedBuilding != null) {
      pushMatrix();
      scale(buildingUniScale);
      selectedBuilding.draw(this, false);
      popMatrix();
    }

    // clearZBuffer();
    hint(DISABLE_DEPTH_TEST);

    /*
     * if (overviewImage != null) { for (int y = 0, y2 = 0; y <
     * (overviewImage.height * width); y += width, y2 +=
     * overviewImage.width) { for (int x = width - overviewImage.width,
     * x2 = 0; x < width; x++, x2++) { //System.out.println("" + (x + y) + " " +
     * (x2+y2)); pixels[y+x] = 0xff000000 + color( (red(pixels[y+x]) +
     * red (overviewImage.pixels[y2+x2]))/2, (green(pixels[y+x]) + green
     * (overviewImage.pixels[y2+x2]))/2, (blue(pixels[y+x]) +
     * blue(overviewImage.pixels[y2+x2]))/2); } } }
     */

    // 2D interface (buttons and sliders so far)
    camera(); // reset camera
    // lights();

    fill(0, 20, 150, 20);
    stroke(255, 0, 0);
    noFill();

    // render SlideCases
    renderSlideCases(mouseX, mouseY);

    if (touring) {
      if (preparingForTouring) {
        detailPreparingStep();
      } else {
        paintTouringRope();
        drawDetailBraces();
      }
    }

    if (overlay != null) {
      image(overlay, 0, 250);
    }

    theCamera.drawFramerate();

    // clean up and similar
    // *****************************************************
    controls.reset();
    env.repaintEnv();

    // wait delay to allow processing of other system tasks
    try {
      delay(30);
    } catch (java.lang.IllegalMonitorStateException e) {
      //        	  e.printStackTrace();
    }
    noHint(DISABLE_DEPTH_TEST);
  }