GAL: added methods to modify rotation in the transformation matrix
This commit is contained in:
parent
b88121e377
commit
1411e1f73a
|
@ -48,6 +48,7 @@ GAL::GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions ) :
|
||||||
SetStrokeColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
|
SetStrokeColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
|
||||||
SetLookAtPoint( VECTOR2D( 0, 0 ) );
|
SetLookAtPoint( VECTOR2D( 0, 0 ) );
|
||||||
SetZoomFactor( 1.0 );
|
SetZoomFactor( 1.0 );
|
||||||
|
SetRotation( 0.0 );
|
||||||
SetWorldUnitLength( 1.0 / METRIC_UNIT_LENGTH * 2.54 ); // 1 inch in nanometers
|
SetWorldUnitLength( 1.0 / METRIC_UNIT_LENGTH * 2.54 ); // 1 inch in nanometers
|
||||||
SetScreenDPI( 106 ); // Display resolution setting
|
SetScreenDPI( 106 ); // Display resolution setting
|
||||||
SetDepthRange( VECTOR2D( GAL::MIN_DEPTH, GAL::MAX_DEPTH ) );
|
SetDepthRange( VECTOR2D( GAL::MIN_DEPTH, GAL::MAX_DEPTH ) );
|
||||||
|
@ -178,18 +179,19 @@ void GAL::ComputeWorldScreenMatrix()
|
||||||
{
|
{
|
||||||
computeWorldScale();
|
computeWorldScale();
|
||||||
|
|
||||||
worldScreenMatrix.SetIdentity();
|
|
||||||
|
|
||||||
MATRIX3x3D translation;
|
MATRIX3x3D translation;
|
||||||
translation.SetIdentity();
|
translation.SetIdentity();
|
||||||
translation.SetTranslation( 0.5 * VECTOR2D( screenSize ) );
|
translation.SetTranslation( 0.5 * VECTOR2D( screenSize ) );
|
||||||
|
|
||||||
|
MATRIX3x3D rotate;
|
||||||
|
rotate.SetIdentity();
|
||||||
|
rotate.SetRotation( rotation );
|
||||||
|
|
||||||
MATRIX3x3D scale;
|
MATRIX3x3D scale;
|
||||||
scale.SetIdentity();
|
scale.SetIdentity();
|
||||||
scale.SetScale( VECTOR2D( worldScale, worldScale ) );
|
scale.SetScale( VECTOR2D( worldScale, worldScale ) );
|
||||||
|
|
||||||
MATRIX3x3D flip;
|
MATRIX3x3D flip;
|
||||||
|
|
||||||
flip.SetIdentity();
|
flip.SetIdentity();
|
||||||
flip.SetScale( VECTOR2D( globalFlipX ? -1.0 : 1.0, globalFlipY ? -1.0 : 1.0 ) );
|
flip.SetScale( VECTOR2D( globalFlipX ? -1.0 : 1.0, globalFlipY ? -1.0 : 1.0 ) );
|
||||||
|
|
||||||
|
@ -197,7 +199,7 @@ void GAL::ComputeWorldScreenMatrix()
|
||||||
lookat.SetIdentity();
|
lookat.SetIdentity();
|
||||||
lookat.SetTranslation( -lookAtPoint );
|
lookat.SetTranslation( -lookAtPoint );
|
||||||
|
|
||||||
worldScreenMatrix = translation * flip * scale * lookat * worldScreenMatrix;
|
worldScreenMatrix = translation * rotate * flip * scale * lookat;
|
||||||
screenWorldMatrix = worldScreenMatrix.Inverse();
|
screenWorldMatrix = worldScreenMatrix.Inverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -506,7 +506,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Transform the context.
|
* @brief Transform the context.
|
||||||
*
|
*
|
||||||
* @param aTransformation is the ransformation matrix.
|
* @param aTransformation is the transformation matrix.
|
||||||
*/
|
*/
|
||||||
virtual void Transform( const MATRIX3x3D& aTransformation ) {};
|
virtual void Transform( const MATRIX3x3D& aTransformation ) {};
|
||||||
|
|
||||||
|
@ -695,6 +695,26 @@ public:
|
||||||
return zoomFactor;
|
return zoomFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the rotation angle.
|
||||||
|
*
|
||||||
|
* @param aRotation is the new rotation angle (radians).
|
||||||
|
*/
|
||||||
|
void SetRotation( double aRotation )
|
||||||
|
{
|
||||||
|
rotation = aRotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the rotation angle.
|
||||||
|
*
|
||||||
|
* @return The rotation angle (radians).
|
||||||
|
*/
|
||||||
|
double GetRotation() const
|
||||||
|
{
|
||||||
|
return rotation;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the range of the layer depth.
|
* @brief Set the range of the layer depth.
|
||||||
*
|
*
|
||||||
|
@ -1009,6 +1029,7 @@ protected:
|
||||||
VECTOR2D lookAtPoint; ///< Point to be looked at in world space
|
VECTOR2D lookAtPoint; ///< Point to be looked at in world space
|
||||||
|
|
||||||
double zoomFactor; ///< The zoom factor
|
double zoomFactor; ///< The zoom factor
|
||||||
|
double rotation; ///< Rotation transformation (radians)
|
||||||
MATRIX3x3D worldScreenMatrix; ///< World transformation
|
MATRIX3x3D worldScreenMatrix; ///< World transformation
|
||||||
MATRIX3x3D screenWorldMatrix; ///< Screen transformation
|
MATRIX3x3D screenWorldMatrix; ///< Screen transformation
|
||||||
double worldScale; ///< The scale factor world->screen
|
double worldScale; ///< The scale factor world->screen
|
||||||
|
|
Loading…
Reference in New Issue