Use an independent pivot representation for the 3dmouse in the 3dviewer.
CHANGED: Instead of using the target style pivot that is used to move the look at position, a different pivot is used for the center of rotation used by the 3dmouse. Both pivots, the camera look at position and the 3dmouse rotation pivot, need not necessarily coincide. A blue ball is used to represent the pivot.
This commit is contained in:
parent
e19e039a47
commit
66b8ecb467
|
@ -521,6 +521,14 @@ void EDA_3D_CANVAS::DoRePaint()
|
||||||
render_pivot( curtime_delta_s, scale );
|
render_pivot( curtime_delta_s, scale );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined( KICAD_USE_3DCONNEXION )
|
||||||
|
if( m_render3dmousePivot )
|
||||||
|
{
|
||||||
|
const float scale = glm::min( m_camera.GetZoom(), 1.0f );
|
||||||
|
render3dmousePivot( scale );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// "Swaps the double-buffer of this window, making the back-buffer the
|
// "Swaps the double-buffer of this window, making the back-buffer the
|
||||||
// front-buffer and vice versa, so that the output of the previous OpenGL
|
// front-buffer and vice versa, so that the output of the previous OpenGL
|
||||||
// commands is displayed on the window."
|
// commands is displayed on the window."
|
||||||
|
|
|
@ -178,6 +178,39 @@ public:
|
||||||
*/
|
*/
|
||||||
void SetRenderPivot( bool aValue ) { m_render_pivot = aValue; }
|
void SetRenderPivot( bool aValue ) { m_render_pivot = aValue; }
|
||||||
|
|
||||||
|
|
||||||
|
#if defined( KICAD_USE_3DCONNEXION )
|
||||||
|
/**
|
||||||
|
* Get a value indicating whether to render the 3dmouse pivot.
|
||||||
|
*/
|
||||||
|
bool GetRender3dmousePivot()
|
||||||
|
{
|
||||||
|
return m_render3dmousePivot;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set aValue indicating whether to render the 3dmouse pivot.
|
||||||
|
*
|
||||||
|
* @param aValue true will cause the pivot to be rendered on the next redraw.
|
||||||
|
*/
|
||||||
|
void SetRender3dmousePivot( bool aValue )
|
||||||
|
{
|
||||||
|
m_render3dmousePivot = aValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the position of the the 3dmouse pivot.
|
||||||
|
*
|
||||||
|
* @param aPos is the position of the 3dmouse rotation pivot
|
||||||
|
*/
|
||||||
|
void Set3dmousePivotPos( const SFVEC3F& aPos )
|
||||||
|
{
|
||||||
|
m_3dmousePivotPos = aPos;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Called by a wxPaintEvent event
|
* Called by a wxPaintEvent event
|
||||||
|
@ -245,6 +278,15 @@ private:
|
||||||
*/
|
*/
|
||||||
void render_pivot( float t, float aScale );
|
void render_pivot( float t, float aScale );
|
||||||
|
|
||||||
|
#if defined( KICAD_USE_3DCONNEXION )
|
||||||
|
/**
|
||||||
|
* Render the 3dmouse pivot cursor.
|
||||||
|
*
|
||||||
|
* @param aScale scale to apply on the cursor.
|
||||||
|
*/
|
||||||
|
void render3dmousePivot( float aScale );
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if OpenGL initialization succeeded.
|
* @return true if OpenGL initialization succeeded.
|
||||||
*/
|
*/
|
||||||
|
@ -289,6 +331,11 @@ private:
|
||||||
|
|
||||||
BOARD_ITEM* m_currentRollOverItem;
|
BOARD_ITEM* m_currentRollOverItem;
|
||||||
|
|
||||||
|
#if defined( KICAD_USE_3DCONNEXION )
|
||||||
|
bool m_render3dmousePivot = false; // Render the 3dmouse pivot
|
||||||
|
SFVEC3F m_3dmousePivotPos; // The position of the 3dmouse pivot
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trace mask used to enable or disable the trace output of this class.
|
* 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
|
* The debug output can be turned on by setting the WXTRACE environment variable to
|
||||||
|
|
|
@ -73,7 +73,7 @@ static void pivot_render_triangles( float t )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDA_3D_CANVAS::render_pivot( float t , float aScale )
|
void EDA_3D_CANVAS::render_pivot( float t, float aScale )
|
||||||
{
|
{
|
||||||
wxASSERT( aScale >= 0.0f );
|
wxASSERT( aScale >= 0.0f );
|
||||||
wxASSERT( t >= 0.0f );
|
wxASSERT( t >= 0.0f );
|
||||||
|
@ -118,3 +118,46 @@ void EDA_3D_CANVAS::render_pivot( float t , float aScale )
|
||||||
pivot_render_triangles( t * 0.5f );
|
pivot_render_triangles( t * 0.5f );
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined( KICAD_USE_3DCONNEXION )
|
||||||
|
void EDA_3D_CANVAS::render3dmousePivot( float aScale )
|
||||||
|
{
|
||||||
|
wxASSERT( aScale >= 0.0f );
|
||||||
|
|
||||||
|
glDisable( GL_LIGHTING );
|
||||||
|
glDisable( GL_DEPTH_TEST );
|
||||||
|
glDisable( GL_CULL_FACE );
|
||||||
|
|
||||||
|
// Set projection and modelview matrixes
|
||||||
|
glMatrixMode( GL_PROJECTION );
|
||||||
|
glLoadMatrixf( glm::value_ptr( m_camera.GetProjectionMatrix() ) );
|
||||||
|
|
||||||
|
glMatrixMode( GL_MODELVIEW );
|
||||||
|
glLoadIdentity();
|
||||||
|
glLoadMatrixf( glm::value_ptr( m_camera.GetViewMatrix() ) );
|
||||||
|
|
||||||
|
glEnable( GL_COLOR_MATERIAL );
|
||||||
|
glColor4f( 0.0f, 0.667f, 0.902f, 0.75f );
|
||||||
|
|
||||||
|
// Translate to the look at position
|
||||||
|
glTranslatef( m_3dmousePivotPos.x, m_3dmousePivotPos.y, m_3dmousePivotPos.z );
|
||||||
|
|
||||||
|
glPointSize( 16.0f );
|
||||||
|
glEnable( GL_POINT_SMOOTH );
|
||||||
|
glHint( GL_POINT_SMOOTH_HINT, GL_NICEST );
|
||||||
|
|
||||||
|
glEnable( GL_BLEND );
|
||||||
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||||
|
|
||||||
|
glScalef( aScale, aScale, aScale );
|
||||||
|
|
||||||
|
// Draw a point at the look at position.
|
||||||
|
glBegin( GL_POINTS );
|
||||||
|
glVertex3f( 0, 0, 0 );
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glDisable( GL_BLEND );
|
||||||
|
glDisable( GL_POINT_SMOOTH );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -459,16 +459,11 @@ long NL_3D_VIEWER_PLUGIN_IMPL::SetPivotPosition( const navlib::point_t& position
|
||||||
{
|
{
|
||||||
SFVEC3F pivotPos = SFVEC3F( position.x, position.y, position.z );
|
SFVEC3F pivotPos = SFVEC3F( position.x, position.y, position.z );
|
||||||
|
|
||||||
// Set the pivot icon position .
|
// Set the 3dmouse pivot position.
|
||||||
m_camera->SetLookAtPos_T1( pivotPos );
|
m_canvas->Set3dmousePivotPos( pivotPos );
|
||||||
|
|
||||||
#if 0
|
// Set the camera lookat pos.
|
||||||
// Set the trackball pivot to the same position as the 3DMouse pivot.
|
m_camera->SetLookAtPos_T1( pivotPos );
|
||||||
glm::mat4 m = m_camera->GetViewMatrix();
|
|
||||||
m_camera->SetLookAtPos( pivotPos );
|
|
||||||
m_camera->SetViewMatrix( std::move( m ) );
|
|
||||||
m_camera->Update();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_canvas->Request_refresh();
|
m_canvas->Request_refresh();
|
||||||
|
|
||||||
|
@ -478,7 +473,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::SetPivotPosition( const navlib::point_t& position
|
||||||
|
|
||||||
long NL_3D_VIEWER_PLUGIN_IMPL::GetPivotVisible( navlib::bool_t& visible ) const
|
long NL_3D_VIEWER_PLUGIN_IMPL::GetPivotVisible( navlib::bool_t& visible ) const
|
||||||
{
|
{
|
||||||
visible = m_canvas->GetRenderPivot();
|
visible = m_canvas->GetRender3dmousePivot();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -486,7 +481,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::GetPivotVisible( navlib::bool_t& visible ) const
|
||||||
|
|
||||||
long NL_3D_VIEWER_PLUGIN_IMPL::SetPivotVisible( bool visible )
|
long NL_3D_VIEWER_PLUGIN_IMPL::SetPivotVisible( bool visible )
|
||||||
{
|
{
|
||||||
m_canvas->SetRenderPivot( visible );
|
m_canvas->SetRender3dmousePivot( visible );
|
||||||
|
|
||||||
m_canvas->Request_refresh();
|
m_canvas->Request_refresh();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue