Jump to content
  • Advertisement
Sign in to follow this  
Calin

OpenGL D3DXMatrixLookAtLH

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

With OpenGL you are free to choose between using gluLookAt and making your own camera manipulation system. Can you do the same thing with DX and D3DXMatrixLookAtLH function? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
You can use any method you like D3DXMatrixLookAtLH is just a helper function. You can fill the view matrix yourself.

Share this post


Link to post
Share on other sites
Yes.

You might notice that D3DXMatrixLookAtLH returns a matrix. In D3D, you compute the transformation matrices yourself (usually using D3DX) and hand them to the renderer. In D3D, there is a separate "view" matrix (as opposed to the "model-view" matrix in OpenGL) that is set by the camera.

Share this post


Link to post
Share on other sites
Hi there Calin,
How are you doing?

[The Problem]
Building your own camera manipulation system

[The Solution]
You certainly may, if I understand correctly you want to be able to manipulate it using your own methods such as specifying the position, which direction the camera is facing and the up vector (which way is up?).

The D3DX classes are mostly helper classes, you may choose to build the view matrix yourself.

Here are some resources on building 3rd person camera's :)

ToyMaker's Camera in Direct3D
Game Tutorial's 3rd Person camera in OpenGL
A Simple Third-Person Camera

I hope this helps, take care buddy.

Share this post


Link to post
Share on other sites
This might be useful, it shows the row make up of the camera matrix, sorry for the layout of it:

Row 1
Right.x
Up.x
Look.x
0.0f

Row 2
Right.y
Up.y
Look.y
0.0f

Row 3
Right.z
Up.z
Look.z
0.0f

Row 4
-position.right
-position.up
-position.look
1.0f

Note that the dot in row 4 is dot product


Share this post


Link to post
Share on other sites
I find it easier to treat the camera just like any other object. Create your matrix from the camera's position and rotation, invert it, and set it to the device's View matrix.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!