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...
 
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 SetProjection (PROJECTION_TYPE aProjectionType)
 
void ToggleProjection ()
 
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 80 of file ccamera.h.

Constructor & Destructor Documentation

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

References INTERPOLATION_BEZIER, m_board_lookat_pos_init, m_camera_pos_init, m_interpolation_mode, m_logTrace, m_projectionType, m_range_scale, m_windowSize, PROJECTION_PERSPECTIVE, and Reset().

46 {
47  wxLogTrace( m_logTrace, wxT( "CCAMERA::CCAMERA" ) );
48 
49  m_range_scale = aRangeScale;
50  m_camera_pos_init = SFVEC3F( 0.0f, 0.0f, -(aRangeScale * 2.0f ) );
52  m_windowSize = SFVEC2I( 0, 0 );
55 
56  Reset();
57 }
virtual void Reset()
Reset the camera to initial state.
Definition: ccamera.cpp:60
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
Definition: ccamera.h:330
SFVEC3F m_board_lookat_pos_init
Default boardlookat position (the board center)
Definition: ccamera.h:296
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:252
SFVEC3F m_camera_pos_init
Definition: ccamera.h:288
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
SFVEC2I m_windowSize
The window size that this camera is working.
Definition: ccamera.h:264
CAMERA_INTERPOLATION m_interpolation_mode
Definition: ccamera.h:302
PROJECTION_TYPE m_projectionType
Definition: ccamera.h:277

Member Function Documentation

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().

const SFVEC3F& CCAMERA::GetCameraPos ( ) const
inline

Definition at line 131 of file ccamera.h.

References m_camera_pos.

Referenced by EDA_3D_CANVAS::DisplayStatus().

131 { return m_camera_pos; }
SFVEC3F m_camera_pos
Definition: ccamera.h:289
const SFVEC3F& CCAMERA::GetDir ( ) const
inline

Definition at line 109 of file ccamera.h.

References m_dir.

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

109 { return m_dir; }
SFVEC3F m_dir
Definition: ccamera.h:283
float CCAMERA::GetFar ( ) const
inline

Definition at line 113 of file ccamera.h.

References FRUSTUM::farD, and m_frustum.

113 { return m_frustum.farD; }
float farD
Definition: ccamera.h:60
FRUSTUM m_frustum
Definition: ccamera.h:279
const SFVEC2F& CCAMERA::GetFocalLen ( ) const
inline

Definition at line 111 of file ccamera.h.

References m_focalLen.

111 { return m_focalLen; }
SFVEC2F m_focalLen
Definition: ccamera.h:286
const SFVEC3F& CCAMERA::GetLookAtPos_T1 ( ) const
inline

Definition at line 129 of file ccamera.h.

References m_lookat_pos_t1.

Referenced by EDA_3D_CANVAS::render_pivot().

129 { return m_lookat_pos_t1; }
SFVEC3F m_lookat_pos_t1
Definition: ccamera.h:295
float CCAMERA::GetNear ( ) const
inline

Definition at line 112 of file ccamera.h.

References m_frustum, and FRUSTUM::nearD.

112 { return m_frustum.nearD; }
float nearD
Definition: ccamera.h:60
FRUSTUM m_frustum
Definition: ccamera.h:279
const SFVEC3F& CCAMERA::GetPos ( ) const
inline

Definition at line 110 of file ccamera.h.

References m_pos.

Referenced by C3D_RENDER_OGL_LEGACY::Redraw().

110 { return m_pos; }
SFVEC3F m_pos
Definition: ccamera.h:284
const glm::mat4 & CCAMERA::GetProjectionMatrix ( ) const

Definition at line 359 of file ccamera.cpp.

References m_projectionMatrix.

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

360 {
361  return m_projectionMatrix;
362 }
glm::mat4 m_projectionMatrix
Definition: ccamera.h:275
const glm::mat4 & CCAMERA::GetProjectionMatrixInv ( ) const

Definition at line 365 of file ccamera.cpp.

References m_projectionMatrixInv.

366 {
367  return m_projectionMatrixInv;
368 }
glm::mat4 m_projectionMatrixInv
Definition: ccamera.h:276
const SFVEC3F& CCAMERA::GetRight ( ) const
inline

Definition at line 107 of file ccamera.h.

References m_right.

107 { return m_right; }
SFVEC3F m_right
Definition: ccamera.h:281
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 130 of file ccamera.cpp.

References m_rotationMatrix, and m_rotationMatrixAux.

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

131 {
133 }
glm::mat4 m_rotationMatrix
Definition: ccamera.h:271
glm::mat4 m_rotationMatrixAux
Definition: ccamera.h:272
const SFVEC3F& CCAMERA::GetUp ( ) const
inline

Definition at line 108 of file ccamera.h.

References m_up.

108 { return m_up; }
SFVEC3F m_up
Definition: ccamera.h:282
const glm::mat4 & CCAMERA::GetViewMatrix ( ) const

Definition at line 389 of file ccamera.cpp.

