A deformation of space. More...
#include <Deformation.h>
Public Member Functions | |
Deformation () | |
Creates a new Deformation. | |
virtual | ~Deformation () |
Deletes this Deformation. | |
virtual vec3d | localToDeformed (const vec3d &localPt) const |
Returns the deformed point corresponding to the given source point. | |
virtual mat4d | localToDeformedDifferential (const vec3d &localPt, bool clamp=false) const |
Returns the differential of the deformation function at the given local point. | |
virtual vec3d | deformedToLocal (const vec3d &deformedPt) const |
Returns the local point corresponding to the given source point. | |
virtual box2f | deformedToLocalBounds (const vec3d &deformedCenter, double deformedRadius) const |
Returns the local bounding box corresponding to the given source disk. | |
virtual mat4d | deformedToTangentFrame (const vec3d &deformedPt) const |
Returns an orthonormal reference frame of the tangent space at the given deformed point. | |
virtual void | setUniforms (ptr< SceneNode > context, ptr< TerrainNode > n, ptr< Program > prog) const |
Sets the shader uniforms that are necessary to project on screen the TerrainQuad of the given TerrainNode. | |
virtual void | setUniforms (ptr< SceneNode > context, ptr< TerrainQuad > q, ptr< Program > prog) const |
Sets the shader uniforms that are necessary to project on screen the given TerrainQuad. | |
virtual float | getLocalDist (const vec3d &localPt, const box3d &localBox) const |
Returns the distance in local (i.e., source) space between a point and a bounding box. | |
virtual SceneManager::visibility | getVisibility (const TerrainNode *t, const box3d &localBox) const |
Returns the visibility of a bounding box in local space, in a view frustum defined in deformed space. | |
Protected Attributes | |
mat4f | cameraToScreen |
The transformation from camera space to screen space. | |
mat4d | localToScreen |
The transformation from local space to screen space. | |
mat3f | localToTangent |
The transformation from local space to tangent space (in z=0 plane). | |
ptr< Program > | lastNodeProg |
The program that contains the uniforms that were set during the last call to setUniforms(ptr<SceneNode>, ptr<TerrainNode>, . | |
ptr< Program > | lastQuadProg |
The program that contains the uniforms that were set during the last call to setUniforms(ptr<SceneNode>, ptr<TerrainQuad>, . | |
ptr< Uniform4f > | offsetU |
The coordinates of a TerrainQuad (ox,oy,l,l). | |
ptr< Uniform4f > | cameraU |
The camera coordinates relatively to a TerrainQuad. | |
ptr< Uniform2f > | blendingU |
The blending parameters for geomorphing. | |
ptr< UniformMatrix4f > | localToScreenU |
The transformation from local space to screen space. | |
ptr< UniformMatrix3f > | tileToTangentU |
The transformation from local tile coordinates to tangent space. | |
ptr< UniformMatrix4f > | screenQuadCornersU |
The deformed corners of a quad in screen space. | |
ptr< UniformMatrix4f > | screenQuadVerticalsU |
The deformed vertical vectors at the corners of a quad, in screen space. |
A deformation of space.
Such a deformation maps a 3D source point to a 3D destination point. The source space is called the local space, while the destination space is called the deformed space. Source and destination points are defined with their x,y,z coordinates in an orthonormal reference frame. A Deformation is also responsible to set the shader uniforms that are necessary to project a TerrainQuad on screen, taking the deformation into account. The default implementation of this class implements the identity deformation, i.e. the deformed point is equal to the local one.
proland::Deformation::Deformation | ( | ) |
Creates a new Deformation.
virtual proland::Deformation::~Deformation | ( | ) | [virtual] |
Deletes this Deformation.
virtual vec3d proland::Deformation::deformedToLocal | ( | const vec3d & | deformedPt | ) | const [virtual] |
Returns the local point corresponding to the given source point.
deformedPt | a point in the deformed (i.e., destination) space. |
Reimplemented in proland::CylindricalDeformation, and proland::SphericalDeformation.
virtual box2f proland::Deformation::deformedToLocalBounds | ( | const vec3d & | deformedCenter, | |
double | deformedRadius | |||
) | const [virtual] |
Returns the local bounding box corresponding to the given source disk.
deformedPt | the source disk center in deformed space. | |
deformedRadius | the source disk radius in deformed space. |
Reimplemented in proland::CylindricalDeformation, and proland::SphericalDeformation.
virtual mat4d proland::Deformation::deformedToTangentFrame | ( | const vec3d & | deformedPt | ) | const [virtual] |
Returns an orthonormal reference frame of the tangent space at the given deformed point.
This reference frame is such that its xy plane is the tangent plane, at deformedPt, to the deformed surface corresponding to the local plane z=0. Note that this orthonormal reference frame does not give the differential of the inverse deformation funtion, which in general is not an orthonormal transformation. If p is a deformed point, then deformedToLocalFrame(deformedPt) * p gives the coordinates of p in the orthonormal reference frame defined above.
deformedPt | a point in the deformed (i.e., destination) space. |
Reimplemented in proland::CylindricalDeformation, and proland::SphericalDeformation.
virtual float proland::Deformation::getLocalDist | ( | const vec3d & | localPt, | |
const box3d & | localBox | |||
) | const [virtual] |
Returns the distance in local (i.e., source) space between a point and a bounding box.
localPt | a point in local space. | |
localBox | a bounding box in local space. |
virtual SceneManager::visibility proland::Deformation::getVisibility | ( | const TerrainNode * | t, | |
const box3d & | localBox | |||
) | const [virtual] |
Returns the visibility of a bounding box in local space, in a view frustum defined in deformed space.
t | a TerrainNode. This is node is used to get the camera position in local and deformed space with TerrainNode::getLocalCamera and TerrainNode::getDeformedCamera, as well as the view frustum planes in deformed space with TerrainNode::getDeformedFrustumPlanes. | |
localBox | a bounding box in local space. |
Reimplemented in proland::CylindricalDeformation, and proland::SphericalDeformation.
virtual vec3d proland::Deformation::localToDeformed | ( | const vec3d & | localPt | ) | const [virtual] |
Returns the deformed point corresponding to the given source point.
localPt | a point in the local (i.e., source) space. |
Reimplemented in proland::CylindricalDeformation, and proland::SphericalDeformation.
virtual mat4d proland::Deformation::localToDeformedDifferential | ( | const vec3d & | localPt, | |
bool | clamp = false | |||
) | const [virtual] |
Returns the differential of the deformation function at the given local point.
This differential gives a linear approximation of the deformation around a given point, represented with a matrix. More precisely, if p is near localPt, then the deformed point corresponding to p can be approximated with localToDeformedDifferential(localPt) * (p - localPt).
localPt | a point in the local (i.e., source) space. The z coordinate of this point is ignored, and considered to be 0. |
Reimplemented in proland::CylindricalDeformation, and proland::SphericalDeformation.
virtual void proland::Deformation::setUniforms | ( | ptr< SceneNode > | context, | |
ptr< TerrainQuad > | q, | |||
ptr< Program > | prog | |||
) | const [virtual] |
Sets the shader uniforms that are necessary to project on screen the given TerrainQuad.
This method can set the uniforms that are specific to the given quad.
context | the SceneNode to which the TerrainNode belongs. This node defines the absolute position and orientation of the terrain in world space (through SceneNode::getLocalToWorld). | |
q | a TerrainQuad. |
Reimplemented in proland::SphericalDeformation.
virtual void proland::Deformation::setUniforms | ( | ptr< SceneNode > | context, | |
ptr< TerrainNode > | n, | |||
ptr< Program > | prog | |||
) | const [virtual] |
Sets the shader uniforms that are necessary to project on screen the TerrainQuad of the given TerrainNode.
This method can set the uniforms that are common to all the quads of the given terrain.
context | the SceneNode to which the TerrainNode belongs. This node defines the absolute position and orientation of the terrain in world space (through SceneNode::getLocalToWorld). | |
n | a TerrainNode. |
Reimplemented in proland::CylindricalDeformation, and proland::SphericalDeformation.
ptr<Uniform2f> proland::Deformation::blendingU [mutable, protected] |
The blending parameters for geomorphing.
This vector is defined by (splitDistance + 1, splitDistance - 1).
mat4f proland::Deformation::cameraToScreen [mutable, protected] |
The transformation from camera space to screen space.
ptr<Uniform4f> proland::Deformation::cameraU [mutable, protected] |
The camera coordinates relatively to a TerrainQuad.
This vector is defined as (camera.x - ox) / l, (camera.y - oy) / l), (camera.z - groundHeightAtCamera) / l), 1.
ptr<Program> proland::Deformation::lastNodeProg [mutable, protected] |
The program that contains the uniforms that were set during the last call to setUniforms(ptr<SceneNode>, ptr<TerrainNode>, .
..).
ptr<Program> proland::Deformation::lastQuadProg [mutable, protected] |
The program that contains the uniforms that were set during the last call to setUniforms(ptr<SceneNode>, ptr<TerrainQuad>, .
..).
mat4d proland::Deformation::localToScreen [mutable, protected] |
The transformation from local space to screen space.
ptr<UniformMatrix4f> proland::Deformation::localToScreenU [mutable, protected] |
The transformation from local space to screen space.
mat3f proland::Deformation::localToTangent [mutable, protected] |
The transformation from local space to tangent space (in z=0 plane).
ptr<Uniform4f> proland::Deformation::offsetU [mutable, protected] |
The coordinates of a TerrainQuad (ox,oy,l,l).
ptr<UniformMatrix4f> proland::Deformation::screenQuadCornersU [mutable, protected] |
The deformed corners of a quad in screen space.
ptr<UniformMatrix4f> proland::Deformation::screenQuadVerticalsU [mutable, protected] |
The deformed vertical vectors at the corners of a quad, in screen space.
ptr<UniformMatrix3f> proland::Deformation::tileToTangentU [mutable, protected] |
The transformation from local tile coordinates to tangent space.