/////////////////////////////// /// GLOBE RENDERING //////////////////////////////// private void renderGlobe() { // smoothly interpolate camera rotation // to new rotation vector based on mouse position // each frame we only approach that rotation by 25% (0.25 value) lights(); /* this looks pink ambientLight(255, 0, 0); specular(255, 0, 0); */ // store default 2D coordinate system pushMatrix(); // switch to 3D coordinate system and rotate view based on mouse translate(width / 2, height / 2, 0); ///// CHECK FOR MOUSE INPUT TO SET CAMERA if (mousePressed) { camRot.interpolateToSelf(new Vec3D(mouseY * 0.01f, mouseX * 0.01f, 0), 0.25f / currZoom); // println("MOUSEX: " + mouseX); // println("MouseY " + mouseY); theCamX = camRot.x; theCamY = camRot.y; ///// CHECK FOR OSC INPUT TO SET CAMERA } else if (hasOsc == true) { /// map(value, low1, high1, low2, high2) println("rotate dammit!"); float newX = map(oscX0, 0, 1, 0, screenWidth); // /// maps our input to 1024 float oscY = map(oscY0, 0, 1, 0, screenHeight); // /// camRot.interpolateToSelf(new Vec3D(oscY * 0.01f, newX * 0.01f, 0), 0.25f / currZoom); theCamX = camRot.x; theCamY = camRot.y; // rotateX(camRot.x); // rotateY(camRot.y); // currZoom += (targetZoom - currZoom) * 0.25; // */ } theOldCamX = theCamX; theOldCamY = theCamY; hasOsc = false; // /switch off osc input until we get another osc signal float newCamX = map(new Float(theCamX), 0, 7, 2, 4); // narrow the range of vertical camera movement currZoom += (targetZoom - currZoom) * 0.25; // theCamX = newCamX; rotateX(new Float(theCamX)); rotateY(new Float(theCamY)); // apply zoom factor scale(currZoom); // compute the normalized camera position/direction // using the same rotation setting as for the coordinate system // this vector is used to figure out if images are visible or not // (see below) Vec3D camPos = new Vec3D(0, 0, 1) .rotateX(new Float(theCamX)) .rotateY(new Float(theCamY)); // / changed from cam.x and cam.y camPos.normalize(); noStroke(); fill(255); // use normalized UV texture coordinates (range 0.0 ... 1.0) textureMode(NORMAL); // draw earth gfx.texturedMesh(globe, earthTex, true); //////////////////////////////////////// // /// SET GPS MARKERS ON THE SPHERE // check marker position for (int i = 0; i < GPSArray.size(); i++) { GPSArray.get(i).updateScreenPos(this, camPos); } // check destroyer position if (isVideoPlaying == false) { // if(thePopUp.isVideoPlaying == true){ theDestroyer.updateScreenPos(this, camPos); } ///////////////////////////////////////// // switch back to 2D coordinate system popMatrix(); // disable depth testing to ensure anything drawn next // will always be on top/infront of the globe hint(DISABLE_DEPTH_TEST); // draw images centered around the given positions imageMode(CENTER); // now that they're in position, draw them for (int i = 0; i < GPSArray.size(); i++) { GPSArray.get(i).drawAsImage(IMG_SIZE * currZoom * 0.9f, showLabels); } // draw the destroyer try { theDestroyer.drawAsImage(this, IMG_SIZE * currZoom * 0.9f, showLabels); } catch (Exception e) { println("Cant draw destroyer" + e); } setDestroyer(); //////////////////////////////////////// // restore (default) depth testing hint(ENABLE_DEPTH_TEST); }