?? ccamera.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 + -