KiCad PCB EDA Suite
TRACK_BALL Class Reference

#include <track_ball.h>

Inheritance diagram for TRACK_BALL:
CAMERA

Public Member Functions

 TRACK_BALL (float aInitialDistance)
 
virtual ~TRACK_BALL ()
 
void Drag (const wxPoint &aNewMousePosition) override
 Calculate a new mouse drag position. More...
 
void Pan (const wxPoint &aNewMousePosition) override
 
void Pan (const SFVEC3F &aDeltaOffsetInc) override
 
void Pan_T1 (const SFVEC3F &aDeltaOffsetInc) override
 
void Reset_T1 () override
 
void SetT0_and_T1_current_T () override
 This will set T0 and T1 with the current values. More...
 
void Interpolate (float t) override
 It will update the matrix to interpolate between T0 and T1 values. More...
 
glm::mat4 GetRotationMatrix () const
 Get the rotation matrix to be applied in a transformation camera. More...
 
const glm::mat4 & GetViewMatrix () const
 
const glm::mat4 & GetViewMatrix_Inv () const
 
const glm::mat4 & GetProjectionMatrix () const
 
const glm::mat4 & GetProjectionMatrixInv () const
 
const SFVEC3FGetRight () const
 
const SFVEC3FGetUp () const
 
const SFVEC3FGetDir () const
 
const SFVEC3FGetPos () const
 
const SFVEC2FGetFocalLen () const
 
float GetNear () const
 
float GetFar () const
 
const CAMERA_FRUSTUMGetFrustum () const
 
const SFVEC3FGetLookAtPos () const
 
void SetRotationMatrix (const glm::mat4 &aRotation)
 Set the rotation matrix to be applied in a transformation camera, without making any new calculations on camera. More...
 
void SetViewMatrix (glm::mat4 aViewMatrix)
 Set the affine matrix to be applied to a transformation camera. More...
 
void SetBoardLookAtPos (const SFVEC3F &aBoardPos)
 
void SetLookAtPos_T1 (const SFVEC3F &aLookAtPos)
 
const SFVEC3FGetLookAtPos_T1 () const
 
const SFVEC3FGetCameraPos () const
 
const SFVEC3FGetCameraInitPos () const
 
float GetCameraMinDimension () const
 
virtual void Reset ()
 Reset the camera to initial state. More...
 
void ResetXYpos ()
 
void ResetXYpos_T1 ()
 
const wxPoint & GetCurMousePosition ()
 Get the current mouse position. More...
 
void SetCurMousePosition (const wxPoint &aPosition)
 Update the current mouse position without make any new calculations on camera. More...
 
void ToggleProjection ()
 
PROJECTION_TYPE GetProjection ()
 
void SetProjection (PROJECTION_TYPE aProjection)
 
bool SetCurWindowSize (const wxSize &aSize)
 Update the windows size of the camera. More...
 
void ZoomReset ()
 
bool Zoom (float aFactor)
 
bool Zoom_T1 (float aFactor)
 
float GetZoom () const
 
float GetMinZoom ()
 
void SetMinZoom (float minZoom)
 
float GetMaxZoom ()
 
void SetMaxZoom (float maxZoom)
 
void RotateX (float aAngleInRadians)
 
void RotateY (float aAngleInRadians)
 
void RotateZ (float aAngleInRadians)
 
void RotateX_T1 (float aAngleInRadians)
 
void RotateY_T1 (float aAngleInRadians)
 
void RotateZ_T1 (float aAngleInRadians)
 
void SetInterpolateMode (CAMERA_INTERPOLATION aInterpolateMode)
 
bool ParametersChanged ()
 
bool ParametersChangedQuery () const
 
void MakeRay (const SFVEC2I &aWindowPos, SFVEC3F &aOutOrigin, SFVEC3F &aOutDirection) const
 Make a ray based on a windows screen position. More...
 
void MakeRay (const SFVEC2F &aWindowPos, SFVEC3F &aOutOrigin, SFVEC3F &aOutDirection) const
 Make a ray based on a windows screen position, it will interpolate based on the aWindowPos. More...
 
void MakeRayAtCurrentMousePosition (SFVEC3F &aOutOrigin, SFVEC3F &aOutDirection) const
 Make a ray based on the latest mouse position. More...
 
void Update ()
 Update the camera. More...
 

Static Public Attributes

static const float DEFAULT_MIN_ZOOM = 0.020f
 
static const float DEFAULT_MAX_ZOOM = 2.0f
 

Protected Member Functions

void zoomChanged ()
 
void rebuildProjection ()
 
void updateFrustum ()
 
void updateViewMatrix ()
 
void updateRotationMatrix ()
 

Protected Attributes

float m_zoom
 3D zoom value – Z-distance is scaled by it More...
 
float m_zoom_t0
 
float m_zoom_t1
 
float m_minZoom
 Possible 3D zoom range. More...
 
float m_maxZoom
 
SFVEC2I m_windowSize
 The window size that this camera is working. More...
 
wxPoint m_lastPosition
 The last mouse position in the screen. More...
 
glm::mat4 m_rotationMatrix
 
glm::mat4 m_rotationMatrixAux
 
glm::mat4 m_viewMatrix
 
glm::mat4 m_viewMatrixInverse
 
glm::mat4 m_projectionMatrix
 
glm::mat4 m_projectionMatrixInv
 
PROJECTION_TYPE m_projectionType
 
CAMERA_FRUSTUM m_frustum
 
SFVEC3F m_right
 
SFVEC3F m_up
 
SFVEC3F m_dir
 
SFVEC3F m_pos
 
SFVEC2F m_focalLen
 
SFVEC3F m_camera_pos_init
 
SFVEC3F m_camera_pos
 
SFVEC3F m_camera_pos_t0
 
SFVEC3F m_camera_pos_t1
 
SFVEC3F m_lookat_pos
 
SFVEC3F m_lookat_pos_t0
 
SFVEC3F m_lookat_pos_t1
 
SFVEC3F m_board_lookat_pos_init
 Default boardlookat position (the board center). More...
 
SFVEC3F m_rotate_aux
 Stores the rotation angle auxiliary. More...
 
SFVEC3F m_rotate_aux_t0
 
SFVEC3F m_rotate_aux_t1
 
CAMERA_INTERPOLATION m_interpolation_mode
 
std::vector< float > m_scr_nX
 Precalc values array used to calc ray for each pixel (constant for the same window size). More...
 
std::vector< float > m_scr_nY
 
std::vector< SFVEC3Fm_right_nX
 Precalc values array used to calc ray for each pixel, for X and Y axis of each new camera position. More...
 
std::vector< SFVEC3Fm_up_nY
 
bool m_parametersChanged
 Set to true if any of the parameters in the camera was changed. More...
 

Static Protected Attributes

static const wxChar * m_logTrace = wxT( "KI_TRACE_CAMERA" )
 Trace mask used to enable or disable the trace output of this class. More...
 

Private Attributes

double m_quat_t0 [4]
 interpolate quaternions of the trackball More...
 
double m_quat_t1 [4]
 

Detailed Description

Definition at line 36 of file track_ball.h.

Constructor & Destructor Documentation

◆ TRACK_BALL()

TRACK_BALL::TRACK_BALL ( float  aInitialDistance)
explicit

Definition at line 41 of file track_ball.cpp.

41 :
42 CAMERA( aInitialDistance )
43{
44 wxLogTrace( m_logTrace, wxT( "TRACK_BALL::TRACK_BALL" ) );
45
46 memset( m_quat_t0, 0, sizeof( m_quat_t0 ) );
47 memset( m_quat_t1, 0, sizeof( m_quat_t1 ) );
48
49 trackball( m_quat_t0, 0.0, 0.0, 0.0, 0.0 );
50 trackball( m_quat_t1, 0.0, 0.0, 0.0, 0.0 );
51}
CAMERA(float aInitialDistance)
Initialize a camera.
Definition: camera.cpp:53
double m_quat_t1[4]
Definition: track_ball.h:64
double m_quat_t0[4]
interpolate quaternions of the trackball
Definition: track_ball.h:63
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
Definition: camera.h:367
void trackball(double q[4], double p1x, double p1y, double p2x, double p2y)
Definition: trackball.cpp:155

