//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴 //Procedure GETALTW //Author Paul. //Date Wed 26 Aug 1998 //------------------------------------------------------------------------------ ULong GETALTW(inptr) { UByte lo,hi; lo=STARPLUSPLUS(inptr); hi=STARPLUSPLUS(inptr); UWord retVal=(hi<<8)+lo; if (retVal<lowestAlt) lowestAlt=retVal; if (retVal>highestAlt) highestAlt=retVal; return UWord(retVal); }
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴 //Procedure FINDEDGEPOINTS //Author Paul. //Date Wed 26 Aug 1998 // //------------------------------------------------------------------------------ UWord FINDEDGEPOINTS(ip) { UByte* inptr=ip; UByte tmp[5]; pointdec[0]=*pplPoint0; pointdec[1]=*pplPoint1; pointdec[2]=*pplPoint2; pointdec[3]=*pplPoint3; for (int i=4;i<256;pointdec[i++]=*pplReset); Max_Points=4; UByte* b0=tmp; tmp[0]=STARPLUSPLUS(inptr); tmp[1]=STARPLUSPLUS(inptr); tmp[2]=STARPLUSPLUS(inptr); tmp[3]=STARPLUSPLUS(inptr); if (tmp[0]==0xFF && tmp[1]==0xFF && tmp[3]==0xFF) { ip=inptr; return UWord(tmp[2])+0x8000; } tmp[4]=STARPLUSPLUS(inptr); //test to see if altitude data is present... altData=NO_ALT; if (tmp[0]&0x80) { tmp[0]&=0x7F; //this means that some extra bytes follow.. baseAltitude=STARPLUSPLUS(inptr); //base alt value for the tile scaleAltitude=STARPLUSPLUS(inptr); //scaling factor for the altitude if (baseAltitude==0xFF&&scaleAltitude==0xFF) altData=WORD_ALT; else { altData=BYTE_ALT; baseAltitude<<=6; } //get the corner point altitudes if (altData==BYTE_ALT) { pointdec[0].alt=GETALTITUDE(inptr); pointdec[1].alt=GETALTITUDE(inptr); pointdec[2].alt=GETALTITUDE(inptr); pointdec[3].alt=GETALTITUDE(inptr); } else { pointdec[0].alt=GETALTWORD(inptr); //and normal data pointdec[0].shadeVal=STARPLUSPLUS(inptr); pointdec[1].alt=GETALTWORD(inptr); //and normal data pointdec[1].shadeVal=STARPLUSPLUS(inptr); pointdec[2].alt=GETALTWORD(inptr); //and normal data pointdec[3].shadeVal=STARPLUSPLUS(inptr); pointdec[3].alt=GETALTWORD(inptr); //and normal data pointdec[2].shadeVal=STARPLUSPLUS(inptr); } } //Used for light shading later on... totalEdgePoints=tmp[0]+tmp[1]+tmp[2]+tmp[3]+4; int lastx,lasty; lastx=0; //top edge lasty=0; int pts=*b0++; topEdgeCnt=pts; int upf=0; pointdec[upf].unpairedfrom[0]=1; if (pts) do { lastx+=STARPLUSPLUS(inptr); pointdec[Max_Points].x=lastx; pointdec[Max_Points].y=lasty; if (altData==BYTE_ALT) { pointdec[Max_Points].alt=GETALTITUDE(inptr); } else if (altData==WORD_ALT) { pointdec[Max_Points].alt=GETALTWORD(inptr); pointdec[Max_Points].shadeVal=STARPLUSPLUS(inptr); } else pointdec[Max_Points].alt=0; PointsConnected(upf,Max_Points); pointdec[Max_Points].lastfrom= pointdec[Max_Points].unpairedfrom[0]=1; pointdec[Max_Points].lastto=upf; pointdec[upf].lastfrom= pointdec[upf].unpairedfrom[0]= Max_Points; pointdec[1].lastto=Max_Points; upf=Max_Points; Max_Points++; } while (--pts!=0!=0); PointsConnected(upf,1); lastx=256; //RHS edge lasty=0; pts=*b0++; rightEdgeCnt=pts; upf=1; pointdec[upf].unpairedfrom[0]=2; if (pts) do { lasty+=STARPLUSPLUS(inptr); pointdec[Max_Points].x=lastx; pointdec[Max_Points].y=lasty; if (altData==BYTE_ALT) pointdec[Max_Points].alt=GETALTITUDE(inptr); else if (altData==WORD_ALT) { pointdec[Max_Points].alt=GETALTWORD(inptr); pointdec[Max_Points].shadeVal=STARPLUSPLUS(inptr); } else pointdec[Max_Points].alt=0; PointsConnected(upf,Max_Points); pointdec[Max_Points].lastfrom= pointdec[Max_Points].unpairedfrom[0]=2; pointdec[Max_Points].lastto=upf; pointdec[upf].lastfrom= pointdec[upf].unpairedfrom[0]=Max_Points; pointdec[2].lastto=Max_Points; upf=Max_Points; Max_Points++; } while (--pts!=0!=0); PointsConnected(upf,2); lastx=0; //BOT edge lasty=256; pts=*b0++; bottomEdgeCnt=pts; upf=3; pointdec[2].unpairedfrom[0]=(UByte)upf; if (pts) do { lastx+=STARPLUSPLUS(inptr); pointdec[Max_Points].x=lastx; pointdec[Max_Points].y=lasty; if (altData==BYTE_ALT) pointdec[Max_Points].alt=GETALTITUDE(inptr); else if (altData==WORD_ALT) { pointdec[Max_Points].alt=GETALTWORD(inptr); pointdec[Max_Points].shadeVal=STARPLUSPLUS(inptr); } else pointdec[Max_Points].alt=0; PointsConnected(upf,Max_Points); pointdec[Max_Points].lastfrom= pointdec[Max_Points].unpairedfrom[0]=(UByte)upf; pointdec[Max_Points].lastto=2; pointdec[upf].lastto=Max_Points; pointdec[2].lastfrom= pointdec[2].unpairedfrom[0]=Max_Points; upf=Max_Points; Max_Points++; } while (--pts!=0); PointsConnected(upf,2); lastx=0; //LHS edge lasty=0; pts=*b0++; leftEdgeCnt=pts; upf=0; pointdec[3].unpairedfrom[0]=(UByte)upf; if (pts) do { lasty+=STARPLUSPLUS(inptr); pointdec[Max_Points].x=lastx; pointdec[Max_Points].y=lasty; if (altData==BYTE_ALT) pointdec[Max_Points].alt=GETALTITUDE(inptr); else if (altData==WORD_ALT) { pointdec[Max_Points].alt=GETALTWORD(inptr); pointdec[Max_Points].shadeVal=STARPLUSPLUS(inptr); } else pointdec[Max_Points].alt=0; PointsConnected(upf,Max_Points); pointdec[Max_Points].lastfrom= pointdec[Max_Points].unpairedfrom[0]=(UByte)upf; pointdec[Max_Points].lastto=3; pointdec[upf].lastto=Max_Points; pointdec[3].lastfrom= pointdec[3].unpairedfrom[0]=Max_Points; upf=Max_Points; Max_Points++; } while (--pts!=0); PointsConnected(upf,3); Highest_Point_Defined=Max_Points; pts=*b0++; if (pts) do { pointdec[Max_Points].x=0; pointdec[Max_Points].y=0; pointdec[Max_Points].alt=0; Max_Points++; } while (--pts!=0); ip=inptr; return UWord(0); }
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴 //Procedure ProcessPistonEngine //Author Craig Beeston //Date Tue 11 Aug 98 // //Description Processes a piston engine // Calculates Thrust, Torque, Engine power and Engine speed // //Inputs // //Returns // //------------------------------------------------------------------------------ void Engine::ProcessPistonEngine (AirStrucPtr const ControlledAC) { AircraftAnimData* adptr = (AircraftAnimData *)ControlledAC->Anim; SWord iDamage = 255 - (255 - UWord(adptr->ENGINELEFT)) * (255 - UWord(adptr->FRONT)) / 255; if(pThrustPoint->Pos.x > 0) iDamage = adptr->ENGINERIGHT; FP MaxSpeed = 2 * Rpm100 * 0.001047197; //RPM 2 Rads/cs if(iDamage == 254) MaxSpeed = 0; FP fDamage = 1.0 - FP(iDamage) * (1.0 / 255.0); //DEADCODE CB 04/11/99 FP MinSpeed = Rpm0 * 0.001047197; //RPM 2 Rads/cs //DEADCODE CB 04/11/99 if (Speed < MinSpeed) Speed = MinSpeed; if (Speed > MaxSpeed) Speed = MaxSpeed; FP EngRPM = Speed * 954.9296586; FP PropSpeed = Speed * GearRatio; FP PropSwirl = SlipRot * 0.5; const FP BladeFract = 0.60; FCRD Vel; CPrd(Vel, pThrustPoint->Pos, pModel->RotVel); Vel.z -= pModel->AirVel.z; //Velocity of air ahead of prop FP PropAirVel = BladeFract * (PropSpeed - PropSwirl) * BladeRadius; FP InflowAng = CalcAngle (PropAirVel, PropVel); //Automatic prop control for AI aircraft if((!Save_Data.flightdifficulty [FD_PROPPITCH]) || (ControlledAC != Persons2::PlayerSeenAC)) { switch(PropType) { case PT_FIXED: break; case PT_2PITCH: if(EngRPM > 1.15 * Rpm100) PropSetting = 0; if(EngRPM < 0.7 * Rpm100) PropSetting = 1; break; case PT_VARIABLE: PropSetting = 1.0 - 1.15 * ControlledAC->vel_ / ControlledAC->classtype->maxvel; MODMAXMIN(PropSetting, 0.01, 1); break; case PT_CONSTSPEED: if(ThrottleSetting <= 75) PropSetting = 0; else PropSetting = (ThrottleSetting - 75.0) / 25.0; //DEADCODE CSB 31/01/00 PropSetting = FP(ThrottleSetting) * 0.01; //DEADCODE CSB 31/01/00 PropSetting = PropSetting * PropSetting * PropSetting; break; } } switch(PropType) { case PT_FIXED: { PropInc = PropMaxPitch; break; } case PT_2PITCH: { FP DesiredInc = PropMaxPitch; if(PropSetting > 0.5) DesiredInc = PropMinPitch; if(DesiredInc > PropInc) { PropInc += 0.002 * MODEL_ENGINE_DT; //AMM 24Nov99 if(PropInc > DesiredInc) PropInc = DesiredInc; } if(DesiredInc < PropInc) { PropInc -= 0.002 * MODEL_ENGINE_DT; //AMM 24Nov99 if(PropInc < DesiredInc) PropInc = DesiredInc; } break; } case PT_VARIABLE: { FP DesiredInc = PropMaxPitch; if(PropSetting > 0) { FP Ratio = 0.5 * (PropSetting + 1.0); DesiredInc = PropMinPitch * Ratio + PropMaxPitch * (1 - Ratio); } if(DesiredInc > PropInc) { PropInc += 0.002 * MODEL_ENGINE_DT; //AMM 24Nov99 if(PropInc > DesiredInc) PropInc = DesiredInc; } if(DesiredInc < PropInc) { PropInc -= 0.002 * MODEL_ENGINE_DT; //AMM 24Nov99 if(PropInc < DesiredInc) PropInc = DesiredInc; } break; } case PT_CONSTSPEED: { FP DesiredRpm = Rpm100 * (0.7 + 0.45 * PropSetting); FP PropPitchRate = (EngRPM - DesiredRpm) * 0.00001; PropInc += PropPitchRate * MODEL_ENGINE_DT; //AMM 24Nov99 break; } } MODMAXMIN(PropInc, PropMinPitch, PropMaxPitch); FP BladeSpeed = FSqrt(PropAirVel * PropAirVel + PropVel * PropVel); FP BladeQS = 0.5 * pModel->AmbDensity * BladeSpeed * BladeArea; //DeadCode AMM 29Jun99 J = PropVel / ((PropSpeed - PropSwirl) * 0.75 * BladeRadius); //Only Used for Text Screen FP BladeL = 4.53 * (PropInc - InflowAng); FP BladeD = 0.005 + (0.071 * BladeL * BladeL); MODMAXMIN(BladeL, -1.0, 1.5); BladeL *= BladeQS; BladeD *= BladeQS; Thrust = BladeL * PropAirVel - BladeD * PropVel; Torque = BladeD * PropAirVel + BladeL * PropVel; Torque *= BladeRadius * 0.5; //effective overall moment //Engine Power Output Power100 = pPower100->GetValue (EngRPM / Rpm100); Power0 = pPower0->GetValue (EngRPM / Rpm100); FP fPower = 0; FP dTorque = 0; ComplexEngineProcess(ControlledAC, fDamage, fPower, dTorque); const FP MinThrottle = 0.125; FP PowerFract = MinThrottle + ThrottleSetting * (1 - MinThrottle) * 0.01; PowerFract *= fPower; FP oldpower = Power; Power = Power0 + ((Power100 - Power0) * PowerFract); if((oldpower <= 0) && (Power > 0)) Trans_Obj.LaunchEngineStartup((mobileitem*)ControlledAC, *ControlledAC->currworld); if((oldpower > 0) && (Power <= 0) && (ControlledAC == Persons2::PlayerSeenAC)) _Miles.PlayOnce(FIL_SFX_ENGINE_COUGH,Save_Data.vol.engine); //RJS 27Sep00 Power *= pPowerAlt->GetValue(pModel->Pos.y * 0.01); Power *= p0; //#define ENGINE_DATA #ifdef ENGINE_DATA //DeadCode CSB 27/10/99 /* TEST CODE CSB 27/10/99 */if(pModel->bACM) /* TEST CODE CSB 27/10/99 */{ //DEADCODE CSB 11/01/00 /* TEST CODE CSB 29/09/99 */ PrintVar(40, 15, "Gravity %.3f ", FP(pModel->Inst.I_NormalAcc)); //DEADCODE CSB 11/01/00 /* TEST CODE CSB 29/09/99 */ PrintVar(40, 16, "IAS %.2f ", FP(pModel->Speed * FSqrt (pModel->AmbDensity / 0.0001225))); //DEADCODE CSB 11/01/00 /* TEST CODE CSB 29/09/99 */ PrintVar(40, 17, "Vel %.2f ", FP(ControlledAC->vel_ * 0.0001)); //DEADCODE CSB 11/01/00 /* TEST CODE CSB 29/09/99 */ PrintVar(40, 18, "DesRpm %.2f ", FP(pModel->ModelPropSetting)); /* TEST CODE CSB 29/09/99 */ PrintVar(20, 15, "Power %.0f ", FP(Power / 745.7)); /* TEST CODE CSB 29/09/99 */ PrintVar(20, 16, "RPM %.0f ", FP(EngRPM)); /* TEST CODE CSB 29/09/99 */ PrintVar(20, 17, "Prop Inc %.2f ", FP(Rads2Degs(PropInc))); /* TEST CODE CSB 29/09/99 */ PrintVar(20, 18, "Vel %.2f ", FP(-pModel->AirVel.z)); /* TEST CODE CSB 29/09/99 */ PrintVar(20, 19, "PropVel %.2f ", FP(PropVel)); /* TEST CODE CSB 29/09/99 */ PrintVar(20, 20, "SlipVel %.2f ", FP(SlipVel)); /* TEST CODE CSB 29/09/99 */ PrintVar(20, 21, "Alpha %.2f ", FP(Rads2Degs(PropInc - InflowAng))); /* TEST CODE CSB 29/09/99 */ PrintVar(20, 24, "ROC fpm %.0f ", FP(pModel->Vel.y * 3.2808 * 60.0)); /* TEST CODE CSB 29/09/99 */ PrintVar(20, 22, "Thrust %.1f ", FP(Thrust)); /* TEST CODE CSB 29/09/99 */ PrintVar(20, 23, "Eff %.3f ", FP(Thrust * -pModel->AirVel.z / Power)); /* TEST CODE CSB 27/10/99 */} #endif FP EngTorque = 0; if(Speed > 0) EngTorque = Power / Speed; EngTorque += dTorque; //Slipstream Conditions FP OldSlipRot = SlipRot; FP SlipInertia = BladeRadius * BladeRadius * BladeRadius * BladeRadius * 0.5 * FPIE * PropVel * pModel->AmbDensity; if(SlipInertia > 0) SlipRot = (Torque / SlipInertia + OldSlipRot) * 0.5; else SlipRot = 0; if(SlipRot > PropSpeed) SlipRot = PropSpeed; FP OldSlipVel = SlipVel; FP PropArea = FPIE * BladeRadius * BladeRadius; FP TempSlip = 2 * Thrust / (pModel->AmbDensity * PropArea) + Vel.z * Vel.z; if (TempSlip < 0) SlipVel = -Vel.z; else SlipVel = sqrt(TempSlip); SlipVel = (SlipVel + OldSlipVel) * 0.5; PropVel = 0.5 * (0.5 * (Vel.z + SlipVel) + PropVel); // calc engine speed FP EngRotAcc = (EngTorque - Torque * GearRatio) / MoI; //DeadCode CSB 27/10/99 if (!Save_Data.flightdifficulty [FD_THRUSTPOWERCONTROL]) //DeadCode CSB 27/10/99 EngRotAcc *= 2; //Fast Spooling //DEADCODE AMM 24/11/99 Speed += pModel->MODEL_DT * EngRotAcc; Speed += MODEL_ENGINE_DT * EngRotAcc; //AMM 24/11/99 if(Speed < 0) Speed = 0; //DEADCODE CB 04/11/99 if (Speed < MinSpeed) Speed = MinSpeed; if (Speed > MaxSpeed) Speed = MaxSpeed; Torque = -Torque * RotateDirection;//(EngTorque - Torque / GearRatio); //Reacted into Airframe if (Save_Data.flightdifficulty [FD_SLIPSTREAMEFFECTS]) { FCRD TempRot; CopyVec(pModel->RotVel, TempRot); TempRot.z += Speed * RotateDirection; moment.x = TempRot.x * PropInertia.x; moment.y = TempRot.y * PropInertia.y; moment.z = TempRot.z * PropInertia.z; CPrd(moment, moment, TempRot); moment.x *= -1; moment.y *= -1; moment.z *= -1; } else NullVec(moment); }
#include "shapes.h" //RJS 02Dec97 // #include "JimLong.h" //PD 06Sep96 #include "3dcom.h" #include "landscap.h" #include "savegame.h" //PD 30Aug96 #include "flymodel.h" //PD 30Aug96 #include "matrix.h" //PD 06Sep96 #include "ranges.h" //RDH 12Sep96 #include "lstream.h" //PD 29Sep96 #include "migLand.h" #include "3dcode.h" const ANGLES ACROLLANGLE = ANGLES_10Deg; //RJS 02JUN99 const ANGLES ACPITCHANGLE= ANGLES_15Deg; //PD 11Sep96 //DEADCODE CSB 29/02/00 const UWord ACUPSIDEDOWNMIN= UWord(ANGLES_180Deg) - UWord(ANGLES_15Deg); //RJS 14Apr99 //DEADCODE CSB 29/02/00 const UWord ACUPSIDEDOWNMAX= UWord(ANGLES_180Deg) + UWord(ANGLES_15Deg); //RJS 14Apr99 const UWord ACUPSIDEDOWNMIN= UWord(ANGLES_180Deg) - UWord(ANGLES_80Deg); //CSB 29/02/00 const UWord ACUPSIDEDOWNMAX= UWord(ANGLES_180Deg) + UWord(ANGLES_80Deg); //CSB 29/02/00 #include "winmove.h" //ARM 08Nov96 #include "modinst.h" #include "model.h" Collide _Collide; typedef struct { double a,b,c,d; } Coeffs,*CoeffsP;
#define F_BATTLE #include "Collided.h" #include "shapes.h" //RJS 02Dec97 // #include "JimLong.h" //PD 06Sep96 #include "3dcom.h" #include "landscap.h" #include "savegame.h" //PD 30Aug96 #include "flymodel.h" //PD 30Aug96 #include "matrix.h" //PD 06Sep96 #include "ranges.h" //RDH 12Sep96 #include "lstream.h" //PD 29Sep96 #include "migLand.h" #include "3dcode.h" const ANGLES ACROLLANGLE = ANGLES_10Deg; //RJS 02JUN99 const ANGLES ACPITCHANGLE= ANGLES_15Deg; //PD 11Sep96 const UWord ACUPSIDEDOWNMIN= UWord(ANGLES_180Deg) - UWord(ANGLES_15Deg); //RJS 14Apr99 const UWord ACUPSIDEDOWNMAX= UWord(ANGLES_180Deg) + UWord(ANGLES_15Deg); //RJS 14Apr99 #include "winmove.h" //ARM 08Nov96 #include "modinst.h" #include "model.h" Collide _Collide; typedef struct { double a,b,c,d; } Coeffs,*CoeffsP;