-bool CControlPointsManagerBFace::OnMouseMove (int xPos, int yPos)
-{
- if (ManagerState == Drag)
- {
- if (m_bGotAnchor)
- {
- // there's an anchor, we are rotating the shape
- // we need to work in XY space for orthonormality
- float Pt[2];
- vec3_t V1,V2;
- vec3_t cross;
- float c,s;
- // used in XY space
- float XYTM[2][3];
- float XYRefAnchor[2];
- float XYAnchor[2];
- m_p2DView->GridForWindow( Pt, xPos, yPos );
- V2[0] = Pt[0] - m_Anchor[0];
- V2[1] = Pt[1] - m_Anchor[1];
- V2[2] = 0.0f;
- V1[0] = m_RefPts.data[m_iDragPoint][0] - m_RefPts.data[m_iAnchorPoint][0];
- V1[1] = m_RefPts.data[m_iDragPoint][1] - m_RefPts.data[m_iAnchorPoint][1];
- V1[2] = 0.0f;
- // compute transformation from V1 to V2
- // we need to work in XY orthonormal space
- XYSpaceForSTSpace( V1, V1 );
- XYSpaceForSTSpace( V2, V2 );
- VectorNormalize( V2, V2 );
- VectorNormalize( V1, V1 );
- c = DotProduct( V1, V2 );
- CrossProduct( V1, V2, cross );
- s = VectorLength( cross );
- // we compute the transformation matrix in XY space
- // reference position of the Anchor in XY space
- XYSpaceForSTSpace( XYRefAnchor, m_RefPts.data[m_iAnchorPoint] );
- // current position of the Anchor in XY space
- XYSpaceForSTSpace( XYAnchor, m_Anchor );
- // compute transformation matrix
- XYTM[0][0] = c; XYTM[1][1] = c;
- if (cross[2]>0)
- s *= -1.0f;
- XYTM[0][1] = s; XYTM[1][0] = -s;
- XYTM[0][2] = -c*XYRefAnchor[0] - s*XYRefAnchor[1] + XYAnchor[0];
- XYTM[1][2] = s*XYRefAnchor[0] - c*XYRefAnchor[1] + XYAnchor[1];
- // express this transformation matrix in ST space
- m_TM[0][0] = XYTM[0][0];
- m_TM[1][0] = XYTM[1][0] * (float)m_TexSize[0] / (float)m_TexSize[1];
- m_TM[0][1] = XYTM[0][1] * (float)m_TexSize[1] / (float)m_TexSize[0];
- m_TM[1][1] = XYTM[1][1];
- m_TM[0][2] = XYTM[0][2] / (float)m_TexSize[0];
- m_TM[1][2] = XYTM[1][2] / (float)m_TexSize[1];
- // update all points
- UpdateCtrlPts();
- }
- else
- {
- // no Anchor point is defined, we translate all points
- m_p2DView->GridForWindow( m_pPts->data[m_iDragPoint], xPos, yPos );
- m_TM[0][2] = m_pPts->data[m_iDragPoint][0] + m_TransOffset[0];
- m_TM[1][2] = m_pPts->data[m_iDragPoint][1] + m_TransOffset[1];
- // update all points
- UpdateCtrlPts();
- }
- // send a repaint message
- g_pToolWnd->Redraw ();
- return true;
- }
+bool CControlPointsManagerBFace::OnMouseMove( int xPos, int yPos ){
+ if ( ManagerState == Drag ) {
+ if ( m_bGotAnchor ) {
+ // there's an anchor, we are rotating the shape
+ // we need to work in XY space for orthonormality
+ float Pt[2];
+ vec3_t V1,V2;
+ vec3_t cross;
+ float c,s;
+ // used in XY space
+ float XYTM[2][3];
+ float XYRefAnchor[2];
+ float XYAnchor[2];
+ m_p2DView->GridForWindow( Pt, xPos, yPos );
+ V2[0] = Pt[0] - m_Anchor[0];
+ V2[1] = Pt[1] - m_Anchor[1];
+ V2[2] = 0.0f;
+ V1[0] = m_RefPts.data[m_iDragPoint][0] - m_RefPts.data[m_iAnchorPoint][0];
+ V1[1] = m_RefPts.data[m_iDragPoint][1] - m_RefPts.data[m_iAnchorPoint][1];
+ V1[2] = 0.0f;
+ // compute transformation from V1 to V2
+ // we need to work in XY orthonormal space
+ XYSpaceForSTSpace( V1, V1 );
+ XYSpaceForSTSpace( V2, V2 );
+ VectorNormalize( V2, V2 );
+ VectorNormalize( V1, V1 );
+ c = DotProduct( V1, V2 );
+ CrossProduct( V1, V2, cross );
+ s = VectorLength( cross );
+ // we compute the transformation matrix in XY space
+ // reference position of the Anchor in XY space
+ XYSpaceForSTSpace( XYRefAnchor, m_RefPts.data[m_iAnchorPoint] );
+ // current position of the Anchor in XY space
+ XYSpaceForSTSpace( XYAnchor, m_Anchor );
+ // compute transformation matrix
+ XYTM[0][0] = c; XYTM[1][1] = c;
+ if ( cross[2] > 0 ) {
+ s *= -1.0f;
+ }
+ XYTM[0][1] = s; XYTM[1][0] = -s;
+ XYTM[0][2] = -c * XYRefAnchor[0] - s * XYRefAnchor[1] + XYAnchor[0];
+ XYTM[1][2] = s * XYRefAnchor[0] - c * XYRefAnchor[1] + XYAnchor[1];
+ // express this transformation matrix in ST space
+ m_TM[0][0] = XYTM[0][0];
+ m_TM[1][0] = XYTM[1][0] * (float)m_TexSize[0] / (float)m_TexSize[1];
+ m_TM[0][1] = XYTM[0][1] * (float)m_TexSize[1] / (float)m_TexSize[0];
+ m_TM[1][1] = XYTM[1][1];
+ m_TM[0][2] = XYTM[0][2] / (float)m_TexSize[0];
+ m_TM[1][2] = XYTM[1][2] / (float)m_TexSize[1];
+ // update all points
+ UpdateCtrlPts();
+ }
+ else
+ {
+ // no Anchor point is defined, we translate all points
+ m_p2DView->GridForWindow( m_pPts->data[m_iDragPoint], xPos, yPos );
+ m_TM[0][2] = m_pPts->data[m_iDragPoint][0] + m_TransOffset[0];
+ m_TM[1][2] = m_pPts->data[m_iDragPoint][1] + m_TransOffset[1];
+ // update all points
+ UpdateCtrlPts();
+ }
+ // send a repaint message
+ g_pToolWnd->Redraw();
+ return true;
+ }