⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ccamera.h

📁 一个DXD制作的读取QUAKE的BSP结构的Demo可以参考
💻 H
字号:
/*
   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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -