bool FGBuoyantForces::Load(Element *document) { Element *gas_cell_element; Debug(2); // Perform base class Pre-Load if (!FGModel::Load(document)) return false; gas_cell_element = document->FindElement("gas_cell"); while (gas_cell_element) { NoneDefined = false; Cells.push_back(new FGGasCell(FDMExec, gas_cell_element, Cells.size(), in)); gas_cell_element = document->FindNextElement("gas_cell"); } PostLoad(document, PropertyManager); if (!NoneDefined) { bind(); } return true; }
void CSnork::Load(LPCSTR section) { inherited::Load (section); anim().accel_load (section); anim().AddReplacedAnim(&m_bDamaged, eAnimStandIdle, eAnimStandDamaged); anim().AddReplacedAnim(&m_bDamaged, eAnimRun, eAnimRunDamaged); anim().AddReplacedAnim(&m_bDamaged, eAnimWalkFwd, eAnimWalkDamaged); anim().AddReplacedAnim(&m_bRunTurnLeft, eAnimRun, eAnimRunTurnLeft); anim().AddReplacedAnim(&m_bRunTurnRight, eAnimRun, eAnimRunTurnRight); SVelocityParam &velocity_none = move().get_velocity(MonsterMovement::eVelocityParameterIdle); SVelocityParam &velocity_turn = move().get_velocity(MonsterMovement::eVelocityParameterStand); SVelocityParam &velocity_walk = move().get_velocity(MonsterMovement::eVelocityParameterWalkNormal); SVelocityParam &velocity_run = move().get_velocity(MonsterMovement::eVelocityParameterRunNormal); SVelocityParam &velocity_walk_dmg = move().get_velocity(MonsterMovement::eVelocityParameterWalkDamaged); SVelocityParam &velocity_run_dmg = move().get_velocity(MonsterMovement::eVelocityParameterRunDamaged); SVelocityParam &velocity_steal = move().get_velocity(MonsterMovement::eVelocityParameterSteal); //SVelocityParam &velocity_drag = move().get_velocity(MonsterMovement::eVelocityParameterDrag); anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r"); anim().AddAnim(eAnimStandDamaged, "stand_idle_damaged_", -1, &velocity_none, PS_STAND, "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r"); anim().AddAnim(eAnimWalkDamaged, "stand_walk_damaged_", -1, &velocity_walk_dmg, PS_STAND, "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r"); anim().AddAnim(eAnimRunDamaged, "stand_run_damaged_", -1, &velocity_run_dmg, PS_STAND, "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r"); anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r"); anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r"); anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r"); anim().AddAnim(eAnimRun, "stand_run_", -1, &velocity_run, PS_STAND, "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r"); anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, PS_STAND, "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r"); anim().AddAnim(eAnimDie, "stand_die_", 0, &velocity_none, PS_STAND, "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r"); anim().AddAnim(eAnimLookAround, "stand_look_around_", -1, &velocity_none, PS_STAND, "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r"); anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND, "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r"); anim().AddAnim(eAnimEat, "stand_eat_", -1, &velocity_none, PS_STAND, "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r"); anim().AddAnim(eAnimCheckCorpse, "stand_check_corpse_", -1, &velocity_none, PS_STAND, "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r"); anim().AddAnim(eAnimRunTurnLeft, "stand_run_look_left_", -1, &velocity_run, PS_STAND, "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r"); anim().AddAnim(eAnimRunTurnRight, "stand_run_look_right_", -1, &velocity_run, PS_STAND, "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r"); anim().LinkAction(ACT_STAND_IDLE, eAnimStandIdle); anim().LinkAction(ACT_SIT_IDLE, eAnimStandIdle); anim().LinkAction(ACT_LIE_IDLE, eAnimStandIdle); anim().LinkAction(ACT_WALK_FWD, eAnimWalkFwd); anim().LinkAction(ACT_WALK_BKWD, eAnimWalkFwd); anim().LinkAction(ACT_RUN, eAnimRun); anim().LinkAction(ACT_EAT, eAnimEat); anim().LinkAction(ACT_SLEEP, eAnimStandIdle); anim().LinkAction(ACT_REST, eAnimStandIdle); anim().LinkAction(ACT_DRAG, eAnimStandIdle); anim().LinkAction(ACT_ATTACK, eAnimAttack); anim().LinkAction(ACT_STEAL, eAnimSteal); anim().LinkAction(ACT_LOOK_AROUND, eAnimLookAround); #ifdef DEBUG anim().accel_chain_test (); #endif PostLoad (section); }
bool FGAircraft::Load(Element* el) { string element_name; Element* element; if (!FGModel::Load(el)) return false; if (el->FindElement("wingarea")) WingArea = el->FindElementValueAsNumberConvertTo("wingarea", "FT2"); if (el->FindElement("wingspan")) WingSpan = el->FindElementValueAsNumberConvertTo("wingspan", "FT"); if (el->FindElement("chord")) cbar = el->FindElementValueAsNumberConvertTo("chord", "FT"); if (el->FindElement("wing_incidence")) WingIncidence = el->FindElementValueAsNumberConvertTo("wing_incidence", "RAD"); if (el->FindElement("htailarea")) HTailArea = el->FindElementValueAsNumberConvertTo("htailarea", "FT2"); if (el->FindElement("htailarm")) HTailArm = el->FindElementValueAsNumberConvertTo("htailarm", "FT"); if (el->FindElement("vtailarea")) VTailArea = el->FindElementValueAsNumberConvertTo("vtailarea", "FT2"); if (el->FindElement("vtailarm")) VTailArm = el->FindElementValueAsNumberConvertTo("vtailarm", "FT"); if (el->FindElement("pitot_angle")) PitotAngle = el->FindElementValueAsNumberConvertTo("pitot_angle", "RAD"); // Find all LOCATION elements that descend from this METRICS branch of the // config file. This would be CG location, eyepoint, etc. element = el->FindElement("location"); while (element) { element_name = element->GetAttributeValue("name"); if (element_name == "AERORP") vXYZrp = element->FindElementTripletConvertTo("IN"); else if (element_name == "EYEPOINT") vXYZep = element->FindElementTripletConvertTo("IN"); else if (element_name == "VRP") vXYZvrp = element->FindElementTripletConvertTo("IN"); element = el->FindNextElement("location"); } // calculate some derived parameters if (cbar != 0.0) { lbarh = HTailArm/cbar; lbarv = VTailArm/cbar; if (WingArea != 0.0) { vbarh = HTailArm*HTailArea / (cbar*WingArea); vbarv = VTailArm*VTailArea / (WingSpan*WingArea); } } PostLoad(el, PropertyManager); Debug(2); return true; }
bool FGOutput::Load(Element* el) { // Unlike the other FGModel classes, properties listed in the <output> section // are not intended to create new properties. For that reason, FGOutput // cannot load its XML directives with FGModel::Load(). // Instead FGModelLoader::Open() and FGModel::PreLoad() must be explicitely // called. FGModelLoader ModelLoader(this); Element* element = ModelLoader.Open(el); if (!element) return false; FGModel::PreLoad(element, PropertyManager); size_t idx = OutputTypes.size(); string type = element->GetAttributeValue("type"); FGOutputType* Output = 0; if (debug_lvl > 0) cout << endl << " Output data set: " << idx << " " << endl; type = to_upper(type); if (type == "CSV") { Output = new FGOutputTextFile(FDMExec); } else if (type == "TABULAR") { Output = new FGOutputTextFile(FDMExec); } else if (type == "SOCKET") { Output = new FGOutputSocket(FDMExec); } else if (type == "FLIGHTGEAR") { Output = new FGOutputFG(FDMExec); } else if (type == "QTJSBSIM") { Output = new FGUDPOutputSocket(FDMExec); } else if (type == "TERMINAL") { // Not done yet } else if (type != string("NONE")) { cerr << "Unknown type of output specified in config file" << endl; } if (!Output) return false; Output->SetIdx(idx); Output->Load(element); PostLoad(element, PropertyManager); OutputTypes.push_back(Output); Debug(2); return true; }
bool FGMassBalance::Load(Element* document) { string element_name = ""; Name = "Mass Properties Model: " + document->GetAttributeValue("name"); // Perform base class Pre-Load if (!FGModel::Load(document)) return false; SetAircraftBaseInertias(ReadInertiaMatrix(document)); if (document->FindElement("emptywt")) { EmptyWeight = document->FindElementValueAsNumberConvertTo("emptywt", "LBS"); } Element *element = document->FindElement("location"); while (element) { element_name = element->GetAttributeValue("name"); if (element_name == "CG") vbaseXYZcg = element->FindElementTripletConvertTo("IN"); element = document->FindNextElement("location"); } // Find all POINTMASS elements that descend from this METRICS branch of the // config file. element = document->FindElement("pointmass"); while (element) { AddPointMass(element); element = document->FindNextElement("pointmass"); } double ChildFDMWeight = 0.0; for (int fdm=0; fdm<FDMExec->GetFDMCount(); fdm++) { if (FDMExec->GetChildFDM(fdm)->mated) ChildFDMWeight += FDMExec->GetChildFDM(fdm)->exec->GetMassBalance()->GetWeight(); } Weight = EmptyWeight + in.TanksWeight + GetTotalPointMassWeight() + in.GasMass*slugtolb + ChildFDMWeight; Mass = lbtoslug*Weight; PostLoad(document, PropertyManager); Debug(2); return true; }
void cStructLoaderPlain::Load(bool reload) { if(SL_TSTFLAG(SL_DISABLED) || reload) return; FILE *f=fopen(path,"r"); if(f) { PreLoad(); ListLock(true); SL_SETFLAG(SL_LOADED); PRINTF(L_GEN_INFO,"loading %s from %s",type,path); CheckAccess(); int lineNum=0; char buff[4096]; while(fgets(buff,sizeof(buff),f)) { lineNum++; if(!index(buff,'\n') && !feof(f)) { PRINTF(L_GEN_ERROR,"file %s readbuffer overflow line#%d",path,lineNum); SL_CLRFLAG(SL_LOADED); break; } strreplace(buff,'\n',0); strreplace(buff,'\r',0); // chomp bool hasContent=false; char *ls; for(ls=buff; *ls; ls++) { if(*ls==';' || *ls=='#') break; if(*ls>' ') hasContent=true; } if(hasContent) { *ls=0; if(!ParseLinePlain(skipspace(buff))) PRINTF(L_GEN_ERROR,"file %s has error in line #%d",path,lineNum); } } ListUnlock(); PostLoad(); fclose(f); LoadFinished(); } else OpenFailed(); }
CThreatMap::CThreatMap(AIClasses* aic): ai(aic) { if (ai) { PostLoad(); #if (LUA_THREATMAP_DEBUG == 1) std::stringstream luaDataStream; // this approach does not work because Spring's loadstring() // function does _not_ run in the global environment, which // means transferring the threatmap values requires an extra // temporary table // // luaDataStream << "threatMapW = " << width << ";\n"; // luaDataStream << "threatMapH = " << height << ";\n"; // // however, writing to a table declared in GG is fine luaDataStream << "GG.AIThreatMap[\"threatMapSizeX\"] = " << width << ";\n"; luaDataStream << "GG.AIThreatMap[\"threatMapSizeZ\"] = " << height << ";\n"; luaDataStream << "GG.AIThreatMap[\"threatMapResX\"] = " << THREATRES << ";\n"; luaDataStream << "GG.AIThreatMap[\"threatMapResZ\"] = " << THREATRES << ";\n"; luaDataStream << "\n"; luaDataStream << "local threatMapSizeX = GG.AIThreatMap[\"threatMapSizeX\"];\n"; luaDataStream << "local threatMapSizeZ = GG.AIThreatMap[\"threatMapSizeZ\"];\n"; luaDataStream << "local threatMapArray = GG.AIThreatMap;\n"; luaDataStream << "\n"; luaDataStream << "for row = 0, (threatMapSizeZ - 1) do\n"; luaDataStream << "\tfor col = 0, (threatMapSizeX - 1) do\n"; luaDataStream << "\t\tthreatMapArray[row * threatMapSizeX + col] = 0.0;\n"; luaDataStream << "\tend\n"; luaDataStream << "end\n"; std::string luaDataStr = luaDataStream.str(); ai->cb->CallLuaRules("[AI::KAIK::ThreatMap::Init]", -1, NULL); ai->cb->CallLuaRules(luaDataStr.c_str(), -1, NULL); #endif } currMaxThreat = 0.0f; // maximum threat (normalizer) currSumThreat = 0.0f; // threat summed over all cells currAvgThreat = 0.0f; // average threat over all cells }
bool FGInput::Load(Element* el) { // Unlike the other FGModel classes, properties listed in the <input> section // are not intended to create new properties. For that reason, FGInput // cannot load its XML directives with FGModel::Load(). // Instead FGModelLoader::Open() and FGModel::PreLoad() must be explicitely // called. FGModelLoader ModelLoader(this); Element* element = ModelLoader.Open(el); if (!element) return false; FGModel::PreLoad(element, PropertyManager); unsigned int idx = InputTypes.size(); string type = element->GetAttributeValue("type"); FGInputType* Input = 0; if (debug_lvl > 0) cout << endl << " Input data set: " << idx << " " << endl; type = to_upper(type); if (type.empty() || type == "SOCKET") { Input = new FGInputSocket(FDMExec); } else if (type != string("NONE")) { cerr << "Unknown type of input specified in config file" << endl; } if (!Input) return false; Input->SetIdx(idx); Input->Load(element); PostLoad(element, PropertyManager); InputTypes.push_back(Input); Debug(2); return true; }
bool VGMMultiSectionSeq::LoadTracks(ReadMode readMode, long stopTime) { this->readMode = readMode; curOffset = dwStartOffset; // Clear all track pointers to prevent delete, they must be aliases of section tracks aTracks.clear(); // reset variables ResetVars(); // load all tracks uint32_t stopOffset = vgmfile->GetEndOffset(); while (curOffset < stopOffset && time < stopTime) { if (!ReadEvent(stopTime)) { break; } } if (readMode == READMODE_ADD_TO_UI) { SetGuessedLength(); if (unLength == 0) { return false; } } bool succeeded = true; if (!PostLoad()) { succeeded = false; } return succeeded; }
void CBurer::Load(LPCSTR section) { inherited::Load (section); //anim().AddReplacedAnim (&m_bDamaged, eAnimStandIdle, eAnimStandDamaged); //anim().AddReplacedAnim (&m_bDamaged, eAnimRun, eAnimRunDamaged); //anim().AddReplacedAnim (&m_bDamaged, eAnimWalkFwd, eAnimWalkDamaged); anim().accel_load (section); anim().accel_chain_add (eAnimWalkFwd, eAnimRun); anim().AddReplacedAnim (&m_bRunTurnLeft, eAnimRun, eAnimRunTurnLeft); anim().AddReplacedAnim (&m_bRunTurnRight, eAnimRun, eAnimRunTurnRight); particle_gravi_wave = pSettings->r_string(section,"Particle_Gravi_Wave"); particle_gravi_prepare = pSettings->r_string(section,"Particle_Gravi_Prepare"); particle_tele_object = pSettings->r_string(section,"Particle_Tele_Object"); ::Sound->create(sound_gravi_wave, pSettings->r_string(section,"sound_gravi_wave"),st_Effect,SOUND_TYPE_WORLD); ::Sound->create(sound_tele_hold, pSettings->r_string(section,"sound_tele_hold"), st_Effect,SOUND_TYPE_WORLD); ::Sound->create(sound_tele_throw, pSettings->r_string(section,"sound_tele_throw"),st_Effect,SOUND_TYPE_WORLD); m_gravi.cooldown = pSettings->r_u32(section,"Gravi_Cooldown"); m_gravi.min_dist = pSettings->r_float(section,"Gravi_MinDist"); m_gravi.max_dist = pSettings->r_float(section,"Gravi_MaxDist"); m_gravi.speed = pSettings->r_float(section,"Gravi_Speed"); m_gravi.step = pSettings->r_float(section,"Gravi_Step"); m_gravi.time_to_hold = pSettings->r_u32(section,"Gravi_Time_To_Hold"); m_gravi.radius = pSettings->r_float(section,"Gravi_Radius"); m_gravi.impulse_to_objects = pSettings->r_float(section,"Gravi_Impulse_To_Objects"); m_gravi.impulse_to_enemy = pSettings->r_float(section,"Gravi_Impulse_To_Enemy"); m_gravi.hit_power = pSettings->r_float(section,"Gravi_Hit_Power"); m_weight_to_stamina_hit = READ_IF_EXISTS(pSettings, r_float, section, "weight_to_stamina_hit", 0.02f); m_weapon_drop_stamina_k = READ_IF_EXISTS(pSettings, r_float, section, "weapon_drop_stamina_k", 3.f); m_runaway_distance = READ_IF_EXISTS(pSettings, r_float, section, "runaway_distance", 6.f); m_normal_distance = READ_IF_EXISTS(pSettings, r_float, section, "normal_distance", 12.f); m_max_runaway_time = READ_IF_EXISTS(pSettings, r_u32, section, "max_runaway_time", 5000); m_weapon_drop_velocity = READ_IF_EXISTS(pSettings, r_float, section, "weapon_drop_velocity", 8); m_shield_cooldown = READ_IF_EXISTS(pSettings, r_u32, section, "shield_cooldown", 4000); m_shield_time = READ_IF_EXISTS(pSettings, r_u32, section, "shield_time", 3000); m_shield_keep_particle = READ_IF_EXISTS(pSettings, r_string, section, "shield_keep_particle", 0); m_shield_keep_particle_period = READ_IF_EXISTS(pSettings, r_u32, section, "shield_keep_particle_period", 1000); m_tele_max_handled_objects = pSettings->r_u32(section,"Tele_Max_Handled_Objects"); m_tele_max_time = READ_IF_EXISTS(pSettings, r_u32, section, "Tele_Max_Time", 10000); m_tele_time_to_hold = pSettings->r_u32(section,"Tele_Time_To_Hold"); m_tele_object_min_mass = pSettings->r_float(section,"Tele_Object_Min_Mass"); m_tele_object_max_mass = pSettings->r_float(section,"Tele_Object_Max_Mass"); m_tele_find_radius = pSettings->r_float(section,"Tele_Find_Radius"); m_tele_min_distance = READ_IF_EXISTS(pSettings, r_float, section, "tele_min_distance", 8); m_tele_max_distance = READ_IF_EXISTS(pSettings, r_float, section, "tele_max_distance", 30); m_tele_raise_speed = READ_IF_EXISTS(pSettings, r_float, section, "tele_raise_speed", 5.f); m_tele_fly_velocity = READ_IF_EXISTS(pSettings, r_float, section, "tele_fly_velocity", 30.f); m_tele_object_height = READ_IF_EXISTS(pSettings, r_float, section, "tele_object_height", 2.f); particle_fire_shield = pSettings->r_string(section,"Particle_Shield"); SVelocityParam &velocity_none = move().get_velocity(MonsterMovement::eVelocityParameterIdle); SVelocityParam &velocity_turn = move().get_velocity(MonsterMovement::eVelocityParameterStand); SVelocityParam &velocity_walk = move().get_velocity(MonsterMovement::eVelocityParameterWalkNormal); SVelocityParam &velocity_run = move().get_velocity(MonsterMovement::eVelocityParameterRunNormal); //SVelocityParam &velocity_walk_dmg = move().get_velocity(MonsterMovement::eVelocityParameterWalkDamaged); //SVelocityParam &velocity_run_dmg = move().get_velocity(MonsterMovement::eVelocityParameterRunDamaged); //SVelocityParam &velocity_steal = move().get_velocity(MonsterMovement::eVelocityParameterSteal); // SVelocityParam &velocity_drag = move().get_velocity(MonsterMovement::eVelocityParameterDrag); anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); // anim().AddAnim(eAnimStandDamaged, "stand_idle_dmg_", -1, &velocity_none, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimWalkDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimRun, "stand_run_fwd_", -1, &velocity_run, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimRunDamaged, "stand_run_dmg_", -1, &velocity_run_dmg, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimDie, "stand_die_", -1, &velocity_none, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimShieldStart, "stand_shield_", -1, &velocity_turn, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimShieldContinue, "stand_shield_idle_", -1, &velocity_turn, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimTeleFire, "stand_power_attack_", -1, &velocity_turn, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimTelekinesis, "telekinesis_", -1, &velocity_turn, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimGraviFire, "stand_power_attack_", -1, &velocity_turn, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimRunTurnLeft, "stand_run_fwd_turn_left_", - 1, &velocity_run, PS_STAND); anim().AddAnim(eAnimRunTurnRight, "stand_run_fwd_turn_right_", -1, &velocity_run, PS_STAND); // anim().AddAnim(eAnimScared, "stand_scared_", -1, &velocity_none, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); // anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); // anim().AddAnim(eAnimEat, "sit_eat_", -1, &velocity_none, PS_SIT); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); // // anim().AddAnim(eAnimSitIdle, "sit_idle_", -1, &velocity_none, PS_SIT); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); // anim().AddAnim(eAnimCheckCorpse, "sit_check_corpse_", -1, &velocity_none, PS_SIT); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); // anim().AddAnim(eAnimSitStandUp, "sit_stand_up_", -1, &velocity_none, PS_SIT); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); // anim().AddAnim(eAnimStandSitDown, "stand_sit_down_", -1, &velocity_none, PS_STAND); //, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); // anim().AddTransition(PS_SIT, PS_STAND, eAnimSitStandUp, false); // anim().AddTransition(PS_STAND, PS_SIT, eAnimStandSitDown, false); anim().LinkAction (ACT_STAND_IDLE, eAnimStandIdle); // anim().LinkAction (ACT_SIT_IDLE, eAnimSitIdle); // anim().LinkAction (ACT_LIE_IDLE, eAnimSitIdle); anim().LinkAction (ACT_WALK_FWD, eAnimWalkFwd); anim().LinkAction (ACT_WALK_BKWD, eAnimWalkFwd); anim().LinkAction (ACT_RUN, eAnimRun); //anim().LinkAction(ACT_EAT, eAnimEat); anim().LinkAction (ACT_SLEEP, eAnimStandIdle);//eAnimSitIdle); anim().LinkAction (ACT_REST, eAnimStandIdle);//eAnimSitIdle); anim().LinkAction (ACT_DRAG, eAnimWalkFwd); anim().LinkAction (ACT_ATTACK, eAnimAttack); //anim().LinkAction(ACT_STEAL, eAnimSteal); //anim().LinkAction(ACT_LOOK_AROUND, eAnimScared); #ifdef DEBUG anim().accel_chain_test (); #endif m_force_gravi_attack = false; PostLoad (section); }
bool FGFCS::Load(Element* document) { if (document->GetName() == "autopilot") { Name = "Autopilot: "; systype = stAutoPilot; } else if (document->GetName() == "flight_control") { Name = "FCS: "; systype = stFCS; } else if (document->GetName() == "system") { Name = "System: "; systype = stSystem; } // Load interface properties from document if (!FGModel::Load(document, true)) return false; Name += document->GetAttributeValue("name"); Debug(2); Element* channel_element = document->FindElement("channel"); while (channel_element) { FGFCSChannel* newChannel = 0; string sOnOffProperty = channel_element->GetAttributeValue("execute"); string sChannelName = channel_element->GetAttributeValue("name"); if (!channel_element->GetAttributeValue("execrate").empty()) ChannelRate = channel_element->GetAttributeValueAsNumber("execrate"); else ChannelRate = 1; if (sOnOffProperty.length() > 0) { FGPropertyNode* OnOffPropertyNode = PropertyManager->GetNode(sOnOffProperty); if (OnOffPropertyNode == 0) { cerr << channel_element->ReadFrom() << highint << fgred << "The On/Off property, " << sOnOffProperty << " specified for channel " << channel_element->GetAttributeValue("name") << " is undefined or not " << "understood. The simulation will abort" << reset << endl; throw("Bad system definition"); } else newChannel = new FGFCSChannel(this, sChannelName, ChannelRate, OnOffPropertyNode); } else newChannel = new FGFCSChannel(this, sChannelName, ChannelRate); SystemChannels.push_back(newChannel); if (debug_lvl > 0) cout << endl << highint << fgblue << " Channel " << normint << channel_element->GetAttributeValue("name") << reset << endl; Element* component_element = channel_element->GetElement(); while (component_element) { try { if ((component_element->GetName() == string("lag_filter")) || (component_element->GetName() == string("lead_lag_filter")) || (component_element->GetName() == string("washout_filter")) || (component_element->GetName() == string("second_order_filter")) || (component_element->GetName() == string("integrator")) ) { newChannel->Add(new FGFilter(this, component_element)); } else if ((component_element->GetName() == string("pure_gain")) || (component_element->GetName() == string("scheduled_gain")) || (component_element->GetName() == string("aerosurface_scale"))) { newChannel->Add(new FGGain(this, component_element)); } else if (component_element->GetName() == string("summer")) { newChannel->Add(new FGSummer(this, component_element)); } else if (component_element->GetName() == string("deadband")) { newChannel->Add(new FGDeadBand(this, component_element)); } else if (component_element->GetName() == string("switch")) { newChannel->Add(new FGSwitch(this, component_element)); } else if (component_element->GetName() == string("kinematic")) { newChannel->Add(new FGKinemat(this, component_element)); } else if (component_element->GetName() == string("fcs_function")) { newChannel->Add(new FGFCSFunction(this, component_element)); } else if (component_element->GetName() == string("pid")) { newChannel->Add(new FGPID(this, component_element)); } else if (component_element->GetName() == string("actuator")) { newChannel->Add(new FGActuator(this, component_element)); } else if (component_element->GetName() == string("sensor")) { newChannel->Add(new FGSensor(this, component_element)); } else if (component_element->GetName() == string("accelerometer")) { newChannel->Add(new FGAccelerometer(this, component_element)); } else if (component_element->GetName() == string("magnetometer")) { newChannel->Add(new FGMagnetometer(this, component_element)); } else if (component_element->GetName() == string("gyro")) { newChannel->Add(new FGGyro(this, component_element)); } else if ((component_element->GetName() == string("waypoint_heading")) || (component_element->GetName() == string("waypoint_distance"))) { newChannel->Add(new FGWaypoint(this, component_element)); } else if (component_element->GetName() == string("angle")) { newChannel->Add(new FGAngles(this, component_element)); } else if (component_element->GetName() == string("distributor")) { newChannel->Add(new FGDistributor(this, component_element)); } else { cerr << "Unknown FCS component: " << component_element->GetName() << endl; } } catch(string& s) { cerr << highint << fgred << endl << " " << s << endl; cerr << reset << endl; return false; } component_element = channel_element->GetNextElement(); } channel_element = document->FindNextElement("channel"); } PostLoad(document, PropertyManager); return true; }
bool FGPropulsion::Load(Element* el) { string type, engine_filename; bool ThrottleAdded = false; Debug(2); FGModel::Load(el); // Perform base class Load. // Process tank definitions first to establish the number of fuel tanks Element* tank_element = el->FindElement("tank"); while (tank_element) { Tanks.push_back(new FGTank(FDMExec, tank_element, numTanks)); if (Tanks.back()->GetType() == FGTank::ttFUEL) numFuelTanks++; else if (Tanks.back()->GetType() == FGTank::ttOXIDIZER) numOxiTanks++; else {cerr << "Unknown tank type specified." << endl; return false;} numTanks++; tank_element = el->FindNextElement("tank"); } numSelectedFuelTanks = numFuelTanks; numSelectedOxiTanks = numOxiTanks; Element* engine_element = el->FindElement("engine"); while (engine_element) { engine_filename = engine_element->GetAttributeValue("file"); if (engine_filename.empty()) { cerr << "Engine definition did not supply an engine file." << endl; return false; } engine_filename = FindEngineFullPathname(engine_filename); document = LoadXMLDocument(engine_filename); document->SetParent(engine_element); type = document->GetName(); if (type == "piston_engine") { HavePistonEngine = true; if (!IsBound) bind(); Engines.push_back(new FGPiston(FDMExec, document, numEngines)); } else if (type == "turbine_engine") { HaveTurbineEngine = true; if (!IsBound) bind(); Engines.push_back(new FGTurbine(FDMExec, document, numEngines)); } else if (type == "turboprop_engine") { HaveTurboPropEngine = true; if (!IsBound) bind(); Engines.push_back(new FGTurboProp(FDMExec, document, numEngines)); } else if (type == "rocket_engine") { HaveRocketEngine = true; if (!IsBound) bind(); Engines.push_back(new FGRocket(FDMExec, document, numEngines)); } else if (type == "electric_engine") { HaveElectricEngine = true; if (!IsBound) bind(); Engines.push_back(new FGElectric(FDMExec, document, numEngines)); } else { cerr << "Unknown engine type: " << type << endl; exit(-5); } FCS->AddThrottle(); ThrottleAdded = true; numEngines++; engine_element = el->FindNextElement("engine"); ResetParser(); } CalculateTankInertias(); if (!ThrottleAdded) FCS->AddThrottle(); // need to have at least one throttle // Process fuel dump rate if (el->FindElement("dump-rate")) DumpRate = el->FindElementValueAsNumberConvertTo("dump-rate", "LBS/MIN"); PostLoad(el, PropertyManager); return true; }
void CTexture::Load () { flags.bLoaded = true; desc_cache = 0; if (pSurface) return; flags.bUser = false; flags.MemoryUsage = 0; if (0==stricmp(*cName,"$null")) return; if (0!=strstr(*cName,"$user$")) { flags.bUser = true; return; } Preload (); //#ifndef DEDICATED_SERVER #ifndef _EDITOR if (!g_dedicated_server) #endif { // Check for OGM string_path fn; if (FS.exist(fn,"$game_textures$",*cName,".ogm")) { // AVI pTheora = new CTheoraSurface(); m_play_time = 0xFFFFFFFF; if (!pTheora->Load(fn)) { xr_delete(pTheora); FATAL ("Can't open video stream"); } else { flags.MemoryUsage = pTheora->Width(true)*pTheora->Height(true)*4; pTheora->Play (TRUE,Device.dwTimeContinual); // Now create texture ID3DTexture2D* pTexture = 0; u32 _w = pTheora->Width(false); u32 _h = pTheora->Height(false); HRESULT hrr = HW.pDevice->CreateTexture( _w, _h, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &pTexture, NULL ); pSurface = pTexture; if (FAILED(hrr)) { FATAL ("Invalid video stream"); R_CHK (hrr); xr_delete (pTheora); pSurface = 0; } } } else if (FS.exist(fn,"$game_textures$",*cName,".avi")) { // AVI pAVI = new CAviPlayerCustom(); if (!pAVI->Load(fn)) { xr_delete(pAVI); FATAL ("Can't open video stream"); } else { flags.MemoryUsage = pAVI->m_dwWidth*pAVI->m_dwHeight*4; // Now create texture ID3DTexture2D* pTexture = 0; HRESULT hrr = HW.pDevice->CreateTexture( pAVI->m_dwWidth,pAVI->m_dwHeight,1,0,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED, &pTexture,NULL ); pSurface = pTexture; if (FAILED(hrr)) { FATAL ("Invalid video stream"); R_CHK (hrr); xr_delete (pAVI); pSurface = 0; } } } else if (FS.exist(fn,"$game_textures$",*cName,".seq")) { // Sequence string256 buffer; IReader* _fs = FS.r_open(fn); flags.seqCycles = FALSE; _fs->r_string (buffer,sizeof(buffer)); if (0==stricmp (buffer,"cycled")) { flags.seqCycles = TRUE; _fs->r_string (buffer,sizeof(buffer)); } u32 fps = atoi(buffer); seqMSPF = 1000/fps; while (!_fs->eof()) { _fs->r_string(buffer,sizeof(buffer)); _Trim (buffer); if (buffer[0]) { // Load another texture u32 mem = 0; pSurface = ::RImplementation.texture_load (buffer,mem); if (pSurface) { // pSurface->SetPriority (PRIORITY_LOW); seqDATA.push_back (pSurface); flags.MemoryUsage += mem; } } } pSurface = 0; FS.r_close (_fs); } else { // Normal texture u32 mem = 0; pSurface = ::RImplementation.texture_load (*cName,mem); // Calc memory usage and preload into vid-mem if (pSurface) { // pSurface->SetPriority (PRIORITY_NORMAL); flags.MemoryUsage = mem; } } //#endif } PostLoad () ; }
bool FGMassBalance::Load(Element* elem) { string element_name = ""; double bixx, biyy, bizz, bixy, bixz, biyz; string fname="", file=""; string separator = "/"; fname = elem->GetAttributeValue("file"); if (!fname.empty()) { file = FDMExec->GetFullAircraftPath() + separator + fname; document = LoadXMLDocument(file); if (document == 0L) return false; } else { document = elem; } FGModel::Load(document); // Perform base class Load. bixx = biyy = bizz = bixy = bixz = biyz = 0.0; if (document->FindElement("ixx")) bixx = document->FindElementValueAsNumberConvertTo("ixx", "SLUG*FT2"); if (document->FindElement("iyy")) biyy = document->FindElementValueAsNumberConvertTo("iyy", "SLUG*FT2"); if (document->FindElement("izz")) bizz = document->FindElementValueAsNumberConvertTo("izz", "SLUG*FT2"); if (document->FindElement("ixy")) bixy = document->FindElementValueAsNumberConvertTo("ixy", "SLUG*FT2"); if (document->FindElement("ixz")) bixz = document->FindElementValueAsNumberConvertTo("ixz", "SLUG*FT2"); if (document->FindElement("iyz")) biyz = document->FindElementValueAsNumberConvertTo("iyz", "SLUG*FT2"); SetAircraftBaseInertias(FGMatrix33( bixx, -bixy, bixz, -bixy, biyy, -biyz, bixz, -biyz, bizz )); if (document->FindElement("emptywt")) { EmptyWeight = document->FindElementValueAsNumberConvertTo("emptywt", "LBS"); } Element *element = document->FindElement("location"); while (element) { element_name = element->GetAttributeValue("name"); if (element_name == "CG") vbaseXYZcg = element->FindElementTripletConvertTo("IN"); element = document->FindNextElement("location"); } // Find all POINTMASS elements that descend from this METRICS branch of the // config file. element = document->FindElement("pointmass"); while (element) { AddPointMass(element); element = document->FindNextElement("pointmass"); } double ChildFDMWeight = 0.0; for (int fdm=0; fdm<FDMExec->GetFDMCount(); fdm++) { if (FDMExec->GetChildFDM(fdm)->mated) ChildFDMWeight += FDMExec->GetChildFDM(fdm)->exec->GetMassBalance()->GetWeight(); } Weight = EmptyWeight + in.TanksWeight + GetTotalPointMassWeight() + in.GasMass*slugtolb + ChildFDMWeight; Mass = lbtoslug*Weight; PostLoad(document, PropertyManager); Debug(2); return true; }
bool FGPropulsion::Load(Element* el) { FGModelLoader ModelLoader(this); Debug(2); ReadingEngine = false; double FuelDensity = 6.0; Name = "Propulsion Model: " + el->GetAttributeValue("name"); // Perform base class Pre-Load if (!FGModel::Load(el)) return false; // Process tank definitions first to establish the number of fuel tanks Element* tank_element = el->FindElement("tank"); while (tank_element) { Tanks.push_back(new FGTank(FDMExec, tank_element, numTanks)); if (Tanks.back()->GetType() == FGTank::ttFUEL) { FuelDensity = Tanks[numFuelTanks]->GetDensity(); numFuelTanks++; } else if (Tanks.back()->GetType() == FGTank::ttOXIDIZER) numOxiTanks++; else {cerr << "Unknown tank type specified." << endl; return false;} numTanks++; tank_element = el->FindNextElement("tank"); } numSelectedFuelTanks = numFuelTanks; numSelectedOxiTanks = numOxiTanks; ReadingEngine = true; Element* engine_element = el->FindElement("engine"); while (engine_element) { if (!ModelLoader.Open(engine_element)) return false; try { // Locate the thruster definition Element* thruster_element = engine_element->FindElement("thruster"); if (!thruster_element || !ModelLoader.Open(thruster_element)) throw("No thruster definition supplied with engine definition."); if (engine_element->FindElement("piston_engine")) { HavePistonEngine = true; if (!IsBound) bind(); Element *element = engine_element->FindElement("piston_engine"); Engines.push_back(new FGPiston(FDMExec, element, numEngines, in)); } else if (engine_element->FindElement("turbine_engine")) { HaveTurbineEngine = true; if (!IsBound) bind(); Element *element = engine_element->FindElement("turbine_engine"); Engines.push_back(new FGTurbine(FDMExec, element, numEngines, in)); } else if (engine_element->FindElement("turboprop_engine")) { HaveTurboPropEngine = true; if (!IsBound) bind(); Element *element = engine_element->FindElement("turboprop_engine"); Engines.push_back(new FGTurboProp(FDMExec, element, numEngines, in)); } else if (engine_element->FindElement("rocket_engine")) { HaveRocketEngine = true; if (!IsBound) bind(); Element *element = engine_element->FindElement("rocket_engine"); Engines.push_back(new FGRocket(FDMExec, element, numEngines, in)); } else if (engine_element->FindElement("electric_engine")) { HaveElectricEngine = true; if (!IsBound) bind(); Element *element = engine_element->FindElement("electric_engine"); Engines.push_back(new FGElectric(FDMExec, element, numEngines, in)); } else { cerr << engine_element->ReadFrom() << " Unknown engine type" << endl; return false; } } catch (std::string& str) { cerr << endl << fgred << str << reset << endl; return false; } numEngines++; engine_element = el->FindNextElement("engine"); } CalculateTankInertias(); if (el->FindElement("dump-rate")) DumpRate = el->FindElementValueAsNumberConvertTo("dump-rate", "LBS/MIN"); if (el->FindElement("refuel-rate")) RefuelRate = el->FindElementValueAsNumberConvertTo("refuel-rate", "LBS/MIN"); unsigned int i; for (i=0; i<Engines.size(); i++) { Engines[i]->SetFuelDensity(FuelDensity); } PostLoad(el, PropertyManager); return true; }
FGEngine::FGEngine(FGFDMExec* exec, Element* engine_element, int engine_number, struct Inputs& input) : in(input), EngineNumber(engine_number) { Element* local_element; FGColumnVector3 location, orientation; Name = ""; Type = etUnknown; X = Y = Z = 0.0; EnginePitch = EngineYaw = 0.0; SLFuelFlowMax = 0.0; FuelExpended = 0.0; MaxThrottle = 1.0; MinThrottle = 0.0; ResetToIC(); // initialize dynamic terms FDMExec = exec; PropertyManager = FDMExec->GetPropertyManager(); Name = engine_element->GetAttributeValue("name"); Load(engine_element, PropertyManager, to_string(EngineNumber)); // Call ModelFunctions loader // Find and set engine location local_element = engine_element->GetParent()->FindElement("location"); if (local_element) location = local_element->FindElementTripletConvertTo("IN"); else cerr << "No engine location found for this engine." << endl; local_element = engine_element->GetParent()->FindElement("orient"); if (local_element) orientation = local_element->FindElementTripletConvertTo("RAD"); // else cerr << "No engine orientation found for this engine." << endl; // Jon: The engine orientation has a default and is not normally used. SetPlacement(location, orientation); // Load thruster local_element = engine_element->GetParent()->FindElement("thruster"); if (local_element) { try { if (!LoadThruster(local_element)) exit(-1); } catch (std::string str) { throw("Error loading engine " + Name + ". " + str); } } else { cerr << "No thruster definition supplied with engine definition." << endl; } // Load feed tank[s] references local_element = engine_element->GetParent()->FindElement("feed"); while (local_element) { int tankID = (int)local_element->GetDataAsNumber(); SourceTanks.push_back(tankID); local_element = engine_element->GetParent()->FindNextElement("feed"); } string property_name, base_property_name; base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber); property_name = base_property_name + "/set-running"; PropertyManager->Tie( property_name.c_str(), this, &FGEngine::GetRunning, &FGEngine::SetRunning ); property_name = base_property_name + "/thrust-lbs"; PropertyManager->Tie( property_name.c_str(), Thruster, &FGThruster::GetThrust); property_name = base_property_name + "/fuel-flow-rate-pps"; PropertyManager->Tie( property_name.c_str(), this, &FGEngine::GetFuelFlowRate); property_name = base_property_name + "/fuel-flow-rate-gph"; PropertyManager->Tie( property_name.c_str(), this, &FGEngine::GetFuelFlowRateGPH); property_name = base_property_name + "/fuel-used-lbs"; PropertyManager->Tie( property_name.c_str(), this, &FGEngine::GetFuelUsedLbs); PostLoad(engine_element, PropertyManager, to_string(EngineNumber)); Debug(0); }
void CTexture::apply_load (u32 dwStage) { if (!flags.bLoaded) Load () ; else PostLoad () ; bind (dwStage) ; };
void cStructLoader::Load(bool reload) { if(SL_TSTFLAG(SL_DISABLED) || (reload && !SL_TSTFLAG(SL_WATCH))) return; FILE *f=fopen(path,"r"); if(f) { PreLoad(); int curr_mtime=MTime(true); ListLock(true); bool doload=false; if(!reload) { Clear(); Modified(false); mtime=curr_mtime; doload=true; } else if(mtime<curr_mtime) { PRINTF(L_CORE_LOAD,"detected change of %s",path); if(IsModified()) PRINTF(L_CORE_LOAD,"discarding in-memory changes"); for(cStructItem *a=First(); a; a=Next(a)) DelItem(a); Modified(false); mtime=curr_mtime; doload=true; } if(doload) { SL_SETFLAG(SL_LOADED); PRINTF(L_GEN_INFO,"loading %s from %s",type,path); CheckAccess(); int lineNum=0, num=0; char buff[4096]; while(fgets(buff,sizeof(buff),f)) { lineNum++; if(!index(buff,'\n') && !feof(f)) { PRINTF(L_GEN_ERROR,"file %s readbuffer overflow line#%d",path,lineNum); SL_CLRFLAG(SL_LOADED); break; } strreplace(buff,'\n',0); strreplace(buff,'\r',0); // chomp bool hasContent=false; char *ls; for(ls=buff; *ls; ls++) { if(*ls==';' || *ls=='#') { // comment if(hasContent) while(ls>buff && ls[-1]<=' ') ls--; // search back to non-whitespace break; } if(*ls>' ') hasContent=true; // line contains something usefull } cStructItem *it=0; if(hasContent) { char save=*ls; *ls=0; it=ParseLine(skipspace(buff)); *ls=save; if(!it) { PRINTF(L_GEN_ERROR,"file %s has error in line #%d",path,lineNum); ls=buff; } else num++; } else ls=buff; if(!it) it=new cCommentItem; if(it) { it->SetComment(ls); Add(it); } else { PRINTF(L_GEN_ERROR,"out of memory loading file %s",path); SL_CLRFLAG(SL_LOADED); break; } } ListUnlock(); PRINTF(L_CORE_LOAD,"loaded %d %s from %s",num,type,path); PostLoad(); } else ListUnlock(); fclose(f); LoadFinished(); } else OpenFailed(); }
bool FGAerodynamics::Load(Element *document) { string parameter, axis, scratch; string scratch_unit=""; Element *temp_element, *axis_element, *function_element; Name = "Aerodynamics Model: " + document->GetAttributeValue("name"); // Perform base class Pre-Load if (!FGModel::Load(document)) return false; DetermineAxisSystem(document); // Determine if Lift/Side/Drag, etc. is used. Debug(2); if ((temp_element = document->FindElement("alphalimits"))) { scratch_unit = temp_element->GetAttributeValue("unit"); if (scratch_unit.empty()) scratch_unit = "RAD"; alphaclmin0 = temp_element->FindElementValueAsNumberConvertFromTo("min", scratch_unit, "RAD"); alphaclmax0 = temp_element->FindElementValueAsNumberConvertFromTo("max", scratch_unit, "RAD"); alphaclmin = alphaclmin0; alphaclmax = alphaclmax0; } if ((temp_element = document->FindElement("hysteresis_limits"))) { scratch_unit = temp_element->GetAttributeValue("unit"); if (scratch_unit.empty()) scratch_unit = "RAD"; alphahystmin = temp_element->FindElementValueAsNumberConvertFromTo("min", scratch_unit, "RAD"); alphahystmax = temp_element->FindElementValueAsNumberConvertFromTo("max", scratch_unit, "RAD"); } if ((temp_element = document->FindElement("aero_ref_pt_shift_x"))) { function_element = temp_element->FindElement("function"); AeroRPShift = new FGFunction(PropertyManager, function_element); } axis_element = document->FindElement("axis"); while (axis_element) { AeroFunctionArray ca; AeroFunctionArray ca_atCG; axis = axis_element->GetAttributeValue("name"); function_element = axis_element->FindElement("function"); while (function_element) { string current_func_name = function_element->GetAttributeValue("name"); bool apply_at_cg = false; if (function_element->HasAttribute("apply_at_cg")) { if (function_element->GetAttributeValue("apply_at_cg") == "true") apply_at_cg = true; } if (!apply_at_cg) { try { ca.push_back( new FGFunction(PropertyManager, function_element) ); } catch (string const str) { cerr << endl << fgred << "Error loading aerodynamic function in " << current_func_name << ":" << str << " Aborting." << reset << endl; return false; } } else { try { ca_atCG.push_back( new FGFunction(PropertyManager, function_element) ); } catch (string const str) { cerr << endl << fgred << "Error loading aerodynamic function in " << current_func_name << ":" << str << " Aborting." << reset << endl; return false; } } function_element = axis_element->FindNextElement("function"); } AeroFunctions[AxisIdx[axis]] = ca; AeroFunctionsAtCG[AxisIdx[axis]] = ca_atCG; axis_element = document->FindNextElement("axis"); } PostLoad(document, PropertyManager); // Perform base class Post-Load return true; }
void CPseudoGigant::Load(LPCSTR section) { inherited::Load (section); anim().AddReplacedAnim(&m_bDamaged, eAnimRun, eAnimRunDamaged); anim().AddReplacedAnim(&m_bDamaged, eAnimWalkFwd, eAnimWalkDamaged); //anim().AddReplacedAnim(&m_bRunTurnLeft, eAnimRun, eAnimRunTurnLeft); //anim().AddReplacedAnim(&m_bRunTurnRight, eAnimRun, eAnimRunTurnRight); anim().accel_load (section); //anim().accel_chain_add (eAnimWalkFwd, eAnimRun); //anim().accel_chain_add (eAnimWalkFwd, eAnimRunTurnLeft); //anim().accel_chain_add (eAnimWalkFwd, eAnimRunTurnRight); //anim().accel_chain_add (eAnimWalkDamaged, eAnimRunDamaged); step_effector.time = pSettings->r_float(section, "step_effector_time"); step_effector.amplitude = pSettings->r_float(section, "step_effector_amplitude"); step_effector.period_number = pSettings->r_float(section, "step_effector_period_number"); SVelocityParam &velocity_none = move().get_velocity(MonsterMovement::eVelocityParameterIdle); SVelocityParam &velocity_turn = move().get_velocity(MonsterMovement::eVelocityParameterStand); SVelocityParam &velocity_walk = move().get_velocity(MonsterMovement::eVelocityParameterWalkNormal); // SVelocityParam &velocity_run = move().get_velocity(MonsterMovement::eVelocityParameterRunNormal); SVelocityParam &velocity_walk_dmg = move().get_velocity(MonsterMovement::eVelocityParameterWalkDamaged); // SVelocityParam &velocity_run_dmg = move().get_velocity(MonsterMovement::eVelocityParameterRunDamaged); SVelocityParam &velocity_steal = move().get_velocity(MonsterMovement::eVelocityParameterSteal); anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimLieIdle, "stand_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimSitIdle, "sit_idle_", -1, &velocity_none, PS_SIT, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimSleep, "stand_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimWalkDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimRun, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimRunDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimEat, "stand_eat_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimLookAround, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimDie, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimStandLieDown, "stand_lie_down_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimLieToSleep, "lie_to_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimLieIdle, "stand_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimSitIdle, "sit_idle_", -1, &velocity_none, PS_SIT, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimSleep, "stand_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimWalkDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimRun, "stand_run_fwd_", -1, &velocity_run, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimRunDamaged, "stand_run_dmg_", -1, &velocity_run_dmg, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimEat, "stand_eat_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimLookAround, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimDie, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimStandLieDown, "stand_lie_down_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimLieToSleep, "lie_to_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimThreaten, "stand_kick_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); // anim().AddAnim(eAnimRunTurnLeft, "stand_run_left_", -1, &velocity_run, PS_STAND); // anim().AddAnim(eAnimRunTurnRight, "stand_run_right_", -1, &velocity_run, PS_STAND); anim().LinkAction(ACT_STAND_IDLE, eAnimStandIdle); anim().LinkAction(ACT_SIT_IDLE, eAnimSitIdle); anim().LinkAction(ACT_LIE_IDLE, eAnimLieIdle); anim().LinkAction(ACT_WALK_FWD, eAnimWalkFwd); anim().LinkAction(ACT_WALK_BKWD, eAnimWalkFwd); anim().LinkAction(ACT_RUN, eAnimRun); anim().LinkAction(ACT_EAT, eAnimEat); anim().LinkAction(ACT_SLEEP, eAnimSleep); anim().LinkAction(ACT_REST, eAnimSleep); anim().LinkAction(ACT_DRAG, eAnimWalkFwd); anim().LinkAction(ACT_ATTACK, eAnimAttack); anim().LinkAction(ACT_STEAL, eAnimSteal); anim().LinkAction(ACT_LOOK_AROUND, eAnimStandIdle); // define transitions anim().AddTransition(eAnimStandLieDown, eAnimSleep, eAnimLieToSleep, false); anim().AddTransition(PS_STAND, eAnimSleep, eAnimStandLieDown, true); anim().AddTransition(PS_STAND, PS_LIE, eAnimStandLieDown, false); #ifdef DEBUG anim().accel_chain_test (); #endif // Load psi postprocess -------------------------------------------------------- LPCSTR ppi_section = pSettings->r_string(section, "threaten_effector"); m_threaten_effector.ppi.duality.h = pSettings->r_float(ppi_section,"duality_h"); m_threaten_effector.ppi.duality.v = pSettings->r_float(ppi_section,"duality_v"); m_threaten_effector.ppi.gray = pSettings->r_float(ppi_section,"gray"); m_threaten_effector.ppi.blur = pSettings->r_float(ppi_section,"blur"); m_threaten_effector.ppi.noise.intensity = pSettings->r_float(ppi_section,"noise_intensity"); m_threaten_effector.ppi.noise.grain = pSettings->r_float(ppi_section,"noise_grain"); m_threaten_effector.ppi.noise.fps = pSettings->r_float(ppi_section,"noise_fps"); VERIFY(!fis_zero(m_threaten_effector.ppi.noise.fps)); sscanf(pSettings->r_string(ppi_section,"color_base"), "%f,%f,%f", &m_threaten_effector.ppi.color_base.r, &m_threaten_effector.ppi.color_base.g, &m_threaten_effector.ppi.color_base.b); sscanf(pSettings->r_string(ppi_section,"color_gray"), "%f,%f,%f", &m_threaten_effector.ppi.color_gray.r, &m_threaten_effector.ppi.color_gray.g, &m_threaten_effector.ppi.color_gray.b); sscanf(pSettings->r_string(ppi_section,"color_add"), "%f,%f,%f", &m_threaten_effector.ppi.color_add.r, &m_threaten_effector.ppi.color_add.g, &m_threaten_effector.ppi.color_add.b); m_threaten_effector.time = pSettings->r_float(ppi_section,"time"); m_threaten_effector.time_attack = pSettings->r_float(ppi_section,"time_attack"); m_threaten_effector.time_release = pSettings->r_float(ppi_section,"time_release"); m_threaten_effector.ce_time = pSettings->r_float(ppi_section,"ce_time"); m_threaten_effector.ce_amplitude = pSettings->r_float(ppi_section,"ce_amplitude"); m_threaten_effector.ce_period_number = pSettings->r_float(ppi_section,"ce_period_number"); m_threaten_effector.ce_power = pSettings->r_float(ppi_section,"ce_power"); // -------------------------------------------------------------------------------- ::Sound->create(m_sound_threaten_hit,pSettings->r_string(section,"sound_threaten_hit"), st_Effect,SOUND_TYPE_WORLD); ::Sound->create(m_sound_start_threaten,pSettings->r_string(section,"sound_threaten_start"), st_Effect,SOUND_TYPE_MONSTER_ATTACKING); m_kick_damage = pSettings->r_float(section,"HugeKick_Damage"); m_kick_particles = pSettings->r_string(section,"HugeKick_Particles"); read_distance (section,"HugeKick_MinMaxDist", m_threaten_dist_min, m_threaten_dist_max); read_delay (section,"HugeKick_MinMaxDelay", m_threaten_delay_min, m_threaten_delay_max); m_time_kick_actor_slow_down = pSettings->r_u32(section,"HugeKick_Time_SlowDown"); PostLoad (section); }
bool FGAerodynamics::Load(Element *element) { string parameter, axis, scratch; string scratch_unit=""; string fname="", file=""; Element *temp_element, *axis_element, *function_element; string separator = "/"; fname = element->GetAttributeValue("file"); if (!fname.empty()) { file = FDMExec->GetFullAircraftPath() + separator + fname; document = LoadXMLDocument(file); if (document == 0L) return false; } else { document = element; } FGModel::Load(document); // Perform base class Pre-Load DetermineAxisSystem(); // Detemine if Lift/Side/Drag, etc. is used. Debug(2); if ((temp_element = document->FindElement("alphalimits"))) { scratch_unit = temp_element->GetAttributeValue("unit"); if (scratch_unit.empty()) scratch_unit = "RAD"; alphaclmin = temp_element->FindElementValueAsNumberConvertFromTo("min", scratch_unit, "RAD"); alphaclmax = temp_element->FindElementValueAsNumberConvertFromTo("max", scratch_unit, "RAD"); } if ((temp_element = document->FindElement("hysteresis_limits"))) { scratch_unit = temp_element->GetAttributeValue("unit"); if (scratch_unit.empty()) scratch_unit = "RAD"; alphahystmin = temp_element->FindElementValueAsNumberConvertFromTo("min", scratch_unit, "RAD"); alphahystmax = temp_element->FindElementValueAsNumberConvertFromTo("max", scratch_unit, "RAD"); } if ((temp_element = document->FindElement("aero_ref_pt_shift_x"))) { function_element = temp_element->FindElement("function"); AeroRPShift = new FGFunction(PropertyManager, function_element); } axis_element = document->FindElement("axis"); while (axis_element) { AeroFunctionArray ca; axis = axis_element->GetAttributeValue("name"); function_element = axis_element->FindElement("function"); while (function_element) { string current_func_name = function_element->GetAttributeValue("name"); try { ca.push_back( new FGFunction(PropertyManager, function_element) ); } catch (string const str) { cerr << endl << fgred << "Error loading aerodynamic function in " << current_func_name << ":" << str << " Aborting." << reset << endl; return false; } function_element = axis_element->FindNextElement("function"); } AeroFunctions[AxisIdx[axis]] = ca; axis_element = document->FindNextElement("axis"); } PostLoad(document, PropertyManager); // Perform base class Post-Load return true; }
static MythImage *LoadImage(MythPainter *painter, // Must be a copy for thread safety ImageProperties imProps, ImageCacheMode cacheMode, // Included only to check address, could be // replaced by generating a unique value for // each MythUIImage object? const MythUIImage *parent, bool &aborted, MythImageReader *imageReader = NULL) { QString cacheKey = GenImageLabel(imProps); if (!PreLoad(cacheKey, parent)) { aborted = true; return NULL; } QString filename = imProps.filename; MythImage *image = NULL; bool bResize = false; bool bFoundInCache = false; int w = -1; int h = -1; if (!imProps.forceSize.isNull()) { if (imProps.forceSize.width() != -1) w = imProps.forceSize.width(); if (imProps.forceSize.height() != -1) h = imProps.forceSize.height(); bResize = true; } if (!imageReader) { image = GetMythUI()->LoadCacheImage(filename, cacheKey, painter, cacheMode); } if (image) { if (VERBOSE_LEVEL_CHECK(VB_GUI | VB_FILE, LOG_INFO)) { image->IncrRef(); int cnt = image->DecrRef(); LOG(VB_GUI | VB_FILE, LOG_INFO, QString("ImageLoader::LoadImage(%1) Found in cache, " "RefCount = %2") .arg(cacheKey).arg(cnt)); } if (imProps.isReflected) image->setIsReflected(true); if (imProps.isOriented) image->setIsOriented(true); bFoundInCache = true; } else { LOG(VB_GUI | VB_FILE, LOG_INFO, QString("ImageLoader::LoadImage(%1) NOT Found in cache. " "Loading Directly").arg(cacheKey)); image = painter->GetFormatImage(); bool ok = false; if (imageReader) ok = image->Load(imageReader); else ok = image->Load(filename); if (!ok) { image->DecrRef(); image = NULL; } } if (image && image->isNull()) { LOG(VB_GUI | VB_FILE, LOG_INFO, QString("ImageLoader::LoadImage(%1) Image is NULL") .arg(filename)); image->DecrRef(); image = NULL; } if (image && !bFoundInCache) { if (imProps.isReflected) image->Reflect(imProps.reflectAxis, imProps.reflectShear, imProps.reflectScale, imProps.reflectLength, imProps.reflectSpacing); if (imProps.isGreyscale) image->ToGreyscale(); if (imProps.isOriented) image->Orientation(imProps.orientation); // Even if an explicit size wasn't defined this image may still need // to be scaled because of a difference between the theme resolution // and the screen resolution. We want to avoid scaling twice. if (!bResize && imProps.isThemeImage) { float wmult; // Width multipler float hmult; // Height multipler GetMythUI()->GetScreenSettings(wmult, hmult); if (wmult != 1.0f || hmult != 1.0f) { w = image->size().width() * wmult; h = image->size().height() * hmult; bResize = true; } } if (bResize) image->Resize(QSize(w, h), imProps.preserveAspect); if (imProps.isMasked) { QRect imageArea = image->rect(); QRect maskArea = imProps.GetMaskImageRect(); // Crop the mask to the image int x = 0; int y = 0; if (maskArea.width() > imageArea.width()) x = (maskArea.width() - imageArea.width()) / 2; if (maskArea.height() > imageArea.height()) y = (maskArea.height() - imageArea.height()) / 2; if (x > 0 || y > 0) imageArea.translate(x, y); QImage mask = imProps.GetMaskImageSubset(imageArea); image->setAlphaChannel(mask.alphaChannel()); } if (!imageReader) GetMythUI()->CacheImage(cacheKey, image); } if (image) image->SetChanged(); PostLoad(cacheKey); return image; }