示例#1
0
  public void preIntroSetup() {
    try {

      int bgWidth = env.bgImg.getWidth(env);
      int bgHeight = env.bgImg.getHeight(env);
      int[] bgPixels = new int[bgWidth * bgHeight];
      for (int i = 0; i < bgPixels.length; i++) if (bgPixels[i] != 0) System.out.print(bgPixels[i]);
      overlay = new PImage(bgWidth, bgHeight);
      overlay.format = ARGB;
      overlay.pixels = bgPixels;
      runNum = 0;
      controls.setEnabled(false);

      /** * get into looping */
      afterFirstStreaming = true;
      /** overview shut */
      draw();
      /*theCamera.moveToNow(new FVector(0.0f, 0.0f, 1000));
      theCamera.lookAtNow(new FVector(0.0f, 1.0f, 0));
      */
      draw();
      ortho(-1500, 800, -800, 800, 1000, 2000);
      loadPixels();
      noStroke();
      getOverviewShut();
      afterOverviewShot = true;
      draw();
      loop();

      /** give the environment the hint to swop the surfaces */
      env.addThem();
      /** * intro */
      theCamera.moveToNow(new FVector(-200.0f, 950.0f, 1000));
      theCamera.lookAtNow(new FVector(-200.51917f, 851.8057f, 0));
      theCamera.lookAtInter(
          new FVector(1341.8213f, 757.865f, 0), new Integer(4000), new Integer(3));
      Object[] actionObjects = {new FVector(0, 0, -88), new Integer(2000), new Integer(0)};
      theCamera.queueAction("lookAtInter", 4000, actionObjects);
      theCamera.moveToNow(new FVector(-500.51917f, 951.8057f, 200));
      theCamera.moveToInter(
          new FVector(1341.8213f, 857.865f, 200), new Integer(4000), new Integer(3));
      Object[] actionObjects2 = {
        new FVector(0, 800, Camera.maxCameraHeight), new Integer(2000), new Integer(1)
      };
      theCamera.queueAction("moveToInter", 0, actionObjects2);
      Object[] actionObjects3 = {Boolean.valueOf(true)};
      theCamera.queueAction("setControlsEnabled", 3500, actionObjects3);
    } catch (Exception e) {
      e.printStackTrace();
      env.setErrorDisplay(
          "Das Applet konnte nicht gestartet werden. Eventuell ist dies ein Speicherproblem. Bitte stoppen sie alle anderen Java-Anwendungen. GGf. muss der Browser neu gestartet werden um den Cache zu leeren.");
    }
  }
示例#2
0
  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);
  }