References m_viewMatrix.

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

390 {
391  return m_viewMatrix;
392 }
glm::mat4 m_viewMatrix
Definition: ccamera.h:273
const glm::mat4 & CCAMERA::GetViewMatrix_Inv ( ) const

Definition at line 395 of file ccamera.cpp.

References m_viewMatrixInverse.

396 {
397  return m_viewMatrixInverse;
398 }
glm::mat4 m_viewMatrixInverse
Definition: ccamera.h:274
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 549 of file ccamera.cpp.

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 CTRACK_BALL::Interpolate(), and EDA_3D_CANVAS::OnPaint().

550 {
551  wxASSERT( t >= 0.0f );
552 
553  const float t0 = 1.0f - t;
554 
558  m_zoom = m_zoom_t0 * t0 + m_zoom_t1 * t;
559 
560  m_parametersChanged = true;
561 
564 }
bool m_parametersChanged
Set to true if any of the parameters in the camera was changed.
Definition: ccamera.h:322
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliar.
Definition: ccamera.h:298
SFVEC3F m_camera_pos_t1
Definition: ccamera.h:291
float m_zoom_t0
Definition: ccamera.h:258
SFVEC3F m_lookat_pos_t1
Definition: ccamera.h:295
SFVEC3F m_lookat_pos_t0
Definition: ccamera.h:294
float m_zoom
3D zoom value (Min 0.0 ...
Definition: ccamera.h:257
SFVEC3F m_rotate_aux_t1
Definition: ccamera.h:300
void updateRotationMatrix()
Definition: ccamera.cpp:109
SFVEC3F m_camera_pos
Definition: ccamera.h:289
SFVEC3F m_camera_pos_t0
Definition: ccamera.h:290
void rebuildProjection()
Definition: ccamera.cpp:136
float m_zoom_t1
Definition: ccamera.h:259
SFVEC3F m_rotate_aux_t0
Definition: ccamera.h:299
SFVEC3F m_lookat_pos
Definition: ccamera.h:293
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 293 of file ccamera.cpp.

References m_dir, m_frustum, m_pos, m_projectionType, m_right_nX, m_up_nY, m_windowSize, FRUSTUM::nc, PROJECTION_ORTHO, and PROJECTION_PERSPECTIVE.

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

296 {
297  wxASSERT( aWindowPos.x < m_windowSize.x );
298  wxASSERT( aWindowPos.y < m_windowSize.y );
299 
300  const SFVEC3F up_plus_right = m_up_nY[aWindowPos.y] +
301  m_right_nX[aWindowPos.x];
302 
303  switch( m_projectionType )
304  {
305  default:
307  aOutOrigin = up_plus_right + m_frustum.nc;
308  aOutDirection = glm::normalize( aOutOrigin - m_pos );
309  break;
310 
311  case PROJECTION_ORTHO:
312  aOutOrigin = up_plus_right * 0.5f + m_frustum.nc;
313  aOutDirection = -m_dir;
314  break;
315  }
316 }
SFVEC3F m_dir
Definition: ccamera.h:283
std::vector< SFVEC3F > m_up_nY
Definition: ccamera.h:316
SFVEC3F m_pos
Definition: ccamera.h:284
FRUSTUM m_frustum
Definition: ccamera.h:279
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:315
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:264
PROJECTION_TYPE m_projectionType
Definition: ccamera.h:277
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 319 of file ccamera.cpp.

References m_dir, m_frustum, m_pos, m_projectionType, m_right_nX, m_up_nY, m_windowSize, FRUSTUM::nc, PROJECTION_ORTHO, and PROJECTION_PERSPECTIVE.

320 {
321  wxASSERT( aWindowPos.x < (float)m_windowSize.x );
322  wxASSERT( aWindowPos.y < (float)m_windowSize.y );
323 
324  const SFVEC2F floorWinPos_f = glm::floor( aWindowPos );
325  const SFVEC2I floorWinPos_i = (SFVEC2I)floorWinPos_f;
326  const SFVEC2F relativeWinPos = aWindowPos - floorWinPos_f;
327 
328  // Note: size of vectors m_up and m_right are m_windowSize + 1
329  const SFVEC3F up_plus_right = m_up_nY[floorWinPos_i.y] * (1.0f - relativeWinPos.y) +
330  m_up_nY[floorWinPos_i.y + 1] * relativeWinPos.y +
331  m_right_nX[floorWinPos_i.x] * (1.0f - relativeWinPos.x) +
332  m_right_nX[floorWinPos_i.x + 1] * relativeWinPos.x;
333 
334  switch( m_projectionType )
335  {
336  default:
338  aOutOrigin = up_plus_right + m_frustum.nc;
339  aOutDirection = glm::normalize( aOutOrigin - m_pos );
340  break;
341 
342  case PROJECTION_ORTHO:
343  aOutOrigin = up_plus_right * 0.5f + m_frustum.nc;
344  aOutDirection = -m_dir;
345  break;
346  }
347 }
SFVEC3F m_dir
Definition: ccamera.h:283
std::vector< SFVEC3F > m_up_nY
Definition: ccamera.h:316
glm::ivec2 SFVEC2I
Definition: xv3d_types.h:42
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
SFVEC3F m_pos
Definition: ccamera.h:284
FRUSTUM m_frustum
Definition: ccamera.h:279
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:315
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:264
PROJECTION_TYPE m_projectionType
Definition: ccamera.h:277
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 350 of file ccamera.cpp.

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

Referenced by EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position().

352 {
355  aOutOrigin, aOutDirection );
356 }
glm::ivec2 SFVEC2I
Definition: xv3d_types.h:42
wxPoint m_lastPosition
The last mouse position in the screen.
Definition: ccamera.h:269
void MakeRay(const SFVEC2I &aWindowPos, SFVEC3F &aOutOrigin, SFVEC3F &aOutDirection) const
MakeRay - Make a ray based on a windows screen position.
Definition: ccamera.cpp:293
SFVEC2I m_windowSize
The window size that this camera is working.
Definition: ccamera.h:264
virtual void CCAMERA::Pan ( const wxPoint aNewMousePosition)
pure virtual
virtual void CCAMERA::Pan ( const SFVEC3F aDeltaOffsetInc)
pure virtual