References CAMERA::m_logTrace, m_quat_t0, m_quat_t1, and trackball().

◆ ~TRACK_BALL()

virtual TRACK_BALL::~TRACK_BALL ( )
inlinevirtual

Definition at line 41 of file track_ball.h.

42 {
43 }

Member Function Documentation

◆ Drag()

void TRACK_BALL::Drag ( const wxPoint &  aNewMousePosition)
overridevirtual

Calculate a new mouse drag position.

Implements CAMERA.

Definition at line 53 of file track_ball.cpp.

54{
56
57 double spin_quat[4];
58
59 // "Pass the x and y coordinates of the last and current positions of
60 // the mouse, scaled so they are from (-1.0 ... 1.0)."
61 const float zoom = 1.0f;
62
63 trackball( spin_quat, zoom * ( 2.0 * m_lastPosition.x - m_windowSize.x ) / m_windowSize.x,
64 zoom * ( m_windowSize.y - 2.0 * m_lastPosition.y ) / m_windowSize.y,
65 zoom * ( 2.0 * aNewMousePosition.x - m_windowSize.x ) / m_windowSize.x,
66 zoom * ( m_windowSize.y - 2.0 * aNewMousePosition.y ) / m_windowSize.y );
67
68 float spin_matrix[4][4];
69 build_rotmatrix( spin_matrix, spin_quat );
70 m_rotationMatrix = glm::make_mat4( &spin_matrix[0][0] ) * m_rotationMatrix;
71
73
75}
bool m_parametersChanged
Set to true if any of the parameters in the camera was changed.
Definition: camera.h:358
wxPoint m_lastPosition
The last mouse position in the screen.
Definition: camera.h:307
void updateFrustum()
Definition: camera.cpp:289
SFVEC2I m_windowSize
The window size that this camera is working.
Definition: camera.h:302
void updateViewMatrix()
Definition: camera.cpp:153
glm::mat4 m_rotationMatrix
Definition: camera.h:309
void build_rotmatrix(float m[4][4], double q[4])
Definition: trackball.cpp:306

References build_rotmatrix(), CAMERA::m_lastPosition, CAMERA::m_parametersChanged, CAMERA::m_rotationMatrix, CAMERA::m_windowSize, trackball(), CAMERA::updateFrustum(), CAMERA::updateViewMatrix(), and zoom.

Referenced by EDA_3D_MODEL_VIEWER::OnMouseMove().

◆ GetCameraInitPos()

const SFVEC3F & CAMERA::GetCameraInitPos ( ) const
inlineinherited

Definition at line 144 of file camera.h.

144{ return m_camera_pos_init; }
SFVEC3F m_camera_pos_init
Definition: camera.h:326

References CAMERA::m_camera_pos_init.

Referenced by RENDER_3D_RAYTRACE::Reload().

◆ GetCameraMinDimension()

float CAMERA::GetCameraMinDimension ( ) const
inherited

Definition at line 426 of file camera.cpp.

427{
428 return -m_camera_pos_init.z * m_frustum.tang;
429}
CAMERA_FRUSTUM m_frustum
Definition: camera.h:317
float tang
Definition: camera.h:59

References CAMERA::m_camera_pos_init, CAMERA::m_frustum, and CAMERA_FRUSTUM::tang.

◆ GetCameraPos()

const SFVEC3F & CAMERA::GetCameraPos ( ) const
inlineinherited

Definition at line 143 of file camera.h.

143{ return m_camera_pos; }
SFVEC3F m_camera_pos
Definition: camera.h:327

References CAMERA::m_camera_pos.

Referenced by EDA_3D_CANVAS::DisplayStatus().

◆ GetCurMousePosition()

const wxPoint & CAMERA::GetCurMousePosition ( )
inlineinherited

Get the current mouse position.

Definition at line 171 of file camera.h.

171{ return m_lastPosition; }

References CAMERA::m_lastPosition.

◆ GetDir()

const SFVEC3F & CAMERA::GetDir ( ) const
inlineinherited

Definition at line 109 of file camera.h.

109{ return m_dir; }
SFVEC3F m_dir
Definition: camera.h:321

References CAMERA::m_dir.

Referenced by RENDER_3D_RAYTRACE::Redraw(), and RENDER_3D_RAYTRACE::render().

◆ GetFar()

float CAMERA::GetFar ( ) const
inlineinherited

Definition at line 113 of file camera.h.

113{ return m_frustum.farD; }
float farD
Definition: camera.h:59

References CAMERA_FRUSTUM::farD, and CAMERA::m_frustum.

◆ GetFocalLen()

const SFVEC2F & CAMERA::GetFocalLen ( ) const
inlineinherited

Definition at line 111 of file camera.h.

111{ return m_focalLen; }
SFVEC2F m_focalLen
Definition: camera.h:324

References CAMERA::m_focalLen.

◆ GetFrustum()

◆ GetLookAtPos()

const SFVEC3F & CAMERA::GetLookAtPos ( ) const
inlineinherited

Definition at line 115 of file camera.h.

115{ return m_lookat_pos; }
SFVEC3F m_lookat_pos
Definition: camera.h:331

References CAMERA::m_lookat_pos.

Referenced by NL_3D_VIEWER_PLUGIN_IMPL::GetPivotPosition(), and NL_3D_VIEWER_PLUGIN_IMPL::SetCameraMatrix().

◆ GetLookAtPos_T1()

const SFVEC3F & CAMERA::GetLookAtPos_T1 ( ) const
inlineinherited

Definition at line 141 of file camera.h.

141{ return m_lookat_pos_t1; }
SFVEC3F m_lookat_pos_t1
Definition: camera.h:333

References CAMERA::m_lookat_pos_t1.

Referenced by EDA_3D_CANVAS::render_pivot().

◆ GetMaxZoom()

float CAMERA::GetMaxZoom ( )
inlineinherited

Definition at line 204 of file camera.h.

204{ return m_maxZoom; }
float m_maxZoom
Definition: camera.h:297

References CAMERA::m_maxZoom.

◆ GetMinZoom()

float CAMERA::GetMinZoom ( )
inlineinherited

Definition at line 197 of file camera.h.

197{ return m_minZoom; }
float m_minZoom
Possible 3D zoom range.
Definition: camera.h:296

References CAMERA::m_minZoom.

◆ GetNear()

float CAMERA::GetNear ( ) const
inlineinherited

Definition at line 112 of file camera.h.

112{ return m_frustum.nearD; }
float nearD
Definition: camera.h:59

References CAMERA::m_frustum, and CAMERA_FRUSTUM::nearD.

◆ GetPos()

const SFVEC3F & CAMERA::GetPos ( ) const
inlineinherited

Definition at line 110 of file camera.h.

110{ return m_pos; }
SFVEC3F m_pos
Definition: camera.h:322

References CAMERA::m_pos.

Referenced by RENDER_3D_OPENGL::Redraw(), RENDER_3D_OPENGL::renderSolderMaskLayer(), and RENDER_3D_OPENGL::renderTransparentModels().

◆ GetProjection()

◆ GetProjectionMatrix()

const glm::mat4 & CAMERA::GetProjectionMatrix ( ) const
inherited

Definition at line 414 of file camera.cpp.

415{
416 return m_projectionMatrix;
417}
glm::mat4 m_projectionMatrix
Definition: camera.h:313

References CAMERA::m_projectionMatrix.

Referenced by EDA_3D_MODEL_VIEWER::OnPaint(), RENDER_3D_OPENGL::Redraw(), and EDA_3D_CANVAS::render_pivot().

◆ GetProjectionMatrixInv()

const glm::mat4 & CAMERA::GetProjectionMatrixInv ( ) const
inherited

Definition at line 420 of file camera.cpp.

421{
423}
glm::mat4 m_projectionMatrixInv
Definition: camera.h:314

References CAMERA::m_projectionMatrixInv.

◆ GetRight()

const SFVEC3F & CAMERA::GetRight ( ) const
inlineinherited

Definition at line 107 of file camera.h.

107{ return m_right; }
SFVEC3F m_right
Definition: camera.h:319

References CAMERA::m_right.

◆ GetRotationMatrix()

glm::mat4 CAMERA::GetRotationMatrix ( ) const
inherited

Get the rotation matrix to be applied in a transformation camera.

Returns
the rotation matrix of the camera

Definition at line 182 of file camera.cpp.

183{
185}
glm::mat4 m_rotationMatrixAux
Definition: camera.h:310

References CAMERA::m_rotationMatrix, and CAMERA::m_rotationMatrixAux.

Referenced by EDA_3D_MODEL_VIEWER::OnPaint(), and RENDER_3D_OPENGL::render3dArrows().

◆ GetUp()

const SFVEC3F & CAMERA::GetUp ( ) const
inlineinherited

Definition at line 108 of file camera.h.

108{ return m_up; }
SFVEC3F m_up
Definition: camera.h:320

References CAMERA::m_up.

◆ GetViewMatrix()

◆ GetViewMatrix_Inv()

const glm::mat4 & CAMERA::GetViewMatrix_Inv ( ) const
inherited

Definition at line 488 of file camera.cpp.

489{
490 return m_viewMatrixInverse;
491}
glm::mat4 m_viewMatrixInverse
Definition: camera.h:312

References CAMERA::m_viewMatrixInverse.

◆ GetZoom()

float CAMERA::GetZoom ( ) const
inlineinherited

Definition at line 195 of file camera.h.

195{ return m_zoom; }
float m_zoom
3D zoom value – Z-distance is scaled by it
Definition: camera.h:289

References CAMERA::m_zoom.

Referenced by EDA_3D_CANVAS::DoRePaint(), HIDPI_GL_3D_CANVAS::OnMouseWheelCamera(), EDA_3D_CANVAS::SetView3D(), and NL_3D_VIEWER_PLUGIN_IMPL::SetViewExtents().

◆ Interpolate()

void TRACK_BALL::Interpolate ( float  t)
overridevirtual

It will update the matrix to interpolate between T0 and T1 values.

Parameters
tthe interpolation time, between 0.0f and 1.0f (it will clamp if >1).

Reimplemented from CAMERA.

Definition at line 138 of file track_ball.cpp.

139{
140 wxASSERT( t >= 0.0f );
141
142 // Limit t o 1.0
143 t = ( t > 1.0f ) ? 1.0f : t;
144
145 switch( m_interpolation_mode )
146 {
148 t = BezierBlend( t );
149 break;
150
152 t = QuadricEasingInOut( t );
153 break;
154
156 default:
157 break;
158 }
159
160 const float t0 = 1.0f - t;
161 double quat[4];
162 quat[0] = m_quat_t0[0] * t0 + m_quat_t1[0] * t;
163 quat[1] = m_quat_t0[1] * t0 + m_quat_t1[1] * t;
164 quat[2] = m_quat_t0[2] * t0 + m_quat_t1[2] * t;
165 quat[3] = m_quat_t0[3] * t0 + m_quat_t1[3] * t;
166
167 float rotationMatrix[4][4];
168
169 build_rotmatrix( rotationMatrix, quat );
170
171 m_rotationMatrix = glm::make_mat4( &rotationMatrix[0][0] );
172
174}
float BezierBlend(float t)
Definition: 3d_math.h:179
float QuadricEasingInOut(float t)
Definition: 3d_math.h:163
CAMERA_INTERPOLATION m_interpolation_mode
Definition: camera.h:340
virtual void Interpolate(float t)
It will update the matrix to interpolate between T0 and T1 values.
Definition: camera.cpp:644

References BEZIER, BezierBlend(), build_rotmatrix(), EASING_IN_OUT, CAMERA::Interpolate(), LINEAR, CAMERA::m_interpolation_mode, m_quat_t0, m_quat_t1, CAMERA::m_rotationMatrix, and QuadricEasingInOut().

◆ MakeRay() [1/2]

void CAMERA::MakeRay ( const SFVEC2F aWindowPos,
SFVEC3F aOutOrigin,
SFVEC3F aOutDirection 
) const
inherited

Make a ray based on a windows screen position, it will interpolate based on the aWindowPos.

Parameters
aWindowPosthe windows buffer position (float value).
aOutOriginout origin position of the ray.
aOutDirectionout direction.

Definition at line 370 of file camera.cpp.

372{
373 wxASSERT( aWindowPos.x < (float)m_windowSize.x );
374 wxASSERT( aWindowPos.y < (float)m_windowSize.y );
375
376 const SFVEC2F floorWinPos_f = glm::floor( aWindowPos );
377 const SFVEC2I floorWinPos_i = (SFVEC2I)floorWinPos_f;
378 const SFVEC2F relativeWinPos = aWindowPos - floorWinPos_f;
379
380 // Note: size of vectors m_up and m_right are m_windowSize + 1
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;
385
386 aOutOrigin = up_plus_right + m_frustum.nc;
387
388 switch( m_projectionType )
389 {
390 default:
392 aOutDirection = glm::normalize( aOutOrigin - m_pos );
393 break;
394
396 aOutDirection = -m_dir + SFVEC3F( FLT_EPSILON );
397 break;
398 }
399}
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.
Definition: camera.h:352
std::vector< SFVEC3F > m_up_nY
Definition: camera.h:353
SFVEC3F nc
Definition: camera.h:49
glm::ivec2 SFVEC2I
Definition: xv3d_types.h:39
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44

References CAMERA::m_dir, CAMERA::m_frustum, CAMERA::m_pos, CAMERA::m_projectionType, CAMERA::m_right_nX, CAMERA::m_up_nY, CAMERA::m_windowSize, CAMERA_FRUSTUM::nc, ORTHO, and PERSPECTIVE.

◆ MakeRay() [2/2]

void CAMERA::MakeRay ( const SFVEC2I aWindowPos,
SFVEC3F aOutOrigin,
SFVEC3F aOutDirection 
) const
inherited

Make a ray based on a windows screen position.

Parameters
aWindowPosthe windows buffer position.
aOutOriginout origin position of the ray.
aOutDirectionout direction

Definition at line 348 of file camera.cpp.

350{
351 wxASSERT( aWindowPos.x < m_windowSize.x );
352 wxASSERT( aWindowPos.y < m_windowSize.y );
353
354 aOutOrigin = m_frustum.nc + m_up_nY[aWindowPos.y] + m_right_nX[aWindowPos.x];
355
356 switch( m_projectionType )
357 {
358 default:
360 aOutDirection = glm::normalize( aOutOrigin - m_pos );
361 break;
362
364 aOutDirection = -m_dir + SFVEC3F( FLT_EPSILON );
365 break;
366 }
367}

References CAMERA::m_dir, CAMERA::m_frustum, CAMERA::m_pos, CAMERA::m_projectionType, CAMERA::m_right_nX, CAMERA::m_up_nY, CAMERA::m_windowSize, CAMERA_FRUSTUM::nc, ORTHO, and PERSPECTIVE.

Referenced by CAMERA::MakeRayAtCurrentMousePosition(), RAYPACKET::RAYPACKET(), RAYPACKET_InitRays(), and RAYPACKET_InitRays_with2DDisplacement().

