CCamera.h
上传用户:arsena_zhu
上传日期:2022-07-12
资源大小:399k
文件大小:2k
源码类别:

OpenGL

开发平台:

Visual C++

  1. /*
  2.    Class Name:
  3.       CCamera.
  4.    Created by:
  5.       Allen Sherrod (Programming Ace of www.UltimateGameProgramming.com).
  6.    Description:
  7.       This class represents a camera in a 3D scene.
  8. */
  9. #ifndef CCAMERA_H
  10. #define CCAMERA_H
  11. #include<math.h>                          // Math header that allows us to use cos() and sin().
  12. #define SPD 0.1f
  13. class CCamera
  14. {
  15.    public:
  16.       CCamera();
  17. void UpDown(float m)
  18. { yPos += m; yView += m; }
  19.       void SetCamera(float x, float y, float z,
  20.                      float xv, float yv, float zv,
  21.                      float xu, float yu, float zu);
  22.       void MoveCamera(float direction);
  23.       void UpdateCamera(float xDir, float yDir,
  24.                         float zDir, float dir);
  25.       void StrafeCam(float direction);
  26.       void CalculateStrafe();
  27.       void RotateCamera(float AngleDir, float xSpeed,
  28.                         float ySpeed, float zSpeed);
  29.       void RotateByMouse(int mousePosX, int mousePosY,
  30.                          int midX, int midY);
  31.       float xPos, yPos, zPos;                         // Camera position.
  32.       float xView, yView, zView;                      // Look at position.
  33.       float xUp, yUp, zUp;                            // Up direction.
  34.       float xStrafe, yStrafe, zStrafe;                // Strafe direction.
  35.       float currentRotationAngle;                     // Keeps us from going too far up or down.
  36. };
  37. #endif
  38. // Copyright October 2004
  39. // All Rights Reserved!
  40. // Allen Sherrod
  41. // ProgrammingAce@UltimateGameProgramming.com
  42. // www.UltimateGameProgramming.com