Jump to content
  • Advertisement
Sign in to follow this  
SeeMe

simple Matrix.LookAtLH problem (Resolved)

This topic is 4441 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

Hello, I'm just beggining whith Managed DirectX. There is a thing I can't understand : I have just displayed a triangle : verts2[0] = new CustomVertex.PositionColored(new Vector3(0, 0, 1), Color.Red.ToArgb()); verts2[1] = new CustomVertex.PositionColored(new Vector3(1, 0, 0), Color.YellowGreen.ToArgb()); verts2[2] = new CustomVertex.PositionColored(new Vector3(-1, 0, 0), Color.Blue.ToArgb()); Why when i try to view it from the Top, it shows my nothing ?? myDevice.Transform.View = Matrix.LookAtLH( new Vector3(0, 6, 0), new Vector3(0, 0, 0), new Vector3(0, 1, 0) ); If I put new Vector3(0, 6, 0.000000001f), It works Perfectly ? Tx you for your help ! [Edited by - SeeMe on May 24, 2006 11:38:00 AM]

Share this post


Link to post
Share on other sites
Advertisement
Hello, my ZNear is set to 1.0f and ZFar is 100.0f ...

Other strange things :

If I set my position at Vector3(0, 6, -0.000000001f) I see the triangle but upside-down !

...

Here are my World, View and Projection matrices :

myDevice.Transform.World = Matrix.Identity;
myDevice.Transform.View = Matrix.LookAtLH(
new Vector3(0, 6, -0.00001f),
new Vector3(0, 0, 0),
new Vector3(0, 1, 0)
);

myDevice.Transform.Projection = Matrix.PerspectiveFovLH(
(float)Math.PI / 4,
(float)myRenderTarget.Width / (float)myRenderTarget.Height, // floats for decimal based division, not integer
1.0f, 100.0f
);

Share this post


Link to post
Share on other sites
It's me again ! :D

In fact for my little "problem", it seems that if you set both camera position and target view with the same Z value, you see nothing !

Still nobody to explain ? :) Thanks you !

Share this post


Link to post
Share on other sites
Quote:
Original post by SeeMe
It's me again ! :D

In fact for my little "problem", it seems that if you set both camera position and target view with the same Z value, you see nothing !

Still nobody to explain ? :) Thanks you !
A usual 'lookat' algorithm fails when the vector from the eye to the target is parallel to the up vector. If you want to view your object from directly above or below, use a different vector for the 'up' argument to the lookat function.

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!