[1378] | 1 | #pragma once
|
---|
| 2 | #include "Box.h"
|
---|
| 3 | #include "Object3d.h"
|
---|
| 4 | #include "Node.h"
|
---|
| 5 | #include "Weapon.h"
|
---|
| 6 | #include "Vector.h"
|
---|
| 7 | #include "Bullet.h"
|
---|
| 8 | #include "SoundNode.h"
|
---|
| 9 | #include <vector>
|
---|
| 10 | #include <cmath>
|
---|
| 11 | #include <ctime>
|
---|
| 12 | #include <math.h>
|
---|
| 13 | #include "NxPhysics.h"
|
---|
| 14 |
|
---|
| 15 | class Terrain;
|
---|
| 16 | class ParticleEmitter;
|
---|
| 17 |
|
---|
| 18 | class Player : public Node
|
---|
| 19 | {
|
---|
| 20 | public:
|
---|
| 21 | Player(void);
|
---|
| 22 | ~Player(void);
|
---|
| 23 | void initPlayer(float _x, float _y, float _z);
|
---|
| 24 |
|
---|
| 25 | void accelerate();
|
---|
| 26 | void stop();
|
---|
| 27 | void toLeft();
|
---|
| 28 | void toRight();
|
---|
| 29 | void setMouse(int x, int y);
|
---|
| 30 |
|
---|
| 31 | void setAvatareFileName(std::string _avatar);
|
---|
| 32 |
|
---|
| 33 | virtual void update(float dt);
|
---|
| 34 | void setPlayerHit(Vector position, Bullet &bullet);
|
---|
| 35 | void hitByFire();
|
---|
| 36 | void hitByIce();
|
---|
| 37 | bool isToasted();
|
---|
| 38 | void setPlayerOnGround();
|
---|
| 39 | void resetValues();
|
---|
| 40 |
|
---|
| 41 | void addWeapon(Weapon &weapon);
|
---|
| 42 | void addMunition(int type, int count);
|
---|
| 43 | void addHealth(float dHealth);
|
---|
| 44 | void setActiveWeapon(int wId);
|
---|
| 45 | Weapon* getActiveWeapon();
|
---|
| 46 | void setHealth(float health);
|
---|
| 47 | float getHealth();
|
---|
| 48 | float getRealHealth();
|
---|
| 49 | int getAmo();
|
---|
| 50 |
|
---|
| 51 | void applyForce(Vector point, Vector force);
|
---|
| 52 |
|
---|
| 53 | Object3d *schale;
|
---|
| 54 |
|
---|
| 55 | virtual Node* clone();
|
---|
| 56 |
|
---|
| 57 | Vector heading; //Car heading
|
---|
| 58 |
|
---|
| 59 | float ixSchale;
|
---|
| 60 | float iySchale;
|
---|
| 61 | float izSchale;
|
---|
| 62 | float iaSchale;
|
---|
| 63 | float ibSchale;
|
---|
| 64 | float igSchale;
|
---|
| 65 | float daSchale;
|
---|
| 66 | float dbSchale;
|
---|
| 67 | float dgSchale;
|
---|
| 68 |
|
---|
| 69 | //got Hit
|
---|
| 70 | bool gotHit;
|
---|
| 71 |
|
---|
| 72 | virtual void killMe();
|
---|
| 73 | virtual void setSoftKill(bool _softKill, float _duration = 1.0f);
|
---|
| 74 |
|
---|
| 75 | friend class Weapon;
|
---|
| 76 |
|
---|
| 77 | void setTeam(int _team);
|
---|
| 78 | int getTeam();
|
---|
| 79 |
|
---|
| 80 | //PhysicStuff
|
---|
| 81 | NxActor* upperSpringActor;
|
---|
| 82 | NxDistanceJoint* upperJoint;
|
---|
| 83 |
|
---|
| 84 |
|
---|
| 85 | void initWin();
|
---|
| 86 | void initLose();
|
---|
| 87 |
|
---|
| 88 | protected:
|
---|
| 89 | //Weapons health...
|
---|
| 90 | int sleepCounter;
|
---|
| 91 | int team;
|
---|
| 92 | float health;
|
---|
| 93 | float munition[10];
|
---|
| 94 | Weapon* weaponList[10];
|
---|
| 95 | std::string avatar;
|
---|
| 96 | float fireHitCount;
|
---|
| 97 | float iceHitCount;
|
---|
| 98 | Weapon *activeWeapon;
|
---|
| 99 | Vector weaponMounting;
|
---|
| 100 |
|
---|
| 101 | ParticleEmitter* pe;
|
---|
| 102 |
|
---|
| 103 | std::string hitSounds[3];
|
---|
| 104 | SoundNode* noSounds[3];
|
---|
| 105 |
|
---|
| 106 | ParticleEmitter* winPe;
|
---|
| 107 |
|
---|
| 108 | //Vehicle variables
|
---|
| 109 | bool baccelerate;
|
---|
| 110 | bool bstop;
|
---|
| 111 | bool btoLeft;
|
---|
| 112 | bool btoRight;
|
---|
| 113 | bool bfire;
|
---|
| 114 | int mouseX;
|
---|
| 115 | int mouseY;
|
---|
| 116 |
|
---|
| 117 | float maxEngineForce;
|
---|
| 118 | float engineForce;
|
---|
| 119 | float deltaEngineForce;
|
---|
| 120 |
|
---|
| 121 | float maxBreakForce;
|
---|
| 122 | float breakForce;
|
---|
| 123 | float deltaBreakForce;
|
---|
| 124 |
|
---|
| 125 | float Cdrag;
|
---|
| 126 | float Crr;
|
---|
| 127 | float Cdaempfung;
|
---|
| 128 | float Croll;
|
---|
| 129 | float Clateral;
|
---|
| 130 | float Cschale;
|
---|
| 131 | float Crotschale;
|
---|
| 132 | float CimpactRot;
|
---|
| 133 | float CrotBeschleunigung;
|
---|
| 134 | float currentRotSchale;
|
---|
| 135 | float upperDelta;
|
---|
| 136 |
|
---|
| 137 | //Steering variables
|
---|
| 138 | float maxSteering;
|
---|
| 139 | float steering;
|
---|
| 140 | float steeringFactor;
|
---|
| 141 |
|
---|
| 142 | Object3d *wurm;
|
---|
| 143 | Object3d *wheel[4];
|
---|
| 144 | SoundNode *motor;
|
---|
| 145 | float schaleAlpha;
|
---|
| 146 | float schaleHoehe;
|
---|
| 147 |
|
---|
| 148 | //Physic stuff
|
---|
| 149 | Vector gravity;
|
---|
| 150 | float cHeight; //Position of Center in y Axis
|
---|
| 151 | float cFront;
|
---|
| 152 | float cRear;
|
---|
| 153 | float cSide;
|
---|
| 154 | float rfDistance; //Distance from rear to front
|
---|
| 155 | float cR_D; //cRear/cDistance
|
---|
| 156 | float cF_D;
|
---|
| 157 | float cH_D;
|
---|
| 158 |
|
---|
| 159 | Vector direction; //Cars driving/slipping direction
|
---|
| 160 |
|
---|
| 161 | Vector a; //Beschleunigung
|
---|
| 162 | Vector v; //Geschwindigkeit
|
---|
| 163 | float vMax; //Hoechstgeschwindigkeit
|
---|
| 164 | Vector s; //Position
|
---|
| 165 |
|
---|
| 166 | Vector e; //W. Beschleunigung (fuer schale)
|
---|
| 167 | float eYaw;//W. Beschleunigung um y achse
|
---|
| 168 | Vector w; //W. Geschwindigkeit
|
---|
| 169 | float p; //W. Position um y Achse
|
---|
| 170 |
|
---|
| 171 | //Kurvenfahrn
|
---|
| 172 | float beta;
|
---|
| 173 | float alphaFront;
|
---|
| 174 | float alphaRear;
|
---|
| 175 | float Flateral[4];
|
---|
| 176 | float Fcornering;
|
---|
| 177 |
|
---|
| 178 | Vector eAcc;
|
---|
| 179 | float vehicleMass;
|
---|
| 180 | float tMoment; //Trägheitsmoment
|
---|
| 181 | float wheelMass;
|
---|
| 182 | float wDownForce[4];
|
---|
| 183 | float vDownForce[4];
|
---|
| 184 | float sForce[4];
|
---|
| 185 | Vector longForce;
|
---|
| 186 | float wheelAngle;
|
---|
| 187 |
|
---|
| 188 | float springL;
|
---|
| 189 | float springK;
|
---|
| 190 |
|
---|
| 191 | Vector terrainHeight[4];
|
---|
| 192 | Vector schalenHeight[4];
|
---|
| 193 |
|
---|
| 194 | float wheelRadius;
|
---|
| 195 |
|
---|
| 196 | float counter;
|
---|
| 197 | float avgy; //average y
|
---|
| 198 | float yf; //average front y
|
---|
| 199 | float yr; //average rear y
|
---|
| 200 | float yleft; //average left y
|
---|
| 201 | float yright; //average right y
|
---|
| 202 | float dyFrontRear; //diverence front rear
|
---|
| 203 | float dyLeftRight;
|
---|
| 204 | Vector terrainAngle;
|
---|
| 205 |
|
---|
| 206 | //vector which stores other Forces (collisions usw.)
|
---|
| 207 | Vector fOther;
|
---|
| 208 | std::vector<Vector> torqueVector;
|
---|
| 209 |
|
---|
| 210 | //PartikelStuff
|
---|
| 211 | void checkPosition();
|
---|
| 212 |
|
---|
| 213 | //Physic Stuff .... wheelActors usw.
|
---|
| 214 | float springDistance;
|
---|
| 215 | float springBias;
|
---|
| 216 |
|
---|
| 217 | NxActor* createDistanceJoint(Vector pos, bool lowerJoint, bool reuse = false);
|
---|
| 218 | ParticleEmitter* rauchEmitter;
|
---|
| 219 |
|
---|
| 220 | float lastYPos; //Save Y position to detect if the player is falling down in flyingmode to activate raycasting
|
---|
| 221 | private:
|
---|
| 222 |
|
---|
| 223 | float playerPlayerCol;
|
---|
| 224 | Vector hitPosition;
|
---|
| 225 | Vector hitDir;
|
---|
| 226 | Vector hitW;
|
---|
| 227 | Vector hitP;
|
---|
| 228 | float hitMaxHeight[4];
|
---|
| 229 | float hitForce;
|
---|
| 230 | float hitTime;
|
---|
| 231 | float timer;
|
---|
| 232 |
|
---|
| 233 |
|
---|
| 234 | void updateDrivingPlayer(float dt);
|
---|
| 235 | void updateFlyingPlayer(float dt);
|
---|
| 236 | Vector getTerrainHeight(Vector v, bool flying = false);
|
---|
| 237 | float calcLateralForce(float angle);
|
---|
| 238 | bool rollingForward;
|
---|
| 239 | float iHealth;
|
---|
| 240 |
|
---|
| 241 | //Physic Stuff
|
---|
| 242 | float vLength;
|
---|
| 243 | float vHeading;
|
---|
| 244 | NxSphereShape *sphere;
|
---|
| 245 | float desiredFlyingDownForce;
|
---|
| 246 | float realFlyingDownForce;
|
---|
| 247 |
|
---|
| 248 |
|
---|
| 249 | NxSphereShapeDesc triggerSphereDesc; //Trigger for detecting events like a bullet hit!
|
---|
| 250 | float springCounter;
|
---|
| 251 | };
|
---|