Make Camera LookDirection look front face

前端 未结 1 705
北荒
北荒 2021-01-06 08:18

How to look at the front of 3D Model in WPF?

I am confused to set X Y Z for LookDirection.

I don\'t know what happens when I set xy

相关标签:
1条回答
  • 2021-01-06 08:44

    Imagine, instead of a camera, you're moving your head around in 3D space. then Camera.Position is specifying where your head is located, Camera.LookDirection determines the direction you're looking at and Camera.UpDirection shows the orientation of your head. the following pictures clear things up for you.

    In the first Image, Camera is centered on the +Z axis looking down to -Z axis and to your shape:

    enter image description here

    When you set camera.Position to for example (x=1, y=0, z=10) then camera position changes like this:

    enter image description here

    as a result, camera moves a little to the right and therefore you will see your shape at the left side of the view.

    Now if camera.LookDirection gets changed to say (x=0, y=1, z=-1), then camera simply looks at the point (0,1,-1) like this:

    enter image description here


    Important Edit:

    Based on DaveInCaz's comment, LookDirection is different from LookAtPoint (former property of PrespectiveCamera which was a Point3D rather than Vector3D).

    LookDirection is actually equals to "the point to look at" minus "camera position".

    This means that in the above diagram, if we want the camera which is located in (1,0,10) to look at point (0,1,-1) then the LookDirection should be:

    (0,1,-1) - (1,0,10) = (-1,1,-11).


    And finally, camera.UpDirection determines where the top of your camera points at. In the following picture, setting camera.UpDirection to (-0.5,1,0) results in rotation of the camera counter clockwise:

    enter image description here

    I hope these pictures clear things up for you.

    0 讨论(0)
提交回复
热议问题