Implemented in CTRACK_BALL.

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

Implemented in CTRACK_BALL.

Referenced by EDA_3D_CANVAS::SetView3D().

bool CCAMERA::ParametersChanged ( )

Function ParametersChanged.

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

Definition at line 567 of file ccamera.cpp.

References m_parametersChanged.

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

568 {
569  const bool parametersChanged = m_parametersChanged;
570 
571  m_parametersChanged = false;
572 
573  return parametersChanged;
574 }
bool m_parametersChanged
Set to true if any of the parameters in the camera was changed.
Definition: ccamera.h:322
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 215 of file ccamera.h.

References m_parametersChanged.

215 { return m_parametersChanged; }
bool m_parametersChanged
Set to true if any of the parameters in the camera was changed.
Definition: ccamera.h:322
void CCAMERA::rebuildProjection ( )
protected

Definition at line 136 of file ccamera.cpp.

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, PROJECTION_ORTHO, PROJECTION_PERSPECTIVE, FRUSTUM::ratio, FRUSTUM::tang, and updateFrustum().

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

137 {
138  if( (m_windowSize.x == 0) ||
139  (m_windowSize.y == 0) )
140  return;
141 
142  m_frustum.ratio = (float) m_windowSize.x / (float)m_windowSize.y;
143 
144  // Consider that we can render double the length multiplied by the 2/sqrt(2)
145  //
146  m_frustum.farD = glm::length( m_camera_pos_init ) * 2.0f * ( 2.0f * sqrtf( 2.0f ) );
147 
148  switch( m_projectionType )
149  {
150  default:
152 
153  m_frustum.nearD = 0.10f;
154 
155  // Ratio width / height of the window display
156  m_frustum.angle = 45.0f * m_zoom;
157 
158 
159  m_projectionMatrix = glm::perspective( glm::radians( m_frustum.angle ),
162  m_frustum.farD );
163 
164  m_projectionMatrixInv = glm::inverse( m_projectionMatrix );
165 
166  m_frustum.tang = glm::tan( glm::radians( m_frustum.angle ) * 0.5f ) ;
167 
168  m_focalLen.x = ( (float)m_windowSize.y / (float)m_windowSize.x ) / m_frustum.tang;
169  m_focalLen.y = 1.0f / m_frustum.tang;
170 
175  break;
176 
177  case PROJECTION_ORTHO:
178 
179  m_frustum.nearD = -m_frustum.farD; // Use a symmetrical clip plane for ortho projection
180 
181  const float orthoReductionFactor = m_zoom / 75.0f;
182 
183  // Initialize Projection Matrix for Ortographic View
184  m_projectionMatrix = glm::ortho( -m_windowSize.x * orthoReductionFactor,
185  m_windowSize.x * orthoReductionFactor,
186  -m_windowSize.y * orthoReductionFactor,
187  m_windowSize.y * orthoReductionFactor,
189 
190  m_projectionMatrixInv = glm::inverse( m_projectionMatrix );
191 
192  m_frustum.nw = m_windowSize.x * orthoReductionFactor * 2.0f;
193  m_frustum.nh = m_windowSize.y * orthoReductionFactor * 2.0f;
196 
197  break;
198  }
199 
200  if ( (m_windowSize.x > 0) &&
201  (m_windowSize.y > 0) )
202  {
203  m_scr_nX.resize( m_windowSize.x + 1 );
204  m_scr_nY.resize( m_windowSize.y + 1 );
205 
206  // Precalc X values for camera -> ray generation
207  for( unsigned int x = 0; x < (unsigned int)m_windowSize.x + 1; ++x )
208  {
209  // Converts 0.0 .. 1.0
210  const float xNormalizedDeviceCoordinates = ( ( (float)x + 0.5f ) /
211  (m_windowSize.x - 0.0f) );
212 
213  // Converts -1.0 .. 1.0
214  m_scr_nX[x] = 2.0f * xNormalizedDeviceCoordinates - 1.0f;
215  }
216 
217  // Precalc Y values for camera -> ray generation
218  for( unsigned int y = 0; y < (unsigned int)m_windowSize.y + 1 ; ++y )
219  {
220  // Converts 0.0 .. 1.0
221  const float yNormalizedDeviceCoordinates = ( ( (float)y + 0.5f ) /
222  (m_windowSize.y - 0.0f) );
223 
224  // Converts -1.0 .. 1.0
225  m_scr_nY[y] = 2.0f * yNormalizedDeviceCoordinates - 1.0f;
226  }
227 
228  updateFrustum();
229  }
230 }
float farD
Definition: ccamera.h:60
void updateFrustum()
Definition: ccamera.cpp:233
float nearD
Definition: ccamera.h:60
float nw
Definition: ccamera.h:61
std::vector< float > m_scr_nY
Definition: ccamera.h:309
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:308
float tang
Definition: ccamera.h:60
float fw
Definition: ccamera.h:61
SFVEC2F m_focalLen
Definition: ccamera.h:286
float angle
Definition: ccamera.h:60
FRUSTUM m_frustum
Definition: ccamera.h:279
glm::mat4 m_projectionMatrix
Definition: ccamera.h:275
float m_zoom
3D zoom value (Min 0.0 ...
Definition: ccamera.h:257
SFVEC3F m_camera_pos_init
Definition: ccamera.h:288
SFVEC2I m_windowSize
The window size that this camera is working.
Definition: ccamera.h:264
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:276
PROJECTION_TYPE m_projectionType
Definition: ccamera.h:277
void CCAMERA::Reset ( )
virtual

Reset the camera to initial state.

Reimplemented in CTRACK_BALL.

Definition at line 60 of file ccamera.cpp.

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().

61 {
62  m_parametersChanged = true;
63  m_projectionMatrix = glm::mat4( 1.0f );
64  m_projectionMatrixInv = glm::mat4( 1.0f );
65  m_rotationMatrix = glm::mat4( 1.0f );
66  m_rotationMatrixAux = glm::mat4( 1.0f );
67  m_lastPosition = wxPoint( 0, 0 );
68 
69  m_zoom = 1.0f;
70  m_zoom_t0 = 1.0f;
71  m_zoom_t1 = 1.0f;
78 
79  m_rotate_aux = SFVEC3F( 0.0f );
80  m_rotate_aux_t0 = SFVEC3F( 0.0f );
81  m_rotate_aux_t1 = SFVEC3F( 0.0f );
82 
85  m_viewMatrixInverse = glm::inverse( m_viewMatrix );
86  m_scr_nX.clear();
87  m_scr_nY.clear();
89 }
bool m_parametersChanged
Set to true if any of the parameters in the camera was changed.
Definition: ccamera.h:322
SFVEC3F m_board_lookat_pos_init
Default boardlookat position (the board center)
Definition: ccamera.h:296
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliar.
Definition: ccamera.h:298
glm::mat4 m_viewMatrixInverse
Definition: ccamera.h:274
std::vector< float > m_scr_nY
Definition: ccamera.h:309
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:308
void updateViewMatrix()
Definition: ccamera.cpp:101
wxPoint m_lastPosition
The last mouse position in the screen.
Definition: ccamera.h:269
SFVEC3F m_camera_pos_t1
Definition: ccamera.h:291
float m_zoom_t0
Definition: ccamera.h:258
SFVEC3F m_lookat_pos_t1
Definition: ccamera.h:295
SFVEC3F m_lookat_pos_t0
Definition: ccamera.h:294
glm::mat4 m_rotationMatrix
Definition: ccamera.h:271
glm::mat4 m_projectionMatrix
Definition: ccamera.h:275
float m_zoom
3D zoom value (Min 0.0 ...
Definition: ccamera.h:257
SFVEC3F m_rotate_aux_t1
Definition: ccamera.h:300
void updateRotationMatrix()
Definition: ccamera.cpp:109
SFVEC3F m_camera_pos_init
Definition: ccamera.h:288
SFVEC3F m_camera_pos
Definition: ccamera.h:289
SFVEC3F m_camera_pos_t0
Definition: ccamera.h:290
void rebuildProjection()
Definition: ccamera.cpp:136
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
float m_zoom_t1
Definition: ccamera.h:259
SFVEC3F m_rotate_aux_t0
Definition: ccamera.h:299
glm::mat4 m_rotationMatrixAux
Definition: ccamera.h:272
glm::mat4 m_viewMatrix
Definition: ccamera.h:273
glm::mat4 m_projectionMatrixInv
Definition: ccamera.h:276
SFVEC3F m_lookat_pos
Definition: ccamera.h:293
void CCAMERA::Reset_T1 ( )
virtual

Reimplemented in CTRACK_BALL.

Definition at line 92 of file ccamera.cpp.

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

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

93 {
95  m_zoom_t1 = 1.0f;
96  m_rotate_aux_t1 = SFVEC3F( 0.0f );
98 }
SFVEC3F m_board_lookat_pos_init
Default boardlookat position (the board center)
Definition: ccamera.h:296
SFVEC3F m_camera_pos_t1
Definition: ccamera.h:291
SFVEC3F m_lookat_pos_t1
Definition: ccamera.h:295
SFVEC3F m_rotate_aux_t1
Definition: ccamera.h:300
SFVEC3F m_camera_pos_init
Definition: ccamera.h:288
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
float m_zoom_t1
Definition: ccamera.h:259
void CCAMERA::ResetXYpos ( )

Definition at line 371 of file ccamera.cpp.

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

372 {
373  m_parametersChanged = true;
374  m_camera_pos.x = 0.0f;
375  m_camera_pos.y = 0.0f;
376 
378  updateFrustum();
379 }
bool m_parametersChanged
Set to true if any of the parameters in the camera was changed.
Definition: ccamera.h:322
void updateFrustum()
Definition: ccamera.cpp:233
void updateViewMatrix()
Definition: ccamera.cpp:101
SFVEC3F m_camera_pos
Definition: ccamera.h:289
void CCAMERA::ResetXYpos_T1 ( )

Definition at line 382 of file ccamera.cpp.

References m_camera_pos_t1.

Referenced by EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position().

383 {
384  m_camera_pos_t1.x = 0.0f;
385  m_camera_pos_t1.y = 0.0f;
386 }
SFVEC3F m_camera_pos_t1
Definition: ccamera.h:291
void CCAMERA::RotateX ( float  aAngleInRadians)

Definition at line 496 of file ccamera.cpp.

References m_rotate_aux, and updateRotationMatrix().

Referenced by EDA_3D_VIEWER::Process_Special_Functions().

497 {
498  m_rotate_aux.x += aAngleInRadians;
500 }
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliar.
Definition: ccamera.h:298
void updateRotationMatrix()
Definition: ccamera.cpp:109
void CCAMERA::RotateX_T1 ( float  aAngleInRadians)

Definition at line 517 of file ccamera.cpp.

References m_rotate_aux_t1.

Referenced by EDA_3D_CANVAS::SetView3D().

518 {
519  m_rotate_aux_t1.x += aAngleInRadians;
520 }
SFVEC3F m_rotate_aux_t1
Definition: ccamera.h:300
void CCAMERA::RotateY ( float  aAngleInRadians)

Definition at line 503 of file ccamera.cpp.

References m_rotate_aux, and updateRotationMatrix().

Referenced by EDA_3D_VIEWER::Process_Special_Functions().

504 {
505  m_rotate_aux.y += aAngleInRadians;
507 }
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliar.
Definition: ccamera.h:298
void updateRotationMatrix()
Definition: ccamera.cpp:109
void CCAMERA::RotateY_T1 ( float  aAngleInRadians)

Definition at line 523 of file ccamera.cpp.

References m_rotate_aux_t1.

524 {
525  m_rotate_aux_t1.y += aAngleInRadians;
526 }
SFVEC3F m_rotate_aux_t1
Definition: ccamera.h:300
void CCAMERA::RotateZ ( float  aAngleInRadians)

Definition at line 510 of file ccamera.cpp.

References m_rotate_aux, and updateRotationMatrix().

Referenced by EDA_3D_VIEWER::Process_Special_Functions().

511 {
512  m_rotate_aux.z += aAngleInRadians;
514 }
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliar.
Definition: ccamera.h:298
void updateRotationMatrix()
Definition: ccamera.cpp:109
void CCAMERA::RotateZ_T1 ( float  aAngleInRadians)

Definition at line 529 of file ccamera.cpp.

References m_rotate_aux_t1.

Referenced by EDA_3D_CANVAS::SetView3D().

530 {
531  m_rotate_aux_t1.z += aAngleInRadians;
532 }
SFVEC3F m_rotate_aux_t1
Definition: ccamera.h:300
void CCAMERA::SetBoardLookAtPos ( const SFVEC3F aBoardPos)
inline

Definition at line 115 of file ccamera.h.

References m_board_lookat_pos_init, and SetLookAtPos().

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

115  {
116  if( m_board_lookat_pos_init != aBoardPos )
117  {
118  m_board_lookat_pos_init = aBoardPos;
119  SetLookAtPos( aBoardPos );
120  }
121  }
SFVEC3F m_board_lookat_pos_init
Default boardlookat position (the board center)
Definition: ccamera.h:296
virtual void SetLookAtPos(const SFVEC3F &aLookAtPos)=0
void CCAMERA::SetCurMousePosition ( const wxPoint aPosition)

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

Definition at line 401 of file ccamera.cpp.

References m_lastPosition.

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

402 {
403  m_lastPosition = aNewMousePosition;
404 }
wxPoint m_lastPosition
The last mouse position in the screen.
Definition: ccamera.h:269
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 428 of file ccamera.cpp.

References m_windowSize, and rebuildProjection().

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

429 {
430  const SFVEC2I newSize = SFVEC2I( aSize.x, aSize.y );
431 
432  if( m_windowSize != newSize )
433  {
434  m_windowSize = newSize;
436 
437  return true;
438  }
439 
440  return false;
441 }
glm::ivec2 SFVEC2I
Definition: xv3d_types.h:42
void rebuildProjection()
Definition: ccamera.cpp:136
SFVEC2I m_windowSize
The window size that this camera is working.
Definition: ccamera.h:264
void CCAMERA::SetInterpolateMode ( CAMERA_INTERPOLATION  aInterpolateMode)
inline

Definition at line 198 of file ccamera.h.

References m_interpolation_mode.

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

199  {
200  m_interpolation_mode = aInterpolateMode;
201  }
CAMERA_INTERPOLATION m_interpolation_mode
Definition: ccamera.h:302
virtual void CCAMERA::SetLookAtPos ( const SFVEC3F aLookAtPos)
pure virtual

Implemented in CTRACK_BALL.

Referenced by SetBoardLookAtPos().

void CCAMERA::SetLookAtPos_T1 ( const SFVEC3F aLookAtPos)
inline

Definition at line 125 of file ccamera.h.

References m_lookat_pos_t1.

Referenced by EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position().

125  {
126  m_lookat_pos_t1 = aLookAtPos;
127  }
SFVEC3F m_lookat_pos_t1
Definition: ccamera.h:295
void CCAMERA::SetProjection ( PROJECTION_TYPE  aProjectionType)

Definition at line 407 of file ccamera.cpp.

References m_projectionType, and rebuildProjection().

408 {
409  if( m_projectionType != aProjectionType )
410  {
411  m_projectionType = aProjectionType;
413  }
414 }
void rebuildProjection()
Definition: ccamera.cpp:136
PROJECTION_TYPE m_projectionType
Definition: ccamera.h:277
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 535 of file ccamera.cpp.

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().

536 {
540  m_zoom_t0 = m_zoom;
541 
545  m_zoom_t1 = m_zoom;
546 }
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliar.
Definition: ccamera.h:298
SFVEC3F m_camera_pos_t1
Definition: ccamera.h:291
float m_zoom_t0
Definition: ccamera.h:258
SFVEC3F m_lookat_pos_t1
Definition: ccamera.h:295
SFVEC3F m_lookat_pos_t0
Definition: ccamera.h:294
float m_zoom
3D zoom value (Min 0.0 ...
Definition: ccamera.h:257
SFVEC3F m_rotate_aux_t1
Definition: ccamera.h:300
SFVEC3F m_camera_pos
Definition: ccamera.h:289
SFVEC3F m_camera_pos_t0
Definition: ccamera.h:290
float m_zoom_t1
Definition: ccamera.h:259
SFVEC3F m_rotate_aux_t0
Definition: ccamera.h:299
SFVEC3F m_lookat_pos
Definition: ccamera.h:293
void CCAMERA::ToggleProjection ( )
void CCAMERA::updateFrustum ( )
protected

Definition at line 233 of file ccamera.cpp.

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().

234 {
235  // Update matrix and vectors
236  m_viewMatrixInverse = glm::inverse( m_viewMatrix );
237 
238  m_right = glm::normalize( SFVEC3F( m_viewMatrixInverse *
239  glm::vec4( SFVEC3F( 1.0, 0.0, 0.0 ), 0.0 ) ) );
240 
241  m_up = glm::normalize( SFVEC3F( m_viewMatrixInverse *
242  glm::vec4( SFVEC3F( 0.0, 1.0, 0.0 ), 0.0 ) ) );
243 
244  m_dir = glm::normalize( SFVEC3F( m_viewMatrixInverse *
245  glm::vec4( SFVEC3F( 0.0, 0.0, 1.0 ), 0.0 ) ) );
246 
247  m_pos = SFVEC3F( m_viewMatrixInverse * glm::vec4( SFVEC3F( 0.0, 0.0, 0.0 ), 1.0 ) );
248 
249 
250  /*
251  * Frustum is a implementation based on a tutorial by
252  * http://www.lighthouse3d.com/tutorials/view-frustum-culling/
253  */
254 
255  // compute the centers of the near and far planes
258 
259  // compute the 4 corners of the frustum on the near plane
264 
265  // compute the 4 corners of the frustum on the far plane
270 
271  if ( (m_windowSize.x > 0) &&
272  (m_windowSize.y > 0) )
273  {
274  // Reserve size for precalc values
275  m_right_nX.resize( m_windowSize.x + 1 );
276  m_up_nY.resize( m_windowSize.y + 1 );
277 
278  // Precalc X values for camera -> ray generation
279  const SFVEC3F right_nw = m_right * m_frustum.nw;
280 
281  for( unsigned int x = 0; x < ((unsigned int)m_windowSize.x + 1); ++x )
282  m_right_nX[x] = right_nw * m_scr_nX[x];
283 
284  // Precalc Y values for camera -> ray generation
285  const SFVEC3F up_nh = m_up * m_frustum.nh;
286 
287  for( unsigned int y = 0; y < ((unsigned int)m_windowSize.y + 1); ++y )
288  m_up_nY[y] = up_nh * m_scr_nY[y];
289  }
290 }
SFVEC3F fc
Definition: ccamera.h:51
SFVEC3F m_dir
Definition: ccamera.h:283
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:316
float nearD
Definition: ccamera.h:60
glm::mat4 m_viewMatrixInverse
Definition: ccamera.h:274
float nw
Definition: ccamera.h:61
std::vector< float > m_scr_nY
Definition: ccamera.h:309
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:308
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:281
SFVEC3F m_pos
Definition: ccamera.h:284
SFVEC3F m_up
Definition: ccamera.h:282
SFVEC3F nbl
Near Bottom Left.
Definition: ccamera.h:54
SFVEC3F ntr
Near Top Right.
Definition: ccamera.h:53
FRUSTUM m_frustum
Definition: ccamera.h:279
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:315
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:264
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:273
void CCAMERA::updateRotationMatrix ( )
protected

Definition at line 109 of file ccamera.cpp.

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

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

110 {
111  m_rotationMatrixAux = glm::rotate( glm::mat4( 1.0f ),
112  m_rotate_aux.x,
113  SFVEC3F( 1.0f, 0.0f, 0.0f ) );
114 
116  m_rotate_aux.y,
117  SFVEC3F( 0.0f, 1.0f, 0.0f ) );
118 
120  m_rotate_aux.z,
121  SFVEC3F( 0.0f, 0.0f, 1.0f ) );
122 
123  m_parametersChanged = true;
124 
126  updateFrustum();
127 }
bool m_parametersChanged
Set to true if any of the parameters in the camera was changed.
Definition: ccamera.h:322
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliar.
Definition: ccamera.h:298
void updateFrustum()
Definition: ccamera.cpp:233
void updateViewMatrix()
Definition: ccamera.cpp:101
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
glm::mat4 m_rotationMatrixAux
Definition: ccamera.h:272
void CCAMERA::updateViewMatrix ( )
protected

Definition at line 101 of file ccamera.cpp.

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().

102 {
103  m_viewMatrix = glm::translate( glm::mat4( 1.0f ), m_camera_pos ) *
105  glm::translate( glm::mat4( 1.0f ), -m_lookat_pos );
106 }
glm::mat4 m_rotationMatrix
Definition: ccamera.h:271
SFVEC3F m_camera_pos
Definition: ccamera.h:289
glm::mat4 m_rotationMatrixAux
Definition: ccamera.h:272
glm::mat4 m_viewMatrix
Definition: ccamera.h:273
SFVEC3F m_lookat_pos
Definition: ccamera.h:293
bool CCAMERA::Zoom ( float  aFactor)

Definition at line 454 of file ccamera.cpp.

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().

455 {
456  if ( ( m_zoom == MIN_ZOOM && aFactor > 1 ) || ( m_zoom == MAX_ZOOM && aFactor < 1 ) || aFactor == 1 )
457  return false;
458 
459  m_zoom /= aFactor;
460  if( m_zoom <= MIN_ZOOM )
461  m_zoom = MIN_ZOOM;
462  if( m_zoom >= MAX_ZOOM )
463  m_zoom = MAX_ZOOM;
464 
466 
469 
470  return true;
471 }
#define MAX_ZOOM
Definition: ccamera.cpp:43
void updateViewMatrix()
Definition: ccamera.cpp:101
float m_zoom
3D zoom value (Min 0.0 ...
Definition: ccamera.h:257
SFVEC3F m_camera_pos_init
Definition: ccamera.h:288
SFVEC3F m_camera_pos
Definition: ccamera.h:289
void rebuildProjection()
Definition: ccamera.cpp:136
#define MIN_ZOOM
Definition: ccamera.cpp:42
bool CCAMERA::Zoom_T1 ( float  aFactor)

Definition at line 473 of file ccamera.cpp.

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().

474 {
475  if( ( m_zoom == MIN_ZOOM && aFactor > 1 ) || ( m_zoom == MAX_ZOOM && aFactor < 1 ) || aFactor == 1 )
476  return false;
477 
478  m_zoom_t1 = m_zoom / aFactor;
479  if (m_zoom_t1 < MIN_ZOOM )
481  if (m_zoom_t1 > MAX_ZOOM )
483 
485 
486  return true;
487 }
#define MAX_ZOOM
Definition: ccamera.cpp:43
SFVEC3F m_camera_pos_t1
Definition: ccamera.h:291
float m_zoom
3D zoom value (Min 0.0 ...
Definition: ccamera.h:257
SFVEC3F m_camera_pos_init
Definition: ccamera.h:288
#define MIN_ZOOM
Definition: ccamera.cpp:42
float m_zoom_t1
Definition: ccamera.h:259
float CCAMERA::ZoomGet ( ) const

Definition at line 490 of file ccamera.cpp.

References m_zoom.

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

491 {
492  return m_zoom;
493 }
float m_zoom
3D zoom value (Min 0.0 ...
Definition: ccamera.h:257
void CCAMERA::ZoomReset ( )

Definition at line 444 of file ccamera.cpp.

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

445 {
446  m_zoom = 1.0f;
447 
449 
452 }
void updateViewMatrix()
Definition: ccamera.cpp:101
float m_zoom
3D zoom value (Min 0.0 ...
Definition: ccamera.h:257
SFVEC3F m_camera_pos_init
Definition: ccamera.h:288
SFVEC3F m_camera_pos
Definition: ccamera.h:289
void rebuildProjection()
Definition: ccamera.cpp:136

Member Data Documentation

SFVEC3F CCAMERA::m_board_lookat_pos_init
protected

Default boardlookat position (the board center)

Definition at line 296 of file ccamera.h.

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

SFVEC3F CCAMERA::m_camera_pos_init
protected

Definition at line 288 of file ccamera.h.

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

SFVEC3F CCAMERA::m_camera_pos_t0
protected

Definition at line 290 of file ccamera.h.

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

SFVEC3F CCAMERA::m_camera_pos_t1
protected
SFVEC3F CCAMERA::m_dir
protected

Definition at line 283 of file ccamera.h.

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

SFVEC2F CCAMERA::m_focalLen
protected

Definition at line 286 of file ccamera.h.

Referenced by GetFocalLen(), and rebuildProjection().

FRUSTUM CCAMERA::m_frustum
protected

Definition at line 279 of file ccamera.h.

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

CAMERA_INTERPOLATION CCAMERA::m_interpolation_mode
protected

Definition at line 302 of file ccamera.h.

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

wxPoint CCAMERA::m_lastPosition
protected

The last mouse position in the screen.

Definition at line 269 of file ccamera.h.

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

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 330 of file ccamera.h.

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

SFVEC3F CCAMERA::m_lookat_pos
protected
SFVEC3F CCAMERA::m_lookat_pos_t0
protected

Definition at line 294 of file ccamera.h.

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

SFVEC3F CCAMERA::m_lookat_pos_t1
protected
bool CCAMERA::m_parametersChanged
protected

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

Definition at line 322 of file ccamera.h.

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

SFVEC3F CCAMERA::m_pos
protected

Definition at line 284 of file ccamera.h.

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

glm::mat4 CCAMERA::m_projectionMatrix
protected

Definition at line 275 of file ccamera.h.

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

glm::mat4 CCAMERA::m_projectionMatrixInv
protected

Definition at line 276 of file ccamera.h.

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

PROJECTION_TYPE CCAMERA::m_projectionType
protected
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 252 of file ccamera.h.

Referenced by CCAMERA().

SFVEC3F CCAMERA::m_right
protected

Definition at line 281 of file ccamera.h.

Referenced by GetRight(), and updateFrustum().

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 315 of file ccamera.h.

Referenced by MakeRay(), and updateFrustum().

SFVEC3F CCAMERA::m_rotate_aux
protected

Stores the rotation angle auxiliar.

Definition at line 298 of file ccamera.h.

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

SFVEC3F CCAMERA::m_rotate_aux_t0
protected

Definition at line 299 of file ccamera.h.

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

SFVEC3F CCAMERA::m_rotate_aux_t1
protected
glm::mat4 CCAMERA::m_rotationMatrix
protected
glm::mat4 CCAMERA::m_rotationMatrixAux
protected

Definition at line 272 of file ccamera.h.

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

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 308 of file ccamera.h.

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

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

Definition at line 309 of file ccamera.h.

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

SFVEC3F CCAMERA::m_up
protected

Definition at line 282 of file ccamera.h.

Referenced by GetUp(), and updateFrustum().

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

Definition at line 316 of file ccamera.h.

Referenced by MakeRay(), and updateFrustum().

glm::mat4 CCAMERA::m_viewMatrix
protected

Definition at line 273 of file ccamera.h.

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

glm::mat4 CCAMERA::m_viewMatrixInverse
protected

Definition at line 274 of file ccamera.h.

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

SFVEC2I CCAMERA::m_windowSize
protected

The window size that this camera is working.

Definition at line 264 of file ccamera.h.

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

float CCAMERA::m_zoom
protected

3D zoom value (Min 0.0 ...

Max 1.0)

Definition at line 257 of file ccamera.h.

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

float CCAMERA::m_zoom_t0
protected

Definition at line 258 of file ccamera.h.

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

float CCAMERA::m_zoom_t1
protected

Definition at line 259 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: