#include <ovprojector.h>
Public Member Functions | |
OVProjector () | |
The constructor for the OVProjector class. | |
~OVProjector () | |
The destructor of the OVProjector class. | |
void | InitProjector (float *camPos, float *camDir, float *camUp, float *maxDisplacement, float basePlaneY, float *zoomFactor, float *fovY, float *fovRatio, float *zNear, float *zFar, int *windowWidth, int *windowHeight) |
Initiates the projector. | |
void | SetUpProjector () |
Sets up the projector. | |
float * | GetMRange () |
Access function for range matrix. | |
void | DrawFrustum () |
Draws the projector frustum. | |
void | Look () |
Sets the modelview matrix according to the projector. | |
void | Perspective () |
Sets the projection matrix according to the projector. | |
bool | Visible () |
Indicates whether water should be drawn or not. | |
Protected Member Functions | |
void | m_CalcProjectionFrustum () |
Calculates projection frustum from camera primitives. | |
void | m_CalcFrustumWaterIntersections () |
Calculates intersections between projector frustum and water volume. | |
void | m_CalcImSpaceMinMax () |
Calculates min max values used by MRange matrix. | |
void | m_CalcMRange () |
Calculates scaling matrix. | |
bool | m_CalcWaterplaneYLineIntersection (float planeY, OVv4 point1, OVv4 point2, OVv4 *intersection) |
Calculates the intersection between a line and a plane parallell to the xz plane. | |
Private Attributes | |
float * | m_zoomFactor |
float * | m_fovY |
float * | m_fovRatio |
float * | m_zNear |
float * | m_zFar |
int * | m_windowWidth |
int * | m_windowHeight |
float * | m_camPos |
float * | m_camDir |
float * | m_camUp |
float * | m_projPos |
float * | m_projDir |
float * | m_projUp |
std::vector< OVv4 > | m_intersectionsWorldSpace |
std::vector< OVv4 > | m_intersectionsImageSpace |
float * | m_maxDisplacement |
float | m_baseplaneY |
OVm4 | m_mRange |
float | m_minImSpaceX |
float | m_minImSpaceY |
float | m_maxImSpaceX |
float | m_maxImSpaceY |
Calculates MRange and MProjection matrices by calculating projection frustom from camera primitives. Its main objective is to create a projection matrix from image space to water plane in world space.
OV::OVProjector::OVProjector | ( | ) |
The constructor for the OVProjector class.
OV::OVProjector::~OVProjector | ( | ) |
The destructor of the OVProjector class.
void OV::OVProjector::InitProjector | ( | float * | camPos, | |
float * | camDir, | |||
float * | camUp, | |||
float * | maxDisplacement, | |||
float | basePlaneY, | |||
float * | zoomFactor, | |||
float * | fovY, | |||
float * | fovRatio, | |||
float * | zNear, | |||
float * | zFar, | |||
int * | windowWidth, | |||
int * | windowHeight | |||
) |
Initiates the projector.
Stores pointers for camera primitives.
camPos | Pointer to position of the camera | |
camDir | Pointer to direction of the camera | |
camUp | Pointer to up vector of the camera | |
maxDisplacement | Pointer to the maximum amplitude of waves, used for volume calculations | |
basePlaneY | Enables vertical positioning of water surface | |
zoomFactor | Pointer to the zoom factor of the camera | |
fovY | Pointer to the field of view of the camera | |
fovRatio | Pointer to the ratio of height and width | |
zNear | Pointer to the distance from the camera to the far clip plane | |
zFar | Pointer to the distance from the camera to the near clip plane | |
windowWidth | Pointer to the window width | |
windowHeight | Pointer to the window height |
void OV::OVProjector::SetUpProjector | ( | ) |
Sets up the projector.
Create the projector frustum using the camera's modelview matrix. Save the current state, and then set the modelview matrix according to the projector. Then construct the projector matrix, and finally set the modelview matrix according to the camera again.
float * OV::OVProjector::GetMRange | ( | ) |
Access function for range matrix.
void OV::OVProjector::DrawFrustum | ( | ) |
Draws the projector frustum.
Draws the frustum using its cornerpoints.
void OV::OVProjector::Look | ( | ) |
Sets the modelview matrix according to the projector.
Sets the modelview matrix according to the projector position, direction and up vectors by calling gluLookAt. Allows the previous modelview matrix to be restored by pushing it on the stack.
void OV::OVProjector::Perspective | ( | ) |
Sets the projection matrix according to the projector.
Sets the projection matrix according to the projector zoomfactor, field of view, field of view ratio, far plane, near plane, and the window width and window height by calling gluPerspective. Allows the previous projection matrix to be restored by pushing it on the stack.
bool OV::OVProjector::Visible | ( | ) |
Indicates whether water should be drawn or not.
If the projector frustum intersects the lower or upper displacement plane the water is visible to the viewer, otherwise it isn't and then it's unnecessairy to draw it.
void OV::OVProjector::m_CalcProjectionFrustum | ( | ) | [protected] |
Calculates projection frustum from camera primitives.
void OV::OVProjector::m_CalcFrustumWaterIntersections | ( | ) | [protected] |
Calculates intersections between projector frustum and water volume.
Result is stored in member m_intersections.
void OV::OVProjector::m_CalcImSpaceMinMax | ( | ) | [protected] |
Calculates min max values used by MRange matrix.
Projects world space intersections to image space and calculates min/max values for x and y coordinates. Resaults are stored in m_minImSpaceX etc.
void OV::OVProjector::m_CalcMRange | ( | ) | [protected] |
Calculates scaling matrix.
Results are stored in m_mRange.
bool OV::OVProjector::m_CalcWaterplaneYLineIntersection | ( | float | planeY, | |
OVv4 | point1, | |||
OVv4 | point2, | |||
OVv4 * | intersection | |||
) | [protected] |
Calculates the intersection between a line and a plane parallell to the xz plane.
Calculates the intersection between a line (point1->point2) and a plane (in the xz plane) with y-coordinate planeY. The resulting intersection, if any, is stored in intersection.
planeY | The y-coordinate of the plane | |
point1 | The point where the line begins | |
point2 | The point where the line ends |
float* OV::OVProjector::m_zoomFactor [private] |
Camera zoom factor (pointer to shell)
float* OV::OVProjector::m_fovY [private] |
Camera FOV for y-axis (pointer to shell)
float* OV::OVProjector::m_fovRatio [private] |
Camera FOV ratio (pointer to shell)
float* OV::OVProjector::m_zNear [private] |
Camera near plane (pointer to shell)
float* OV::OVProjector::m_zFar [private] |
Camera far position (pointer to shell)
int* OV::OVProjector::m_windowWidth [private] |
The window width (pointer to shell)
int* OV::OVProjector::m_windowHeight [private] |
The window height (pointer to shell)
float* OV::OVProjector::m_camPos [private] |
Camera position (pointer to shell)
float* OV::OVProjector::m_camDir [private] |
Camera direction (pointer to shell)
float* OV::OVProjector::m_camUp [private] |
Camera up vector (pointer to shell)
float* OV::OVProjector::m_projPos [private] |
Projector position
float* OV::OVProjector::m_projDir [private] |
Projector direction
float* OV::OVProjector::m_projUp [private] |
Projector up vector
std::vector<OVv4> OV::OVProjector::m_intersectionsWorldSpace [private] |
Intersections between projector frustum and water volume in world space coordinates
std::vector<OVv4> OV::OVProjector::m_intersectionsImageSpace [private] |
Intersections between projector frustum and water volume when projected to image space coordinates
float* OV::OVProjector::m_maxDisplacement [private] |
Maximum displacement of the water surface dependent on windspeed etc. (pointer to ovwater)
float OV::OVProjector::m_baseplaneY [private] |
Offset from Y=0 in world space coordinates
OVm4 OV::OVProjector::m_mRange [private] |
Matrix for scaling grid in image space, caculated from min max coverage values
float OV::OVProjector::m_minImSpaceX [private] |
Water min x coverage in image space
float OV::OVProjector::m_minImSpaceY [private] |
Water min y coverage in image space
float OV::OVProjector::m_maxImSpaceX [private] |
Water max x coverage in image space
float OV::OVProjector::m_maxImSpaceY [private] |
Water max y coverage in image space