Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7403041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:56:52+00:00 2026-05-29T04:56:52+00:00

I use DirectX3D 11 to wirte an application and my Camera target vector is

  • 0

I use DirectX3D 11 to wirte an application and my Camera target vector is determined by the variables xdelta, ydelta, and zdelta.

I have to PAN my view in the XY as I move my mouse across the screen with the RMB & LMB pressed.

I figured that I need to add the delta in the mouse movement to my VIEW space, so that it pans in X and Y relative to my view, not world X and Y.

However, being new to this, I’m not sure how to convert my VIEW coordinates back to WORLD coordinates.

I hope that I am following all of the formatting rules, as I don’t post here enough to remember all of them exactly.

Any help would be appreciated. below is my snippet of code. Perhaps there is also a better way.

if ( m_Input->RMBPressed() == true && m_Input->LMBPressed() == true ) // Pan View
{
if ( curX != mouseX || curY != mouseY ) {
//Get Target Coordinates in View Space
D3DXVECTOR3 targetView = (D3DXVECTOR3 ( mView(2,0), mView(2,1), mView(2,2) );
//Add mouse XY delta vector to target View Coordinates
     D3DXVECTOR3 delta ( (float)curX-(float)mouseX, 
                         (float)curY-(float)mouseY, zdelta );
targetView += delta;
//Convert back to World Coordinates


}
}

I’m Trying a different approach, that I believe is the correct approach, but it still doesn’t appear to be working correctly.
I get the the delta in X and Y from the screen as my mouse moves and store them in the variables “xdelta” and “ydelta”.

I then create a transformation matrix

D3DXMATRIX mTrans;

I then populate the values in the matrix

// Rotation
mTrans(0,0) = delta.x;
mTrans(1,1) = delta.y;
// Translation
mTrans(0,3) = delta.x;
mTrans(1,3) = delta.y;

Now to get their corresponding View coordinates, I think I should multiply it by the View Matrix, which I call mView.

mTrans= mTrans*mView;

Now add these translated values to my current target X and Y which is determind by the variables “target_x” and “target_y”, it should move my target vector, relative to my view coordinates X and Y (i.e. orthogonal to my current view).

target_x += mTrans(0,3);
target_y += mTrans(1,3);

But it doesn’t. It moves my target, along the world X and Y axis, not my View X and Y axis.

MORE SNIPPETS

I do use the D3DXMatrixLookAtLH function, but I’m trying to calculate the change in the target location based on my mouse movements to get new target to feed into that function. I added in some code snippets:

if ( m_Input->RMBPressed() == true && m_Input->LMBPressed() == true ) // Pan View
    {
        if ( curX != mouseX || curY != mouseY ) {
            //Get mouse XY delta vector
            D3DXVECTOR3 delta ( (float)curX-(float)mouseX, (float)curY-(float)mouseY, zdelta );
            //Create Transformation Matrix
            D3DXMATRIX mTemp;
            // Rotation
            mTemp (0,0) = delta.x;
            mTemp (1,1) = delta.y;
            mTemp (2,2) = delta.z;
        // Translation
            mTemp (0,3) = delta.x;
            mTemp (1,3) = delta.y;
            mTemp (2,3) = delta.z;
            //Convert to View Coordinates
            mTemp = mTemp*mView;
            xdelta += mTemp(0,3);
            ydelta += mTemp(1,3);

    // Convert Spherical to Cartesian coordinates: mPhi measured from +y
    // and mTheta measured counterclockwise from z.
    float height = mRadius * cosf(mPhi);
    float sideRadius = mRadius * sinf(mPhi);
    float x = xdelta + sideRadius * cosf(mTheta);
        float z = zdelta + sideRadius * sinf(mTheta);
    float y = ydelta + height;

    // Build the view matrix.
    D3DXVECTOR3 pos(x, y, z);

    D3DXVECTOR3 target(xdelta, ydelta, zdelta);

    D3DXVECTOR3 up(0.0f, 1.0f, 0.0f); // Y Axis is up. Looking down Z.

    D3DXMatrixLookAtLH(&mView, &pos, &target, &up);

First of all, thank you for all of your information. It is helping me slowly understand DirectX matrices.
Am I correct in the logic below?
Assume my mouse change is 5.0 in X and 5.0 in Y on the screen. that is my delta. Z would always be 0.0.
I could find the view coordinates as follows.

 D3DXVECTOR3 up(0.0f, 1.0f, 0.0f); // Y Axis is up. Looking down Z.
 D3DXVECTOR3  delta ( 5.0f,  5.0f, 0.0f );
 D3DXVECTOR3 origin ( 0.0f. 0.0f, 0.0f );
 D3DMATRIX mTemp;
 D3DXMatrixIdentity (&mTemp);
 D3DXMatrixLookAtLH (&mTemp, &delta, &origin, &up );

I should now have the view coordinates of the XY delta stored in the mTemp view matrix?

If so, is the best way to proceed, by adding the XY delta View coordinates to the mView XY coordinates and then translating back to world coordinates, to get the actual XY world value I have to set the target to?

I’m at a loss as to how to achieve this. It’s really not all that clear to me, and all the books that I purchased on the subject are not clear either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:57:00+00:00Added an answer on May 29, 2026 at 4:57 am

    You can calculate world coordinates from local coordinates by multiplying you local coords by world matrix.
    If you want your camera to move, than just define their current position using 3D vector, and then use D3DXMatrixLookAtLH to calculate view matrix from your current position.
    Check out this tutorial for more details: http://www.braynzarsoft.net/index.php?p=D3D11WVP

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an application which needs to use Direct3D. Specifically, it needs at least
I need to use the RGBRast software renderer for a DirectX application I'm developing.
Use case: 3rd party application wants to programatically monitor a text file being generated
I have an application that uses DirectX to capture the screen. The application works
our delphi application can have multiple DirectX windows, often on multiple screens. up to
I have an application that, to this point, is mostly DirectX 10 3D graphics.
I have C Static Library for Capturing Video from Camera.It uses Direct X to
I'm trying to write a callback event system in DirectX9. I'm attempting to use
Is there an easy way to use DirectX in Java? In particular, DirectX's video
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.