38 aAngle -=
static_cast<float>(
M_PI * 2.0f );
41 aAngle +=
static_cast<float>(
M_PI * 2.0f );
63 wxLogTrace(
m_logTrace, wxT(
"CAMERA::CAMERA" ) );
112 switch( aRequestedView )
297 const float orthoReductionFactor =
303 -orthoReductionFactor,
304 orthoReductionFactor,
310 m_frustum.nh = orthoReductionFactor * 2.0f;
323 for(
unsigned int x = 0; x < (
unsigned int)
m_windowSize.x + 1; ++x )
326 const float xNormalizedDeviceCoordinates = ( ( (float)x + 0.5f ) /
330 m_scr_nX[x] = 2.0f * xNormalizedDeviceCoordinates - 1.0f;
334 for(
unsigned int y = 0; y < (
unsigned int)
m_windowSize.y + 1 ; ++y )
337 const float yNormalizedDeviceCoordinates = ( ( (float)y + 0.5f ) /
341 m_scr_nY[y] = 2.0f * yNormalizedDeviceCoordinates - 1.0f;
355 glm::vec4(
SFVEC3F( 1.0, 0.0, 0.0 ), 0.0 ) ) );
358 glm::vec4(
SFVEC3F( 0.0, 1.0, 0.0 ), 0.0 ) ) );
361 glm::vec4(
SFVEC3F( 0.0, 0.0, 1.0 ), 0.0 ) ) );
398 for(
unsigned int x = 0; x < ( (
unsigned int)
m_windowSize.x + 1 ); ++x )
402 for(
unsigned int y = 0; y < ( (
unsigned int)
m_windowSize.y + 1 ); ++y )
420 aOutDirection = glm::normalize( aOutOrigin -
m_pos );
436 const SFVEC2F floorWinPos_f = glm::floor( aWindowPos );
438 const SFVEC2F relativeWinPos = aWindowPos - floorWinPos_f;
441 const SFVEC3F up_plus_right =
m_up_nY[floorWinPos_i.y] * (1.0f - relativeWinPos.y) +
442 m_up_nY[floorWinPos_i.y + 1] * relativeWinPos.y +
443 m_right_nX[floorWinPos_i.x] * (1.0f - relativeWinPos.x) +
444 m_right_nX[floorWinPos_i.x + 1] * relativeWinPos.x;
446 aOutOrigin = up_plus_right +
m_frustum.nc;
452 aOutDirection = glm::normalize( aOutOrigin -
m_pos );
466 if( ( 0 < windowPos.x ) && ( windowPos.x <
m_windowSize.x ) &&
467 ( 0 < windowPos.y ) && ( windowPos.y <
m_windowSize.y ) )
469 MakeRay( windowPos, aOutOrigin, aOutDirection );
521 glm::vec4 lookat = aViewMatrix * glm::vec4(
m_lookat_pos, 1.0f );
524 wxT(
"CAMERA::SetViewMatrix aViewMatrix[3].z =%f, old_zoom=%f, new_zoom=%f, "
544 * glm::translate( glm::mat4( 1.0f ), -
m_lookat_pos ) )[3];
714 wxASSERT( t >= 0.0f );
716 const float t0 = 1.0f - t;
736 return parametersChanged;
declared enumerations and flags
void normalise2PI(float &aAngle)
Define an abstract camera.
glm::mat4 GetRotationMatrix() const
Get the rotation matrix to be applied in a transformation camera.
bool m_parametersChanged
Set to true if any of the parameters in the camera was changed.
void RotateY(float aAngleInRadians)
glm::mat4 m_projectionMatrixInv
void RotateX(float aAngleInRadians)
const glm::mat4 & GetProjectionMatrix() const
void SetBoardLookAtPos(const SFVEC3F &aBoardPos)
void RotateY_T1(float aAngleInRadians)
virtual void Reset()
Reset the camera to initial state.
glm::mat4 m_projectionMatrix
CAMERA_INTERPOLATION m_interpolation_mode
wxPoint m_lastPosition
The last mouse position in the screen.
void RotateScreen(float aAngleInRadians)
Rotates the camera in screen plane.
const glm::mat4 & GetViewMatrix_Inv() const
bool Zoom_T1(float aFactor)
static const float DEFAULT_MIN_ZOOM
void updateRotationMatrix()
void MakeRay(const SFVEC2I &aWindowPos, SFVEC3F &aOutOrigin, SFVEC3F &aOutDirection) const
Make a ray based on a windows screen position.
static const float DEFAULT_MAX_ZOOM
virtual void Interpolate(float t)
It will update the matrix to interpolate between T0 and T1 values.
bool SetCurWindowSize(const wxSize &aSize)
Update the windows size of the camera.
SFVEC3F m_camera_pos_init
CAMERA(float aInitialDistance)
Initialize a camera.
const glm::mat4 & GetProjectionMatrixInv() const
float m_minZoom
Possible 3D zoom range.
float GetCameraMinDimension() const
bool ViewCommand_T1(VIEW3D_TYPE aRequestedView)
std::vector< SFVEC3F > m_right_nX
Precalc values array used to calc ray for each pixel, for X and Y axis of each new camera position.
void RotateZ(float aAngleInRadians)
virtual void SetT0_and_T1_current_T()
This will set T0 and T1 with the current values.
PROJECTION_TYPE m_projectionType
SFVEC2I m_windowSize
The window size that this camera is working.
void MakeRayAtCurrentMousePosition(SFVEC3F &aOutOrigin, SFVEC3F &aOutDirection) const
Make a ray based on the latest mouse position.
std::vector< float > m_scr_nX
Precalc values array used to calc ray for each pixel (constant for the same window size).
void RotateX_T1(float aAngleInRadians)
const glm::mat4 & GetViewMatrix() const
glm::mat4 m_viewMatrixInverse
const SFVEC3F & GetDir() const
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliary.
glm::mat4 m_rotationMatrixAux
glm::mat4 m_rotationMatrix
std::vector< float > m_scr_nY
void SetViewMatrix(glm::mat4 aViewMatrix)
Set the affine matrix to be applied to a transformation camera.
void RotateZ_T1(float aAngleInRadians)
SFVEC3F m_board_lookat_pos_init
Default boardlookat position (the board center).
std::vector< SFVEC3F > m_up_nY
void SetRotationMatrix(const glm::mat4 &aRotation)
Set the rotation matrix to be applied in a transformation camera, without making any new calculations...
float m_zoom
3D zoom value – Z-distance is scaled by it
void SetCurMousePosition(const wxPoint &aPosition)
Update the current mouse position without make any new calculations on camera.
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.