1 // Copyright © 2013-14 Meteoric Games Ltd 2 // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt 3 4 #ifndef _SHIP_COCKPIT_H_ 5 #define _SHIP_COCKPIT_H_ 6 7 #include "ModelBody.h" 8 9 static const float COCKPIT_LAG_MAX_ANGLE = 7.5f; 10 static const float COCKPIT_ROTATION_INTERP_MULTIPLIER = 5.0f; 11 static const float COCKPIT_ACCEL_INTERP_MULTIPLIER = 0.5f; 12 static const float COCKPIT_MAX_GFORCE = 10000.0f; 13 static const float COCKPIT_ACCEL_OFFSET = 0.075f; 14 15 class Player; 16 class Camera; 17 class InternalCameraController; 18 19 class ShipCockpit : public ModelBody { 20 public: 21 explicit ShipCockpit(const std::string &modelName); 22 virtual ~ShipCockpit(); 23 24 virtual void Render(Graphics::Renderer *r, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform) override; 25 26 void Update(const Player *player, float timeStep); 27 void RenderCockpit(Graphics::Renderer *renderer, const Camera *camera, FrameId frameId); 28 void OnActivated(const Player *player); 29 void resetInternalCameraController(void); 30 31 protected: 32 float CalculateSignedForwardVelocity(const vector3d &forward, const vector3d &velocity); 33 34 private: 35 ShipCockpit(const ShipCockpit &) = delete; 36 ShipCockpit &operator=(const ShipCockpit &) = delete; 37 38 vector3d m_shipDir; // current ship direction 39 vector3d m_shipYaw; // current ship yaw vector 40 vector3d m_dir; // cockpit direction 41 vector3d m_yaw; // cockpit yaw vector 42 float m_rotInterp; // for rotation interpolation 43 float m_transInterp; // for translation interpolation 44 float m_gForce; // current ship gforce 45 float m_offset; // current ship offset due to acceleration effect 46 float m_shipVel; // current ship velocity 47 vector3d m_translate; // cockpit translation 48 matrix4x4d m_transform; // cockpit transformation 49 InternalCameraController *m_icc; 50 }; 51 #endif 52