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 (C) 2015-2024 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 projections.
291 m_frustum.angle = 45.0f;
292 m_frustum.tang = glm::tan( glm::radians( m_frustum.angle ) * 0.5f );
293
294 m_frustum.nearD = -m_frustum.farD; // Use a symmetrical clip plane for ortho projection
295
296 const float orthoReductionFactor =
297 glm::length( m_camera_pos_init ) * m_zoom * m_frustum.tang;
298
299 // Initialize Projection Matrix for Orthographic View
300 m_projectionMatrix = glm::ortho( -m_frustum.ratio * orthoReductionFactor,
301 m_frustum.ratio * orthoReductionFactor,
302 -orthoReductionFactor,
303 orthoReductionFactor,
305
307
308 m_frustum.nw = orthoReductionFactor * 2.0f * m_frustum.ratio;
309 m_frustum.nh = orthoReductionFactor * 2.0f;
312
313 break;
314 }
315
316 if( ( m_windowSize.x > 0 ) && ( m_windowSize.y > 0 ) )
317 {
318 m_scr_nX.resize( m_windowSize.x + 1 );
319 m_scr_nY.resize( m_windowSize.y + 1 );
320
321 // Precalc X values for camera -> ray generation
322 for( unsigned int x = 0; x < (unsigned int)m_windowSize.x + 1; ++x )
323 {
324 // Converts 0.0 .. 1.0
325 const float xNormalizedDeviceCoordinates = ( ( (float)x + 0.5f ) /
326 (m_windowSize.x - 0.0f) );
327
328 // Converts -1.0 .. 1.0
329 m_scr_nX[x] = 2.0f * xNormalizedDeviceCoordinates - 1.0f;
330 }
331
332 // Precalc Y values for camera -> ray generation
333 for( unsigned int y = 0; y < (unsigned int)m_windowSize.y + 1 ; ++y )
334 {
335 // Converts 0.0 .. 1.0
336 const float yNormalizedDeviceCoordinates = ( ( (float)y + 0.5f ) /
337 (m_windowSize.y - 0.0f) );
338
339 // Converts -1.0 .. 1.0
340 m_scr_nY[y] = 2.0f * yNormalizedDeviceCoordinates - 1.0f;
341 }
342
344 }
345}
346
347
349{
350 // Update matrix and vectors
351 m_viewMatrixInverse = glm::inverse( m_viewMatrix );
352
353 m_right = glm::normalize( SFVEC3F( m_viewMatrixInverse *
354 glm::vec4( SFVEC3F( 1.0, 0.0, 0.0 ), 0.0 ) ) );
355
356 m_up = glm::normalize( SFVEC3F( m_viewMatrixInverse *
357 glm::vec4( SFVEC3F( 0.0, 1.0, 0.0 ), 0.0 ) ) );
358
359 m_dir = glm::normalize( SFVEC3F( m_viewMatrixInverse *
360 glm::vec4( SFVEC3F( 0.0, 0.0, 1.0 ), 0.0 ) ) );
361
362 m_pos = SFVEC3F( m_viewMatrixInverse * glm::vec4( SFVEC3F( 0.0, 0.0, 0.0 ), 1.0 ) );
363
364 /*
365 * Frustum is a implementation based on a tutorial by
366 * http://www.lighthouse3d.com/tutorials/view-frustum-culling/
367 */
368
369 const SFVEC3F half_right_nw = m_right * m_frustum.nw * 0.5f;
370 const SFVEC3F half_right_fw = m_right * m_frustum.fw * 0.5f;
371 const SFVEC3F half_up_nh = m_up * m_frustum.nh * 0.5f;
372 const SFVEC3F half_up_fh = m_up * m_frustum.fh * 0.5f;
373
374 // compute the centers of the near and far planes
377
378 // compute the 4 corners of the frustum on the near plane
379 m_frustum.ntl = m_frustum.nc + half_up_nh - half_right_nw;
380 m_frustum.ntr = m_frustum.nc + half_up_nh + half_right_nw;
381 m_frustum.nbl = m_frustum.nc - half_up_nh - half_right_nw;
382 m_frustum.nbr = m_frustum.nc - half_up_nh + half_right_nw;
383
384 // compute the 4 corners of the frustum on the far plane
385 m_frustum.ftl = m_frustum.fc + half_up_fh - half_right_fw;
386 m_frustum.ftr = m_frustum.fc + half_up_fh + half_right_fw;
387 m_frustum.fbl = m_frustum.fc - half_up_fh - half_right_fw;
388 m_frustum.fbr = m_frustum.fc - half_up_fh + half_right_fw;
389
390 if( ( m_windowSize.x > 0 ) && ( m_windowSize.y > 0 ) )
391 {
392 // Reserve size for precalc values
393 m_right_nX.resize( m_windowSize.x + 1 );
394 m_up_nY.resize( m_windowSize.y + 1 );
395
396 // Precalc X values for camera -> ray generation
397 for( unsigned int x = 0; x < ( (unsigned int) m_windowSize.x + 1 ); ++x )
398 m_right_nX[x] = half_right_nw * m_scr_nX[x];
399
400 // Precalc Y values for camera -> ray generation
401 for( unsigned int y = 0; y < ( (unsigned int) m_windowSize.y + 1 ); ++y )
402 m_up_nY[y] = half_up_nh * m_scr_nY[y];
403 }
404}
405
406
407void CAMERA::MakeRay( const SFVEC2I& aWindowPos, SFVEC3F& aOutOrigin,
408 SFVEC3F& aOutDirection ) const
409{
410 wxASSERT( aWindowPos.x < m_windowSize.x );
411 wxASSERT( aWindowPos.y < m_windowSize.y );
412
413 aOutOrigin = m_frustum.nc + m_up_nY[aWindowPos.y] + m_right_nX[aWindowPos.x];
414
415 switch( m_projectionType )
416 {
417 default:
418 case PROJECTION_TYPE::PERSPECTIVE:
419 aOutDirection = glm::normalize( aOutOrigin - m_pos );
420 break;
421
422 case PROJECTION_TYPE::ORTHO:
423 aOutDirection = -m_dir + SFVEC3F( FLT_EPSILON );
424 break;
425 }
426}
427
428
429void CAMERA::MakeRay( const SFVEC2F& aWindowPos, SFVEC3F& aOutOrigin,
430 SFVEC3F& aOutDirection ) const
431{
432 wxASSERT( aWindowPos.x < (float)m_windowSize.x );
433 wxASSERT( aWindowPos.y < (float)m_windowSize.y );
434
435 const SFVEC2F floorWinPos_f = glm::floor( aWindowPos );
436 const SFVEC2I floorWinPos_i = (SFVEC2I)floorWinPos_f;
437 const SFVEC2F relativeWinPos = aWindowPos - floorWinPos_f;
438
439 // Note: size of vectors m_up and m_right are m_windowSize + 1
440 const SFVEC3F up_plus_right = m_up_nY[floorWinPos_i.y] * (1.0f - relativeWinPos.y) +
441 m_up_nY[floorWinPos_i.y + 1] * relativeWinPos.y +
442 m_right_nX[floorWinPos_i.x] * (1.0f - relativeWinPos.x) +
443 m_right_nX[floorWinPos_i.x + 1] * relativeWinPos.x;
444
445 aOutOrigin = up_plus_right + m_frustum.nc;
446
447 switch( m_projectionType )
448 {
449 default:
450 case PROJECTION_TYPE::PERSPECTIVE:
451 aOutDirection = glm::normalize( aOutOrigin - m_pos );
452 break;
453
454 case PROJECTION_TYPE::ORTHO:
455 aOutDirection = -m_dir + SFVEC3F( FLT_EPSILON );
456 break;
457 }
458}
459
460
461void CAMERA::MakeRayAtCurrentMousePosition( SFVEC3F& aOutOrigin, SFVEC3F& aOutDirection ) const
462{
463 const SFVEC2I windowPos = SFVEC2I( m_lastPosition.x, m_windowSize.y - m_lastPosition.y );
464
465 if( ( 0 < windowPos.x ) && ( windowPos.x < m_windowSize.x ) &&
466 ( 0 < windowPos.y ) && ( windowPos.y < m_windowSize.y ) )
467 {
468 MakeRay( windowPos, aOutOrigin, aOutDirection );
469 }
470}
471
472
473const glm::mat4& CAMERA::GetProjectionMatrix() const
474{
475 return m_projectionMatrix;
476}
477
478
479const glm::mat4& CAMERA::GetProjectionMatrixInv() const
480{
482}
483
484
486{
487 return -m_camera_pos_init.z * m_frustum.tang;
488}
489
490
492{
493 m_parametersChanged = true;
494 m_camera_pos.x = 0.0f;
495 m_camera_pos.y = 0.0f;
496
499}
500
501
503{
504 m_camera_pos_t1.x = 0.0f;
505 m_camera_pos_t1.y = 0.0f;
506}
507
508
509const glm::mat4& CAMERA::GetViewMatrix() const
510{
511 return m_viewMatrix;
512}
513
514
515void CAMERA::SetViewMatrix( glm::mat4 aViewMatrix )
516{
517 SetRotationMatrix( aViewMatrix );
518
519 // The look at position in the view frame.
520 glm::vec4 lookat = aViewMatrix * glm::vec4( m_lookat_pos, 1.0f );
521
522 wxLogTrace( m_logTrace,
523 wxT( "CAMERA::SetViewMatrix aViewMatrix[3].z =%f, old_zoom=%f, new_zoom=%f, "
524 "m[3].z=%f" ),
525 aViewMatrix[3].z, m_zoom, lookat.z / m_camera_pos_init.z, lookat.z );
526
527 m_zoom = lookat.z / m_camera_pos_init.z;
528
529 if( m_zoom > m_maxZoom )
530 {
532 aViewMatrix[3].z += -lookat.z + m_maxZoom * m_camera_pos_init.z;
533 }
534 else if( m_zoom < m_minZoom )
535 {
537 aViewMatrix[3].z += -lookat.z + m_minZoom * m_camera_pos_init.z;
538 }
539
540 m_viewMatrix = std::move( aViewMatrix );
542 * glm::inverse( m_rotationMatrix * m_rotationMatrixAux
543 * glm::translate( glm::mat4( 1.0f ), -m_lookat_pos ) )[3];
544}
545
546
547const glm::mat4& CAMERA::GetViewMatrix_Inv() const
548{
549 return m_viewMatrixInverse;
550}
551
552
553void CAMERA::SetCurMousePosition( const wxPoint& aNewMousePosition )
554{
555 m_lastPosition = aNewMousePosition;
556}
557
558
560{
561 if( m_projectionType == PROJECTION_TYPE::ORTHO )
562 m_projectionType = PROJECTION_TYPE::PERSPECTIVE;
563 else
564 m_projectionType = PROJECTION_TYPE::ORTHO;
565
567}
568
569
570bool CAMERA::SetCurWindowSize( const wxSize& aSize )
571{
572 const SFVEC2I newSize = SFVEC2I( aSize.x, aSize.y );
573
574 if( m_windowSize != newSize )
575 {
576 m_windowSize = newSize;
578
579 return true;
580 }
581
582 return false;
583}
584
585
587{
588 m_zoom = 1.0f;
589
591
594}
595
596
597bool CAMERA::Zoom( float aFactor )
598{
599 if( ( m_zoom <= m_minZoom && aFactor > 1 ) || ( m_zoom >= m_maxZoom && aFactor < 1 )
600 || aFactor == 1 )
601 {
602 return false;
603 }
604
605 float zoom = m_zoom;
606 m_zoom /= aFactor;
607
608 if( m_zoom <= m_minZoom && aFactor > 1 )
609 {
610 aFactor = zoom / m_minZoom;
612 }
613 else if( m_zoom >= m_maxZoom && aFactor < 1 )
614 {
615 aFactor = zoom / m_maxZoom;
617 }
618
619 m_camera_pos.z /= aFactor;
620
623
624 return true;
625}
626
627
628bool CAMERA::Zoom_T1( float aFactor )
629{
630 if( ( m_zoom <= m_minZoom && aFactor > 1 ) || ( m_zoom >= m_maxZoom && aFactor < 1 )
631 || aFactor == 1 )
632 {
633 return false;
634 }
635
636 m_zoom_t1 = m_zoom / aFactor;
637
638 if( m_zoom_t1 < m_minZoom )
640
641 if( m_zoom_t1 > m_maxZoom )
643
645
646 return true;
647}
648
649
650void CAMERA::RotateScreen( float aAngleInRadians )
651{
652 glm::mat4 matrix = GetRotationMatrix();
653 SetRotationMatrix( glm::rotate( matrix, aAngleInRadians, GetDir() ) );
655}
656
657
658void CAMERA::RotateX( float aAngleInRadians )
659{
660 m_rotate_aux.x += aAngleInRadians;
662}
663
664
665void CAMERA::RotateY( float aAngleInRadians )
666{
667 m_rotate_aux.y += aAngleInRadians;
669}
670
671
672void CAMERA::RotateZ( float aAngleInRadians )
673{
674 m_rotate_aux.z += aAngleInRadians;
676}
677
678
679void CAMERA::RotateX_T1( float aAngleInRadians )
680{
681 m_rotate_aux_t1.x += aAngleInRadians;
682}
683
684
685void CAMERA::RotateY_T1( float aAngleInRadians )
686{
687 m_rotate_aux_t1.y += aAngleInRadians;
688}
689
690
691void CAMERA::RotateZ_T1( float aAngleInRadians )
692{
693 m_rotate_aux_t1.z += aAngleInRadians;
694}
695
696
698{
703
708}
709
710
711void CAMERA::Interpolate( float t )
712{
713 wxASSERT( t >= 0.0f );
714
715 const float t0 = 1.0f - t;
716
720 m_zoom = m_zoom_t0 * t0 + m_zoom_t1 * t;
721
722 m_parametersChanged = true;
723
726}
727
728
730{
731 const bool parametersChanged = m_parametersChanged;
732
733 m_parametersChanged = false;
734
735 return parametersChanged;
736}
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:665
glm::mat4 m_projectionMatrixInv
Definition: camera.h:347
void RotateX(float aAngleInRadians)
Definition: camera.cpp:658
SFVEC3F m_lookat_pos
Definition: camera.h:364
const glm::mat4 & GetProjectionMatrix() const
Definition: camera.cpp:473
void SetBoardLookAtPos(const SFVEC3F &aBoardPos)
Definition: camera.cpp:182
bool Zoom(float aFactor)
Definition: camera.cpp:597
SFVEC3F m_camera_pos_t0
Definition: camera.h:361
void RotateY_T1(float aAngleInRadians)
Definition: camera.cpp:685
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:586
void ResetXYpos()
Definition: camera.cpp:491
void RotateScreen(float aAngleInRadians)
Rotates the camera in screen plane.
Definition: camera.cpp:650
const glm::mat4 & GetViewMatrix_Inv() const
Definition: camera.cpp:547
bool Zoom_T1(float aFactor)
Definition: camera.cpp:628
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:407
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:711
SFVEC3F m_dir
Definition: camera.h:354
bool SetCurWindowSize(const wxSize &aSize)
Update the windows size of the camera.
Definition: camera.cpp:570
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:479
void ResetXYpos_T1()
Definition: camera.cpp:502
float m_minZoom
Possible 3D zoom range.
Definition: camera.h:329
float GetCameraMinDimension() const
Definition: camera.cpp:485
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:348
SFVEC3F m_lookat_pos_t0
Definition: camera.h:365
void RotateZ(float aAngleInRadians)
Definition: camera.cpp:672
virtual void SetT0_and_T1_current_T()
This will set T0 and T1 with the current values.
Definition: camera.cpp:697
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:559
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:461
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:679
const glm::mat4 & GetViewMatrix() const
Definition: camera.cpp:509
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:515
void RotateZ_T1(float aAngleInRadians)
Definition: camera.cpp:691
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:729
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:553
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