simple Matrix.LookAtLH problem (Resolved)

Started by
5 comments, last by SeeMe 17 years, 11 months ago
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]
Advertisement
Perhaps your near clipping plane is at 6? Check your projection matrix setup.
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
);
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 !
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.
Edit: My mistake
Adamhttp://www.allgamedevelopment.com
Tx you !!!

This topic is closed to new replies.

Advertisement