◆ MakeRayAtCurrentMousePosition()

void CAMERA::MakeRayAtCurrentMousePosition ( SFVEC3F aOutOrigin,
SFVEC3F aOutDirection 
) const
inherited

Make a ray based on the latest mouse position.

Parameters
aOutOriginout origin position of the ray.
aOutDirectionout direction.

Definition at line 402 of file camera.cpp.

403{
404 const SFVEC2I windowPos = SFVEC2I( m_lastPosition.x, m_windowSize.y - m_lastPosition.y );
405
406 if( ( 0 < windowPos.x ) && ( windowPos.x < m_windowSize.x ) &&
407 ( 0 < windowPos.y ) && ( windowPos.y < m_windowSize.y ) )
408 {
409 MakeRay( windowPos, aOutOrigin, aOutDirection );
410 }
411}
void MakeRay(const SFVEC2I &aWindowPos, SFVEC3F &aOutOrigin, SFVEC3F &aOutDirection) const
Make a ray based on a windows screen position.
Definition: camera.cpp:348

References CAMERA::m_lastPosition, CAMERA::m_windowSize, and CAMERA::MakeRay().

Referenced by NL_3D_VIEWER_PLUGIN_IMPL::GetPointerPosition(), and EDA_3D_CANVAS::getRayAtCurrentMousePosition().

◆ Pan() [1/2]

void TRACK_BALL::Pan ( const SFVEC3F aDeltaOffsetInc)
overridevirtual

Implements CAMERA.

Definition at line 101 of file track_ball.cpp.

102{
103 m_parametersChanged = true;
104
105 m_camera_pos += aDeltaOffsetInc;
106
109}

References CAMERA::m_camera_pos, CAMERA::m_parametersChanged, CAMERA::updateFrustum(), and CAMERA::updateViewMatrix().

◆ Pan() [2/2]

void TRACK_BALL::Pan ( const wxPoint &  aNewMousePosition)
overridevirtual

Implements CAMERA.

Definition at line 77 of file track_ball.cpp.

78{
80
82 {
84 ( m_lastPosition.x - aNewMousePosition.x ) / m_windowSize.x;
86 ( aNewMousePosition.y - m_lastPosition.y ) / m_windowSize.y;
87 }
88 else // PROJECTION_TYPE::PERSPECTIVE
89 {
90 // Unproject the coordinates using the precomputed frustum tangent (zoom level dependent)
91 const float panFactor = -m_camera_pos.z * m_frustum.tang * 2;
92 m_camera_pos.x -= panFactor * m_frustum.ratio *
93 ( m_lastPosition.x - aNewMousePosition.x ) / m_windowSize.x;
94 m_camera_pos.y -= panFactor * ( aNewMousePosition.y - m_lastPosition.y ) / m_windowSize.y;
95 }
96
99}
float ratio
Definition: camera.h:59
float nh
Definition: camera.h:60
float nw
Definition: camera.h:60

References CAMERA::m_camera_pos, CAMERA::m_frustum, CAMERA::m_lastPosition, CAMERA::m_parametersChanged, CAMERA::m_projectionType, CAMERA::m_windowSize, CAMERA_FRUSTUM::nh, CAMERA_FRUSTUM::nw, ORTHO, CAMERA_FRUSTUM::ratio, CAMERA_FRUSTUM::tang, CAMERA::updateFrustum(), and CAMERA::updateViewMatrix().

◆ Pan_T1()

void TRACK_BALL::Pan_T1 ( const SFVEC3F aDeltaOffsetInc)
overridevirtual

Implements CAMERA.

Definition at line 111 of file track_ball.cpp.

112{
113 m_camera_pos_t1 = m_camera_pos + aDeltaOffsetInc;
114}
SFVEC3F m_camera_pos_t1
Definition: camera.h:329

References CAMERA::m_camera_pos, and CAMERA::m_camera_pos_t1.

◆ ParametersChanged()

bool CAMERA::ParametersChanged ( )
inherited
Returns
true if some of the parameters in camera was changed, it will reset the flag.

Definition at line 662 of file camera.cpp.

663{
664 const bool parametersChanged = m_parametersChanged;
665
666 m_parametersChanged = false;
667
668 return parametersChanged;
669}

References CAMERA::m_parametersChanged.

Referenced by EDA_3D_CANVAS::DoRePaint(), and RENDER_3D_RAYTRACE::Redraw().

◆ ParametersChangedQuery()

bool CAMERA::ParametersChangedQuery ( ) const
inlineinherited
Returns
true if some of the parameters in camera was changed, it will NOT reset the flag.

Definition at line 244 of file camera.h.

244{ return m_parametersChanged; }

References CAMERA::m_parametersChanged.

◆ rebuildProjection()

void CAMERA::rebuildProjection ( )
protectedinherited

Definition at line 196 of file camera.cpp.

197{
198 if( ( m_windowSize.x == 0 ) || ( m_windowSize.y == 0 ) )
199 return;
200
201 m_frustum.ratio = (float) m_windowSize.x / (float)m_windowSize.y;
202 m_frustum.farD = glm::length( m_camera_pos_init ) * m_maxZoom * 2.0f;
203
204 switch( m_projectionType )
205 {
206 default:
208
209 m_frustum.nearD = 0.10f;
210
211 m_frustum.angle = 45.0f;
212
213 m_projectionMatrix = glm::perspective( glm::radians( m_frustum.angle ), m_frustum.ratio,
215
217
218 m_frustum.tang = glm::tan( glm::radians( m_frustum.angle ) * 0.5f );
219
220 m_focalLen.x = ( (float)m_windowSize.y / (float)m_windowSize.x ) / m_frustum.tang;
221 m_focalLen.y = 1.0f / m_frustum.tang;
222
227 break;
228
230
231 // Keep the viewed plane at (m_camera_pos_init * m_zoom) the same dimensions in both projections.
232 m_frustum.angle = 45.0f;
233 m_frustum.tang = glm::tan( glm::radians( m_frustum.angle ) * 0.5f );
234
235 m_frustum.nearD = -m_frustum.farD; // Use a symmetrical clip plane for ortho projection
236
237 const float orthoReductionFactor =
238 glm::length( m_camera_pos_init ) * m_zoom * m_frustum.tang;
239
240 // Initialize Projection Matrix for Orthographic View
241 m_projectionMatrix = glm::ortho( -m_frustum.ratio * orthoReductionFactor,
242 m_frustum.ratio * orthoReductionFactor,
243 -orthoReductionFactor,
244 orthoReductionFactor,
246
248
249 m_frustum.nw = orthoReductionFactor * 2.0f * m_frustum.ratio;
250 m_frustum.nh = orthoReductionFactor * 2.0f;
253
254 break;
255 }
256
257 if( ( m_windowSize.x > 0 ) && ( m_windowSize.y > 0 ) )
258 {
259 m_scr_nX.resize( m_windowSize.x + 1 );
260 m_scr_nY.resize( m_windowSize.y + 1 );
261
262 // Precalc X values for camera -> ray generation
263 for( unsigned int x = 0; x < (unsigned int)m_windowSize.x + 1; ++x )
264 {
265 // Converts 0.0 .. 1.0
266 const float xNormalizedDeviceCoordinates = ( ( (float)x + 0.5f ) /
267 (m_windowSize.x - 0.0f) );
268
269 // Converts -1.0 .. 1.0
270 m_scr_nX[x] = 2.0f * xNormalizedDeviceCoordinates - 1.0f;
271 }
272
273 // Precalc Y values for camera -> ray generation
274 for( unsigned int y = 0; y < (unsigned int)m_windowSize.y + 1 ; ++y )
275 {
276 // Converts 0.0 .. 1.0
277 const float yNormalizedDeviceCoordinates = ( ( (float)y + 0.5f ) /
278 (m_windowSize.y - 0.0f) );
279
280 // Converts -1.0 .. 1.0
281 m_scr_nY[y] = 2.0f * yNormalizedDeviceCoordinates - 1.0f;
282 }
283
285 }
286}
std::vector< float > m_scr_nX
Precalc values array used to calc ray for each pixel (constant for the same window size).
Definition: camera.h:345
std::vector< float > m_scr_nY
Definition: camera.h:346
float angle
Definition: camera.h:59
float fh
Definition: camera.h:60
float fw
Definition: camera.h:60

References CAMERA_FRUSTUM::angle, CAMERA_FRUSTUM::farD, CAMERA_FRUSTUM::fh, CAMERA_FRUSTUM::fw, CAMERA::m_camera_pos_init, CAMERA::m_focalLen, CAMERA::m_frustum, CAMERA::m_maxZoom, CAMERA::m_projectionMatrix, CAMERA::m_projectionMatrixInv, CAMERA::m_projectionType, CAMERA::m_scr_nX, CAMERA::m_scr_nY, CAMERA::m_windowSize, CAMERA::m_zoom, CAMERA_FRUSTUM::nearD, CAMERA_FRUSTUM::nh, CAMERA_FRUSTUM::nw, ORTHO, PERSPECTIVE, CAMERA_FRUSTUM::ratio, CAMERA_FRUSTUM::tang, and CAMERA::updateFrustum().

Referenced by CAMERA::Interpolate(), CAMERA::Reset(), CAMERA::SetCurWindowSize(), CAMERA::ToggleProjection(), CAMERA::Zoom(), CAMERA::zoomChanged(), and CAMERA::ZoomReset().

◆ Reset()

void CAMERA::Reset ( )
virtualinherited

Reset the camera to initial state.

Definition at line 70 of file camera.cpp.

71{
73 m_projectionMatrix = glm::mat4( 1.0f );
74 m_projectionMatrixInv = glm::mat4( 1.0f );
75 m_rotationMatrix = glm::mat4( 1.0f );
76 m_rotationMatrixAux = glm::mat4( 1.0f );
77 m_lastPosition = wxPoint( 0, 0 );
78
79 m_zoom = 1.0f;
80 m_zoom_t0 = 1.0f;
81 m_zoom_t1 = 1.0f;
88
89 m_rotate_aux = SFVEC3F( 0.0f );
90 m_rotate_aux_t0 = SFVEC3F( 0.0f );
91 m_rotate_aux_t1 = SFVEC3F( 0.0f );
92
95 m_viewMatrixInverse = glm::inverse( m_viewMatrix );
96 m_scr_nX.clear();
97 m_scr_nY.clear();
99}
float m_zoom_t0
Definition: camera.h:290
SFVEC3F m_camera_pos_t0
Definition: camera.h:328
SFVEC3F m_rotate_aux_t1
Definition: camera.h:338
void updateRotationMatrix()
Definition: camera.cpp:161
SFVEC3F m_rotate_aux_t0
Definition: camera.h:337
void rebuildProjection()
Definition: camera.cpp:196
float m_zoom_t1
Definition: camera.h:291
SFVEC3F m_lookat_pos_t0
Definition: camera.h:332
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliary.
Definition: camera.h:336
SFVEC3F m_board_lookat_pos_init
Default boardlookat position (the board center).
Definition: camera.h:334

References CAMERA::m_board_lookat_pos_init, CAMERA::m_camera_pos, CAMERA::m_camera_pos_init, CAMERA::m_camera_pos_t0, CAMERA::m_camera_pos_t1, CAMERA::m_lastPosition, CAMERA::m_lookat_pos, CAMERA::m_lookat_pos_t0, CAMERA::m_lookat_pos_t1, CAMERA::m_parametersChanged, CAMERA::m_projectionMatrix, CAMERA::m_projectionMatrixInv, CAMERA::m_rotate_aux, CAMERA::m_rotate_aux_t0, CAMERA::m_rotate_aux_t1, CAMERA::m_rotationMatrix, CAMERA::m_rotationMatrixAux, CAMERA::m_scr_nX, CAMERA::m_scr_nY, CAMERA::m_viewMatrix, CAMERA::m_viewMatrixInverse, CAMERA::m_zoom, CAMERA::m_zoom_t0, CAMERA::m_zoom_t1, CAMERA::rebuildProjection(), CAMERA::updateRotationMatrix(), and CAMERA::updateViewMatrix().

Referenced by CAMERA::CAMERA().

◆ Reset_T1()

void TRACK_BALL::Reset_T1 ( )
overridevirtual

Reimplemented from CAMERA.

Definition at line 116 of file track_ball.cpp.

117{
119
120 memset( m_quat_t1, 0, sizeof( m_quat_t1 ) );
121 trackball( m_quat_t1, 0.0, 0.0, 0.0, 0.0 );
122}
virtual void Reset_T1()
Definition: camera.cpp:102

References m_quat_t1, CAMERA::Reset_T1(), and trackball().

◆ ResetXYpos()

void CAMERA::ResetXYpos ( )
inherited

Definition at line 432 of file camera.cpp.

433{
434 m_parametersChanged = true;
435 m_camera_pos.x = 0.0f;
436 m_camera_pos.y = 0.0f;
437
440}

References CAMERA::m_camera_pos, CAMERA::m_parametersChanged, CAMERA::updateFrustum(), and CAMERA::updateViewMatrix().

◆ ResetXYpos_T1()

void CAMERA::ResetXYpos_T1 ( )
inherited

Definition at line 443 of file camera.cpp.

444{
445 m_camera_pos_t1.x = 0.0f;
446 m_camera_pos_t1.y = 0.0f;
447}

References CAMERA::m_camera_pos_t1.

Referenced by EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position().

◆ RotateX()

void CAMERA::RotateX ( float  aAngleInRadians)
inherited

Definition at line 591 of file camera.cpp.

592{
593 m_rotate_aux.x += aAngleInRadians;
595}

References CAMERA::m_rotate_aux, and CAMERA::updateRotationMatrix().

Referenced by EDA_3D_CONTROLLER::RotateView().

◆ RotateX_T1()

void CAMERA::RotateX_T1 ( float  aAngleInRadians)
inherited

Definition at line 612 of file camera.cpp.

613{
614 m_rotate_aux_t1.x += aAngleInRadians;
615}

References CAMERA::m_rotate_aux_t1.

Referenced by EDA_3D_CANVAS::SetView3D().

◆ RotateY()

void CAMERA::RotateY ( float  aAngleInRadians)
inherited

Definition at line 598 of file camera.cpp.

599{
600 m_rotate_aux.y += aAngleInRadians;
602}

References CAMERA::m_rotate_aux, and CAMERA::updateRotationMatrix().

Referenced by EDA_3D_CONTROLLER::RotateView().

◆ RotateY_T1()

void CAMERA::RotateY_T1 ( float  aAngleInRadians)
inherited

Definition at line 618 of file camera.cpp.

619{
620 m_rotate_aux_t1.y += aAngleInRadians;
621}

References CAMERA::m_rotate_aux_t1.

Referenced by EDA_3D_CANVAS::SetView3D().

◆ RotateZ()

void CAMERA::RotateZ ( float  aAngleInRadians)
inherited

Definition at line 605 of file camera.cpp.

606{
607 m_rotate_aux.z += aAngleInRadians;
609}

References CAMERA::m_rotate_aux, and CAMERA::updateRotationMatrix().

Referenced by EDA_3D_CONTROLLER::RotateView().

◆ RotateZ_T1()

void CAMERA::RotateZ_T1 ( float  aAngleInRadians)
inherited

Definition at line 624 of file camera.cpp.

625{
626 m_rotate_aux_t1.z += aAngleInRadians;
627}

References CAMERA::m_rotate_aux_t1.

Referenced by EDA_3D_CANVAS::SetView3D().

◆ SetBoardLookAtPos()

void CAMERA::SetBoardLookAtPos ( const SFVEC3F aBoardPos)
inherited

◆ SetCurMousePosition()

void CAMERA::SetCurMousePosition ( const wxPoint &  aPosition)
inherited

Update the current mouse position without make any new calculations on camera.

Definition at line 494 of file camera.cpp.

495{
496 m_lastPosition = aNewMousePosition;
497}

References CAMERA::m_lastPosition.

Referenced by EDA_3D_MODEL_VIEWER::OnMouseMove(), HIDPI_GL_3D_CANVAS::OnMouseMoveCamera(), EDA_3D_MODEL_VIEWER::OnMouseWheel(), and HIDPI_GL_3D_CANVAS::OnMouseWheelCamera().

◆ SetCurWindowSize()

bool CAMERA::SetCurWindowSize ( const wxSize &  aSize)
inherited

Update the windows size of the camera.

Returns
true if the windows size changed since last time.

Definition at line 511 of file camera.cpp.

512{
513 const SFVEC2I newSize = SFVEC2I( aSize.x, aSize.y );
514
515 if( m_windowSize != newSize )
516 {
517 m_windowSize = newSize;
519
520 return true;
521 }
522
523 return false;
524}

References CAMERA::m_windowSize, and CAMERA::rebuildProjection().

Referenced by EDA_3D_CANVAS::DoRePaint(), EDA_3D_MODEL_VIEWER::OnMouseMove(), HIDPI_GL_3D_CANVAS::OnMouseMoveCamera(), and EDA_3D_MODEL_VIEWER::OnPaint().

◆ SetInterpolateMode()

void CAMERA::SetInterpolateMode ( CAMERA_INTERPOLATION  aInterpolateMode)
inlineinherited

Definition at line 231 of file camera.h.

232 {
233 m_interpolation_mode = aInterpolateMode;
234 }

References CAMERA::m_interpolation_mode.

Referenced by EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position(), and EDA_3D_CANVAS::SetView3D().

◆ SetLookAtPos_T1()

void CAMERA::SetLookAtPos_T1 ( const SFVEC3F aLookAtPos)
inlineinherited

◆ SetMaxZoom()

void CAMERA::SetMaxZoom ( float  maxZoom)
inlineinherited

Definition at line 205 of file camera.h.

206 {
207 m_maxZoom = maxZoom;
208 zoomChanged();
209 }
void zoomChanged()
Definition: camera.cpp:138

References CAMERA::m_maxZoom, and CAMERA::zoomChanged().

Referenced by RENDER_3D_RAYTRACE::Reload().

◆ SetMinZoom()

void CAMERA::SetMinZoom ( float  minZoom)
inlineinherited

Definition at line 198 of file camera.h.

199 {
200 m_minZoom = minZoom;
201 zoomChanged();
202 }

References CAMERA::m_minZoom, and CAMERA::zoomChanged().

Referenced by RENDER_3D_RAYTRACE::Reload().

◆ SetProjection()

void CAMERA::SetProjection ( PROJECTION_TYPE  aProjection)
inlineinherited

Definition at line 180 of file camera.h.

180{ m_projectionType = aProjection; }

References CAMERA::m_projectionType.

Referenced by EDA_3D_CANVAS::SetProjectionMode().

◆ SetRotationMatrix()

void CAMERA::SetRotationMatrix ( const glm::mat4 &  aRotation)
inherited

Set the rotation matrix to be applied in a transformation camera, without making any new calculations on camera.

Parameters
aRotationis the total rotation matrix of the camera.

Definition at line 188 of file camera.cpp.

189{
190 m_parametersChanged = true;
191 std::copy_n( glm::value_ptr( aRotation * glm::inverse( m_rotationMatrixAux ) ), 12,
192 glm::value_ptr( m_rotationMatrix ) );
193}

References CAMERA::m_parametersChanged, CAMERA::m_rotationMatrix, and CAMERA::m_rotationMatrixAux.

Referenced by CAMERA::SetViewMatrix().

◆ SetT0_and_T1_current_T()

void TRACK_BALL::SetT0_and_T1_current_T ( )
overridevirtual

This will set T0 and T1 with the current values.

Reimplemented from CAMERA.

Definition at line 124 of file track_ball.cpp.

125{
127
128 double quat[4];
129
130 // Charge the quaternions with the current rotation matrix to allow dual input.
131 std::copy_n( glm::value_ptr( glm::conjugate( glm::quat_cast( m_rotationMatrix ) ) ),
132 sizeof( quat ) / sizeof( quat[0] ), quat );
133
134 memcpy( m_quat_t0, quat, sizeof( quat ) );
135 memcpy( m_quat_t1, quat, sizeof( quat ) );
136}
virtual void SetT0_and_T1_current_T()
This will set T0 and T1 with the current values.
Definition: camera.cpp:630

References m_quat_t0, m_quat_t1, CAMERA::m_rotationMatrix, and CAMERA::SetT0_and_T1_current_T().

◆ SetViewMatrix()

void CAMERA::SetViewMatrix ( glm::mat4  aViewMatrix)
inherited

Set the affine matrix to be applied to a transformation camera.

Parameters
aViewMatrixis the affine matrix of the camera. The affine matrix maps coordinates in the world frame to those in the camera frame.

Definition at line 456 of file camera.cpp.

457{
458 SetRotationMatrix( aViewMatrix );
459
460 // The look at position in the view frame.
461 glm::vec4 lookat = aViewMatrix * glm::vec4( m_lookat_pos, 1.0f );
462
463 wxLogTrace( m_logTrace,
464 wxT( "CAMERA::SetViewMatrix aViewMatrix[3].z =%f, old_zoom=%f, new_zoom=%f, "
465 "m[3].z=%f" ),
466 aViewMatrix[3].z, m_zoom, lookat.z / m_camera_pos_init.z, lookat.z );
467
468 m_zoom = lookat.z / m_camera_pos_init.z;
469
470 if( m_zoom > m_maxZoom )
471 {
473 aViewMatrix[3].z += -lookat.z + m_maxZoom * m_camera_pos_init.z;
474 }
475 else if( m_zoom < m_minZoom )
476 {
478 aViewMatrix[3].z += -lookat.z + m_minZoom * m_camera_pos_init.z;
479 }
480
481 m_viewMatrix = std::move( aViewMatrix );
483 * glm::inverse( m_rotationMatrix * m_rotationMatrixAux
484 * glm::translate( glm::mat4( 1.0f ), -m_lookat_pos ) )[3];
485}
void SetRotationMatrix(const glm::mat4 &aRotation)
Set the rotation matrix to be applied in a transformation camera, without making any new calculations...
Definition: camera.cpp:188

References CAMERA::m_camera_pos, CAMERA::m_camera_pos_init, CAMERA::m_logTrace, CAMERA::m_lookat_pos, CAMERA::m_maxZoom, CAMERA::m_minZoom, CAMERA::m_rotationMatrix, CAMERA::m_rotationMatrixAux, CAMERA::m_viewMatrix, CAMERA::m_zoom, and CAMERA::SetRotationMatrix().

Referenced by EDA_3D_VIEWER_FRAME::applyViewport(), and NL_3D_VIEWER_PLUGIN_IMPL::SetCameraMatrix().

◆ ToggleProjection()

◆ Update()

void CAMERA::Update ( )
inlineinherited

Update the camera.

Definition at line 276 of file camera.h.

276{ updateFrustum(); }

References CAMERA::updateFrustum().

Referenced by NL_3D_VIEWER_PLUGIN_IMPL::SetCameraMatrix().

◆ updateFrustum()

void CAMERA::updateFrustum ( )
protectedinherited

Definition at line 289 of file camera.cpp.

290{
291 // Update matrix and vectors
292 m_viewMatrixInverse = glm::inverse( m_viewMatrix );
293
294 m_right = glm::normalize( SFVEC3F( m_viewMatrixInverse *
295 glm::vec4( SFVEC3F( 1.0, 0.0, 0.0 ), 0.0 ) ) );
296
297 m_up = glm::normalize( SFVEC3F( m_viewMatrixInverse *
298 glm::vec4( SFVEC3F( 0.0, 1.0, 0.0 ), 0.0 ) ) );
299
300 m_dir = glm::normalize( SFVEC3F( m_viewMatrixInverse *
301 glm::vec4( SFVEC3F( 0.0, 0.0, 1.0 ), 0.0 ) ) );
302
303 m_pos = SFVEC3F( m_viewMatrixInverse * glm::vec4( SFVEC3F( 0.0, 0.0, 0.0 ), 1.0 ) );
304
305 /*
306 * Frustum is a implementation based on a tutorial by
307 * http://www.lighthouse3d.com/tutorials/view-frustum-culling/
308 */
309
310 const SFVEC3F half_right_nw = m_right * m_frustum.nw * 0.5f;
311 const SFVEC3F half_right_fw = m_right * m_frustum.fw * 0.5f;
312 const SFVEC3F half_up_nh = m_up * m_frustum.nh * 0.5f;
313 const SFVEC3F half_up_fh = m_up * m_frustum.fh * 0.5f;
314
315 // compute the centers of the near and far planes
318
319 // compute the 4 corners of the frustum on the near plane
320 m_frustum.ntl = m_frustum.nc + half_up_nh - half_right_nw;
321 m_frustum.ntr = m_frustum.nc + half_up_nh + half_right_nw;
322 m_frustum.nbl = m_frustum.nc - half_up_nh - half_right_nw;
323 m_frustum.nbr = m_frustum.nc - half_up_nh + half_right_nw;
324
325 // compute the 4 corners of the frustum on the far plane
326 m_frustum.ftl = m_frustum.fc + half_up_fh - half_right_fw;
327 m_frustum.ftr = m_frustum.fc + half_up_fh + half_right_fw;
328 m_frustum.fbl = m_frustum.fc - half_up_fh - half_right_fw;
329 m_frustum.fbr = m_frustum.fc - half_up_fh + half_right_fw;
330
331 if( ( m_windowSize.x > 0 ) && ( m_windowSize.y > 0 ) )
332 {
333 // Reserve size for precalc values
334 m_right_nX.resize( m_windowSize.x + 1 );
335 m_up_nY.resize( m_windowSize.y + 1 );
336
337 // Precalc X values for camera -> ray generation
338 for( unsigned int x = 0; x < ( (unsigned int) m_windowSize.x + 1 ); ++x )
339 m_right_nX[x] = half_right_nw * m_scr_nX[x];
340
341 // Precalc Y values for camera -> ray generation
342 for( unsigned int y = 0; y < ( (unsigned int) m_windowSize.y + 1 ); ++y )
343 m_up_nY[y] = half_up_nh * m_scr_nY[y];
344 }
345}
SFVEC3F ntr
Near Top Right.
Definition: camera.h:52
SFVEC3F ntl
Near Top Left.
Definition: camera.h:51
SFVEC3F fc
Definition: camera.h:50
SFVEC3F ftl
Far Top Left.
Definition: camera.h:55
SFVEC3F fbr
Far Bottom Right.
Definition: camera.h:58
SFVEC3F nbl
Near Bottom Left.
Definition: camera.h:53
SFVEC3F nbr
Near Bottom Right.
Definition: camera.h:54
SFVEC3F fbl
Far Bottom Left.
Definition: camera.h:57
SFVEC3F ftr
Far Top Right.
Definition: camera.h:56

References CAMERA_FRUSTUM::farD, CAMERA_FRUSTUM::fbl, CAMERA_FRUSTUM::fbr, CAMERA_FRUSTUM::fc, CAMERA_FRUSTUM::fh, CAMERA_FRUSTUM::ftl, CAMERA_FRUSTUM::ftr, CAMERA_FRUSTUM::fw, CAMERA::m_dir, CAMERA::m_frustum, CAMERA::m_pos, CAMERA::m_right, CAMERA::m_right_nX, CAMERA::m_scr_nX, CAMERA::m_scr_nY, CAMERA::m_up, CAMERA::m_up_nY, CAMERA::m_viewMatrix, CAMERA::m_viewMatrixInverse, CAMERA::m_windowSize, CAMERA_FRUSTUM::nbl, CAMERA_FRUSTUM::nbr, CAMERA_FRUSTUM::nc, CAMERA_FRUSTUM::nearD, CAMERA_FRUSTUM::nh, CAMERA_FRUSTUM::ntl, CAMERA_FRUSTUM::ntr, and CAMERA_FRUSTUM::nw.

Referenced by Drag(), Pan(), CAMERA::rebuildProjection(), CAMERA::ResetXYpos(), CAMERA::SetBoardLookAtPos(), CAMERA::Update(), and CAMERA::updateRotationMatrix().

◆ updateRotationMatrix()

void CAMERA::updateRotationMatrix ( )
protectedinherited

Definition at line 161 of file camera.cpp.

162{
163 m_rotationMatrixAux = glm::rotate( glm::mat4( 1.0f ), m_rotate_aux.x,
164 SFVEC3F( 1.0f, 0.0f, 0.0f ) );
166
168 SFVEC3F( 0.0f, 1.0f, 0.0f ) );
170
172 SFVEC3F( 0.0f, 0.0f, 1.0f ) );
174
175 m_parametersChanged = true;
176
179}
void normalise2PI(float &aAngle)
Definition: camera.cpp:34

