Jump to content
• Advertisement

Public Group

# 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

##### Share on other sites
Advertisement
Perhaps your near clipping plane is at 6? Check your projection matrix setup.

#### Share this 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

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

##### Share on other sites
Quote:
 Original post by SeeMeIt's me again ! :DIn 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

Tx you !!!

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
24
4. 4
JoeJ
18
5. 5
• Advertisement

• 14
• 23
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631766
• Total Posts
3002232
×

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