KiCad PCB EDA Suite
CCAMERA Class Referenceabstract

Class CCAMERA is a virtual class used to derive CCAMERA objects from. More...

#include <ccamera.h>

Inheritance diagram for CCAMERA:
CTRACK_BALL

Public Member Functions

 CCAMERA (float aRangeScale)
 CCAMERA initialize a camera. More...
 
virtual ~CCAMERA ()
 
const glm::mat4 GetRotationMatrix () const
 Function GetRotationMatrix 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
 
void SetBoardLookAtPos (const SFVEC3F &aBoardPos)
 
virtual void SetLookAtPos (const SFVEC3F &aLookAtPos)=0
 
void SetLookAtPos_T1 (const SFVEC3F &aLookAtPos)
 
const SFVEC3FGetLookAtPos_T1 () const
 
const SFVEC3FGetCameraPos () const
 
virtual void Drag (const wxPoint &aNewMousePosition)=0
 Calculate a new mouse drag position. More...
 
virtual void Pan (const wxPoint &aNewMousePosition)=0
 
virtual void Pan (const SFVEC3F &aDeltaOffsetInc)=0
 
virtual void Pan_T1 (const SFVEC3F &aDeltaOffsetInc)=0
 
virtual void Reset ()
 Reset the camera to initial state. More...
 
virtual void Reset_T1 ()
 
void ResetXYpos ()
 
void ResetXYpos_T1 ()
 
void SetCurMousePosition (const wxPoint &aPosition)
 It updates the current mouse position without make any new recalculations on camera. More...
 
void ToggleProjection ()
 
PROJECTION_TYPE GetProjection ()
 
bool SetCurWindowSize (const wxSize &aSize)
 SetCurWindowSize - update the windows size of the camera. More...
 
void ZoomReset ()
 
bool Zoom (float aFactor)
 
bool Zoom_T1 (float aFactor)
 
float ZoomGet () const
 
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)
 
virtual void SetT0_and_T1_current_T ()
 SetT0_and_T1_current_T - This will set T0 and T1 with the current values. More...
 
virtual void Interpolate (float t)
 Interpolate - It will update the matrix to interpolate between T0 and T1 values. More...
 
void SetInterpolateMode (CAMERA_INTERPOLATION aInterpolateMode)
 
bool ParametersChanged ()
 Function ParametersChanged. More...
 
bool ParametersChangedQuery () const
 Function ParametersChangedQuery. More...
 
void MakeRay (const SFVEC2I &aWindowPos, SFVEC3F &aOutOrigin, SFVEC3F &aOutDirection) const
 MakeRay - Make a ray based on a windows screen position. More...
 
void MakeRay (const SFVEC2F &aWindowPos, SFVEC3F &aOutOrigin, SFVEC3F &aOutDirection) const
 MakeRay - Make a ray based on a windows screen position, it will interpolate based on the float aWindowPos. More...
 
void MakeRayAtCurrrentMousePosition (SFVEC3F &aOutOrigin, SFVEC3F &aOutDirection) const
 MakeRayAtCurrrentMousePosition - Make a ray based on the latest mouse position. More...
 

Protected Member Functions

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

Protected Attributes

float m_range_scale
 m_range_scale - the nominal range expected to be used in the camera. More...
 
float m_zoom
 3D zoom value (Min 0.0 ... More...
 
float m_zoom_t0
 
float m_zoom_t1
 
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
 
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 auxiliar. 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_CCAMERA" )
 Trace mask used to enable or disable the trace output of this class. More...
 

Detailed Description

Class CCAMERA is a virtual class used to derive CCAMERA objects from.

It must be derived to other classes to implement a real camera object.

Definition at line 79 of file ccamera.h.

Constructor & Destructor Documentation

◆ CCAMERA()

CCAMERA::CCAMERA ( float  aRangeScale)
explicit

CCAMERA initialize a camera.

Parameters
aRangeScaleit will be expected that the board will have a -aRangeScale/2 to +aRangeScale/2 it will initialize the initial Z position with aRangeScale

Definition at line 56 of file ccamera.cpp.

57 {
58  wxLogTrace( m_logTrace, wxT( "CCAMERA::CCAMERA" ) );
59 
60  m_range_scale = aRangeScale;
61  m_camera_pos_init = SFVEC3F( 0.0f, 0.0f, -(aRangeScale * 2.0f ) );
63  m_windowSize = SFVEC2I( 0, 0 );
66 
67  Reset();
68 }
virtual void Reset()
Reset the camera to initial state.
Definition: ccamera.cpp:71
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
Definition: ccamera.h:332
SFVEC3F m_board_lookat_pos_init
Default boardlookat position (the board center)
Definition: ccamera.h:298
glm::ivec2 SFVEC2I
Definition: xv3d_types.h:42
float m_range_scale
m_range_scale - the nominal range expected to be used in the camera.
Definition: ccamera.h:254
SFVEC3F m_camera_pos_init
Definition: ccamera.h:290
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
SFVEC2I m_windowSize
The window size that this camera is working.
Definition: ccamera.h:266
CAMERA_INTERPOLATION m_interpolation_mode
Definition: ccamera.h:304
PROJECTION_TYPE m_projectionType
Definition: ccamera.h:279

References BEZIER, m_board_lookat_pos_init, m_camera_pos_init, m_interpolation_mode, m_logTrace, m_projectionType, m_range_scale, m_windowSize, PERSPECTIVE, and Reset().

◆ ~CCAMERA()

virtual CCAMERA::~CCAMERA ( )
inlinevirtual

Definition at line 92 of file ccamera.h.

93  {
94  }

Member Function Documentation

◆ Drag()

virtual void CCAMERA::Drag ( const wxPoint aNewMousePosition)
pure virtual

Calculate a new mouse drag position.

Implemented in CTRACK_BALL.

Referenced by EDA_3D_CANVAS::OnMouseMove().

◆ GetCameraPos()

const SFVEC3F& CCAMERA::GetCameraPos ( ) const
inline

Definition at line 134 of file ccamera.h.

134 { return m_camera_pos; }
SFVEC3F m_camera_pos
Definition: ccamera.h:291

References m_camera_pos.

Referenced by EDA_3D_CANVAS::DisplayStatus().

◆ GetDir()

const SFVEC3F& CCAMERA::GetDir ( ) const
inline

Definition at line 112 of file ccamera.h.

112 { return m_dir; }
SFVEC3F m_dir
Definition: ccamera.h:285

References m_dir.

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

◆ GetFar()

float CCAMERA::GetFar ( ) const
inline

Definition at line 116 of file ccamera.h.

116 { return m_frustum.farD; }
float farD
Definition: ccamera.h:60
FRUSTUM m_frustum
Definition: ccamera.h:281

References FRUSTUM::farD, and m_frustum.

◆ GetFocalLen()

const SFVEC2F& CCAMERA::GetFocalLen ( ) const
inline

Definition at line 114 of file ccamera.h.

114 { return m_focalLen; }
SFVEC2F m_focalLen
Definition: ccamera.h:288

References m_focalLen.

◆ GetLookAtPos_T1()

const SFVEC3F& CCAMERA::GetLookAtPos_T1 ( ) const
inline

Definition at line 132 of file ccamera.h.

132 { return m_lookat_pos_t1; }
SFVEC3F m_lookat_pos_t1
Definition: ccamera.h:297

References m_lookat_pos_t1.

Referenced by EDA_3D_CANVAS::render_pivot().

◆ GetNear()

float CCAMERA::GetNear ( ) const
inline

Definition at line 115 of file ccamera.h.

115 { return m_frustum.nearD; }
float nearD
Definition: ccamera.h:60
FRUSTUM m_frustum
Definition: ccamera.h:281

References m_frustum, and FRUSTUM::nearD.

◆ GetPos()

const SFVEC3F& CCAMERA::GetPos ( ) const
inline

Definition at line 113 of file ccamera.h.

113 { return m_pos; }
SFVEC3F m_pos
Definition: ccamera.h:286

References m_pos.

Referenced by C3D_RENDER_OGL_LEGACY::Redraw(), and C3D_RENDER_OGL_LEGACY::render_solder_mask_layer().

◆ GetProjection()

PROJECTION_TYPE CCAMERA::GetProjection ( )
inline

Definition at line 164 of file ccamera.h.

164 { return m_projectionType; }
PROJECTION_TYPE m_projectionType
Definition: ccamera.h:279

References m_projectionType.

Referenced by EDA_3D_VIEWER::SyncToolbars().

◆ GetProjectionMatrix()

const glm::mat4 & CCAMERA::GetProjectionMatrix ( ) const

Definition at line 389 of file ccamera.cpp.

390 {
391  return m_projectionMatrix;
392 }
glm::mat4 m_projectionMatrix
Definition: ccamera.h:277

References m_projectionMatrix.

Referenced by C3D_MODEL_VIEWER::OnPaint(), C3D_RENDER_OGL_LEGACY::Redraw(), and EDA_3D_CANVAS::render_pivot().

◆ GetProjectionMatrixInv()

const glm::mat4 & CCAMERA::GetProjectionMatrixInv ( ) const

Definition at line 395 of file ccamera.cpp.

396 {
397  return m_projectionMatrixInv;
398 }
glm::mat4 m_projectionMatrixInv
Definition: ccamera.h:278

References m_projectionMatrixInv.

◆ GetRight()

const SFVEC3F& CCAMERA::GetRight ( ) const
inline

Definition at line 110 of file ccamera.h.

110 { return m_right; }
SFVEC3F m_right
Definition: ccamera.h:283

References m_right.

◆ GetRotationMatrix()

const glm::mat4 CCAMERA::GetRotationMatrix ( ) const

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

Returns
the rotation matrix of the camera

Definition at line 158 of file ccamera.cpp.

159 {
161 }
glm::mat4 m_rotationMatrix
Definition: ccamera.h:273
glm::mat4 m_rotationMatrixAux
Definition: ccamera.h:274

References m_rotationMatrix, and m_rotationMatrixAux.

Referenced by C3D_MODEL_VIEWER::OnPaint(), and C3D_RENDER_OGL_LEGACY::render_3D_arrows().

◆ GetUp()

const SFVEC3F& CCAMERA::GetUp ( ) const
inline

Definition at line 111 of file ccamera.h.

111 { return m_up; }
SFVEC3F m_up
Definition: ccamera.h:284

References m_up.

◆ GetViewMatrix()

const glm::mat4 & CCAMERA::GetViewMatrix ( ) const

Definition at line 419 of file ccamera.cpp.

420 {
421  return m_viewMatrix;
422 }
glm::mat4 m_viewMatrix
Definition: ccamera.h:275

References m_viewMatrix.

Referenced by C3D_MODEL_VIEWER::OnPaint(), C3D_RENDER_OGL_LEGACY::Redraw(), and EDA_3D_CANVAS::render_pivot().

◆ GetViewMatrix_Inv()

const glm::mat4 & CCAMERA::GetViewMatrix_Inv ( ) const

Definition at line 425 of file ccamera.cpp.

426 {
427  return m_viewMatrixInverse;
428 }
glm::mat4 m_viewMatrixInverse
Definition: ccamera.h:276

References m_viewMatrixInverse.

◆ Interpolate()

void CCAMERA::Interpolate ( float  t)
virtual

Interpolate - 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 in CTRACK_BALL.

Definition at line 569 of file ccamera.cpp.

570 {
571  wxASSERT( t >= 0.0f );
572 
573  const float t0 = 1.0f - t;
574 
578  m_zoom = m_zoom_t0 * t0 + m_zoom_t1 * t;
579 
580  m_parametersChanged = true;
581 
584 }
bool m_parametersChanged
Set to true if any of the parameters in the camera was changed.
Definition: ccamera.h:324
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliar.
Definition: ccamera.h:300
SFVEC3F m_camera_pos_t1
Definition: ccamera.h:293
float m_zoom_t0
Definition: ccamera.h:260
SFVEC3F m_lookat_pos_t1
Definition: ccamera.h:297
SFVEC3F m_lookat_pos_t0
Definition: ccamera.h:296
float m_zoom
3D zoom value (Min 0.0 ...
Definition: ccamera.h:259
SFVEC3F m_rotate_aux_t1
Definition: ccamera.h:302
void updateRotationMatrix()
Definition: ccamera.cpp:134
SFVEC3F m_camera_pos
Definition: ccamera.h:291
SFVEC3F m_camera_pos_t0
Definition: ccamera.h:292
void rebuildProjection()
Definition: ccamera.cpp:164
float m_zoom_t1
Definition: ccamera.h:261
SFVEC3F m_rotate_aux_t0
Definition: ccamera.h:301
SFVEC3F m_lookat_pos
Definition: ccamera.h:295

References m_camera_pos, m_camera_pos_t0, m_camera_pos_t1, m_lookat_pos, m_lookat_pos_t0, m_lookat_pos_t1, m_parametersChanged, m_rotate_aux, m_rotate_aux_t0, m_rotate_aux_t1, m_zoom, m_zoom_t0, m_zoom_t1, rebuildProjection(), and updateRotationMatrix().

Referenced by EDA_3D_CANVAS::DoRePaint(), CTRACK_BALL::Interpolate(), and EDA_3D_CANVAS::request_start_moving_camera().

◆ MakeRay() [1/2]

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

MakeRay - 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 323 of file ccamera.cpp.

326 {
327  wxASSERT( aWindowPos.x < m_windowSize.x );
328  wxASSERT( aWindowPos.y < m_windowSize.y );
329 
330  const SFVEC3F up_plus_right = m_up_nY[aWindowPos.y] +
331  m_right_nX[aWindowPos.x];
332 
333  switch( m_projectionType )
334  {
335  default:
337  aOutOrigin = up_plus_right + m_frustum.nc;
338  aOutDirection = glm::normalize( aOutOrigin - m_pos );
339  break;
340 
342  aOutOrigin = up_plus_right * 0.5f + m_frustum.nc;
343  aOutDirection = -m_dir + SFVEC3F( FLT_EPSILON );
344  break;
345  }
346 }
SFVEC3F m_dir
Definition: ccamera.h:285
std::vector< SFVEC3F > m_up_nY
Definition: ccamera.h:318
SFVEC3F m_pos
Definition: ccamera.h:286
FRUSTUM m_frustum
Definition: ccamera.h:281
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: ccamera.h:317
SFVEC3F nc
Definition: ccamera.h:50
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
SFVEC2I m_windowSize
The window size that this camera is working.
Definition: ccamera.h:266
PROJECTION_TYPE m_projectionType
Definition: ccamera.h:279

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

Referenced by MakeRayAtCurrrentMousePosition(), RAYPACKET::RAYPACKET(), RAYPACKET_InitRays(), and RAYPACKET_InitRays_with2DDisplacement().

◆ MakeRay() [2/2]

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

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

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

Definition at line 349 of file ccamera.cpp.

350 {
351  wxASSERT( aWindowPos.x < (float)m_windowSize.x );
352  wxASSERT( aWindowPos.y < (float)m_windowSize.y );
353 
354  const SFVEC2F floorWinPos_f = glm::floor( aWindowPos );
355  const SFVEC2I floorWinPos_i = (SFVEC2I)floorWinPos_f;
356  const SFVEC2F relativeWinPos = aWindowPos - floorWinPos_f;
357 
358  // Note: size of vectors m_up and m_right are m_windowSize + 1
359  const SFVEC3F up_plus_right = m_up_nY[floorWinPos_i.y] * (1.0f - relativeWinPos.y) +
360  m_up_nY[floorWinPos_i.y + 1] * relativeWinPos.y +
361  m_right_nX[floorWinPos_i.x] * (1.0f - relativeWinPos.x) +
362  m_right_nX[floorWinPos_i.x + 1] * relativeWinPos.x;
363 
364  switch( m_projectionType )
365  {
366  default:
368  aOutOrigin = up_plus_right + m_frustum.nc;
369  aOutDirection = glm::normalize( aOutOrigin - m_pos );
370  break;
371 
373  aOutOrigin = up_plus_right * 0.5f + m_frustum.nc;
374  aOutDirection = -m_dir + SFVEC3F( FLT_EPSILON );
375  break;
376  }
377 }
SFVEC3F m_dir
Definition: ccamera.h:285
std::vector< SFVEC3F > m_up_nY
Definition: ccamera.h:318
glm::ivec2 SFVEC2I
Definition: xv3d_types.h:42
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
SFVEC3F m_pos
Definition: ccamera.h:286
FRUSTUM m_frustum
Definition: ccamera.h:281
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: ccamera.h:317
SFVEC3F nc
Definition: ccamera.h:50
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
SFVEC2I m_windowSize
The window size that this camera is working.
Definition: ccamera.h:266
PROJECTION_TYPE m_projectionType
Definition: ccamera.h:279

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

◆ MakeRayAtCurrrentMousePosition()

void CCAMERA::MakeRayAtCurrrentMousePosition ( SFVEC3F aOutOrigin,
SFVEC3F aOutDirection 
) const

MakeRayAtCurrrentMousePosition - Make a ray based on the latest mouse position.

Parameters
aOutOriginout origin position of the ray
aOutDirectionout direction

Definition at line 380 of file ccamera.cpp.

382 {
385  aOutOrigin, aOutDirection );
386 }
glm::ivec2 SFVEC2I
Definition: xv3d_types.h:42
wxPoint m_lastPosition
The last mouse position in the screen.
Definition: ccamera.h:271
SFVEC2I m_windowSize
The window size that this camera is working.
Definition: ccamera.h:266
void MakeRay(const SFVEC2I &aWindowPos, SFVEC3F &aOutOrigin, SFVEC3F &aOutDirection) const
MakeRay - Make a ray based on a windows screen position.
Definition: ccamera.cpp:323

References m_lastPosition, m_windowSize, MakeRay(), wxPoint::x, and wxPoint::y.

Referenced by EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position().

◆ Pan() [1/2]

virtual void CCAMERA::Pan ( const wxPoint aNewMousePosition)
pure virtual

◆ Pan() [2/2]

virtual void CCAMERA::Pan ( const SFVEC3F aDeltaOffsetInc)
pure virtual

Implemented in CTRACK_BALL.

◆ Pan_T1()

virtual void CCAMERA::Pan_T1 ( const SFVEC3F aDeltaOffsetInc)
pure virtual

Implemented in CTRACK_BALL.

Referenced by EDA_3D_CANVAS::SetView3D().

◆ ParametersChanged()

bool CCAMERA::ParametersChanged ( )

Function ParametersChanged.

Returns
true if some of the parameters in camera was changed, it will reset the flag

Definition at line 587 of file ccamera.cpp.

588 {
589  const bool parametersChanged = m_parametersChanged;
590 
591  m_parametersChanged = false;
592 
593  return parametersChanged;
594 }
bool m_parametersChanged
Set to true if any of the parameters in the camera was changed.
Definition: ccamera.h:324

References m_parametersChanged.

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

◆ ParametersChangedQuery()

bool CCAMERA::ParametersChangedQuery ( ) const
inline

Function ParametersChangedQuery.

Returns
true if some of the parameters in camera was changed, it will NOT reset the flag

Definition at line 217 of file ccamera.h.

217 { return m_parametersChanged; }
bool m_parametersChanged
Set to true if any of the parameters in the camera was changed.
Definition: ccamera.h:324

References m_parametersChanged.

◆ rebuildProjection()

void CCAMERA::rebuildProjection ( )
protected

Definition at line 164 of file ccamera.cpp.

165 {
166  if( (m_windowSize.x == 0) ||
167  (m_windowSize.y == 0) )
168  return;
169 
170  m_frustum.ratio = (float) m_windowSize.x / (float)m_windowSize.y;
171 
172  // Consider that we can render double the length multiplied by the 2/sqrt(2)
173  //
174  m_frustum.farD = glm::length( m_camera_pos_init ) * 2.0f * ( 2.0f * sqrtf( 2.0f ) );
175 
176  switch( m_projectionType )
177  {
178  default:
180 
181  m_frustum.nearD = 0.10f;
182 
183  // Ratio width / height of the window display
184  m_frustum.angle = 45.0f * m_zoom;
185 
186 
187  m_projectionMatrix = glm::perspective( glm::radians( m_frustum.angle ),
190  m_frustum.farD );
191 
192  m_projectionMatrixInv = glm::inverse( m_projectionMatrix );
193 
194  m_frustum.tang = glm::tan( glm::radians( m_frustum.angle ) * 0.5f );
195 
196  m_focalLen.x = ( (float)m_windowSize.y / (float)m_windowSize.x ) / m_frustum.tang;
197  m_focalLen.y = 1.0f / m_frustum.tang;
198 
203  break;
204 
206 
207  m_frustum.nearD = -m_frustum.farD; // Use a symmetrical clip plane for ortho projection
208 
209  // This formula was found by trial and error
210  const float orthoReductionFactor = glm::length( m_camera_pos_init ) *
211  m_zoom * m_zoom * 0.5f;
212 
213  // Initialize Projection Matrix for Ortographic View
214  m_projectionMatrix = glm::ortho( -m_frustum.ratio * orthoReductionFactor,
215  m_frustum.ratio * orthoReductionFactor,
216  -orthoReductionFactor,
217  orthoReductionFactor,
219 
220  m_projectionMatrixInv = glm::inverse( m_projectionMatrix );
221 
222  m_frustum.nw = orthoReductionFactor * 2.0f * m_frustum.ratio;
223  m_frustum.nh = orthoReductionFactor * 2.0f;
226 
227  break;
228  }
229 
230  if ( (m_windowSize.x > 0) &&
231  (m_windowSize.y > 0) )
232  {
233  m_scr_nX.resize( m_windowSize.x + 1 );
234  m_scr_nY.resize( m_windowSize.y + 1 );
235 
236  // Precalc X values for camera -> ray generation
237  for( unsigned int x = 0; x < (unsigned int)m_windowSize.x + 1; ++x )
238  {
239  // Converts 0.0 .. 1.0
240  const float xNormalizedDeviceCoordinates = ( ( (float)x + 0.5f ) /
241  (m_windowSize.x - 0.0f) );
242 
243  // Converts -1.0 .. 1.0
244  m_scr_nX[x] = 2.0f * xNormalizedDeviceCoordinates - 1.0f;
245  }
246 
247  // Precalc Y values for camera -> ray generation
248  for( unsigned int y = 0; y < (unsigned int)m_windowSize.y + 1 ; ++y )
249  {
250  // Converts 0.0 .. 1.0
251  const float yNormalizedDeviceCoordinates = ( ( (float)y + 0.5f ) /
252  (m_windowSize.y - 0.0f) );
253 
254  // Converts -1.0 .. 1.0
255  m_scr_nY[y] = 2.0f * yNormalizedDeviceCoordinates - 1.0f;
256  }
257 
258  updateFrustum();
259  }
260 }
float farD
Definition: ccamera.h:60
void updateFrustum()
Definition: ccamera.cpp:263
float nearD
Definition: ccamera.h:60
float nw
Definition: ccamera.h:61
std::vector< float > m_scr_nY
Definition: ccamera.h:311
std::vector< float > m_scr_nX
Precalc values array used to calc ray for each pixel (constant for the same window size)
Definition: ccamera.h:310
float tang
Definition: ccamera.h:60
float fw
Definition: ccamera.h:61
SFVEC2F m_focalLen
Definition: ccamera.h:288
float angle
Definition: ccamera.h:60
FRUSTUM m_frustum
Definition: ccamera.h:281
glm::mat4 m_projectionMatrix
Definition: ccamera.h:277
float m_zoom
3D zoom value (Min 0.0 ...
Definition: ccamera.h:259
SFVEC3F m_camera_pos_init
Definition: ccamera.h:290
SFVEC2I m_windowSize
The window size that this camera is working.
Definition: ccamera.h:266
float fh
Definition: ccamera.h:61
float nh
Definition: ccamera.h:61
float ratio
Definition: ccamera.h:60
glm::mat4 m_projectionMatrixInv
Definition: ccamera.h:278
PROJECTION_TYPE m_projectionType
Definition: ccamera.h:279

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

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

◆ Reset()

void CCAMERA::Reset ( )
virtual

Reset the camera to initial state.

Reimplemented in CTRACK_BALL.

Definition at line 71 of file ccamera.cpp.

72 {
73  m_parametersChanged = true;
74  m_projectionMatrix = glm::mat4( 1.0f );
75  m_projectionMatrixInv = glm::mat4( 1.0f );
76  m_rotationMatrix = glm::mat4( 1.0f );
77  m_rotationMatrixAux = glm::mat4( 1.0f );
78  m_lastPosition = wxPoint( 0, 0 );
79 
80  m_zoom = 1.0f;
81  m_zoom_t0 = 1.0f;
82  m_zoom_t1 = 1.0f;
89 
90  m_rotate_aux = SFVEC3F( 0.0f );
91  m_rotate_aux_t0 = SFVEC3F( 0.0f );
92  m_rotate_aux_t1 = SFVEC3F( 0.0f );
93 
96  m_viewMatrixInverse = glm::inverse( m_viewMatrix );
97  m_scr_nX.clear();
98  m_scr_nY.clear();
100 }
bool m_parametersChanged
Set to true if any of the parameters in the camera was changed.
Definition: ccamera.h:324
SFVEC3F m_board_lookat_pos_init
Default boardlookat position (the board center)
Definition: ccamera.h:298
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliar.
Definition: ccamera.h:300
glm::mat4 m_viewMatrixInverse
Definition: ccamera.h:276
std::vector< float > m_scr_nY
Definition: ccamera.h:311
std::vector< float > m_scr_nX
Precalc values array used to calc ray for each pixel (constant for the same window size)
Definition: ccamera.h:310
void updateViewMatrix()
Definition: ccamera.cpp:126
wxPoint m_lastPosition
The last mouse position in the screen.
Definition: ccamera.h:271
SFVEC3F m_camera_pos_t1
Definition: ccamera.h:293
float m_zoom_t0
Definition: ccamera.h:260
SFVEC3F m_lookat_pos_t1
Definition: ccamera.h:297
SFVEC3F m_lookat_pos_t0
Definition: ccamera.h:296
glm::mat4 m_rotationMatrix
Definition: ccamera.h:273
glm::mat4 m_projectionMatrix
Definition: ccamera.h:277
float m_zoom
3D zoom value (Min 0.0 ...
Definition: ccamera.h:259
SFVEC3F m_rotate_aux_t1
Definition: ccamera.h:302
void updateRotationMatrix()
Definition: ccamera.cpp:134
SFVEC3F m_camera_pos_init
Definition: ccamera.h:290
SFVEC3F m_camera_pos
Definition: ccamera.h:291
SFVEC3F m_camera_pos_t0
Definition: ccamera.h:292
void rebuildProjection()
Definition: ccamera.cpp:164
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
float m_zoom_t1
Definition: ccamera.h:261
SFVEC3F m_rotate_aux_t0
Definition: ccamera.h:301
glm::mat4 m_rotationMatrixAux
Definition: ccamera.h:274
glm::mat4 m_viewMatrix
Definition: ccamera.h:275
glm::mat4 m_projectionMatrixInv
Definition: ccamera.h:278
SFVEC3F m_lookat_pos
Definition: ccamera.h:295

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

Referenced by CCAMERA(), and CTRACK_BALL::Reset().

◆ Reset_T1()

void CCAMERA::Reset_T1 ( )
virtual

Reimplemented in CTRACK_BALL.

Definition at line 103 of file ccamera.cpp.

104 {
106  m_zoom_t1 = 1.0f;
107  m_rotate_aux_t1 = SFVEC3F( 0.0f );
109 
110 
111  // Since 0 = 2pi, we want to reset the angle to be the closest
112  // one to where we currently are. That ensures that we rotate
113  // the board around the smallest distance getting there.
114  if( m_rotate_aux_t0.x > M_PI )
115  m_rotate_aux_t1.x = 2*M_PI;
116 
117  if( m_rotate_aux_t0.y > M_PI )
118  m_rotate_aux_t1.y = 2*M_PI;
119 
120  if( m_rotate_aux_t0.z > M_PI )
121  m_rotate_aux_t1.z = 2*M_PI;
122 
123 }
SFVEC3F m_board_lookat_pos_init
Default boardlookat position (the board center)
Definition: ccamera.h:298
SFVEC3F m_camera_pos_t1
Definition: ccamera.h:293
SFVEC3F m_lookat_pos_t1
Definition: ccamera.h:297
SFVEC3F m_rotate_aux_t1
Definition: ccamera.h:302
SFVEC3F m_camera_pos_init
Definition: ccamera.h:290
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
float m_zoom_t1
Definition: ccamera.h:261
SFVEC3F m_rotate_aux_t0
Definition: ccamera.h:301

References m_board_lookat_pos_init, m_camera_pos_init, m_camera_pos_t1, m_lookat_pos_t1, m_rotate_aux_t0, m_rotate_aux_t1, and m_zoom_t1.

Referenced by CTRACK_BALL::Reset_T1(), and EDA_3D_CANVAS::SetView3D().

◆ ResetXYpos()

void CCAMERA::ResetXYpos ( )

Definition at line 401 of file ccamera.cpp.

402 {
403  m_parametersChanged = true;
404  m_camera_pos.x = 0.0f;
405  m_camera_pos.y = 0.0f;
406 
408  updateFrustum();
409 }
bool m_parametersChanged
Set to true if any of the parameters in the camera was changed.
Definition: ccamera.h:324
void updateFrustum()
Definition: ccamera.cpp:263
void updateViewMatrix()
Definition: ccamera.cpp:126
SFVEC3F m_camera_pos
Definition: ccamera.h:291

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

◆ ResetXYpos_T1()

void CCAMERA::ResetXYpos_T1 ( )

Definition at line 412 of file ccamera.cpp.

413 {
414  m_camera_pos_t1.x = 0.0f;
415  m_camera_pos_t1.y = 0.0f;
416 }
SFVEC3F m_camera_pos_t1
Definition: ccamera.h:293

References m_camera_pos_t1.

Referenced by EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position().

◆ RotateX()

void CCAMERA::RotateX ( float  aAngleInRadians)

Definition at line 516 of file ccamera.cpp.

517 {
518  m_rotate_aux.x += aAngleInRadians;
520 }
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliar.
Definition: ccamera.h:300
void updateRotationMatrix()
Definition: ccamera.cpp:134

References m_rotate_aux, and updateRotationMatrix().

Referenced by EDA_3D_CONTROLLER::RotateView().

◆ RotateX_T1()

void CCAMERA::RotateX_T1 ( float  aAngleInRadians)

Definition at line 537 of file ccamera.cpp.

538 {
539  m_rotate_aux_t1.x += aAngleInRadians;
540 }
SFVEC3F m_rotate_aux_t1
Definition: ccamera.h:302

References m_rotate_aux_t1.

Referenced by EDA_3D_CANVAS::SetView3D().

◆ RotateY()

void CCAMERA::RotateY ( float  aAngleInRadians)

Definition at line 523 of file ccamera.cpp.

524 {
525  m_rotate_aux.y += aAngleInRadians;
527 }
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliar.
Definition: ccamera.h:300
void updateRotationMatrix()
Definition: ccamera.cpp:134

References m_rotate_aux, and updateRotationMatrix().

Referenced by EDA_3D_CONTROLLER::RotateView().

◆ RotateY_T1()

void CCAMERA::RotateY_T1 ( float  aAngleInRadians)

Definition at line 543 of file ccamera.cpp.

544 {
545  m_rotate_aux_t1.y += aAngleInRadians;
546 }
SFVEC3F m_rotate_aux_t1
Definition: ccamera.h:302

References m_rotate_aux_t1.

Referenced by EDA_3D_CANVAS::SetView3D().

◆ RotateZ()

void CCAMERA::RotateZ ( float  aAngleInRadians)

Definition at line 530 of file ccamera.cpp.

531 {
532  m_rotate_aux.z += aAngleInRadians;
534 }
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliar.
Definition: ccamera.h:300
void updateRotationMatrix()
Definition: ccamera.cpp:134

References m_rotate_aux, and updateRotationMatrix().

Referenced by EDA_3D_CONTROLLER::RotateView().

◆ RotateZ_T1()

void CCAMERA::RotateZ_T1 ( float  aAngleInRadians)

Definition at line 549 of file ccamera.cpp.

550 {
551  m_rotate_aux_t1.z += aAngleInRadians;
552 }
SFVEC3F m_rotate_aux_t1
Definition: ccamera.h:302

References m_rotate_aux_t1.

Referenced by EDA_3D_CANVAS::SetView3D().

◆ SetBoardLookAtPos()

void CCAMERA::SetBoardLookAtPos ( const SFVEC3F aBoardPos)
inline

Definition at line 118 of file ccamera.h.

118  {
119  if( m_board_lookat_pos_init != aBoardPos )
120  {
121  m_board_lookat_pos_init = aBoardPos;
122  SetLookAtPos( aBoardPos );
123  }
124  }
SFVEC3F m_board_lookat_pos_init
Default boardlookat position (the board center)
Definition: ccamera.h:298
virtual void SetLookAtPos(const SFVEC3F &aLookAtPos)=0

References m_board_lookat_pos_init, and SetLookAtPos().

Referenced by C3D_RENDER_OGL_LEGACY::reload(), and C3D_RENDER_RAYTRACING::reload().

◆ SetCurMousePosition()

void CCAMERA::SetCurMousePosition ( const wxPoint aPosition)

It updates the current mouse position without make any new recalculations on camera.

Definition at line 431 of file ccamera.cpp.

432 {
433  m_lastPosition = aNewMousePosition;
434 }
wxPoint m_lastPosition
The last mouse position in the screen.
Definition: ccamera.h:271

References m_lastPosition.

Referenced by C3D_MODEL_VIEWER::OnMouseMove(), EDA_3D_CANVAS::OnMouseMove(), C3D_MODEL_VIEWER::OnMouseWheel(), and EDA_3D_CANVAS::OnMouseWheel().

◆ SetCurWindowSize()

bool CCAMERA::SetCurWindowSize ( const wxSize &  aSize)

SetCurWindowSize - update the windows size of the camera.

Parameters
aSize
Returns
true if the windows size changed since last time

Definition at line 448 of file ccamera.cpp.

449 {
450  const SFVEC2I newSize = SFVEC2I( aSize.x, aSize.y );
451 
452  if( m_windowSize != newSize )
453  {
454  m_windowSize = newSize;
456 
457  return true;
458  }
459 
460  return false;
461 }
glm::ivec2 SFVEC2I
Definition: xv3d_types.h:42
void rebuildProjection()
Definition: ccamera.cpp:164
SFVEC2I m_windowSize
The window size that this camera is working.
Definition: ccamera.h:266

References m_windowSize, and rebuildProjection().

Referenced by EDA_3D_CANVAS::DoRePaint(), C3D_MODEL_VIEWER::OnMouseMove(), EDA_3D_CANVAS::OnMouseMove(), and C3D_MODEL_VIEWER::OnPaint().

◆ SetInterpolateMode()

void CCAMERA::SetInterpolateMode ( CAMERA_INTERPOLATION  aInterpolateMode)
inline

Definition at line 200 of file ccamera.h.

201  {
202  m_interpolation_mode = aInterpolateMode;
203  }
CAMERA_INTERPOLATION m_interpolation_mode
Definition: ccamera.h:304

References m_interpolation_mode.

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

◆ SetLookAtPos()

virtual void CCAMERA::SetLookAtPos ( const SFVEC3F aLookAtPos)
pure virtual

Implemented in CTRACK_BALL.

Referenced by SetBoardLookAtPos().

◆ SetLookAtPos_T1()

void CCAMERA::SetLookAtPos_T1 ( const SFVEC3F aLookAtPos)
inline

Definition at line 128 of file ccamera.h.

128  {
129  m_lookat_pos_t1 = aLookAtPos;
130  }
SFVEC3F m_lookat_pos_t1
Definition: ccamera.h:297

References m_lookat_pos_t1.

Referenced by EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position().

◆ SetT0_and_T1_current_T()

void CCAMERA::SetT0_and_T1_current_T ( )
virtual

SetT0_and_T1_current_T - This will set T0 and T1 with the current values.

Reimplemented in CTRACK_BALL.

Definition at line 555 of file ccamera.cpp.

556 {
560  m_zoom_t0 = m_zoom;
561 
565  m_zoom_t1 = m_zoom;
566 }
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliar.
Definition: ccamera.h:300
SFVEC3F m_camera_pos_t1
Definition: ccamera.h:293
float m_zoom_t0
Definition: ccamera.h:260
SFVEC3F m_lookat_pos_t1
Definition: ccamera.h:297
SFVEC3F m_lookat_pos_t0
Definition: ccamera.h:296
float m_zoom
3D zoom value (Min 0.0 ...
Definition: ccamera.h:259
SFVEC3F m_rotate_aux_t1
Definition: ccamera.h:302
SFVEC3F m_camera_pos
Definition: ccamera.h:291
SFVEC3F m_camera_pos_t0
Definition: ccamera.h:292
float m_zoom_t1
Definition: ccamera.h:261
SFVEC3F m_rotate_aux_t0
Definition: ccamera.h:301
SFVEC3F m_lookat_pos
Definition: ccamera.h:295

References m_camera_pos, m_camera_pos_t0, m_camera_pos_t1, m_lookat_pos, m_lookat_pos_t0, m_lookat_pos_t1, m_rotate_aux, m_rotate_aux_t0, m_rotate_aux_t1, m_zoom, m_zoom_t0, and m_zoom_t1.

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

◆ ToggleProjection()

void CCAMERA::ToggleProjection ( )

◆ updateFrustum()

void CCAMERA::updateFrustum ( )
protected

Definition at line 263 of file ccamera.cpp.

264 {
265  // Update matrix and vectors
266  m_viewMatrixInverse = glm::inverse( m_viewMatrix );
267 
268  m_right = glm::normalize( SFVEC3F( m_viewMatrixInverse *
269  glm::vec4( SFVEC3F( 1.0, 0.0, 0.0 ), 0.0 ) ) );
270 
271  m_up = glm::normalize( SFVEC3F( m_viewMatrixInverse *
272  glm::vec4( SFVEC3F( 0.0, 1.0, 0.0 ), 0.0 ) ) );
273 
274  m_dir = glm::normalize( SFVEC3F( m_viewMatrixInverse *
275  glm::vec4( SFVEC3F( 0.0, 0.0, 1.0 ), 0.0 ) ) );
276 
277  m_pos = SFVEC3F( m_viewMatrixInverse * glm::vec4( SFVEC3F( 0.0, 0.0, 0.0 ), 1.0 ) );
278 
279 
280  /*
281  * Frustum is a implementation based on a tutorial by
282  * http://www.lighthouse3d.com/tutorials/view-frustum-culling/
283  */
284 
285  // compute the centers of the near and far planes
288 
289  // compute the 4 corners of the frustum on the near plane
294 
295  // compute the 4 corners of the frustum on the far plane
300 
301  if ( (m_windowSize.x > 0) &&
302  (m_windowSize.y > 0) )
303  {
304  // Reserve size for precalc values
305  m_right_nX.resize( m_windowSize.x + 1 );
306  m_up_nY.resize( m_windowSize.y + 1 );
307 
308  // Precalc X values for camera -> ray generation
309  const SFVEC3F right_nw = m_right * m_frustum.nw;
310 
311  for( unsigned int x = 0; x < ((unsigned int)m_windowSize.x + 1); ++x )
312  m_right_nX[x] = right_nw * m_scr_nX[x];
313 
314  // Precalc Y values for camera -> ray generation
315  const SFVEC3F up_nh = m_up * m_frustum.nh;
316 
317  for( unsigned int y = 0; y < ((unsigned int)m_windowSize.y + 1); ++y )
318  m_up_nY[y] = up_nh * m_scr_nY[y];
319  }
320 }
SFVEC3F fc
Definition: ccamera.h:51
SFVEC3F m_dir
Definition: ccamera.h:285
SFVEC3F ftl
Far Top Left.
Definition: ccamera.h:56
SFVEC3F ntl
Near Top Left.
Definition: ccamera.h:52
float farD
Definition: ccamera.h:60
std::vector< SFVEC3F > m_up_nY
Definition: ccamera.h:318
float nearD
Definition: ccamera.h:60
glm::mat4 m_viewMatrixInverse
Definition: ccamera.h:276
float nw
Definition: ccamera.h:61
std::vector< float > m_scr_nY
Definition: ccamera.h:311
std::vector< float > m_scr_nX
Precalc values array used to calc ray for each pixel (constant for the same window size)
Definition: ccamera.h:310
SFVEC3F fbr
Far Bottom Right.
Definition: ccamera.h:59
float fw
Definition: ccamera.h:61
SFVEC3F nbr
Near Bottom Right.
Definition: ccamera.h:55
SFVEC3F fbl
Far Bottom Left.
Definition: ccamera.h:58
SFVEC3F m_right
Definition: ccamera.h:283
SFVEC3F m_pos
Definition: ccamera.h:286
SFVEC3F m_up
Definition: ccamera.h:284
SFVEC3F nbl
Near Bottom Left.
Definition: ccamera.h:54
SFVEC3F ntr
Near Top Right.
Definition: ccamera.h:53
FRUSTUM m_frustum
Definition: ccamera.h:281
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: ccamera.h:317
SFVEC3F nc
Definition: ccamera.h:50
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
SFVEC2I m_windowSize
The window size that this camera is working.
Definition: ccamera.h:266
SFVEC3F ftr
Far Top Right.
Definition: ccamera.h:57
float fh
Definition: ccamera.h:61
float nh
Definition: ccamera.h:61
glm::mat4 m_viewMatrix
Definition: ccamera.h:275

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

Referenced by CTRACK_BALL::Drag(), CTRACK_BALL::Pan(), rebuildProjection(), ResetXYpos(), CTRACK_BALL::SetLookAtPos(), and updateRotationMatrix().

◆ updateRotationMatrix()

void CCAMERA::updateRotationMatrix ( )
protected

Definition at line 134 of file ccamera.cpp.

135 {
136  m_rotationMatrixAux = glm::rotate( glm::mat4( 1.0f ),
137  m_rotate_aux.x,
138  SFVEC3F( 1.0f, 0.0f, 0.0f ) );
140 
142  m_rotate_aux.y,
143  SFVEC3F( 0.0f, 1.0f, 0.0f ) );
145 
147  m_rotate_aux.z,
148  SFVEC3F( 0.0f, 0.0f, 1.0f ) );
150 
151  m_parametersChanged = true;
152 
154  updateFrustum();
155 }
bool m_parametersChanged
Set to true if any of the parameters in the camera was changed.
Definition: ccamera.h:324
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliar.
Definition: ccamera.h:300
void updateFrustum()
Definition: ccamera.cpp:263
void updateViewMatrix()
Definition: ccamera.cpp:126
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
void normalise2PI(float &aAngle)
Definition: ccamera.cpp:35
glm::mat4 m_rotationMatrixAux
Definition: ccamera.h:274

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

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

◆ updateViewMatrix()

void CCAMERA::updateViewMatrix ( )
protected

Definition at line 126 of file ccamera.cpp.

127 {
128  m_viewMatrix = glm::translate( glm::mat4( 1.0f ), m_camera_pos ) *
130  glm::translate( glm::mat4( 1.0f ), -m_lookat_pos );
131 }
glm::mat4 m_rotationMatrix
Definition: ccamera.h:273
SFVEC3F m_camera_pos
Definition: ccamera.h:291
glm::mat4 m_rotationMatrixAux
Definition: ccamera.h:274
glm::mat4 m_viewMatrix
Definition: ccamera.h:275
SFVEC3F m_lookat_pos
Definition: ccamera.h:295

References m_camera_pos, m_lookat_pos, m_rotationMatrix, m_rotationMatrixAux, and m_viewMatrix.

Referenced by CTRACK_BALL::Drag(), CTRACK_BALL::Pan(), Reset(), ResetXYpos(), CTRACK_BALL::SetLookAtPos(), updateRotationMatrix(), Zoom(), and ZoomReset().

◆ Zoom()

bool CCAMERA::Zoom ( float  aFactor)

Definition at line 474 of file ccamera.cpp.

475 {
476  if ( ( m_zoom == MIN_ZOOM && aFactor > 1 ) || ( m_zoom == MAX_ZOOM && aFactor < 1 ) || aFactor == 1 )
477  return false;
478 
479  m_zoom /= aFactor;
480  if( m_zoom <= MIN_ZOOM )
481  m_zoom = MIN_ZOOM;
482  if( m_zoom >= MAX_ZOOM )
483  m_zoom = MAX_ZOOM;
484 
486 
489 
490  return true;
491 }
#define MAX_ZOOM
Definition: ccamera.cpp:54
void updateViewMatrix()
Definition: ccamera.cpp:126
float m_zoom
3D zoom value (Min 0.0 ...
Definition: ccamera.h:259
SFVEC3F m_camera_pos_init
Definition: ccamera.h:290
SFVEC3F m_camera_pos
Definition: ccamera.h:291
void rebuildProjection()
Definition: ccamera.cpp:164
#define MIN_ZOOM
Definition: ccamera.cpp:53

References m_camera_pos, m_camera_pos_init, m_zoom, MAX_ZOOM, MIN_ZOOM, rebuildProjection(), and updateViewMatrix().

Referenced by C3D_MODEL_VIEWER::OnMouseWheel(), and EDA_3D_CANVAS::OnMouseWheel().

◆ Zoom_T1()

bool CCAMERA::Zoom_T1 ( float  aFactor)

Definition at line 493 of file ccamera.cpp.

494 {
495  if( ( m_zoom == MIN_ZOOM && aFactor > 1 ) || ( m_zoom == MAX_ZOOM && aFactor < 1 ) || aFactor == 1 )
496  return false;
497 
498  m_zoom_t1 = m_zoom / aFactor;
499  if (m_zoom_t1 < MIN_ZOOM )
501  if (m_zoom_t1 > MAX_ZOOM )
503 
505 
506  return true;
507 }
#define MAX_ZOOM
Definition: ccamera.cpp:54
SFVEC3F m_camera_pos_t1
Definition: ccamera.h:293
float m_zoom
3D zoom value (Min 0.0 ...
Definition: ccamera.h:259
SFVEC3F m_camera_pos_init
Definition: ccamera.h:290
#define MIN_ZOOM
Definition: ccamera.cpp:53
float m_zoom_t1
Definition: ccamera.h:261

References m_camera_pos_init, m_camera_pos_t1, m_zoom, m_zoom_t1, MAX_ZOOM, and MIN_ZOOM.

Referenced by EDA_3D_CANVAS::SetView3D().

◆ ZoomGet()

float CCAMERA::ZoomGet ( ) const

Definition at line 510 of file ccamera.cpp.

511 {
512  return m_zoom;
513 }
float m_zoom
3D zoom value (Min 0.0 ...
Definition: ccamera.h:259

References m_zoom.

Referenced by EDA_3D_CANVAS::DoRePaint(), EDA_3D_CANVAS::OnMouseWheel(), and EDA_3D_CANVAS::SetView3D().

◆ ZoomReset()

void CCAMERA::ZoomReset ( )

Definition at line 464 of file ccamera.cpp.

465 {
466  m_zoom = 1.0f;
467 
469 
472 }
void updateViewMatrix()
Definition: ccamera.cpp:126
float m_zoom
3D zoom value (Min 0.0 ...
Definition: ccamera.h:259
SFVEC3F m_camera_pos_init
Definition: ccamera.h:290
SFVEC3F m_camera_pos
Definition: ccamera.h:291
void rebuildProjection()
Definition: ccamera.cpp:164

References m_camera_pos, m_camera_pos_init, m_zoom, rebuildProjection(), and updateViewMatrix().

Member Data Documentation

◆ m_board_lookat_pos_init

SFVEC3F CCAMERA::m_board_lookat_pos_init
protected

Default boardlookat position (the board center)

Definition at line 298 of file ccamera.h.

Referenced by CCAMERA(), Reset(), Reset_T1(), and SetBoardLookAtPos().

◆ m_camera_pos

◆ m_camera_pos_init

SFVEC3F CCAMERA::m_camera_pos_init
protected

Definition at line 290 of file ccamera.h.

Referenced by CCAMERA(), rebuildProjection(), Reset(), Reset_T1(), Zoom(), Zoom_T1(), and ZoomReset().

◆ m_camera_pos_t0

SFVEC3F CCAMERA::m_camera_pos_t0
protected

Definition at line 292 of file ccamera.h.

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

◆ m_camera_pos_t1

SFVEC3F CCAMERA::m_camera_pos_t1
protected

◆ m_dir

SFVEC3F CCAMERA::m_dir
protected

Definition at line 285 of file ccamera.h.

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

◆ m_focalLen

SFVEC2F CCAMERA::m_focalLen
protected

Definition at line 288 of file ccamera.h.

Referenced by GetFocalLen(), and rebuildProjection().

◆ m_frustum

FRUSTUM CCAMERA::m_frustum
protected

Definition at line 281 of file ccamera.h.

Referenced by GetFar(), GetNear(), MakeRay(), CTRACK_BALL::Pan(), rebuildProjection(), and updateFrustum().

◆ m_interpolation_mode

CAMERA_INTERPOLATION CCAMERA::m_interpolation_mode
protected

Definition at line 304 of file ccamera.h.

Referenced by CCAMERA(), CTRACK_BALL::Interpolate(), and SetInterpolateMode().

◆ m_lastPosition

wxPoint CCAMERA::m_lastPosition
protected

The last mouse position in the screen.

Definition at line 271 of file ccamera.h.

Referenced by CTRACK_BALL::Drag(), MakeRayAtCurrrentMousePosition(), CTRACK_BALL::Pan(), Reset(), and SetCurMousePosition().

◆ m_logTrace

const wxChar * CCAMERA::m_logTrace = wxT( "KI_TRACE_CCAMERA" )
staticprotected

Trace mask used to enable or disable the trace output of this class.

The debug output can be turned on by setting the WXTRACE environment variable to "KI_TRACE_CCAMERA". See the wxWidgets documentation on wxLogTrace for more information.

Definition at line 332 of file ccamera.h.

Referenced by CCAMERA(), and CTRACK_BALL::CTRACK_BALL().

◆ m_lookat_pos

SFVEC3F CCAMERA::m_lookat_pos
protected

◆ m_lookat_pos_t0

SFVEC3F CCAMERA::m_lookat_pos_t0
protected

Definition at line 296 of file ccamera.h.

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

◆ m_lookat_pos_t1

SFVEC3F CCAMERA::m_lookat_pos_t1
protected

◆ m_parametersChanged

bool CCAMERA::m_parametersChanged
protected

Set to true if any of the parameters in the camera was changed.

Definition at line 324 of file ccamera.h.

Referenced by CTRACK_BALL::Drag(), Interpolate(), CTRACK_BALL::Pan(), ParametersChanged(), ParametersChangedQuery(), Reset(), ResetXYpos(), CTRACK_BALL::SetLookAtPos(), and updateRotationMatrix().

◆ m_pos

SFVEC3F CCAMERA::m_pos
protected

Definition at line 286 of file ccamera.h.

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

◆ m_projectionMatrix

glm::mat4 CCAMERA::m_projectionMatrix
protected

Definition at line 277 of file ccamera.h.

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

◆ m_projectionMatrixInv

glm::mat4 CCAMERA::m_projectionMatrixInv
protected

Definition at line 278 of file ccamera.h.

Referenced by GetProjectionMatrixInv(), rebuildProjection(), and Reset().

◆ m_projectionType

PROJECTION_TYPE CCAMERA::m_projectionType
protected

◆ m_range_scale

float CCAMERA::m_range_scale
protected

m_range_scale - the nominal range expected to be used in the camera.

It will be used to initialize the Z position

Definition at line 254 of file ccamera.h.

Referenced by CCAMERA().

◆ m_right

SFVEC3F CCAMERA::m_right
protected

Definition at line 283 of file ccamera.h.

Referenced by GetRight(), and updateFrustum().

◆ m_right_nX

std::vector< SFVEC3F > CCAMERA::m_right_nX
protected

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

Definition at line 317 of file ccamera.h.

Referenced by MakeRay(), and updateFrustum().

◆ m_rotate_aux

SFVEC3F CCAMERA::m_rotate_aux
protected

Stores the rotation angle auxiliar.

Definition at line 300 of file ccamera.h.

Referenced by Interpolate(), Reset(), RotateX(), RotateY(), RotateZ(), SetT0_and_T1_current_T(), and updateRotationMatrix().

◆ m_rotate_aux_t0

SFVEC3F CCAMERA::m_rotate_aux_t0
protected

Definition at line 301 of file ccamera.h.

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

◆ m_rotate_aux_t1

SFVEC3F CCAMERA::m_rotate_aux_t1
protected

◆ m_rotationMatrix

glm::mat4 CCAMERA::m_rotationMatrix
protected

◆ m_rotationMatrixAux

glm::mat4 CCAMERA::m_rotationMatrixAux
protected

Definition at line 274 of file ccamera.h.

Referenced by GetRotationMatrix(), Reset(), updateRotationMatrix(), and updateViewMatrix().

◆ m_scr_nX

std::vector< float > CCAMERA::m_scr_nX
protected

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

Definition at line 310 of file ccamera.h.

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

◆ m_scr_nY

std::vector< float > CCAMERA::m_scr_nY
protected

Definition at line 311 of file ccamera.h.

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

◆ m_up

SFVEC3F CCAMERA::m_up
protected

Definition at line 284 of file ccamera.h.

Referenced by GetUp(), and updateFrustum().

◆ m_up_nY

std::vector< SFVEC3F > CCAMERA::m_up_nY
protected

Definition at line 318 of file ccamera.h.

Referenced by MakeRay(), and updateFrustum().

◆ m_viewMatrix

glm::mat4 CCAMERA::m_viewMatrix
protected

Definition at line 275 of file ccamera.h.

Referenced by GetViewMatrix(), Reset(), updateFrustum(), and updateViewMatrix().

◆ m_viewMatrixInverse

glm::mat4 CCAMERA::m_viewMatrixInverse
protected

Definition at line 276 of file ccamera.h.

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

◆ m_windowSize

SFVEC2I CCAMERA::m_windowSize
protected

The window size that this camera is working.

Definition at line 266 of file ccamera.h.

Referenced by CCAMERA(), CTRACK_BALL::Drag(), MakeRay(), MakeRayAtCurrrentMousePosition(), CTRACK_BALL::Pan(), rebuildProjection(), SetCurWindowSize(), and updateFrustum().

◆ m_zoom

float CCAMERA::m_zoom
protected

3D zoom value (Min 0.0 ...

Max 1.0)

Definition at line 259 of file ccamera.h.

Referenced by Interpolate(), CTRACK_BALL::Pan(), rebuildProjection(), Reset(), SetT0_and_T1_current_T(), Zoom(), Zoom_T1(), ZoomGet(), and ZoomReset().

◆ m_zoom_t0

float CCAMERA::m_zoom_t0
protected

Definition at line 260 of file ccamera.h.

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

◆ m_zoom_t1

float CCAMERA::m_zoom_t1
protected

Definition at line 261 of file ccamera.h.

Referenced by Interpolate(), Reset(), Reset_T1(), SetT0_and_T1_current_T(), and Zoom_T1().


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