flyingVehicle.h
Engine/source/T3D/vehicles/flyingVehicle.h
Classes:
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _FLYINGVEHICLE_H_ 25#define _FLYINGVEHICLE_H_ 26 27#ifndef _VEHICLE_H_ 28#include "T3D/vehicles/vehicle.h" 29#endif 30 31#ifndef _CLIPPEDPOLYLIST_H_ 32#include "collision/clippedPolyList.h" 33#endif 34 35class ParticleEmitter; 36class ParticleEmitterData; 37 38 39//---------------------------------------------------------------------------- 40 41struct FlyingVehicleData: public VehicleData { 42 typedef VehicleData Parent; 43 44 enum Sounds { 45 JetSound, 46 EngineSound, 47 MaxSounds, 48 }; 49 SFXProfile* sound[MaxSounds]; 50 51 enum Jets { 52 // These enums index into a static name list. 53 ForwardJetEmitter, // Thrust forward 54 BackwardJetEmitter, // Thrust backward 55 DownwardJetEmitter, // Thrust down 56 TrailEmitter, // Contrail 57 MaxJetEmitters, 58 }; 59 ParticleEmitterData* jetEmitter[MaxJetEmitters]; 60 F32 minTrailSpeed; 61 62 // 63 F32 maneuveringForce; 64 F32 horizontalSurfaceForce; 65 F32 verticalSurfaceForce; 66 F32 autoInputDamping; 67 F32 steeringForce; 68 F32 steeringRollForce; 69 F32 rollForce; 70 F32 autoAngularForce; 71 F32 rotationalDrag; 72 F32 maxAutoSpeed; 73 F32 autoLinearForce; 74 F32 hoverHeight; 75 F32 createHoverHeight; 76 77 F32 vertThrustMultiple; 78 79 // Initialized in preload 80 ClippedPolyList rigidBody; 81 F32 maxSpeed; 82 83 enum JetNodes { 84 // These enums index into a static name list. 85 ForwardJetNode, 86 ForwardJetNode1, 87 BackwardJetNode, 88 BackwardJetNode1, 89 DownwardJetNode, 90 DownwardJetNode1, 91 // 92 TrailNode, 93 TrailNode1, 94 TrailNode2, 95 TrailNode3, 96 // 97 MaxJetNodes, 98 MaxDirectionJets = 2, 99 ThrustJetStart = ForwardJetNode, 100 NumThrustJets = TrailNode, 101 MaxTrails = 4, 102 }; 103 static const char *sJetNode[MaxJetNodes]; 104 S32 jetNode[MaxJetNodes]; 105 106 // 107 FlyingVehicleData(); 108 DECLARE_CONOBJECT(FlyingVehicleData); 109 static void initPersistFields(); 110 bool preload(bool server, String &errorStr); 111 void packData(BitStream* stream); 112 void unpackData(BitStream* stream); 113}; 114 115 116//---------------------------------------------------------------------------- 117 118class FlyingVehicle: public Vehicle 119{ 120 typedef Vehicle Parent; 121 122 FlyingVehicleData* mDataBlock; 123 124 SFXSource* mJetSound; 125 SFXSource* mEngineSound; 126 127 enum NetMaskBits { 128 InitMask = BIT(0), 129 HoverHeight = BIT(1) 130 }; 131 bool createHeightOn; 132 F32 mCeilingFactor; 133 134 enum ThrustDirection { 135 // Enums index into sJetActivationTable 136 ThrustForward, 137 ThrustBackward, 138 ThrustDown, 139 NumThrustDirections, 140 NumThrustBits = 3 141 }; 142 Point2F mThrust; 143 ThrustDirection mThrustDirection; 144 145 // Jet Threads 146 enum Jets { 147 // These enums index into a static name list. 148 BackActivate, 149 BackMaintain, 150 BottomActivate, 151 BottomMaintain, 152 JetAnimCount 153 }; 154 static const char* sJetSequence[FlyingVehicle::JetAnimCount]; 155 TSThread* mJetThread[JetAnimCount]; 156 S32 mJetSeq[JetAnimCount]; 157 bool mBackMaintainOn; 158 bool mBottomMaintainOn; 159 // Jet Particles 160 struct JetActivation { 161 // Convert thrust direction into nodes & emitters 162 S32 node; 163 S32 emitter; 164 }; 165 static JetActivation sJetActivation[NumThrustDirections]; 166 SimObjectPtr<ParticleEmitter> mJetEmitter[FlyingVehicleData::MaxJetNodes]; 167 168 // 169 bool onNewDataBlock(GameBaseData* dptr,bool reload); 170 void updateMove(const Move *move); 171 void updateForces(F32); 172// bool collideBody(const MatrixF& mat,Collision* info); 173 F32 getHeight(); 174 175 // Client sounds & particles 176 void updateJet(F32 dt); 177 void updateEngineSound(F32 level); 178 void updateEmitter(bool active,F32 dt,ParticleEmitterData *emitter,S32 idx,S32 count); 179 180 U32 getCollisionMask(); 181 public: 182 DECLARE_CONOBJECT(FlyingVehicle); 183 static void initPersistFields(); 184 185 FlyingVehicle(); 186 ~FlyingVehicle(); 187 188 bool onAdd(); 189 void onRemove(); 190 void advanceTime(F32 dt); 191 192 void writePacketData(GameConnection *conn, BitStream *stream); 193 void readPacketData(GameConnection *conn, BitStream *stream); 194 U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream); 195 void unpackUpdate(NetConnection *conn, BitStream *stream); 196 void useCreateHeight(bool val); 197}; 198 199 200#endif 201