Sign in to follow this  
SeeMe

simple Matrix.LookAtLH problem (Resolved)

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this