beginning opengl game programming 2004 phần 4

Tham khảo tài liệu 'beginning opengl game programming 2004 phần 4', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 94 Chapter 4 Transformations and Matrices Now we set the viewing transformation with the glTranslatef function. We move the modeling transformation to moving the world 10 units along the negative z-axis which effectively moves the camera to the position . glTranslatef draw a triangle at the origin glBegin GL_TRIANGLE glVertexf glVertexf glVertexf glEnd In this case there isn t a serious difference in code from the gluLookAt function because all you are doing is moving the camera along the z axis. But if you were orienting the camera at an odd angle you would need to use the glRotate function as well you will see more of glTranslate and glRotate soon which leads to the next way of manipulating the camera your own custom routines. Creating Your Own Custom Routines Suppose you want to create your own flight simulator. In a typical flight simulator the camera is positioned in the pilot s seat so it moves and is oriented in the same manner as the plane. Plane orientation is defined by pitch yaw and roll which are rotation angles relative to the center of gravity of the plane in your case the pilot camera position . Using the modeling-transformation functions you could create the following function to create the viewing transformation void PlaneView GLfloat planeX GLfloat planeY GLfloat planeZ the plane s position GLfloat roll GLfloat pitch GLfloat yaw orientation roll is rotation about the z axis glRotatef roll yaw or heading is rotation about the y axis glRotatef yaw pitch is rotation about the x axis glRotatef pitch move the plane to the plane s world coordinates glTranslatef -planeX -planeY -planeZ TLFeBOOK Using Your Own Matrices 95 Using this function places the camera in the pilot s seat of your airplane regardless of the orientation or location of the plane. This is just one of the uses of your own customized routines. Other .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
144    113    5    16-05-2024
Đã 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.