References CAMERA::m_parametersChanged, CAMERA::m_rotate_aux, CAMERA::m_rotationMatrixAux, normalise2PI(), CAMERA::updateFrustum(), and CAMERA::updateViewMatrix().

Referenced by CAMERA::Interpolate(), CAMERA::Reset(), CAMERA::RotateX(), CAMERA::RotateY(), and CAMERA::RotateZ().

◆ updateViewMatrix()

void CAMERA::updateViewMatrix ( )
protectedinherited

◆ Zoom()

bool CAMERA::Zoom ( float  aFactor)
inherited

Definition at line 538 of file camera.cpp.

539{
540 if( ( m_zoom <= m_minZoom && aFactor > 1 ) || ( m_zoom >= m_maxZoom && aFactor < 1 )
541 || aFactor == 1 )
542 {
543 return false;
544 }
545
546 float zoom = m_zoom;
547 m_zoom /= aFactor;
548
549 if( m_zoom <= m_minZoom && aFactor > 1 )
550 {
551 aFactor = zoom / m_minZoom;
553 }
554 else if( m_zoom >= m_maxZoom && aFactor < 1 )
555 {
556 aFactor = zoom / m_maxZoom;
558 }
559
560 m_camera_pos.z /= aFactor;
561
564
565 return true;
566}

