简体   繁体   中英

directx camera position is confusing me

I have just read the following:

Let's say we want to have the player view an object located at the world's origin (0, 0, 0). We want the player to be viewing the object from the coordinates (100, 100, 100). To do this we need to build a matrix containing this data. We build this matrix using a function called XMMatrixLookAtLH(). Here is how you use it:

 XMVECTOR vecCamPosition = XMVectorSet(100, 100, 100, 0); XMVECTOR vecCamLookAt = XMVectorSet(0, 0, 0, 0); XMVECTOR vecCamUp = XMVectorSet(0, 1, 0, 0); XMMATRIX matView = XMMatrixLookAtLH(vecCamPosition, vecCamLookAt, vecCamUp); 

from: http://www.directxtutorial.com/Lesson.aspx?lessonid=111-6-1

I do not understand why if you want to look at an object located at 0, 0, 0, you should position the camera at 100, 100, 100... surely that would mean the camera was way past it... and then looking back at it?

thing is, if I set my camera to 0.0, 0.0, -1.0 and have my objects at az index of 1.0... my camera can no longer see my objects...

I don't get it?

在此处输入图片说明

It sounds like you have 2D objects "facing" away from the camera when positioned at (0, 0, -1). If you reverse your ordering on your triangle vertices, they should show up.

You are fine to put the camera wherever you wish. If you are looking at 3D objects, you should have no issues.

In DirectX, 2D objects can only be seen when their vertices are in clockwise ordering as seen from the camera (though you can turn this off, or change it to discard counter-clockwise triangles if you wish). DirectX uses the clockwise vs counter-clockwise ordering to discard faces so it doesn't draw the backs of 3D objects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM