Difference between revisions of "CameraFlight"

From Immersive Visualization Lab Wiki
Jump to: navigation, search
(Project Overview)
(Status)
 
(16 intermediate revisions by one user not shown)
Line 1: Line 1:
==CameraFlight - osgEarth Camera Transitions==
+
==Project Overview==
 +
CameraFlight is a plugin for OsgEarth that helps users to navigate OsgEarth. Although the the project is named CameraFlight, the algorithm involves rotating earth and moving earth closer to Camera. There are two types of Navigation; Instant and Satellite. User can choose which algorithm to navigate osgEarth from algorithm sub-menu. Then user can choose one of the predefined destination or go to custom navigation menu and select latitude and longitude of the location and navigate. These navigations are time dependent.
  
===Project Overview===
+
==Status==
CameraFlight is a plugin for OsgEarth that helps users to navigate OsgEarth. Although the the project is named CameraFlight, the algorithm involves rotating earth and moving earth closer to Camera. There are two types of Navigation; Instant and Satellite.  
+
[[Image:CameraFlightSample1Crop.png]] [[Image:CameraFlightSample2Crop.png]] [[Image:CameraFlightSample3Crop.png]]
* Instant Navigation will show the desired location instantly having user facing down the earth. The algorithm used is by setting the object space matrix to specified matrix that is already saved.  
+
===Implemented===
* Satellite Navigation is a navigation style that is similar to Google Earth's navigation. It will slowly zoom out and rotate the earth simultaneously and zoom back in to the destination.  
+
* Created menu for plugin with algorithm submenu entries: instant, satellite, airplane.
 +
* Created checkbox menu with list of predefined destinations. There are 6 predefined location; UCSD, Tokyo, South Pole, Sydney, Rome, Fullerton.
 +
* Created custom destination submenu entries, which user can personally input latitude and longitude of destination and navigate. (works for both instant and satellite algorithm)
 +
* Acquires the variables required to navigate; vectors of destination and current position, angle between the two vectors, and maximum and minimum height.
 +
** Current and destination vectors are calculated by converting latitude and longitude of the location and making height to 0 and normalizing them.
 +
** Using the cross product of the vectors will give us the rotation vector to rotate around.
 +
** Angle between the vectors are calculated by acos((a*b)/(|a|*|b|)).
 +
* Implemented instant navigation: switch to destination position immediately without transition
 +
** Rotate from current vector to destination vector by angle between them once and set the height to the minimum.
 +
* Implemented satellite mode: like Google Earth's transition mode, ~10 seconds for transition, time value is configurable in CalVR's configuration file
 +
** This algorithm is time dependent and time is calculated every frame (maximum 10 seconds).
 +
** Both zooming and rotation shares same base function of pow(t-5,2).
 +
** For zooming, find a ratio using maxHeight and current height and apply the equation shown below:
 +
  For first 5 seconds:
 +
    a = (maxHeight - currentHeight)/25.0;
 +
    currentHeight = (-a * pow((t-5),2)) + maxHeight;
  
===Done===
+
  For Last 5 seconds:
* Create menu for plugin with algorithm submenu; checkbox entries: instant, satellite, airplane
+
    a = (maxHeight - minHeight)/25.0;
* Create submenu with list of destinations; for starters just use two destinations to switch between (eg, UCSD and China)
+
    currentHeight = (-a * pow((t-5),2)) + maxHeight;
* Implement instant switching: switch to destination position immediately without transition
+
** For Rotation, find angle rotating per each time interval using equation shown below:
* Implement satellite mode: like Google Earth's transition mode, ~10 seconds for transition, make this time value configurable in CalVR's configuration file
+
  rotationAngle = (original Angle + (-(original Angle / 25) * pow((t-5),2)))/360;
** Make sure that the transition's duration is time dependent, not dependent on number of frames rendered
+
* Implemented custom destination menu using MenuRangeValue.
** Come up with math/functions for camera height and for angular motion of camera (=rotation of planet)
+
** User can set desired latitude and longitude of the planet and click navigate button to desired location.
 +
** Converts inputted latitude and longitude into vectors and navigate with them.
 +
* Implement airplane mode: the user will experience similar effect of being inside of the aircraft.
 +
[[Image:Screenshot1crop.png‎]] [[Image:Screenshot-1crop.png]] [[Image:Screenshot-3crop.png]]
 +
** Selecting Airplane mode will change the position of Camera so that the view will be in first person.
 +
*** This was done by having object matrix, all the way to Camera matrix and rotate the object along with Camera axis horizontally, and modified transition of earth back.
 +
** If you select Instant or Satellite mode, Camera will return normally, facing earth down.
 +
** Direction of the airplane will rotate towards the destination before flight.
 +
  xVector = crsV1^crsV2;
 +
 
 +
  if(xVector.z() > 0);
 +
      if((origPlanetPoint.z()) > 0)
 +
        rotdir = right;
 +
      else
 +
        rotdir = left;
 +
  else
 +
      if((origPlanetPoint.z()) < 0)
 +
        rotdir = right;
 +
      else
 +
        rotdir = left;
 +
* First find the angle between where you are facing and the destination, and then find cross product of two vectors, and then compare the z value of origPlanetPoint and the product. If the sign of both z.values are same, then rotate right, if not, rotate left.
 +
** the plane will travel(rotate) in smilar manner with how the rotation is applied on satellite algorithm. The flight is also depending on time variable and slower than satellite, which around 30 seconds.
 +
  rotAngle = (origAngle + (-(origAngle/900)*pow((t-30),2)))/450;
 +
** As plane travels, it will rise based on how much is the angle between from one point to another. For smooth transition, I have used cos(theta) to implement this.
 +
  For first 1/4 of angle:
 +
      v[2] = (maxHeight/2) * cos(PIE * (origAngle - angle)/(origAngle/4.0)) + (curHeight - (maxHeight/2));
 +
 
 +
  For last 1/4 of angle:
 +
      v[2] = (maxHeight/2) * cos(PIE + (PIE * (1.0 - (angle/(origAngle/4.0))))) + (-6.373e+09(radius of earth) - (maxHeight/2));
 +
 
 +
* between 1/4 and 3/4 angle, the plane will fly without changing elevation.
 +
* Since the elevation of plane will vary depending on where the plane is, plane will lower itself more if the elevation from ground is lower, and less if elevation is higher.
  
 
===Milestones===
 
===Milestones===
** Implement camera path
+
* Implement GUI to save way points between starting points and destination. These points will help you create bezier curves of flight path.
* Implement airplane mode
+
** Define the transition time between each way points and maintain constant speed.
 +
** Saving orientation of each way point is recommended.
 +
 
 +
==Participants==
 +
 
 +
Software Developers:
 +
 
 +
* William Seo
 +
 
 +
Project Advisors:
 +
 
 +
* [http://www.calit2.net/~jschulze/ Jurgen Schulze]
 +
 
 +
Development Assistance:
 +
 
 +
* Philip Weber
 +
 
 +
* Andrew Prudhomme
 +
 
 +
Initial Concept Base:
 +
 
 +
* Google Earth

Latest revision as of 12:02, 4 June 2012

Contents

Project Overview

CameraFlight is a plugin for OsgEarth that helps users to navigate OsgEarth. Although the the project is named CameraFlight, the algorithm involves rotating earth and moving earth closer to Camera. There are two types of Navigation; Instant and Satellite. User can choose which algorithm to navigate osgEarth from algorithm sub-menu. Then user can choose one of the predefined destination or go to custom navigation menu and select latitude and longitude of the location and navigate. These navigations are time dependent.

Status

CameraFlightSample1Crop.png CameraFlightSample2Crop.png CameraFlightSample3Crop.png

Implemented

  • Created menu for plugin with algorithm submenu entries: instant, satellite, airplane.
  • Created checkbox menu with list of predefined destinations. There are 6 predefined location; UCSD, Tokyo, South Pole, Sydney, Rome, Fullerton.
  • Created custom destination submenu entries, which user can personally input latitude and longitude of destination and navigate. (works for both instant and satellite algorithm)
  • Acquires the variables required to navigate; vectors of destination and current position, angle between the two vectors, and maximum and minimum height.
    • Current and destination vectors are calculated by converting latitude and longitude of the location and making height to 0 and normalizing them.
    • Using the cross product of the vectors will give us the rotation vector to rotate around.
    • Angle between the vectors are calculated by acos((a*b)/(|a|*|b|)).
  • Implemented instant navigation: switch to destination position immediately without transition
    • Rotate from current vector to destination vector by angle between them once and set the height to the minimum.
  • Implemented satellite mode: like Google Earth's transition mode, ~10 seconds for transition, time value is configurable in CalVR's configuration file
    • This algorithm is time dependent and time is calculated every frame (maximum 10 seconds).
    • Both zooming and rotation shares same base function of pow(t-5,2).
    • For zooming, find a ratio using maxHeight and current height and apply the equation shown below:
  For first 5 seconds:
    a = (maxHeight - currentHeight)/25.0;
    currentHeight = (-a * pow((t-5),2)) + maxHeight;
  For Last 5 seconds:
    a = (maxHeight - minHeight)/25.0;
    currentHeight = (-a * pow((t-5),2)) + maxHeight;
    • For Rotation, find angle rotating per each time interval using equation shown below:
  rotationAngle = (original Angle + (-(original Angle / 25) * pow((t-5),2)))/360;
  • Implemented custom destination menu using MenuRangeValue.
    • User can set desired latitude and longitude of the planet and click navigate button to desired location.
    • Converts inputted latitude and longitude into vectors and navigate with them.
  • Implement airplane mode: the user will experience similar effect of being inside of the aircraft.

Screenshot1crop.png Screenshot-1crop.png Screenshot-3crop.png

    • Selecting Airplane mode will change the position of Camera so that the view will be in first person.
      • This was done by having object matrix, all the way to Camera matrix and rotate the object along with Camera axis horizontally, and modified transition of earth back.
    • If you select Instant or Satellite mode, Camera will return normally, facing earth down.
    • Direction of the airplane will rotate towards the destination before flight.
  xVector = crsV1^crsV2;
  if(xVector.z() > 0);
     if((origPlanetPoint.z()) > 0)
        rotdir = right;
     else
        rotdir = left;
  else
     if((origPlanetPoint.z()) < 0)
        rotdir = right;
     else
        rotdir = left;
  • First find the angle between where you are facing and the destination, and then find cross product of two vectors, and then compare the z value of origPlanetPoint and the product. If the sign of both z.values are same, then rotate right, if not, rotate left.
    • the plane will travel(rotate) in smilar manner with how the rotation is applied on satellite algorithm. The flight is also depending on time variable and slower than satellite, which around 30 seconds.
  rotAngle = (origAngle + (-(origAngle/900)*pow((t-30),2)))/450;
    • As plane travels, it will rise based on how much is the angle between from one point to another. For smooth transition, I have used cos(theta) to implement this.
  For first 1/4 of angle:
     v[2] = (maxHeight/2) * cos(PIE * (origAngle - angle)/(origAngle/4.0)) + (curHeight - (maxHeight/2));
  For last 1/4 of angle:
     v[2] = (maxHeight/2) * cos(PIE + (PIE * (1.0 - (angle/(origAngle/4.0))))) + (-6.373e+09(radius of earth) - (maxHeight/2));
  • between 1/4 and 3/4 angle, the plane will fly without changing elevation.
  • Since the elevation of plane will vary depending on where the plane is, plane will lower itself more if the elevation from ground is lower, and less if elevation is higher.

Milestones

  • Implement GUI to save way points between starting points and destination. These points will help you create bezier curves of flight path.
    • Define the transition time between each way points and maintain constant speed.
    • Saving orientation of each way point is recommended.

Participants

Software Developers:

  • William Seo

Project Advisors:

Development Assistance:

  • Philip Weber
  • Andrew Prudhomme

Initial Concept Base:

  • Google Earth