Optional Translation

Hi, I need a little help
I used your Mouse-rotation function from the nehe lesson 48. it was very usefull, and have a great performance. A wan't to use it to translate in x, y z. I know, with a little os patience that I could find how to use it. But I'm a little short of time because I must present my tesis soon. I hope it doen't be mush trouble for you to explain me how to do that, and excuse bothers.

Well, for “translation”, you could use the right mouse button for translation instead of resetting all of the rotations:

if (isRClicked) //if right mouse clicked, translate X, Y
{
        Transform.TX += Delta Mouse X
        Transform.TY += Delta Mouse Y
}

Where “delta” means “change in”

Rememeber, in the article I say:

“Transform is our final transform- our rotation and any optional translation you may want to provide.”

So the “optional translation” in Transform can be dealt with like that, using the right mouse button for movement of the object.

Best wishes.

–Terence J. Grant

Ok Terence, Thank you very much.
I was lost, I thought that the translation could be donde with a change the transform matrix (the original), your answer work fine. So, here I reply my mouse handle-code, if it's some usefull, I have wrote a few programs in many areas, so if you have any question or need, just ask for it.
Greest, Claudio.
PD: Here is the code
        if (PeekMessage(&MSGmsg,NULL,0,0,PM_REMOVE))    // Is there a message waiting?
                {
                        switch(MSGmsg.message)
                        {
                                case WM_QUIT:
                                        done=true;
                                break;
                                case WM_MOUSEMOVE:
                                        MousePt.s.X = (GLfloat)LOWORD(MSGmsg.lParam);
                                        MousePt.s.Y = (GLfloat)HIWORD(MSGmsg.lParam);
                                        isClicked   = (LOWORD(MSGmsg.wParam) & MK_LBUTTON) ? true : false;
                                        isRClicked  = (LOWORD(MSGmsg.wParam) & MK_RBUTTON) ? true : false;
                                break;
                                case WM_LBUTTONUP:
                                    isClicked   = false;
                                break;
                                case WM_RBUTTONUP:
                                    isRClicked  = false;
                                break;
                                case WM_LBUTTONDOWN:
                                    isClicked   = true;
                                break;
                                case WM_RBUTTONDOWN:
                                    isRClicked  = true;
                                break;
                                case WM_MOUSEWHEEL:
                                    isScrolled  = true; //MouseWheel
                                    ((short) HIWORD(MSGmsg.wParam)> 0) ? nZoom-=50 : nZoom+=50;
 
                                break;
                        }
                        if (MSGmsg.message == WM_QUIT)             // Have we received a quit message?
                        {
                                done = true;                    // If so done = TRUE
                        }
                        else                                    // If not, deal with window messages
                        {
                                TranslateMessage(&MSGmsg);         //Translate the message
                                DispatchMessage(&MSGmsg);          //Dispatch the message
 
                        }
                        /*if (isRClicked) // If Right Mouse Clicked, Reset All Rotations
                        {
                                Matrix3fSetIdentity(&LastRot); // Reset Rotation
                                Matrix3fSetIdentity(&ThisRot); // Reset Rotation
                                Matrix4fSetRotationFromMatrix3f(&Transform, &ThisRot);              // Reset Rotation
                        }*/
                        if (MSGmsg.message == WM_MOUSEWHEEL)             //Have we received a quit message?
                        {
                                 Transform.s.TZ=nZoom;                    //If so done = TRUE
                        }
                        if (!isDragging) // Not Dragging
                        {
                                if (isClicked) // First Click
                                {
                                        isDragging = true; // Prepare For Dragging
                                        LastRot = ThisRot; // Set Last Static Rotation To Last Dynamic One
                                        ArcBall.click(&MousePt); // Update Start Vector And Prepare For Dragging
                                }
                                else if (isRClicked) // First Click
                                {
                                        isDragging = true; // Prepare For Dragging
                                        LastRot = ThisRot;
                                        MouseSavedPt=MousePt; // Set Last Static Rotation To Last Dynamic One
                                        ArcBall.click(&MousePt); // Update Start Vector And Prepare For Dragging
                                }
                        }
                        else
                        {
                                if (isClicked) // Still Clicked, So Still Dragging
                                {
                                    Quat4fT     ThisQuat;
 
                                    ArcBall.drag(&MousePt, &ThisQuat); // Update End Vector And Get Rotation As Quaternion
                                    Matrix3fSetRotationFromQuat4f(&ThisRot, &ThisQuat);             // Convert Quaternion Into Matrix3fT
                                    Matrix3fMulMatrix3f(&ThisRot, &LastRot); // Accumulate Last Rotation Into This One
 
Matrix4fSetRotationFromMatrix3f(&Transform, &ThisRot);  // Set Our Final Transform's Rotation From This One
                                }
                                else if (isRClicked) // Still Clicked, So Still Dragging
                                {
                                  /*  Quat4fT     ThisQuat;
 
                                    ArcBall.drag(&MousePt, &ThisQuat); // Update End Vector And Get Rotation As Quaternion
                                    Matrix3fSetRotationFromQuat4f(&ThisRot, &ThisQuat);             // Convert Quaternion Into Matrix3fT
                                    Matrix3fMulMatrix3f(&ThisRot, &LastRot); // Accumulate Last Rotation Into This One
 
Matrix4fSetRotationFromMatrix3f(&Transform, &ThisRot);  // Set Our Final Transform's Rotation From This One*/
                                    if(MouseSavedPt.s.X>MousePt.s.X)
 
Transform.s.TX+=fabs(MouseSavedPt.s.X-MousePt.s.X);
                                    else
 
Transform.s.TX-=fabs(MouseSavedPt.s.X-MousePt.s.X);
                                    if(MouseSavedPt.s.Y>MousePt.s.Y)
 
Transform.s.TY-=fabs(MouseSavedPt.s.Y-MousePt.s.Y);
                                    else
 
Transform.s.TY+=fabs(MouseSavedPt.s.Y-MousePt.s.Y);;
 
                                }
                                else // No Longer Dragging
                                    isDragging = false;
                        }
 
                }