KiCad PCB EDA Suite
Loading...
Searching...
No Matches
camera.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015-2016 Mario Luzeiro <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
29#include <gal/3d/camera.h>
30#include <wx/log.h>
31#include <algorithm>
32#include <3d_enums.h>
33
34// A helper function to normalize aAngle between -2PI and +2PI
35inline void normalise2PI( float& aAngle )
36{
37 while( aAngle > 0.0 )
38 aAngle -= static_cast<float>( M_PI * 2.0f );
39
40 while( aAngle < 0.0 )
41 aAngle += static_cast<float>( M_PI * 2.0f );
42}
43
44
48const wxChar *CAMERA::m_logTrace = wxT( "KI_TRACE_CAMERA" );
49
50const float CAMERA::DEFAULT_MIN_ZOOM = 0.020f;
51const float CAMERA::DEFAULT_MAX_ZOOM = 2.0f;
52
53
54CAMERA::CAMERA( float aInitialDistance ) :
55 CAMERA( SFVEC3F( 0.0f, 0.0f, -aInitialDistance ), SFVEC3F( 0.0f ),
57{
58}
59
60
61CAMERA::CAMERA( SFVEC3F aInitPos, SFVEC3F aLookat, PROJECTION_TYPE aProjectionType )
62{
63 wxLogTrace( m_logTrace, wxT( "CAMERA::CAMERA" ) );
64
65 m_camera_pos_init = aInitPos;
67 m_windowSize = SFVEC2I( 0, 0 );
68 m_projectionType = aProjectionType;
69 m_interpolation_mode = CAMERA_INTERPOLATION::BEZIER;
70
73
74 Reset();
75}
76
77
79{
81 m_projectionMatrix = glm::mat4( 1.0f );
82 m_projectionMatrixInv = glm::mat4( 1.0f );
83 m_rotationMatrix = glm::mat4( 1.0f );
84 m_rotationMatrixAux = glm::mat4( 1.0f );
85 m_lastPosition = wxPoint( 0, 0 );
86
87 m_zoom = 1.0f;
88 m_zoom_t0 = 1.0f;
89 m_zoom_t1 = 1.0f;
96
97 m_rotate_aux = SFVEC3F( 0.0f );
98 m_rotate_aux_t0 = SFVEC3F( 0.0f );
99 m_rotate_aux_t1 = SFVEC3F( 0.0f );
100
103 m_viewMatrixInverse = glm::inverse( m_viewMatrix );
104 m_scr_nX.clear();
105 m_scr_nY.clear();
107}
108
109
111{
112 switch( aRequestedView )
113 {
114 case VIEW3D_TYPE::VIEW3D_RIGHT:
116 Reset_T1();
117 RotateZ_T1( glm::radians( -90.0f ) );
118 RotateX_T1( glm::radians( -90.0f ) );
119 return true;
120
121 case VIEW3D_TYPE::VIEW3D_LEFT:
122 Reset_T1();
123 RotateZ_T1( glm::radians( 90.0f ) );
124 RotateX_T1( glm::radians( -90.0f ) );
125 return true;
126
127 case VIEW3D_TYPE::VIEW3D_FRONT:
128 Reset_T1();
129 RotateX_T1( glm::radians( -90.0f ) );
130 return true;
131
132 case VIEW3D_TYPE::VIEW3D_BACK:
133 Reset_T1();
134 RotateX_T1( glm::radians( -90.0f ) );
135
136 // The rotation angle should be 180.
137 // We use 179.999 (180 - epsilon) to avoid a full 360 deg rotation when
138 // using 180 deg if the previous rotated position was already 180 deg
139 RotateZ_T1( glm::radians( 179.999f ) );
140 return true;
141
142 case VIEW3D_TYPE::VIEW3D_TOP:
143 Reset_T1();
144 return true;
145
146 case VIEW3D_TYPE::VIEW3D_BOTTOM:
147 Reset_T1();
148 RotateY_T1( glm::radians( 179.999f ) ); // Rotation = 180 - epsilon
149 return true;
150
151 case VIEW3D_TYPE::VIEW3D_FLIP:
152 RotateY_T1( glm::radians( 179.999f ) );
153 return true;
154
155 default:
156 return false;
157 }
158}
159
160
162{
164 m_zoom_t1 = 1.0f;
165 m_rotate_aux_t1 = SFVEC3F( 0.0f );
167
168 // Since 0 = 2pi, we want to reset the angle to be the closest
169 // one to where we currently are. That ensures that we rotate
170 // the board around the smallest distance getting there.
171 if( m_rotate_aux_t0.x > M_PI )
172 m_rotate_aux_t1.x = static_cast<float>( 2.0f * M_PI );
173
174 if( m_rotate_aux_t0.y > M_PI )
175 m_rotate_aux_t1.y = static_cast<float>( 2.0f * M_PI );
176
177 if( m_rotate_aux_t0.z > M_PI )
178 m_rotate_aux_t1.z = static_cast<float>( 2.0f * M_PI );
179}
180
181
182void CAMERA::SetBoardLookAtPos( const SFVEC3F& aBoardPos )
183{
184 if( m_board_lookat_pos_init != aBoardPos )
185 {
186 m_board_lookat_pos_init = aBoardPos;
187 m_lookat_pos = aBoardPos;
188
189 m_parametersChanged = true;
190
193 }
194}
195
196
198{
199 if( m_zoom < m_minZoom )
201
202 if( m_zoom > m_maxZoom )
204
206
209}
210
211
213{
214 m_viewMatrix = glm::translate( glm::mat4( 1.0f ), m_camera_pos ) *
216 glm::translate( glm::mat4( 1.0f ), -m_lookat_pos );
217}
218
219
221{
222 m_rotationMatrixAux = glm::rotate( glm::mat4( 1.0f ), m_rotate_aux.x,
223 SFVEC3F( 1.0f, 0.0f, 0.0f ) );
225
227 SFVEC3F( 0.0f, 1.0f, 0.0f ) );
229
231 SFVEC3F( 0.0f, 0.0f, 1.0f ) );
233
234 m_parametersChanged = true;
235
238}
239
240
242{
244}
245
246
247void CAMERA::SetRotationMatrix( const glm::mat4& aRotation )
248{
249 m_parametersChanged = true;
250 std::copy_n( glm::value_ptr( aRotation * glm::inverse( m_rotationMatrixAux ) ), 12,
251 glm::value_ptr( m_rotationMatrix ) );
252}
253
254
256{
257 if( ( m_windowSize.x == 0 ) || ( m_windowSize.y == 0 ) )
258 return;
259
260 m_frustum.ratio = (float) m_windowSize.x / (float)m_windowSize.y;
261 m_frustum.farD = glm::length( m_camera_pos_init ) * m_maxZoom * 2.0f;
262
263 switch( m_projectionType )
264 {
265 default:
266 case PROJECTION_TYPE::PERSPECTIVE:
267
268 m_frustum.nearD = 0.10f;
269
270 m_frustum.angle = 45.0f;
271
272 m_projectionMatrix = glm::perspective( glm::radians( m_frustum.angle ), m_frustum.ratio,
274
276
277 m_frustum.tang = glm::tan( glm::radians( m_frustum.angle ) * 0.5f );
278
279 m_focalLen.x = ( (float)m_windowSize.y / (float)m_windowSize.x ) / m_frustum.tang;
280 m_focalLen.y = 1.0f / m_frustum.tang;
281
286 break;
287
288 case PROJECTION_TYPE::ORTHO:
289
290 // Keep the viewed plane at (m_camera_pos_init * m_zoom) the same dimensions in both
291 // projections.
292 m_frustum.angle = 45.0f;
293 m_frustum.tang = glm::tan( glm::radians( m_frustum.angle ) * 0.5f );
294
295 m_frustum.nearD = -m_frustum.farD; // Use a symmetrical clip plane for ortho projection
296
297 const float orthoReductionFactor =
298 glm::length( m_camera_pos_init ) * m_zoom * m_frustum.tang;
299
300 // Initialize Projection Matrix for Orthographic View
301 m_projectionMatrix = glm::ortho( -m_frustum.ratio * orthoReductionFactor,
302 m_frustum.ratio * orthoReductionFactor,
303 -orthoReductionFactor,
304 orthoReductionFactor,
306
308
309 m_frustum.nw = orthoReductionFactor * 2.0f * m_frustum.ratio;
310 m_frustum.nh = orthoReductionFactor * 2.0f;
313
314 break;
315 }
316
317 if( ( m_windowSize.x > 0 ) && ( m_windowSize.y > 0 ) )
318 {
319 m_scr_nX.resize( m_windowSize.x + 1 );
320 m_scr_nY.resize( m_windowSize.y + 1 );
321
322 // Precalc X values for camera -> ray generation
323 for( unsigned int x = 0; x < (unsigned int)m_windowSize.x + 1; ++x )
324 {
325 // Converts 0.0 .. 1.0
326 const float xNormalizedDeviceCoordinates = ( ( (float)x + 0.5f ) /
327 (m_windowSize.x - 0.0f) );
328
329 // Converts -1.0 .. 1.0
330 m_scr_nX[x] = 2.0f * xNormalizedDeviceCoordinates - 1.0f;
331 }
332
333 // Precalc Y values for camera -> ray generation
334 for( unsigned int y = 0; y < (unsigned int)m_windowSize.y + 1 ; ++y )
335 {
336 // Converts 0.0 .. 1.0
337 const float yNormalizedDeviceCoordinates = ( ( (float)y + 0.5f ) /
338 (m_windowSize.y - 0.0f) );
339
340 // Converts -1.0 .. 1.0
341 m_scr_nY[y] = 2.0f * yNormalizedDeviceCoordinates - 1.0f;
342 }
343
345 }
346}
347
348
350{
351 // Update matrix and vectors
352 m_viewMatrixInverse = glm::inverse( m_viewMatrix );
353
354 m_right = glm::normalize( SFVEC3F( m_viewMatrixInverse *
355 glm::vec4( SFVEC3F( 1.0, 0.0, 0.0 ), 0.0 ) ) );
356
357 m_up = glm::normalize( SFVEC3F( m_viewMatrixInverse *
358 glm::vec4( SFVEC3F( 0.0, 1.0, 0.0 ), 0.0 ) ) );
359
360 m_dir = glm::normalize( SFVEC3F( m_viewMatrixInverse *
361 glm::vec4( SFVEC3F( 0.0, 0.0, 1.0 ), 0.0 ) ) );
362
363 m_pos = SFVEC3F( m_viewMatrixInverse * glm::vec4( SFVEC3F( 0.0, 0.0, 0.0 ), 1.0 ) );
364
365 /*
366 * Frustum is a implementation based on a tutorial by
367 * http://www.lighthouse3d.com/tutorials/view-frustum-culling/
368 */
369
370 const SFVEC3F half_right_nw = m_right * m_frustum.nw * 0.5f;
371 const SFVEC3F half_right_fw = m_right * m_frustum.fw * 0.5f;
372 const SFVEC3F half_up_nh = m_up * m_frustum.nh * 0.5f;
373 const SFVEC3F half_up_fh = m_up * m_frustum.fh * 0.5f;
374
375 // compute the centers of the near and far planes
378
379 // compute the 4 corners of the frustum on the near plane
380 m_frustum.ntl = m_frustum.nc + half_up_nh - half_right_nw;
381 m_frustum.ntr = m_frustum.nc + half_up_nh + half_right_nw;
382 m_frustum.nbl = m_frustum.nc - half_up_nh - half_right_nw;
383 m_frustum.nbr = m_frustum.nc - half_up_nh + half_right_nw;
384
385 // compute the 4 corners of the frustum on the far plane
386 m_frustum.ftl = m_frustum.fc + half_up_fh - half_right_fw;
387 m_frustum.ftr = m_frustum.fc + half_up_fh + half_right_fw;
388 m_frustum.fbl = m_frustum.fc - half_up_fh - half_right_fw;
389 m_frustum.fbr = m_frustum.fc - half_up_fh + half_right_fw;
390
391 if( ( m_windowSize.x > 0 ) && ( m_windowSize.y > 0 ) )
392 {
393 // Reserve size for precalc values
394 m_right_nX.resize( m_windowSize.x + 1 );
395 m_up_nY.resize( m_windowSize.y + 1 );
396
397 // Precalc X values for camera -> ray generation
398 for( unsigned int x = 0; x < ( (unsigned int) m_windowSize.x + 1 ); ++x )
399 m_right_nX[x] = half_right_nw * m_scr_nX[x];
400
401 // Precalc Y values for camera -> ray generation
402 for( unsigned int y = 0; y < ( (unsigned int) m_windowSize.y + 1 ); ++y )
403 m_up_nY[y] = half_up_nh * m_scr_nY[y];
404 }
405}
406
407
408void CAMERA::MakeRay( const SFVEC2I& aWindowPos, SFVEC3F& aOutOrigin,
409 SFVEC3F& aOutDirection ) const
410{
411 wxASSERT( aWindowPos.x < m_windowSize.x );
412 wxASSERT( aWindowPos.y < m_windowSize.y );
413
414 aOutOrigin = m_frustum.nc + m_up_nY[aWindowPos.y] + m_right_nX[aWindowPos.x];
415
416 switch( m_projectionType )
417 {
418 default:
419 case PROJECTION_TYPE::PERSPECTIVE:
420 aOutDirection = glm::normalize( aOutOrigin - m_pos );
421 break;
422
423 case PROJECTION_TYPE::ORTHO:
424 aOutDirection = -m_dir + SFVEC3F( FLT_EPSILON );
425 break;
426 }
427}
428
429
430void CAMERA::MakeRay( const SFVEC2F& aWindowPos, SFVEC3F& aOutOrigin,
431 SFVEC3F& aOutDirection ) const
432{
433 wxASSERT( aWindowPos.x < (float)m_windowSize.x );
434 wxASSERT( aWindowPos.y < (float)m_windowSize.y );
435
436 const SFVEC2F floorWinPos_f = glm::floor( aWindowPos );
437 const SFVEC2I floorWinPos_i = (SFVEC2I)floorWinPos_f;
438 const SFVEC2F relativeWinPos = aWindowPos - floorWinPos_f;
439
440 // Note: size of vectors m_up and m_right are m_windowSize + 1
441 const SFVEC3F up_plus_right = m_up_nY[floorWinPos_i.y] * (1.0f - relativeWinPos.y) +
442 m_up_nY[floorWinPos_i.y + 1] * relativeWinPos.y +
443 m_right_nX[floorWinPos_i.x] * (1.0f - relativeWinPos.x) +
444 m_right_nX[floorWinPos_i.x + 1] * relativeWinPos.x;
445
446 aOutOrigin = up_plus_right + m_frustum.nc;
447
448 switch( m_projectionType )
449 {
450 default:
451 case PROJECTION_TYPE::PERSPECTIVE:
452 aOutDirection = glm::normalize( aOutOrigin - m_pos );
453 break;
454
455 case PROJECTION_TYPE::ORTHO:
456 aOutDirection = -m_dir + SFVEC3F( FLT_EPSILON );
457 break;
458 }
459}
460
461
462void CAMERA::MakeRayAtCurrentMousePosition( SFVEC3F& aOutOrigin, SFVEC3F& aOutDirection ) const
463{
464 const SFVEC2I windowPos = SFVEC2I( m_lastPosition.x, m_windowSize.y - m_lastPosition.y );
465
466 if( ( 0 < windowPos.x ) && ( windowPos.x < m_windowSize.x ) &&
467 ( 0 < windowPos.y ) && ( windowPos.y < m_windowSize.y ) )
468 {
469 MakeRay( windowPos, aOutOrigin, aOutDirection );
470 }
471}
472
473
474const glm::mat4& CAMERA::GetProjectionMatrix() const
475{
476 return m_projectionMatrix;
477}
478
479
480const glm::mat4& CAMERA::GetProjectionMatrixInv() const
481{
483}
484
485
487{
488 return -m_camera_pos_init.z * m_frustum.tang;
489}
490
491
493{
494 m_parametersChanged = true;
495 m_camera_pos.x = 0.0f;
496 m_camera_pos.y = 0.0f;
497
500}
501
502
504{
505 m_camera_pos_t1.x = 0.0f;
506 m_camera_pos_t1.y = 0.0f;
507}
508
509
510const glm::mat4& CAMERA::GetViewMatrix() const
511{
512 return m_viewMatrix;
513}
514
515
516void CAMERA::SetViewMatrix( glm::mat4 aViewMatrix )
517{
518 SetRotationMatrix( aViewMatrix );
519
520 // The look at position in the view frame.
521 glm::vec4 lookat = aViewMatrix * glm::vec4( m_lookat_pos, 1.0f );
522
523 wxLogTrace( m_logTrace,
524 wxT( "CAMERA::SetViewMatrix aViewMatrix[3].z =%f, old_zoom=%f, new_zoom=%f, "
525 "m[3].z=%f" ),
526 aViewMatrix[3].z, m_zoom, lookat.z / m_camera_pos_init.z, lookat.z );
527
528 m_zoom = lookat.z / m_camera_pos_init.z;
529
530 if( m_zoom > m_maxZoom )
531 {
533 aViewMatrix[3].z += -lookat.z + m_maxZoom * m_camera_pos_init.z;
534 }
535 else if( m_zoom < m_minZoom )
536 {
538 aViewMatrix[3].z += -lookat.z + m_minZoom * m_camera_pos_init.z;
539 }
540
541 m_viewMatrix = std::move( aViewMatrix );
543 * glm::inverse( m_rotationMatrix * m_rotationMatrixAux
544 * glm::translate( glm::mat4( 1.0f ), -m_lookat_pos ) )[3];
545}
546
547
548const glm::mat4& CAMERA::GetViewMatrix_Inv() const
549{
550 return m_viewMatrixInverse;
551}
552
553
554void CAMERA::SetCurMousePosition( const wxPoint& aNewMousePosition )
555{
556 m_lastPosition = aNewMousePosition;
557}
558
559
561{
562 if( m_projectionType == PROJECTION_TYPE::ORTHO )
563 m_projectionType = PROJECTION_TYPE::PERSPECTIVE;
564 else
565 m_projectionType = PROJECTION_TYPE::ORTHO;
566
568}
569
570
571bool CAMERA::SetCurWindowSize( const wxSize& aSize )
572{
573 const SFVEC2I newSize = SFVEC2I( aSize.x, aSize.y );
574
575 if( m_windowSize != newSize )
576 {
577 m_windowSize = newSize;
579
580 return true;
581 }
582
583 return false;
584}
585
586
588{
589 m_zoom = 1.0f;
590
592
595}
596
597
598bool CAMERA::Zoom( float aFactor )
599{
600 if( ( m_zoom <= m_minZoom && aFactor > 1 ) || ( m_zoom >= m_maxZoom && aFactor < 1 )
601 || aFactor == 1 )
602 {
603 return false;
604 }
605
606 float zoom = m_zoom;
607 m_zoom /= aFactor;
608
609 if( m_zoom <= m_minZoom && aFactor > 1 )
610 {
611 aFactor = zoom / m_minZoom;
613 }
614 else if( m_zoom >= m_maxZoom && aFactor < 1 )
615 {
616 aFactor = zoom / m_maxZoom;
618 }
619
620 m_camera_pos.z /= aFactor;
621
624
625 return true;
626}
627
628
629bool CAMERA::Zoom_T1( float aFactor )
630{
631 if( ( m_zoom <= m_minZoom && aFactor > 1 ) || ( m_zoom >= m_maxZoom && aFactor < 1 )
632 || aFactor == 1 )
633 {
634 return false;
635 }
636
637 m_zoom_t1 = m_zoom / aFactor;
638
639 if( m_zoom_t1 < m_minZoom )
641
642 if( m_zoom_t1 > m_maxZoom )
644
646
647 return true;
648}
649
650
651void CAMERA::RotateScreen( float aAngleInRadians )
652{
653 glm::mat4 matrix = GetRotationMatrix();
654 SetRotationMatrix( glm::rotate( matrix, aAngleInRadians, GetDir() ) );
656}
657
658
659void CAMERA::RotateX( float aAngleInRadians )
660{
661 m_rotate_aux.x += aAngleInRadians;
663}
664
665
666void CAMERA::RotateY( float aAngleInRadians )
667{
668 m_rotate_aux.y += aAngleInRadians;
670}
671
672
673void CAMERA::RotateZ( float aAngleInRadians )
674{
675 m_rotate_aux.z += aAngleInRadians;
677}
678
679
680void CAMERA::RotateX_T1( float aAngleInRadians )
681{
682 m_rotate_aux_t1.x += aAngleInRadians;
683}
684
685
686void CAMERA::RotateY_T1( float aAngleInRadians )
687{
688 m_rotate_aux_t1.y += aAngleInRadians;
689}
690
691
692void CAMERA::RotateZ_T1( float aAngleInRadians )
693{
694 m_rotate_aux_t1.z += aAngleInRadians;
695}
696
697
699{
704
709}
710
711
712void CAMERA::Interpolate( float t )
713{
714 wxASSERT( t >= 0.0f );
715
716 const float t0 = 1.0f - t;
717
721 m_zoom = m_zoom_t0 * t0 + m_zoom_t1 * t;
722
723 m_parametersChanged = true;
724
727}
728
729
731{
732 const bool parametersChanged = m_parametersChanged;
733
734 m_parametersChanged = false;
735
736 return parametersChanged;
737}
declared enumerations and flags
VIEW3D_TYPE
Definition: 3d_enums.h:78
void normalise2PI(float &aAngle)
Definition: camera.cpp:35
Define an abstract camera.
PROJECTION_TYPE
Definition: camera.h:40
A class used to derive camera objects from.
Definition: camera.h:103
glm::mat4 GetRotationMatrix() const
Get the rotation matrix to be applied in a transformation camera.
Definition: camera.cpp:241
float m_zoom_t0
Definition: camera.h:323
bool m_parametersChanged
Set to true if any of the parameters in the camera was changed.
Definition: camera.h:391
void RotateY(float aAngleInRadians)
Definition: camera.cpp:666
glm::mat4 m_projectionMatrixInv
Definition: camera.h:347
void RotateX(float aAngleInRadians)
Definition: camera.cpp:659
SFVEC3F m_lookat_pos
Definition: camera.h:364
const glm::mat4 & GetProjectionMatrix() const
Definition: camera.cpp:474
void SetBoardLookAtPos(const SFVEC3F &aBoardPos)
Definition: camera.cpp:182
bool Zoom(float aFactor)
Definition: camera.cpp:598
SFVEC3F m_camera_pos_t0
Definition: camera.h:361
void RotateY_T1(float aAngleInRadians)
Definition: camera.cpp:686
virtual void Reset()
Reset the camera to initial state.
Definition: camera.cpp:78
SFVEC3F m_right
Definition: camera.h:352
glm::mat4 m_projectionMatrix
Definition: camera.h:346
CAMERA_INTERPOLATION m_interpolation_mode
Definition: camera.h:373
SFVEC3F m_rotate_aux_t1
Definition: camera.h:371
wxPoint m_lastPosition
The last mouse position in the screen.
Definition: camera.h:340
void ZoomReset()
Definition: camera.cpp:587
void ResetXYpos()
Definition: camera.cpp:492
void RotateScreen(float aAngleInRadians)
Rotates the camera in screen plane.
Definition: camera.cpp:651
const glm::mat4 & GetViewMatrix_Inv() const
Definition: camera.cpp:548
bool Zoom_T1(float aFactor)
Definition: camera.cpp:629
static const float DEFAULT_MIN_ZOOM
Definition: camera.h:105
void updateRotationMatrix()
Definition: camera.cpp:220
SFVEC3F m_rotate_aux_t0
Definition: camera.h:370
virtual void Reset_T1()
Definition: camera.cpp:161
void MakeRay(const SFVEC2I &aWindowPos, SFVEC3F &aOutOrigin, SFVEC3F &aOutDirection) const
Make a ray based on a windows screen position.
Definition: camera.cpp:408
static const float DEFAULT_MAX_ZOOM
Definition: camera.h:106
virtual void Interpolate(float t)
It will update the matrix to interpolate between T0 and T1 values.
Definition: camera.cpp:712
SFVEC3F m_dir
Definition: camera.h:354
bool SetCurWindowSize(const wxSize &aSize)
Update the windows size of the camera.
Definition: camera.cpp:571
SFVEC3F m_camera_pos_init
Definition: camera.h:359
CAMERA(float aInitialDistance)
Initialize a camera.
Definition: camera.cpp:54
const glm::mat4 & GetProjectionMatrixInv() const
Definition: camera.cpp:480
void ResetXYpos_T1()
Definition: camera.cpp:503
float m_minZoom
Possible 3D zoom range.
Definition: camera.h:329
float GetCameraMinDimension() const
Definition: camera.cpp:486
bool ViewCommand_T1(VIEW3D_TYPE aRequestedView)
Definition: camera.cpp:110
float m_maxZoom
Definition: camera.h:330
std::vector< SFVEC3F > m_right_nX
Precalc values array used to calc ray for each pixel, for X and Y axis of each new camera position.
Definition: camera.h:385
void rebuildProjection()
Definition: camera.cpp:255
float m_zoom_t1
Definition: camera.h:324
SFVEC3F m_lookat_pos_t1
Definition: camera.h:366
CAMERA_FRUSTUM m_frustum
Definition: camera.h:350
void updateFrustum()
Definition: camera.cpp:349
SFVEC3F m_lookat_pos_t0
Definition: camera.h:365
void RotateZ(float aAngleInRadians)
Definition: camera.cpp:673
virtual void SetT0_and_T1_current_T()
This will set T0 and T1 with the current values.
Definition: camera.cpp:698
SFVEC3F m_camera_pos
Definition: camera.h:360
PROJECTION_TYPE m_projectionType
Definition: camera.h:348
SFVEC3F m_pos
Definition: camera.h:355
void ToggleProjection()
Definition: camera.cpp:560
SFVEC2I m_windowSize
The window size that this camera is working.
Definition: camera.h:335
void MakeRayAtCurrentMousePosition(SFVEC3F &aOutOrigin, SFVEC3F &aOutDirection) const
Make a ray based on the latest mouse position.
Definition: camera.cpp:462
SFVEC2F m_focalLen
Definition: camera.h:357
void updateViewMatrix()
Definition: camera.cpp:212
std::vector< float > m_scr_nX
Precalc values array used to calc ray for each pixel (constant for the same window size).
Definition: camera.h:378
void RotateX_T1(float aAngleInRadians)
Definition: camera.cpp:680
const glm::mat4 & GetViewMatrix() const
Definition: camera.cpp:510
glm::mat4 m_viewMatrixInverse
Definition: camera.h:345
SFVEC3F m_up
Definition: camera.h:353
const SFVEC3F & GetDir() const
Definition: camera.h:135
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliary.
Definition: camera.h:369
glm::mat4 m_rotationMatrixAux
Definition: camera.h:343
glm::mat4 m_rotationMatrix
Definition: camera.h:342
std::vector< float > m_scr_nY
Definition: camera.h:379
void SetViewMatrix(glm::mat4 aViewMatrix)
Set the affine matrix to be applied to a transformation camera.
Definition: camera.cpp:516
void RotateZ_T1(float aAngleInRadians)
Definition: camera.cpp:692
glm::mat4 m_viewMatrix
Definition: camera.h:344
SFVEC3F m_board_lookat_pos_init
Default boardlookat position (the board center).
Definition: camera.h:367
std::vector< SFVEC3F > m_up_nY
Definition: camera.h:386
bool ParametersChanged()
Definition: camera.cpp:730
void SetRotationMatrix(const glm::mat4 &aRotation)
Set the rotation matrix to be applied in a transformation camera, without making any new calculations...
Definition: camera.cpp:247
SFVEC3F m_camera_pos_t1
Definition: camera.h:362
float m_zoom
3D zoom value – Z-distance is scaled by it
Definition: camera.h:322
void zoomChanged()
Definition: camera.cpp:197
void SetCurMousePosition(const wxPoint &aPosition)
Update the current mouse position without make any new calculations on camera.
Definition: camera.cpp:554
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
Definition: camera.h:400
SFVEC3F ntr
Near Top Right.
Definition: camera.h:54
SFVEC3F ntl
Near Top Left.
Definition: camera.h:53
SFVEC3F fc
Definition: camera.h:52
float angle
Definition: camera.h:61
float ratio
Definition: camera.h:61
float fh
Definition: camera.h:62
float nh
Definition: camera.h:62
SFVEC3F ftl
Far Top Left.
Definition: camera.h:57
SFVEC3F fbr
Far Bottom Right.
Definition: camera.h:60
float fw
Definition: camera.h:62
float farD
Definition: camera.h:61
SFVEC3F nbl
Near Bottom Left.
Definition: camera.h:55
SFVEC3F nc
Definition: camera.h:51
SFVEC3F nbr
Near Bottom Right.
Definition: camera.h:56
float nw
Definition: camera.h:62
SFVEC3F fbl
Far Bottom Left.
Definition: camera.h:59
float tang
Definition: camera.h:61
float nearD
Definition: camera.h:61
SFVEC3F ftr
Far Top Right.
Definition: camera.h:58
glm::ivec2 SFVEC2I
Definition: xv3d_types.h:39
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44