#pragma once #include "Box.h" #include "Object3d.h" #include "Node.h" #include "Weapon.h" #include "Vector.h" #include "Bullet.h" #include "SoundNode.h" #include #include #include #include #include "NxPhysics.h" class Terrain; class ParticleEmitter; class Player : public Node { public: Player(void); ~Player(void); void initPlayer(float _x, float _y, float _z); void accelerate(); void stop(); void toLeft(); void toRight(); void setMouse(int x, int y); void setAvatareFileName(std::string _avatar); virtual void update(float dt); void setPlayerHit(Vector position, Bullet &bullet); void hitByFire(); void hitByIce(); bool isToasted(); void setPlayerOnGround(); void resetValues(); void addWeapon(Weapon &weapon); void addMunition(int type, int count); void addHealth(float dHealth); void setActiveWeapon(int wId); Weapon* getActiveWeapon(); void setHealth(float health); float getHealth(); float getRealHealth(); int getAmo(); void applyForce(Vector point, Vector force); Object3d *schale; virtual Node* clone(); Vector heading; //Car heading float ixSchale; float iySchale; float izSchale; float iaSchale; float ibSchale; float igSchale; float daSchale; float dbSchale; float dgSchale; //got Hit bool gotHit; virtual void killMe(); virtual void setSoftKill(bool _softKill, float _duration = 1.0f); friend class Weapon; void setTeam(int _team); int getTeam(); //PhysicStuff NxActor* upperSpringActor; NxDistanceJoint* upperJoint; void initWin(); void initLose(); protected: //Weapons health... int sleepCounter; int team; float health; float munition[10]; Weapon* weaponList[10]; std::string avatar; float fireHitCount; float iceHitCount; Weapon *activeWeapon; Vector weaponMounting; ParticleEmitter* pe; std::string hitSounds[3]; SoundNode* noSounds[3]; ParticleEmitter* winPe; //Vehicle variables bool baccelerate; bool bstop; bool btoLeft; bool btoRight; bool bfire; int mouseX; int mouseY; float maxEngineForce; float engineForce; float deltaEngineForce; float maxBreakForce; float breakForce; float deltaBreakForce; float Cdrag; float Crr; float Cdaempfung; float Croll; float Clateral; float Cschale; float Crotschale; float CimpactRot; float CrotBeschleunigung; float currentRotSchale; float upperDelta; //Steering variables float maxSteering; float steering; float steeringFactor; Object3d *wurm; Object3d *wheel[4]; SoundNode *motor; float schaleAlpha; float schaleHoehe; //Physic stuff Vector gravity; float cHeight; //Position of Center in y Axis float cFront; float cRear; float cSide; float rfDistance; //Distance from rear to front float cR_D; //cRear/cDistance float cF_D; float cH_D; Vector direction; //Cars driving/slipping direction Vector a; //Beschleunigung Vector v; //Geschwindigkeit float vMax; //Hoechstgeschwindigkeit Vector s; //Position Vector e; //W. Beschleunigung (fuer schale) float eYaw;//W. Beschleunigung um y achse Vector w; //W. Geschwindigkeit float p; //W. Position um y Achse //Kurvenfahrn float beta; float alphaFront; float alphaRear; float Flateral[4]; float Fcornering; Vector eAcc; float vehicleMass; float tMoment; //Trägheitsmoment float wheelMass; float wDownForce[4]; float vDownForce[4]; float sForce[4]; Vector longForce; float wheelAngle; float springL; float springK; Vector terrainHeight[4]; Vector schalenHeight[4]; float wheelRadius; float counter; float avgy; //average y float yf; //average front y float yr; //average rear y float yleft; //average left y float yright; //average right y float dyFrontRear; //diverence front rear float dyLeftRight; Vector terrainAngle; //vector which stores other Forces (collisions usw.) Vector fOther; std::vector torqueVector; //PartikelStuff void checkPosition(); //Physic Stuff .... wheelActors usw. float springDistance; float springBias; NxActor* createDistanceJoint(Vector pos, bool lowerJoint, bool reuse = false); ParticleEmitter* rauchEmitter; float lastYPos; //Save Y position to detect if the player is falling down in flyingmode to activate raycasting private: float playerPlayerCol; Vector hitPosition; Vector hitDir; Vector hitW; Vector hitP; float hitMaxHeight[4]; float hitForce; float hitTime; float timer; void updateDrivingPlayer(float dt); void updateFlyingPlayer(float dt); Vector getTerrainHeight(Vector v, bool flying = false); float calcLateralForce(float angle); bool rollingForward; float iHealth; //Physic Stuff float vLength; float vHeading; NxSphereShape *sphere; float desiredFlyingDownForce; float realFlyingDownForce; NxSphereShapeDesc triggerSphereDesc; //Trigger for detecting events like a bullet hit! float springCounter; };