37 aAngle -=
static_cast<float>( M_PI * 2.0f );
40 aAngle +=
static_cast<float>( M_PI * 2.0f );
55 wxLogTrace(
m_logTrace, wxT(
"CAMERA::CAMERA" ) );
207 case PROJECTION_TYPE::PERSPECTIVE:
229 case PROJECTION_TYPE::ORTHO:
237 const float orthoReductionFactor =
243 -orthoReductionFactor,
244 orthoReductionFactor,
263 for(
unsigned int x = 0; x < (
unsigned int)
m_windowSize.x + 1; ++x )
266 const float xNormalizedDeviceCoordinates = ( ( (float)x + 0.5f ) /
270 m_scr_nX[x] = 2.0f * xNormalizedDeviceCoordinates - 1.0f;
274 for(
unsigned int y = 0; y < (
unsigned int)
m_windowSize.y + 1 ; ++y )
277 const float yNormalizedDeviceCoordinates = ( ( (float)y + 0.5f ) /
281 m_scr_nY[y] = 2.0f * yNormalizedDeviceCoordinates - 1.0f;
295 glm::vec4(
SFVEC3F( 1.0, 0.0, 0.0 ), 0.0 ) ) );
298 glm::vec4(
SFVEC3F( 0.0, 1.0, 0.0 ), 0.0 ) ) );
301 glm::vec4(
SFVEC3F( 0.0, 0.0, 1.0 ), 0.0 ) ) );
338 for(
unsigned int x = 0; x < ( (
unsigned int)
m_windowSize.x + 1 ); ++x )
342 for(
unsigned int y = 0; y < ( (
unsigned int)
m_windowSize.y + 1 ); ++y )
359 case PROJECTION_TYPE::PERSPECTIVE:
360 aOutDirection = glm::normalize( aOutOrigin -
m_pos );
363 case PROJECTION_TYPE::ORTHO:
376 const SFVEC2F floorWinPos_f = glm::floor( aWindowPos );
378 const SFVEC2F relativeWinPos = aWindowPos - floorWinPos_f;
381 const SFVEC3F up_plus_right =
m_up_nY[floorWinPos_i.y] * (1.0f - relativeWinPos.y) +
382 m_up_nY[floorWinPos_i.y + 1] * relativeWinPos.y +
383 m_right_nX[floorWinPos_i.x] * (1.0f - relativeWinPos.x) +
384 m_right_nX[floorWinPos_i.x + 1] * relativeWinPos.x;
391 case PROJECTION_TYPE::PERSPECTIVE:
392 aOutDirection = glm::normalize( aOutOrigin -
m_pos );
395 case PROJECTION_TYPE::ORTHO:
406 if( ( 0 < windowPos.x ) && ( windowPos.x <
m_windowSize.x ) &&
407 ( 0 < windowPos.y ) && ( windowPos.y <
m_windowSize.y ) )
409 MakeRay( windowPos, aOutOrigin, aOutDirection );
461 glm::vec4 lookat = aViewMatrix * glm::vec4(
m_lookat_pos, 1.0f );
464 wxT(
"CAMERA::SetViewMatrix aViewMatrix[3].z =%f, old_zoom=%f, new_zoom=%f, "
484 * glm::translate( glm::mat4( 1.0f ), -
m_lookat_pos ) )[3];
540 if( ( m_zoom <= m_minZoom && aFactor > 1 ) || (
m_zoom >=
m_maxZoom && aFactor < 1 )
549 if( m_zoom <= m_minZoom && aFactor > 1 )
571 if( ( m_zoom <= m_minZoom && aFactor > 1 ) || (
m_zoom >=
m_maxZoom && aFactor < 1 )
646 wxASSERT( t >= 0.0f );
648 const float t0 = 1.0f - t;
668 return parametersChanged;
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.
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
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
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.
SFVEC3F ntr
Near Top Right.
SFVEC3F ntl
Near Top Left.
SFVEC3F fbr
Far Bottom Right.
SFVEC3F nbl
Near Bottom Left.
SFVEC3F nbr
Near Bottom Right.
SFVEC3F fbl
Far Bottom Left.
SFVEC3F ftr
Far Top Right.