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, see <https://www.gnu.org/licenses/>.
19 */
20
24
25#include <gal/3d/camera.h>
26#include <wx/log.h>
27#include <algorithm>
28#include <3d_enums.h>
29
30// A helper function to normalize aAngle between -2PI and +2PI
31inline void normalise2PI( float& aAngle )
32{
33 while( aAngle > 0.0 )
34 aAngle -= static_cast<float>( M_PI * 2.0f );
35
36 while( aAngle < 0.0 )
37 aAngle += static_cast<float>( M_PI * 2.0f );
38}
39
40
44const wxChar *CAMERA::m_logTrace = wxT( "KI_TRACE_CAMERA" );
45
46const float CAMERA::DEFAULT_MIN_ZOOM = 0.020f;
47const float CAMERA::DEFAULT_MAX_ZOOM = 2.0f;
48
49
50CAMERA::CAMERA( float aInitialDistance ) :
51 CAMERA( SFVEC3F( 0.0f, 0.0f, -aInitialDistance ), SFVEC3F( 0.0f ),
53{
54}
55
56
57CAMERA::CAMERA( SFVEC3F aInitPos, SFVEC3F aLookat, PROJECTION_TYPE aProjectionType )
58{
59 wxLogTrace( m_logTrace, wxT( "CAMERA::CAMERA" ) );
60
61 m_camera_pos_init = aInitPos;
63 m_windowSize = SFVEC2I( 0, 0 );
64 m_projectionType = aProjectionType;
66
69
70 Reset();
71}
72
73
75{
77 m_projectionMatrix = glm::mat4( 1.0f );
78 m_projectionMatrixInv = glm::mat4( 1.0f );
79 m_rotationMatrix = glm::mat4( 1.0f );
80 m_rotationMatrixAux = glm::mat4( 1.0f );
81 m_lastPosition = wxPoint( 0, 0 );
82
83 m_zoom = 1.0f;
84 m_zoom_t0 = 1.0f;
85 m_zoom_t1 = 1.0f;
92
93 m_rotate_aux = SFVEC3F( 0.0f );
94 m_rotate_aux_t0 = SFVEC3F( 0.0f );
95 m_rotate_aux_t1 = SFVEC3F( 0.0f );
96
99 m_viewMatrixInverse = glm::inverse( m_viewMatrix );
100 m_scr_nX.clear();
101 m_scr_nY.clear();
103}
104
105
107{
108 switch( aRequestedView )
109 {
112 Reset_T1();
113 RotateZ_T1( glm::radians( -90.0f ) );
114 RotateX_T1( glm::radians( -90.0f ) );
115 return true;
116
118 Reset_T1();
119 RotateZ_T1( glm::radians( 90.0f ) );
120 RotateX_T1( glm::radians( -90.0f ) );
121 return true;
122
124 Reset_T1();
125 RotateX_T1( glm::radians( -90.0f ) );
126 return true;
127
129 Reset_T1();
130 RotateX_T1( glm::radians( -90.0f ) );
131
132 // The rotation angle should be 180.
133 // We use 179.999 (180 - epsilon) to avoid a full 360 deg rotation when
134 // using 180 deg if the previous rotated position was already 180 deg
135 RotateZ_T1( glm::radians( 179.999f ) );
136 return true;
137
139 Reset_T1();
140 return true;
141
143 Reset_T1();
144 RotateY_T1( glm::radians( 179.999f ) ); // Rotation = 180 - epsilon
145 return true;
146
148 RotateY_T1( glm::radians( 179.999f ) );
149 return true;
150
151 default:
152 return false;
153 }
154}
155
156
158{
160 m_zoom_t1 = 1.0f;
161 m_rotate_aux_t1 = SFVEC3F( 0.0f );
163
164 // Since 0 = 2pi, we want to reset the angle to be the closest
165 // one to where we currently are. That ensures that we rotate
166 // the board around the smallest distance getting there.
167 if( m_rotate_aux_t0.x > M_PI )
168 m_rotate_aux_t1.x = static_cast<float>( 2.0f * M_PI );
169
170 if( m_rotate_aux_t0.y > M_PI )
171 m_rotate_aux_t1.y = static_cast<float>( 2.0f * M_PI );
172
173 if( m_rotate_aux_t0.z > M_PI )
174 m_rotate_aux_t1.z = static_cast<float>( 2.0f * M_PI );
175}
176
177
178void CAMERA::SetBoardLookAtPos( const SFVEC3F& aBoardPos )
179{
180 if( m_board_lookat_pos_init != aBoardPos )
181 {
182 m_board_lookat_pos_init = aBoardPos;
183 m_lookat_pos = aBoardPos;
184
185 m_parametersChanged = true;
186
189 }
190}
191
192
194{
195 if( m_zoom < m_minZoom )
197
198 if( m_zoom > m_maxZoom )
200
202
205}
206
207
209{
210 m_viewMatrix = glm::translate( glm::mat4( 1.0f ), m_camera_pos ) *
212 glm::translate( glm::mat4( 1.0f ), -m_lookat_pos );
213}
214
215
217{
218 m_rotationMatrixAux = glm::rotate( glm::mat4( 1.0f ), m_rotate_aux.x,
219 SFVEC3F( 1.0f, 0.0f, 0.0f ) );
221
223 SFVEC3F( 0.0f, 1.0f, 0.0f ) );
225
227 SFVEC3F( 0.0f, 0.0f, 1.0f ) );
229
230 m_parametersChanged = true;
231
234}
235
236
238{
240}
241
242
243void CAMERA::SetRotationMatrix( const glm::mat4& aRotation )
244{
245 m_parametersChanged = true;
246 std::copy_n( glm::value_ptr( aRotation * glm::inverse( m_rotationMatrixAux ) ), 12,
247 glm::value_ptr( m_rotationMatrix ) );
248}
249
250
252{
253 if( ( m_windowSize.x == 0 ) || ( m_windowSize.y == 0 ) )
254 return;
255
256 m_frustum.ratio = (float) m_windowSize.x / (float)m_windowSize.y;
257 m_frustum.farD = glm::length( m_camera_pos_init ) * m_maxZoom * 2.0f;
258
259 switch( m_projectionType )
260 {
261 default:
263
264 m_frustum.nearD = 0.10f;
265
266 m_frustum.angle = 45.0f;
267
268 m_projectionMatrix = glm::perspective( glm::radians( m_frustum.angle ), m_frustum.ratio,
269 m_frustum.nearD, m_frustum.farD );
270
272
273 m_frustum.tang = glm::tan( glm::radians( m_frustum.angle ) * 0.5f );
274
275 m_focalLen.x = ( (float)m_windowSize.y / (float)m_windowSize.x ) / m_frustum.tang;
276 m_focalLen.y = 1.0f / m_frustum.tang;
277
278 m_frustum.nh = 2.0f * m_frustum.nearD * m_frustum.tang;
279 m_frustum.nw = m_frustum.nh * m_frustum.ratio;
280 m_frustum.fh = 2.0f * m_frustum.farD * m_frustum.tang;
281 m_frustum.fw = m_frustum.fh * m_frustum.ratio;
282 break;
283
285
286 // Keep the viewed plane at (m_camera_pos_init * m_zoom) the same dimensions in both
287 // projections.
288 m_frustum.angle = 45.0f;
289 m_frustum.tang = glm::tan( glm::radians( m_frustum.angle ) * 0.5f );
290
291 m_frustum.nearD = -m_frustum.farD; // Use a symmetrical clip plane for ortho projection
292
293 const float orthoReductionFactor =
294 glm::length( m_camera_pos_init ) * m_zoom * m_frustum.tang;
295
296 // Initialize Projection Matrix for Orthographic View
297 m_projectionMatrix = glm::ortho( -m_frustum.ratio * orthoReductionFactor,
298 m_frustum.ratio * orthoReductionFactor,
299 -orthoReductionFactor,
300 orthoReductionFactor,
301 m_frustum.nearD, m_frustum.farD );
302
304
305 m_frustum.nw = orthoReductionFactor * 2.0f * m_frustum.ratio;
306 m_frustum.nh = orthoReductionFactor * 2.0f;
307 m_frustum.fw = m_frustum.nw;
308 m_frustum.fh = m_frustum.nh;
309
310 break;
311 }
312
313 if( ( m_windowSize.x > 0 ) && ( m_windowSize.y > 0 ) )
314 {
315 m_scr_nX.resize( m_windowSize.x + 1 );
316 m_scr_nY.resize( m_windowSize.y + 1 );
317
318 // Precalc X values for camera -> ray generation
319 for( unsigned int x = 0; x < (unsigned int)m_windowSize.x + 1; ++x )
320 {
321 // Converts 0.0 .. 1.0
322 const float xNormalizedDeviceCoordinates = ( ( (float)x + 0.5f ) /
323 (m_windowSize.x - 0.0f) );
324
325 // Converts -1.0 .. 1.0
326 m_scr_nX[x] = 2.0f * xNormalizedDeviceCoordinates - 1.0f;
327 }
328
329 // Precalc Y values for camera -> ray generation
330 for( unsigned int y = 0; y < (unsigned int)m_windowSize.y + 1 ; ++y )
331 {
332 // Converts 0.0 .. 1.0
333 const float yNormalizedDeviceCoordinates = ( ( (float)y + 0.5f ) /
334 (m_windowSize.y - 0.0f) );
335
336 // Converts -1.0 .. 1.0
337 m_scr_nY[y] = 2.0f * yNormalizedDeviceCoordinates - 1.0f;
338 }
339
341 }
342}
343
344
346{
347 // Update matrix and vectors
348 m_viewMatrixInverse = glm::inverse( m_viewMatrix );
349
350 m_right = glm::normalize( SFVEC3F( m_viewMatrixInverse *
351 glm::vec4( SFVEC3F( 1.0, 0.0, 0.0 ), 0.0 ) ) );
352
353 m_up = glm::normalize( SFVEC3F( m_viewMatrixInverse *
354 glm::vec4( SFVEC3F( 0.0, 1.0, 0.0 ), 0.0 ) ) );
355
356 m_dir = glm::normalize( SFVEC3F( m_viewMatrixInverse *
357 glm::vec4( SFVEC3F( 0.0, 0.0, 1.0 ), 0.0 ) ) );
358
359 m_pos = SFVEC3F( m_viewMatrixInverse * glm::vec4( SFVEC3F( 0.0, 0.0, 0.0 ), 1.0 ) );
360
361 /*
362 * Frustum is a implementation based on a tutorial by
363 * http://www.lighthouse3d.com/tutorials/view-frustum-culling/
364 */
365
366 const SFVEC3F half_right_nw = m_right * m_frustum.nw * 0.5f;
367 const SFVEC3F half_right_fw = m_right * m_frustum.fw * 0.5f;
368 const SFVEC3F half_up_nh = m_up * m_frustum.nh * 0.5f;
369 const SFVEC3F half_up_fh = m_up * m_frustum.fh * 0.5f;
370
371 // compute the centers of the near and far planes
372 m_frustum.nc = m_pos - m_dir * m_frustum.nearD;
373 m_frustum.fc = m_pos - m_dir * m_frustum.farD;
374
375 // compute the 4 corners of the frustum on the near plane
376 m_frustum.ntl = m_frustum.nc + half_up_nh - half_right_nw;
377 m_frustum.ntr = m_frustum.nc + half_up_nh + half_right_nw;
378 m_frustum.nbl = m_frustum.nc - half_up_nh - half_right_nw;
379 m_frustum.nbr = m_frustum.nc - half_up_nh + half_right_nw;
380
381 // compute the 4 corners of the frustum on the far plane
382 m_frustum.ftl = m_frustum.fc + half_up_fh - half_right_fw;
383 m_frustum.ftr = m_frustum.fc + half_up_fh + half_right_fw;
384 m_frustum.fbl = m_frustum.fc - half_up_fh - half_right_fw;
385 m_frustum.fbr = m_frustum.fc - half_up_fh + half_right_fw;
386
387 if( ( m_windowSize.x > 0 ) && ( m_windowSize.y > 0 ) )
388 {
389 // Reserve size for precalc values
390 m_right_nX.resize( m_windowSize.x + 1 );
391 m_up_nY.resize( m_windowSize.y + 1 );
392
393 // Precalc X values for camera -> ray generation
394 for( unsigned int x = 0; x < ( (unsigned int) m_windowSize.x + 1 ); ++x )
395 m_right_nX[x] = half_right_nw * m_scr_nX[x];
396
397 // Precalc Y values for camera -> ray generation
398 for( unsigned int y = 0; y < ( (unsigned int) m_windowSize.y + 1 ); ++y )
399 m_up_nY[y] = half_up_nh * m_scr_nY[y];
400 }
401}
402
403
404void CAMERA::MakeRay( const SFVEC2I& aWindowPos, SFVEC3F& aOutOrigin,
405 SFVEC3F& aOutDirection ) const
406{
407 wxASSERT( aWindowPos.x < m_windowSize.x );
408 wxASSERT( aWindowPos.y < m_windowSize.y );
409
410 aOutOrigin = m_frustum.nc + m_up_nY[aWindowPos.y] + m_right_nX[aWindowPos.x];
411
412 switch( m_projectionType )
413 {
414 default:
416 aOutDirection = glm::normalize( aOutOrigin - m_pos );
417 break;
418
420 aOutDirection = -m_dir + SFVEC3F( FLT_EPSILON );
421 break;
422 }
423}
424
425
426void CAMERA::MakeRay( const SFVEC2F& aWindowPos, SFVEC3F& aOutOrigin,
427 SFVEC3F& aOutDirection ) const
428{
429 wxASSERT( aWindowPos.x < (float)m_windowSize.x );
430 wxASSERT( aWindowPos.y < (float)m_windowSize.y );
431
432 const SFVEC2F floorWinPos_f = glm::floor( aWindowPos );
433 const SFVEC2I floorWinPos_i = (SFVEC2I)floorWinPos_f;
434 const SFVEC2F relativeWinPos = aWindowPos - floorWinPos_f;
435
436 // Note: size of vectors m_up and m_right are m_windowSize + 1
437 const SFVEC3F up_plus_right = m_up_nY[floorWinPos_i.y] * (1.0f - relativeWinPos.y) +
438 m_up_nY[floorWinPos_i.y + 1] * relativeWinPos.y +
439 m_right_nX[floorWinPos_i.x] * (1.0f - relativeWinPos.x) +
440 m_right_nX[floorWinPos_i.x + 1] * relativeWinPos.x;
441
442 aOutOrigin = up_plus_right + m_frustum.nc;
443
444 switch( m_projectionType )
445 {
446 default:
448 aOutDirection = glm::normalize( aOutOrigin - m_pos );
449 break;
450
452 aOutDirection = -m_dir + SFVEC3F( FLT_EPSILON );
453 break;
454 }
455}
456
457
458void CAMERA::MakeRayAtCurrentMousePosition( SFVEC3F& aOutOrigin, SFVEC3F& aOutDirection ) const
459{
460 const SFVEC2I windowPos = SFVEC2I( m_lastPosition.x, m_windowSize.y - m_lastPosition.y );
461
462 if( ( 0 < windowPos.x ) && ( windowPos.x < m_windowSize.x ) &&
463 ( 0 < windowPos.y ) && ( windowPos.y < m_windowSize.y ) )
464 {
465 MakeRay( windowPos, aOutOrigin, aOutDirection );
466 }
467}
468
469
470const glm::mat4& CAMERA::GetProjectionMatrix() const
471{
472 return m_projectionMatrix;
473}
474
475
476const glm::mat4& CAMERA::GetProjectionMatrixInv() const
477{
479}
480
481
483{
484 return -m_camera_pos_init.z * m_frustum.tang;
485}
486
487
489{
490 m_parametersChanged = true;
491 m_camera_pos.x = 0.0f;
492 m_camera_pos.y = 0.0f;
493
496}
497
498
500{
501 m_camera_pos_t1.x = 0.0f;
502 m_camera_pos_t1.y = 0.0f;
503}
504
505
506const glm::mat4& CAMERA::GetViewMatrix() const
507{
508 return m_viewMatrix;
509}
510
511
512void CAMERA::SetViewMatrix( glm::mat4 aViewMatrix )
513{
514 SetRotationMatrix( aViewMatrix );
515
516 // The look at position in the view frame.
517 glm::vec4 lookat = aViewMatrix * glm::vec4( m_lookat_pos, 1.0f );
518
519 wxLogTrace( m_logTrace,
520 wxT( "CAMERA::SetViewMatrix aViewMatrix[3].z =%f, old_zoom=%f, new_zoom=%f, "
521 "m[3].z=%f" ),
522 aViewMatrix[3].z, m_zoom, lookat.z / m_camera_pos_init.z, lookat.z );
523
524 m_zoom = lookat.z / m_camera_pos_init.z;
525
526 if( m_zoom > m_maxZoom )
527 {
529 aViewMatrix[3].z += -lookat.z + m_maxZoom * m_camera_pos_init.z;
530 }
531 else if( m_zoom < m_minZoom )
532 {
534 aViewMatrix[3].z += -lookat.z + m_minZoom * m_camera_pos_init.z;
535 }
536
537 m_viewMatrix = std::move( aViewMatrix );
539 * glm::inverse( m_rotationMatrix * m_rotationMatrixAux
540 * glm::translate( glm::mat4( 1.0f ), -m_lookat_pos ) )[3];
541}
542
543
544const glm::mat4& CAMERA::GetViewMatrix_Inv() const
545{
546 return m_viewMatrixInverse;
547}
548
549
550void CAMERA::SetCurMousePosition( const wxPoint& aNewMousePosition )
551{
552 m_lastPosition = aNewMousePosition;
553}
554
555
565
566
567bool CAMERA::SetCurWindowSize( const wxSize& aSize )
568{
569 const SFVEC2I newSize = SFVEC2I( aSize.x, aSize.y );
570
571 if( m_windowSize != newSize )
572 {
573 m_windowSize = newSize;
575
576 return true;
577 }
578
579 return false;
580}
581
582
584{
585 m_zoom = 1.0f;
586
588
591}
592
593
594bool CAMERA::Zoom( float aFactor )
595{
596 if( ( m_zoom <= m_minZoom && aFactor > 1 ) || ( m_zoom >= m_maxZoom && aFactor < 1 )
597 || aFactor == 1 )
598 {
599 return false;
600 }
601
602 float zoom = m_zoom;
603 m_zoom /= aFactor;
604
606 {
607 aFactor = zoom / m_minZoom;
609 }
610 else if( m_zoom >= m_maxZoom && aFactor < 1 )
611 {
612 aFactor = zoom / m_maxZoom;
614 }
615
616 m_camera_pos.z /= aFactor;
617
620
621 return true;
622}
623
624
625bool CAMERA::Zoom_T1( float aFactor )
626{
627 if( ( m_zoom <= m_minZoom && aFactor > 1 ) || ( m_zoom >= m_maxZoom && aFactor < 1 )
628 || aFactor == 1 )
629 {
630 return false;
631 }
632
633 m_zoom_t1 = m_zoom / aFactor;
634
635 if( m_zoom_t1 < m_minZoom )
637
638 if( m_zoom_t1 > m_maxZoom )
640
642
643 return true;
644}
645
646
647void CAMERA::RotateScreen( float aAngleInRadians )
648{
649 glm::mat4 matrix = GetRotationMatrix();
650 SetRotationMatrix( glm::rotate( matrix, aAngleInRadians, GetDir() ) );
652}
653
654
655void CAMERA::RotateX( float aAngleInRadians )
656{
657 m_rotate_aux.x += aAngleInRadians;
659}
660
661
662void CAMERA::RotateY( float aAngleInRadians )
663{
664 m_rotate_aux.y += aAngleInRadians;
666}
667
668
669void CAMERA::RotateZ( float aAngleInRadians )
670{
671 m_rotate_aux.z += aAngleInRadians;
673}
674
675
676void CAMERA::RotateX_T1( float aAngleInRadians )
677{
678 m_rotate_aux_t1.x += aAngleInRadians;
679}
680
681
682void CAMERA::RotateY_T1( float aAngleInRadians )
683{
684 m_rotate_aux_t1.y += aAngleInRadians;
685}
686
687
688void CAMERA::RotateZ_T1( float aAngleInRadians )
689{
690 m_rotate_aux_t1.z += aAngleInRadians;
691}
692
693
706
707
708void CAMERA::Interpolate( float t )
709{
710 wxASSERT( t >= 0.0f );
711
712 const float t0 = 1.0f - t;
713
717 m_zoom = m_zoom_t0 * t0 + m_zoom_t1 * t;
718
719 m_parametersChanged = true;
720
723}
724
725
727{
728 const bool parametersChanged = m_parametersChanged;
729
730 m_parametersChanged = false;
731
732 return parametersChanged;
733}
declared enumerations and flags
VIEW3D_TYPE
Definition 3d_enums.h:74
@ VIEW3D_BOTTOM
Definition 3d_enums.h:77
void normalise2PI(float &aAngle)
Definition camera.cpp:31
Define an abstract camera.
PROJECTION_TYPE
Definition camera.h:36
glm::mat4 GetRotationMatrix() const
Get the rotation matrix to be applied in a transformation camera.
Definition camera.cpp:237
float m_zoom_t0
Definition camera.h:319
bool m_parametersChanged
Set to true if any of the parameters in the camera was changed.
Definition camera.h:387
void RotateY(float aAngleInRadians)
Definition camera.cpp:662
glm::mat4 m_projectionMatrixInv
Definition camera.h:343
void RotateX(float aAngleInRadians)
Definition camera.cpp:655
SFVEC3F m_lookat_pos
Definition camera.h:360
const glm::mat4 & GetProjectionMatrix() const
Definition camera.cpp:470
void SetBoardLookAtPos(const SFVEC3F &aBoardPos)
Definition camera.cpp:178
bool Zoom(float aFactor)
Definition camera.cpp:594
SFVEC3F m_camera_pos_t0
Definition camera.h:357
void RotateY_T1(float aAngleInRadians)
Definition camera.cpp:682
virtual void Reset()
Reset the camera to initial state.
Definition camera.cpp:74
SFVEC3F m_right
Definition camera.h:348
glm::mat4 m_projectionMatrix
Definition camera.h:342
CAMERA_INTERPOLATION m_interpolation_mode
Definition camera.h:369
SFVEC3F m_rotate_aux_t1
Definition camera.h:367
wxPoint m_lastPosition
The last mouse position in the screen.
Definition camera.h:336
void ZoomReset()
Definition camera.cpp:583
void ResetXYpos()
Definition camera.cpp:488
void RotateScreen(float aAngleInRadians)
Rotates the camera in screen plane.
Definition camera.cpp:647
const glm::mat4 & GetViewMatrix_Inv() const
Definition camera.cpp:544
bool Zoom_T1(float aFactor)
Definition camera.cpp:625
static const float DEFAULT_MIN_ZOOM
Definition camera.h:101
void updateRotationMatrix()
Definition camera.cpp:216
SFVEC3F m_rotate_aux_t0
Definition camera.h:366
virtual void Reset_T1()
Definition camera.cpp:157
void MakeRay(const SFVEC2I &aWindowPos, SFVEC3F &aOutOrigin, SFVEC3F &aOutDirection) const
Make a ray based on a windows screen position.
Definition camera.cpp:404
static const float DEFAULT_MAX_ZOOM
Definition camera.h:102
virtual void Interpolate(float t)
It will update the matrix to interpolate between T0 and T1 values.
Definition camera.cpp:708
SFVEC3F m_dir
Definition camera.h:350
bool SetCurWindowSize(const wxSize &aSize)
Update the windows size of the camera.
Definition camera.cpp:567
SFVEC3F m_camera_pos_init
Definition camera.h:355
CAMERA(float aInitialDistance)
Initialize a camera.
Definition camera.cpp:50
const glm::mat4 & GetProjectionMatrixInv() const
Definition camera.cpp:476
void ResetXYpos_T1()
Definition camera.cpp:499
float m_minZoom
Possible 3D zoom range.
Definition camera.h:325
float GetCameraMinDimension() const
Definition camera.cpp:482
bool ViewCommand_T1(VIEW3D_TYPE aRequestedView)
Definition camera.cpp:106
float m_maxZoom
Definition camera.h:326
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:381
void rebuildProjection()
Definition camera.cpp:251
float m_zoom_t1
Definition camera.h:320
SFVEC3F m_lookat_pos_t1
Definition camera.h:362
CAMERA_FRUSTUM m_frustum
Definition camera.h:346
void updateFrustum()
Definition camera.cpp:345
SFVEC3F m_lookat_pos_t0
Definition camera.h:361
void RotateZ(float aAngleInRadians)
Definition camera.cpp:669
virtual void SetT0_and_T1_current_T()
This will set T0 and T1 with the current values.
Definition camera.cpp:694
SFVEC3F m_camera_pos
Definition camera.h:356
PROJECTION_TYPE m_projectionType
Definition camera.h:344
SFVEC3F m_pos
Definition camera.h:351
void ToggleProjection()
Definition camera.cpp:556
SFVEC2I m_windowSize
The window size that this camera is working.
Definition camera.h:331
void MakeRayAtCurrentMousePosition(SFVEC3F &aOutOrigin, SFVEC3F &aOutDirection) const
Make a ray based on the latest mouse position.
Definition camera.cpp:458
SFVEC2F m_focalLen
Definition camera.h:353
void updateViewMatrix()
Definition camera.cpp:208
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:374
void RotateX_T1(float aAngleInRadians)
Definition camera.cpp:676
const glm::mat4 & GetViewMatrix() const
Definition camera.cpp:506
glm::mat4 m_viewMatrixInverse
Definition camera.h:341
SFVEC3F m_up
Definition camera.h:349
const SFVEC3F & GetDir() const
Definition camera.h:131
SFVEC3F m_rotate_aux
Stores the rotation angle auxiliary.
Definition camera.h:365
glm::mat4 m_rotationMatrixAux
Definition camera.h:339
glm::mat4 m_rotationMatrix
Definition camera.h:338
std::vector< float > m_scr_nY
Definition camera.h:375
void SetViewMatrix(glm::mat4 aViewMatrix)
Set the affine matrix to be applied to a transformation camera.
Definition camera.cpp:512
void RotateZ_T1(float aAngleInRadians)
Definition camera.cpp:688
glm::mat4 m_viewMatrix
Definition camera.h:340
SFVEC3F m_board_lookat_pos_init
Default boardlookat position (the board center).
Definition camera.h:363
std::vector< SFVEC3F > m_up_nY
Definition camera.h:382
bool ParametersChanged()
Definition camera.cpp:726
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:243
SFVEC3F m_camera_pos_t1
Definition camera.h:358
float m_zoom
3D zoom value – Z-distance is scaled by it
Definition camera.h:318
void zoomChanged()
Definition camera.cpp:193
void SetCurMousePosition(const wxPoint &aPosition)
Update the current mouse position without make any new calculations on camera.
Definition camera.cpp:550
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
Definition camera.h:396
#define M_PI
glm::ivec2 SFVEC2I
Definition xv3d_types.h:35
glm::vec2 SFVEC2F
Definition xv3d_types.h:38
glm::vec3 SFVEC3F
Definition xv3d_types.h:40