ccamera.h

来自「一个DXD制作的读取QUAKE的BSP结构的Demo可以参考」· C头文件 代码 · 共 66 行

H
66
字号
/*
   Class Name:

      CCamera.

   Created by:

      Allen Sherrod (Programming Ace of www.UltimateGameProgramming.com).

   Description:

      This class represents a camera in a 3D scene.
*/


#ifndef CCAMERA_H
#define CCAMERA_H

#include<math.h>                          // Math header that allows us to use cos() and sin().
#include"CVector.h"                       // CVector3 class.

#define FORWARD         1.0               // Forward speed.
#define BACKWARD        -1.0              // Backward speed.
#define UP              0.03              // Up speed.
#define DOWN            -0.03             // Down speed.
#define LEFT            -0.03             // Left speed.
#define RIGHT           0.03              // Right speed.
#define STRAFE_LEFT     1.0               // Left straft speed.
#define STRAFE_RIGHT    -1.0              // Right straft speed.

#define GET_COS(a, b)   a = (float)cos(b) // Get the cos angle of b and store it in a.
#define GET_SINE(a, b)  a = (float)sin(b) // Get the sine angle of b and store it in a.


class CCamera
{
   public:
      CCamera();                                      // Constructor.

      void SetCamera(float x, float y, float z,       // Set the camera's position.
                     float xv, float yv, float zv,
                     float xu, float yu, float zu);

      void GetDirection(CVector4 &Direction);         // Get the view direction.
      void MoveCamera(float speed);                   // Move the camera forwards and backwards.
      void UpdateCamera(CVector4 Direction, float speed);// Update the camera's position.
      void StrafeCam(float speed);
      void CalculateStrafe();                            // Calculate the direction of the straft.
      void RotateCamera(float AngleDir, CVector4 Speed); // Rotate the camera around a point.
      void RotateByMouse(int mousePosX, int mousePosY, int midX, int midY);

      CVector4 mPos;                                  // Camera position.
      CVector4 mView;                                 // Look at position.
      CVector4 mUp;                                   // Up direction.
      CVector4 mStrafe;                               // Strafe direction.
      float currentRotationAngle;                     // Keeps us from going too far up or down.
};

#endif


// Copyright May 2003
// All Rights Reserved!
// Allen Sherrod
// ProgrammingAce@UltimateGameProgramming.com
// www.UltimateGameProgramming.com

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?