tailieunhanh - Learning XNA 3.0 phần 6

Chú ý rằng bạn đã xác định hai biến ở cấp lớp: một ma trận điểm và một ma trận chiếu. Chiếc máy ảnh được đại diện bởi lớp này được thiết kế để được tĩnh. Như đã đề cập trước đây, xem ma trận đại diện cho vị trí và luân chuyển của máy ảnh. Nếu bạn đang đi để tạo ra một máy ảnh có thể được di chuyển trong không gian 3D, | Notice that you have specified two variables at the class level one for the view matrix and one for the projection matrix. The camera represented by this class was designed to be stationary. As mentioned previously the view matrix represents the location and rotation of the camera. If you re going to create a camera that can be moved through 3D space you re going to have to be able to modify the view matrix. In fact rather than modifying the view matrix you ll be rebuilding the matrix every frame. Remember that the view matrix is composed of a position vector a direction vector and an up vector. By creating class-level variables for each of those vectors you can modify things like the position of the camera the direction of the camera and which direction is up for the camera by simply modifying the appropriate vector variable and then rebuilding the view matrix of the camera with the new vectors. To move and rotate your camera you ll need to add the following three class-level variables to your Camera class Camera vectors public Vectors cameraposition get protected set Vectors cameraDirection Vectors cameraUp These three variables will be used to re-create your camera s view matrix each frame. Note that the cameraDirection variable is not the same as the camera s target or the actual point at which the camera is looking . The view matrix is created by the method which takes three parameters the position target and up vectors for the camera. The second parameter the camera s target represents the actual point at which your camera will be looking. In contrast the cameraDirection variable represents a relative direction in which your camera is facing rather than a target at which the camera is looking. In order to determine the actual target point that the camera is looking at you need to add your cameraPosition and cameraDirection vectors together see Figure 11-1 . This means two important things in relation to your cameraDirection vector. First

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.