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 7722801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:16:51+00:00 2026-06-01T04:16:51+00:00

I have multiple objects moving about in a 3D space and am looking for

  • 0

I have multiple objects moving about in a 3D space and am looking for ways to, on button press, have the camera snap and follow the object chosen.

Is there a way to make use of each object’s worldMatrix? (Below is an example of one object. This one is a planet that spins & orbits)

//set up matrices for rendering
D3DXMATRIX worldMatrixMer, viewMatrixMer, projectionMatrixMer;
m_Camera->GetViewMatrix(viewMatrixMer);
m_D3D->GetWorldMatrix(worldMatrixMer);
m_D3D->GetProjectionMatrix(projectionMatrixMer);
D3DXMatrixRotationX( &matRotateX, rx/65.0f);
//Rotate about Y axis
D3DXMatrixRotationY( &matRotateY, rotation * 15.0f);
D3DXMatrixRotationZ( &matRotateZ, rz/65.0f); 
//Collate Rot Matrices
D3DXMATRIX rotMatrixMer = matRotateX * matRotateY * matRotateZ;
D3DXVECTOR3 newVecDirMer;
D3DXVec3TransformCoord(&newVecDirMer, &initVecDirMer, &rotMatrixMer);
D3DXVec3Normalize( &currentVecDirMer, &newVecDirMer );
//Create the size of the object
D3DXMATRIX matScaleMer;
D3DXMatrixScaling(&matScaleMer, 0.1f, 0.1f, 0.1f);
//Starting position of object
D3DXMatrixTranslation(&matTranslateMer, 0.0f, 0.0f, 3.5983f * 3);
//Rotate about it's own axis
D3DXMatrixRotationY(&worldMatrixMer, rotation);
worldMatrixMer *= rotMatrixMer * matScaleMer * matTranslateMer;
//'Orbit'
D3DXMatrixRotationY( &matOrbit, (-1000.0f * rotation) / 88);
worldMatrixMer *= matOrbit;

I’m really trying to find an elegant way of making this happen, so any suggestions would be greatly appreciated.

Thanks

  • 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-06-01T04:16:52+00:00Added an answer on June 1, 2026 at 4:16 am

    Is there a way to make use of each object’s worldMatrix?

    Object matrix can be represented this way:

    objx.x     objx.y     objx.z  0 //m[0][0]..m[0][3] or _11, _12, _13, _14
    objy.x     objy.y     objy.z  0 //m[1][0]..m[1][3] or _21, _22, _23, _24
    objz.x     objz.y     objz.z  0 //m[2][0]..m[2][3] or _31, _32, _33, _34
    objpos.x   objpos.y   objpos.z  1 //m[3][0]..m[3][3] or _41, _42, _43, _44
    

    Where m[][] and _11.._44 are corresponding elements of D3DMATRIX, objpos – object position vector, objx – object x (‘local x” transformed to world space) vector, etc.

    So as long as the last column (m[0..3][3]) is 0, 0, 0, 1 you can extract object position and its “x”, “y”, “z” vectors (“side”, “up”, “front” – which is which depends on application) from matrix. If last column is not “0, 0, 0, 1”, then it is projection matrix and you can’t extract object data from it this easily.

    From there you could do anything you want with your camera.

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

Sidebar

Related Questions

I have multiple NSURLConnections running providing data back to the delegate objects. Is it
I'd like to have multiple versions of an object with different access modifiers on
I have object A which contains multiple instances of object B, which in turn
In my app, I have am receiving multiple memory leaks. The object is Malloc
I have an object (Client * client) which starts multiple threads to handle various
I have been attempting to have a object that I can use across multiple
I want to have multiple objects share a reference through a private field, such
Using Hashtable I want to have multiple objects mapped to the same key. E.g.
I have multiple objects, each with a series of attributes. I'd like the user
I have multiple business objects in my application (C#, Winforms, WinXP). When the user

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.