| 44 | } |
| 45 | |
| 46 | void Tr2ScalingTool::Move( int mouseX, int mouseY, int mouseXDelta, int mouseYDelta, Tr2Viewport& viewport, Matrix& viewMatrix, Matrix& projectionMatrix ) |
| 47 | { |
| 48 | Vector3 pos; |
| 49 | Vector2 screenPos; |
| 50 | Vector3 normal; |
| 51 | Vector3 ray; |
| 52 | Vector3 startPos; |
| 53 | pos.x = m_localTransform._41; |
| 54 | pos.y = m_localTransform._42; |
| 55 | pos.z = m_localTransform._43; |
| 56 | |
| 57 | |
| 58 | if( m_initialLength < 0.0 ) |
| 59 | { |
| 60 | Vector3 vecResult; |
| 61 | Vector3 vecCenterOfMass = TransformPoint( Vector3( 1, 0, 0 ), m_xBox, viewMatrix ); |
| 62 | float tmpInitialLength = Length( pos - vecCenterOfMass ); |
| 63 | // the initiallength could not have been set up... |
| 64 | m_initialLength = tmpInitialLength; |
| 65 | } |
| 66 | |
| 67 | |
| 68 | // We might be in world or local |
| 69 | Vector3 xAxis; |
| 70 | Vector3 yAxis; |
| 71 | Vector3 zAxis; |
| 72 | GetBaseVectors( xAxis, yAxis, zAxis ); |
| 73 | |
| 74 | // Get the location of the tool on screen |
| 75 | PointToScreenCoordinates( pos, screenPos, viewport, viewMatrix, projectionMatrix ); |
| 76 | int curMouseX = int( screenPos.x ); |
| 77 | int curMouseY = int( screenPos.y ); |
| 78 | // Get the pick ray from the tools screen location |
| 79 | ScreenCoordinatesToRay( curMouseX, curMouseY, ray, startPos, viewport, viewMatrix, projectionMatrix ); |
| 80 | |
| 81 | // Get the normal for the best plane to use |
| 82 | normal = GetDesiredPlaneNormal( ray, viewMatrix ); |
| 83 | Vector3 delta = MovePointOnPlane( curMouseX, curMouseY, curMouseX + mouseXDelta, curMouseY + mouseYDelta, pos, normal, viewport, viewMatrix, projectionMatrix ); |
| 84 | |
| 85 | Vector3 translate; |
| 86 | if( m_selectedAxis == "w" ) |
| 87 | { |
| 88 | translate = delta; |
| 89 | } |
| 90 | else if( m_selectedAxis == "x" ) |
| 91 | { |
| 92 | float scale = Dot( delta, xAxis ); |
| 93 | translate = xAxis * scale; |
| 94 | } |
| 95 | else if( m_selectedAxis == "y" ) |
| 96 | { |
| 97 | float scale = Dot( delta, yAxis ); |
| 98 | translate = yAxis * scale; |
| 99 | } |
| 100 | else if( m_selectedAxis == "z" ) |
| 101 | { |
| 102 | float scale = Dot( delta, zAxis ); |
| 103 | translate = zAxis * scale; |
nothing calls this directly
no test coverage detected