1 #pragma once 2 #include <OgreVector3.h> 3 #include <OgreQuaternion.h> 4 #include <OgreString.h> 5 #include <vector> 6 7 8 enum CamTypes 9 { 10 CAM_Follow = 0, // 0 Follow - car rotY & pos from behind car, smooth 11 CAM_Free, // 1 Free - free rot, pos from car 12 CAM_Arena, // 2 Arena - free pos & rot, fly 13 CAM_Car, // 3 Car - car pos & rot, full 14 CAM_ExtAng, // 4 Extended, angles - car rotY & pos, smooth, const distance 15 CAM_ALL 16 }; 17 18 const char CAM_Str[CAM_ALL][10] = 19 {"Follow", "Free", "Arena", "Car", "ExtAng" }; 20 21 22 class CameraAngle 23 { 24 public: 25 CamTypes mType; Ogre::String mName; 26 Ogre::Real mDist, mSpeed, mSpeedRot, mOfsMul; 27 Ogre::Radian mYaw, mPitch; 28 Ogre::Vector3 mOffset; 29 int mMain, mHideGlass; 30 31 CameraAngle(); 32 }; 33 34 35 namespace Ogre { class TerrainGroup; class Camera; class OverlayElement; class SceneNode; } 36 struct PosInfo; class SETTINGS; 37 38 39 //#define CAM_TILT_DBG // show wheels in ray hit poses 40 class COLLISION_WORLD; 41 42 43 class FollowCamera 44 { 45 public: 46 FollowCamera(Ogre::Camera* cam, SETTINGS* pSet1); 47 ~FollowCamera(); 48 49 SETTINGS* pSet; 50 51 // ogre 52 Ogre::Camera* mCamera; 53 Ogre::TerrainGroup* mTerrain; 54 class btRigidBody* chassis; 55 56 /// state vars 57 Ogre::Vector3 mLook, mPosNodeOld; Ogre::Real mVel; 58 Ogre::Quaternion qq; // for ext cam 59 Ogre::Radian mAPitch,mAYaw, mATilt; // for arena cam, smoothing 60 Ogre::Vector3 camPosFinal; Ogre::Real mDistReduce; //float dbgLen; 61 62 #ifdef CAM_TILT_DBG 63 Ogre::Vector3 posHit[4]; 64 #endif 65 66 /// update, simulates camera 67 void update(Ogre::Real time, const PosInfo& posInPrev, PosInfo* posOut, COLLISION_WORLD* world, bool bounce); 68 bool updInfo(Ogre::Real time = 0); char ss[512]; 69 Ogre::String sName; bool updName; 70 71 // apply, sets mCamera's pos and rot 72 void Apply(const PosInfo& posIn); 73 74 void Move( bool mbLeft, bool mbRight, bool mbMiddle, bool shift, Ogre::Real mx, Ogre::Real my, Ogre::Real mz ); 75 Ogre::Real fMoveTime; 76 77 78 // Camera Angles 79 CameraAngle* ca; 80 int miCount, miCurrent; 81 std::vector<CameraAngle*> mCameraAngles; 82 // first (after change, reset etc) 83 bool first; int iFirst; void First(); 84 85 bool loadCameras(); void saveCamera(), Destroy(); 86 void updAngle(), incCur(int dir); 87 void Next(bool bPrev = false, bool bMainOnly = false); 88 void setCamera(int ang); 89 TypeCar()90 bool TypeCar() { return ca && ca->mType == CAM_Car; } 91 92 // info text formats 93 Ogre::String sFmt_Follow, sFmt_Free, sFmt_ExtAng, sFmt_Arena, sFmt_Car; 94 void updFmtTxt(); 95 }; 96