References CAMERA::m_camera_pos, CAMERA::m_maxZoom, CAMERA::m_minZoom, CAMERA::m_zoom, CAMERA::rebuildProjection(), CAMERA::updateViewMatrix(), and zoom.

Referenced by EDA_3D_MODEL_VIEWER::OnMouseWheel(), HIDPI_GL_3D_CANVAS::OnMouseWheelCamera(), and NL_3D_VIEWER_PLUGIN_IMPL::SetViewExtents().

◆ Zoom_T1()

bool CAMERA::Zoom_T1 ( float  aFactor)
inherited

Definition at line 569 of file camera.cpp.

570{
571 if( ( m_zoom <= m_minZoom && aFactor > 1 ) || ( m_zoom >= m_maxZoom && aFactor < 1 )
572 || aFactor == 1 )
573 {
574 return false;
575 }
576
577 m_zoom_t1 = m_zoom / aFactor;
578
579 if( m_zoom_t1 < m_minZoom )
581
582 if( m_zoom_t1 > m_maxZoom )
584
586
587 return true;
588}

References CAMERA::m_camera_pos_init, CAMERA::m_camera_pos_t1, CAMERA::m_maxZoom, CAMERA::m_minZoom, CAMERA::m_zoom, and CAMERA::m_zoom_t1.

Referenced by EDA_3D_CANVAS::SetView3D().

◆ zoomChanged()

void CAMERA::zoomChanged ( )
protectedinherited

◆ ZoomReset()

void CAMERA::ZoomReset ( )
inherited

Member Data Documentation

◆ DEFAULT_MAX_ZOOM

const float CAMERA::DEFAULT_MAX_ZOOM = 2.0f
staticinherited

Definition at line 81 of file camera.h.

Referenced by CAMERA::CAMERA(), and RENDER_3D_RAYTRACE::Reload().

◆ DEFAULT_MIN_ZOOM

const float CAMERA::DEFAULT_MIN_ZOOM = 0.020f
staticinherited

Definition at line 80 of file camera.h.

Referenced by CAMERA::CAMERA().

◆ m_board_lookat_pos_init

SFVEC3F CAMERA::m_board_lookat_pos_init
protectedinherited

Default boardlookat position (the board center).

Definition at line 334 of file camera.h.

Referenced by CAMERA::CAMERA(), CAMERA::Reset(), CAMERA::Reset_T1(), and CAMERA::SetBoardLookAtPos().

◆ m_camera_pos

◆ m_camera_pos_init

◆ m_camera_pos_t0

SFVEC3F CAMERA::m_camera_pos_t0
protectedinherited

Definition at line 328 of file camera.h.

Referenced by CAMERA::Interpolate(), CAMERA::Reset(), and CAMERA::SetT0_and_T1_current_T().

◆ m_camera_pos_t1

SFVEC3F CAMERA::m_camera_pos_t1
protectedinherited

◆ m_dir

SFVEC3F CAMERA::m_dir
protectedinherited

Definition at line 321 of file camera.h.

Referenced by CAMERA::GetDir(), CAMERA::MakeRay(), and CAMERA::updateFrustum().

◆ m_focalLen

SFVEC2F CAMERA::m_focalLen
protectedinherited

Definition at line 324 of file camera.h.

Referenced by CAMERA::GetFocalLen(), and CAMERA::rebuildProjection().

◆ m_frustum

◆ m_interpolation_mode

CAMERA_INTERPOLATION CAMERA::m_interpolation_mode
protectedinherited

Definition at line 340 of file camera.h.

Referenced by CAMERA::CAMERA(), Interpolate(), and CAMERA::SetInterpolateMode().

◆ m_lastPosition

wxPoint CAMERA::m_lastPosition
protectedinherited

The last mouse position in the screen.

Definition at line 307 of file camera.h.

Referenced by Drag(), CAMERA::GetCurMousePosition(), CAMERA::MakeRayAtCurrentMousePosition(), Pan(), CAMERA::Reset(), and CAMERA::SetCurMousePosition().

◆ m_lookat_pos

◆ m_lookat_pos_t0

SFVEC3F CAMERA::m_lookat_pos_t0
protectedinherited

Definition at line 332 of file camera.h.

Referenced by CAMERA::Interpolate(), CAMERA::Reset(), and CAMERA::SetT0_and_T1_current_T().

◆ m_lookat_pos_t1

SFVEC3F CAMERA::m_lookat_pos_t1
protectedinherited

◆ m_maxZoom

◆ m_minZoom

float CAMERA::m_minZoom
protectedinherited

◆ m_parametersChanged

bool CAMERA::m_parametersChanged
protectedinherited

◆ m_pos

SFVEC3F CAMERA::m_pos
protectedinherited

Definition at line 322 of file camera.h.

Referenced by CAMERA::GetPos(), CAMERA::MakeRay(), and CAMERA::updateFrustum().

◆ m_projectionMatrix

glm::mat4 CAMERA::m_projectionMatrix
protectedinherited

Definition at line 313 of file camera.h.

Referenced by CAMERA::GetProjectionMatrix(), CAMERA::rebuildProjection(), and CAMERA::Reset().

◆ m_projectionMatrixInv

glm::mat4 CAMERA::m_projectionMatrixInv
protectedinherited

◆ m_projectionType

◆ m_quat_t0

double TRACK_BALL::m_quat_t0[4]
private

interpolate quaternions of the trackball

Definition at line 63 of file track_ball.h.

Referenced by Interpolate(), SetT0_and_T1_current_T(), and TRACK_BALL().

◆ m_quat_t1

double TRACK_BALL::m_quat_t1[4]
private

Definition at line 64 of file track_ball.h.

Referenced by Interpolate(), Reset_T1(), SetT0_and_T1_current_T(), and TRACK_BALL().

◆ m_right

SFVEC3F CAMERA::m_right
protectedinherited

Definition at line 319 of file camera.h.

Referenced by CAMERA::GetRight(), and CAMERA::updateFrustum().

◆ m_right_nX

std::vector< SFVEC3F > CAMERA::m_right_nX
protectedinherited

Precalc values array used to calc ray for each pixel, for X and Y axis of each new camera position.

Definition at line 352 of file camera.h.

Referenced by CAMERA::MakeRay(), and CAMERA::updateFrustum().

◆ m_rotate_aux

SFVEC3F CAMERA::m_rotate_aux
protectedinherited

◆ m_rotate_aux_t0

SFVEC3F CAMERA::m_rotate_aux_t0
protectedinherited

◆ m_rotate_aux_t1

◆ m_rotationMatrix

glm::mat4 CAMERA::m_rotationMatrix
protectedinherited

◆ m_rotationMatrixAux

glm::mat4 CAMERA::m_rotationMatrixAux
protectedinherited

◆ m_scr_nX

std::vector< float > CAMERA::m_scr_nX
protectedinherited

Precalc values array used to calc ray for each pixel (constant for the same window size).

Definition at line 345 of file camera.h.

Referenced by CAMERA::rebuildProjection(), CAMERA::Reset(), and CAMERA::updateFrustum().

◆ m_scr_nY

std::vector< float > CAMERA::m_scr_nY
protectedinherited

Definition at line 346 of file camera.h.

Referenced by CAMERA::rebuildProjection(), CAMERA::Reset(), and CAMERA::updateFrustum().

◆ m_up

SFVEC3F CAMERA::m_up
protectedinherited

Definition at line 320 of file camera.h.

Referenced by CAMERA::GetUp(), and CAMERA::updateFrustum().

◆ m_up_nY

std::vector< SFVEC3F > CAMERA::m_up_nY
protectedinherited

Definition at line 353 of file camera.h.

Referenced by CAMERA::MakeRay(), and CAMERA::updateFrustum().

◆ m_viewMatrix

glm::mat4 CAMERA::m_viewMatrix
protectedinherited

◆ m_viewMatrixInverse

glm::mat4 CAMERA::m_viewMatrixInverse
protectedinherited

Definition at line 312 of file camera.h.

Referenced by CAMERA::GetViewMatrix_Inv(), CAMERA::Reset(), and CAMERA::updateFrustum().

◆ m_windowSize

SFVEC2I CAMERA::m_windowSize
protectedinherited

◆ m_zoom

float CAMERA::m_zoom
protectedinherited

◆ m_zoom_t0

float CAMERA::m_zoom_t0
protectedinherited

Definition at line 290 of file camera.h.

Referenced by CAMERA::Interpolate(), CAMERA::Reset(), and CAMERA::SetT0_and_T1_current_T().

◆ m_zoom_t1

float CAMERA::m_zoom_t1
protectedinherited

The documentation for this class was generated from the following files: