A view controller for flat terrains. More...
#include <TerrainViewController.h>
Public Member Functions | |
TerrainViewController (ptr< SceneNode > node, double d0) | |
Creates a new TerrainViewController to control the given SceneNode. | |
virtual | ~TerrainViewController () |
Deletes this TerrainViewController. | |
ptr< SceneNode > | getNode () |
Returns the SceneNode associated with this TerrainViewController. | |
void | setNode (ptr< SceneNode > node) |
Sets the SceneNode associated with this TerrainViewController. | |
float | getGroundHeight () |
Returns the terrain elevation below the camera. | |
void | setGroundHeight (float groundHeight) |
Sets the terrain elevation below the camera. | |
virtual double | getHeight () |
Returns the height of the camera above the z=0 surface. | |
virtual void | move (vec3d &oldp, vec3d &p) |
Moves the "look at" point so that "oldp" appears at the position of "p" on screen. | |
virtual double | interpolate (double sx0, double sy0, double stheta, double sphi, double sd, double dx0, double dy0, double dtheta, double dphi, double dd, double t) |
Sets the position as the interpolation of the two given positions with the interpolation parameter t (between 0 and 1). | |
void | interpolateDirection (double slon, double slat, double elon, double elat, double t, double &lon, double &lat) |
Returns a direction interpolated between the two given direction. | |
virtual void | update () |
Sets the localToParent transform of the SceneNode associated with this TerrainViewController. | |
virtual void | setProjection (float znear=0.0f, float zfar=0.0f, vec4f viewport=vec4f(-1.0f, 1.0f,-1.0f, 1.0f)) |
Sets the camera to screen perspective projection. | |
Public Attributes | |
double | fov |
The field of view angle. | |
double | x0 |
The x coordinate of the point the camera is looking at on the ground. | |
double | y0 |
The y coordinate of the point the camera is looking at on the ground. | |
double | theta |
The zenith angle of the vector between the "look at" point and the camera. | |
double | phi |
The azimuth angle of the vector between the "look at" point and the camera. | |
double | d |
The distance between the "look at" point and the camera. | |
double | zoom |
Zoom factor (realized by increasing d and decreasing fov). | |
vec3d | position |
The camera position in world space resulting from the x0,y0,theta,phi, and d parameters. | |
Protected Attributes | |
ptr< SceneNode > | node |
The SceneNode associated with this TerrainViewController. | |
float | groundHeight |
The terrain elevation below the camera. |
A view controller for flat terrains.
The camera position is specified from a "look at" position (x0,y0) on ground, with a distance d between camera and this position, and two angles (theta,phi) for the direction of this vector. The update method sets the localToParent transformation of the SceneNode associated with this controller, which is intended to represent the camera position and orientation in the scene.
proland::TerrainViewController::TerrainViewController | ( | ptr< SceneNode > | node, | |
double | d0 | |||
) |
Creates a new TerrainViewController to control the given SceneNode.
node | a SceneNode representing a camera position and orientation in the scene. | |
d0 | the initial valued of the d distance. |
virtual proland::TerrainViewController::~TerrainViewController | ( | ) | [virtual] |
Deletes this TerrainViewController.
float proland::TerrainViewController::getGroundHeight | ( | ) |
Returns the terrain elevation below the camera.
virtual double proland::TerrainViewController::getHeight | ( | ) | [virtual] |
Returns the height of the camera above the z=0 surface.
Reimplemented in proland::CylinderViewController, and proland::PlanetViewController.
ptr<SceneNode> proland::TerrainViewController::getNode | ( | ) |
Returns the SceneNode associated with this TerrainViewController.
This SceneNode represents a camera position and orientation in the scene.
virtual double proland::TerrainViewController::interpolate | ( | double | sx0, | |
double | sy0, | |||
double | stheta, | |||
double | sphi, | |||
double | sd, | |||
double | dx0, | |||
double | dy0, | |||
double | dtheta, | |||
double | dphi, | |||
double | dd, | |||
double | t | |||
) | [virtual] |
Sets the position as the interpolation of the two given positions with the interpolation parameter t (between 0 and 1).
The source position is sx0,sy0,stheta,sphi,sd, the destination is dx0,dy0,dtheta,dphi,dd.
Reimplemented in proland::PlanetViewController.
void proland::TerrainViewController::interpolateDirection | ( | double | slon, | |
double | slat, | |||
double | elon, | |||
double | elat, | |||
double | t, | |||
double & | lon, | |||
double & | lat | |||
) |
Returns a direction interpolated between the two given direction.
slon | start longitude. | |
slat | start latitude. | |
elon | end longitude. | |
elat | end latitude. | |
t | interpolation parameter between 0 and 1. | |
[out] | lon | interpolated longitude. |
[out] | lat | interpolated latitude. |
virtual void proland::TerrainViewController::move | ( | vec3d & | oldp, | |
vec3d & | p | |||
) | [virtual] |
Moves the "look at" point so that "oldp" appears at the position of "p" on screen.
oldp | a terrain point. | |
p | another terrain point. |
Reimplemented in proland::CylinderViewController, and proland::PlanetViewController.
void proland::TerrainViewController::setGroundHeight | ( | float | groundHeight | ) |
Sets the terrain elevation below the camera.
This elevation is used to adjust the camera position so that it is not below the ground.
groundHeight | the terrain elevation below the camera. |
void proland::TerrainViewController::setNode | ( | ptr< SceneNode > | node | ) |
Sets the SceneNode associated with this TerrainViewController.
node | a SceneNode representing a camera position and orientation in the scene. |
virtual void proland::TerrainViewController::setProjection | ( | float | znear = 0.0f , |
|
float | zfar = 0.0f , |
|||
vec4f | viewport = vec4f(-1.0f, 1.0f,-1.0f, 1.0f) | |||
) | [virtual] |
Sets the camera to screen perspective projection.
znear | an optional znear plane (0.0 means that a default value must be used). | |
zfar | an optional zfar plane (0.0 means that a default value must be used). | |
viewport | an optional viewport to select a part of the image. The default value [-1:1]x[-1:1] selects the whole image. |
virtual void proland::TerrainViewController::update | ( | ) | [virtual] |
Sets the localToParent transform of the SceneNode associated with this TerrainViewController.
The transform is computed from the view parameters x0,y0,theta,phi and d.
Reimplemented in proland::CylinderViewController, and proland::PlanetViewController.
The distance between the "look at" point and the camera.
The field of view angle.
float proland::TerrainViewController::groundHeight [protected] |
The terrain elevation below the camera.
ptr<SceneNode> proland::TerrainViewController::node [protected] |
The SceneNode associated with this TerrainViewController.
The azimuth angle of the vector between the "look at" point and the camera.
The camera position in world space resulting from the x0,y0,theta,phi, and d parameters.
The zenith angle of the vector between the "look at" point and the camera.
The x coordinate of the point the camera is looking at on the ground.
The y coordinate of the point the camera is looking at on the ground.
Zoom factor (realized by increasing d and decreasing fov).