# view matrix - look opposite direction

This topic is 2588 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have my view matrix and everything works fine, however I am trying to make it look behind. I hope I'm explaining this properly, but say you are driving your virtual car around and press the "A" button to look at the traffic behind/following you. That what I am trying to do, just a rear-view mirror look. Any ideas how I can take my current view matrix and change it so I can point it to the rear of the direction its currently facing?

Thank you.

##### Share on other sites

I have my view matrix and everything works fine, however I am trying to make it look behind. I hope I'm explaining this properly, but say you are driving your virtual car around and press the "A" button to look at the traffic behind/following you. That what I am trying to do, just a rear-view mirror look. Any ideas how I can take my current view matrix and change it so I can point it to the rear of the direction its currently facing?

Thank you.

I'm definately no expert on the matter but how about you do the following? ( given that ViewMatrix, EyeVector and UpVector are already defined globally )

 UserPressedA() { D3DXMATRIX RotationMatrix; D3DXVECTOR4 LookAtVector_buffer; D3DXVECTOR3 LookAtVector; // Just to clarify we're dealing with a vector and not a point LookAtVector_buffer.w = 0.0f; // Create a 180 degree rotation matrix D3DXMatrixRotationY(&RotationMatrix, D3DX_PI); // PI radians equals 180 degrees // Apply the rotation matrix to the buffer vector4 D3DXVec4Transform(&LookAtVector_buffer, &LookAtVector_buffer, &RotationMatrix); // Convert to a vector3 that works with D3DXMatrixLookAtLH method LookAtVector = D3DXVECTOR3(LookAtVector_buffer.x, LookAtVector_buffer.y, LookATVector_buffer.z); // Update the viewmatrix based on the new LookAtVector D3DXMatrixLookAtLH(&ViewMatrix, &EyeVector, &LookAtVector, &UpVector); } 

You'd call this function once when the user presses A, and then call it again once the user releases A. I'm not sure this'll do it but that's what i would've tried

##### Share on other sites
Are you wanting to look behind from your "Exact" position?

if so you can just minus the lookat position -(lookAt) flips the positions behind the cameras current pos, build a view mat from that and your current pos and up vector and your sorted
no need to build a rotation matrix and transform a position etc if thats the case

##### Share on other sites
Ok I will give it a shot. I haven't looked at my issue in a few days as I've had other stuff going on, but now I'm back on the wagon. Thanks everyone

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631435
• Total Posts
3000056
×