void SCarLight::ParseDefinitions(LPCSTR section) { light_render = ::Render->light_create(); light_render->set_type (IRender_Light::SPOT); light_render->set_shadow(true); glow_render = ::Render->glow_create(); // lanim = 0; // time2hide = 0; // set bone id IKinematics* pKinematics=smart_cast<IKinematics*>(m_holder->PCar()->Visual()); CInifile* ini = pKinematics->LL_UserData(); Fcolor clr; clr.set (ini->r_fcolor(section,"color")); //clr.mul_rgb (torch->spot_brightness); //fBrightness = torch->spot_brightness; light_render->set_range (ini->r_float(section,"range")); light_render->set_color (clr); light_render->set_cone (deg2rad(ini->r_float(section,"cone_angle"))); light_render->set_texture(ini->r_string(section,"spot_texture")); glow_render->set_texture(ini->r_string(section,"glow_texture")); glow_render->set_color (clr); glow_render->set_radius (ini->r_float(section,"glow_radius")); bone_id = pKinematics->LL_BoneID(ini->r_string(section,"bone")); glow_render ->set_active(false); light_render->set_active(false); pKinematics->LL_SetBoneVisible(bone_id,FALSE,TRUE); //lanim = LALib.FindItem(ini->r_string(section,"animator")); }
void CGameFont::Initialize (LPCSTR cShader, LPCSTR cTextureName) { string_path cTexture; LPCSTR _lang = pSettings->r_string("string_table", "font_prefix"); bool is_di = strstr(cTextureName, "ui_font_hud_01") || strstr(cTextureName, "ui_font_hud_02") || strstr(cTextureName, "ui_font_console_02"); if(_lang && !is_di) strconcat (cTexture, cTextureName, _lang); else strcpy (cTexture, cTextureName); uFlags &=~fsValid; vTS.set (1.f,1.f); // обязательно !!! eCurrentAlignment = alLeft; vInterval.set (1.f,1.f); for (int i=0; i<256; i++) CharMap[i] = i; strings.reserve (128); // check ini exist string256 fn,buf; strcpy (buf,cTexture); if (strext(buf)) *strext(buf)=0; R_ASSERT2 (FS.exist(fn,"$game_textures$",buf,".ini"),fn); CInifile* ini = CInifile::Create(fn); if (ini->section_exist("symbol_coords")){ for (int i=0; i<256; i++){ sprintf (buf,"%03d",i); Fvector v = ini->r_fvector3("symbol_coords",buf); TCMap[i].set (v.x,v.y,v[2]-v[0]); } fHeight = ini->r_float("symbol_coords","height"); }else{ if (ini->section_exist("char widths")){ fHeight = ini->r_float("char widths","height"); int cpl = 16; for (int i=0; i<256; i++){ sprintf (buf,"%d",i); float w = ini->r_float("char widths",buf); TCMap[i].set ((i%cpl)*fHeight,(i/cpl)*fHeight,w); } }else{ R_ASSERT(ini->section_exist("font_size")); fHeight = ini->r_float("font_size","height"); float width = ini->r_float("font_size","width"); const int cpl = ini->r_s32 ("font_size","cpl"); for (int i=0; i<256; i++) TCMap[i].set ((i%cpl)*width,(i/cpl)*fHeight,width); } } fCurrentHeight = fHeight; CInifile::Destroy (ini); // Shading pShader.create (cShader,cTexture); pGeom.create (FVF::F_TL, RCache.Vertex.Buffer(), RCache.QuadIB); }
//----------------------------------------------------------------------------- // Environment ambient //----------------------------------------------------------------------------- void CEnvAmbient::SSndChannel::load(CInifile& config, LPCSTR sect) { m_load_section = sect; m_sound_dist.x = config.r_float(m_load_section, "min_distance"); m_sound_dist.y = config.r_float(m_load_section, "max_distance"); m_sound_period.x = config.r_s32(m_load_section, "period0"); m_sound_period.y = config.r_s32(m_load_section, "period1"); m_sound_period.z = config.r_s32(m_load_section, "period2"); m_sound_period.w = config.r_s32(m_load_section, "period3"); // m_sound_period = config.r_ivector4(sect,"sound_period"); R_ASSERT(m_sound_period.x <= m_sound_period.y && m_sound_period.z <= m_sound_period.w); // m_sound_period.mul (1000);// now in ms // m_sound_dist = config.r_fvector2(sect,"sound_dist"); R_ASSERT2(m_sound_dist.y > m_sound_dist.x, sect); LPCSTR snds = config.r_string(sect, "sounds"); u32 cnt = _GetItemCount(snds); string_path tmp; R_ASSERT3(cnt, "sounds empty", sect); m_sounds.resize(cnt); for (u32 k = 0; k < cnt; ++k) { _GetItem(snds, k, tmp); m_sounds[k].create(tmp, st_Effect, sg_SourceType); } }
void SThunderboltDesc::create_center_gradient (CInifile& pIni, shared_str const& sect) { m_GradientCenter = new SFlare(); m_GradientCenter->shader = pIni.r_string ( sect,"gradient_center_shader" ); m_GradientCenter->texture = pIni.r_string ( sect,"gradient_center_texture" ); m_GradientCenter->fRadius = pIni.r_fvector2 (sect,"gradient_center_radius" ); m_GradientCenter->fOpacity = pIni.r_float ( sect,"gradient_center_opacity" ); m_GradientCenter->m_pFlare->CreateShader (*m_GradientCenter->shader,*m_GradientCenter->texture); }
void CCar::SWheel::Load(LPCSTR section) { CKinematics *K =PKinematics(car->Visual()) ; CInifile *ini =K->LL_UserData() ; VERIFY (ini) ; if(ini->section_exist(section)) { collision_params.damping_factor =READ_IF_EXISTS(ini,r_float,section,"damping_factor",collision_params.damping_factor); collision_params.spring_factor =READ_IF_EXISTS(ini,r_float,section,"spring_factor",collision_params.spring_factor); collision_params.mu_factor =READ_IF_EXISTS(ini,r_float,section,"friction_factor",collision_params.mu_factor); } else if(ini->section_exist("wheels_params")) { collision_params.damping_factor =ini->r_float("wheels_params","damping_factor") ; collision_params.spring_factor =ini->r_float("wheels_params","spring_factor") ; collision_params.mu_factor =ini->r_float("wheels_params","friction_factor") ; } }
//---------------------------------------------------- bool ESoundSource::LoadLTX(CInifile& ini, LPCSTR sect_name) { u32 version = ini.r_u32(sect_name, "version"); if(version!=SOUND_SOURCE_VERSION) { ELog.Msg( mtError, "ESoundSource: Unsupported version."); return false; } inherited::LoadLTX (ini, sect_name); m_Type = ini.r_u32 (sect_name, "snd_type"); m_WAVName = ini.r_string (sect_name, "snd_name"); m_Flags.assign (ini.r_u32 (sect_name, "flags")); m_Params.position = ini.r_fvector3 (sect_name, "snd_position"); m_Params.volume = ini.r_float (sect_name, "volume"); m_Params.freq = ini.r_float (sect_name, "freq"); m_Params.min_distance=ini.r_float (sect_name, "min_dist"); m_Params.max_distance= ini.r_float (sect_name, "max_dist"); m_Params.max_ai_distance=ini.r_float (sect_name, "max_ai_dist"); m_RandomPause = ini.r_fvector2 (sect_name, "random_pause"); m_ActiveTime = ini.r_fvector2 (sect_name, "active_time"); m_PlayTime = ini.r_fvector2 (sect_name, "play_time"); ResetSource (); switch (m_Type) { case stStaticSource: if (m_Flags.is(flPlaying)) Play(); //. if (m_Flags.is(flSimulating)) Simulate(); break; default: THROW; } return true; }
void CCar::SWheelBreak::Load(LPCSTR section) { CKinematics *K =PKinematics(pwheel->car->Visual()) ; CInifile *ini =K->LL_UserData() ; VERIFY (ini) ; break_torque = ini->r_float("car_definition","break_torque") ; hand_break_torque = READ_IF_EXISTS(ini,r_float,"car_definition","hand_break_torque",break_torque) ; if(ini->section_exist(section)) { break_torque =READ_IF_EXISTS(ini,r_float,section,"break_torque",break_torque); hand_break_torque =READ_IF_EXISTS(ini,r_float,section,"hand_break_torque",hand_break_torque); } }
void CEnvAmbient::load( CInifile& ambients_config, CInifile& sound_channels_config, CInifile& effects_config, const shared_str& sect ) { m_ambients_config_filename = ambients_config.fname(); m_load_section = sect; string_path tmp; // sounds LPCSTR channels = ambients_config.r_string(sect, "sound_channels"); u32 cnt = _GetItemCount(channels); // R_ASSERT3 (cnt,"sound_channels empty", sect.c_str()); m_sound_channels.resize(cnt); for (u32 i = 0; i < cnt; ++i) m_sound_channels[i] = create_sound_channel(sound_channels_config, _GetItem(channels, i, tmp)); // effects m_effect_period.set( iFloor( ambients_config.r_float(sect, "min_effect_period")*1000.f ), iFloor( ambients_config.r_float(sect, "max_effect_period")*1000.f ) ); LPCSTR effs = ambients_config.r_string(sect, "effects"); cnt = _GetItemCount(effs); // R_ASSERT3 (cnt,"effects empty", sect.c_str()); m_effects.resize(cnt); for (u32 k = 0; k < cnt; ++k) m_effects[k] = create_effect(effects_config, _GetItem(effs, k, tmp)); R_ASSERT(!m_sound_channels.empty() || !m_effects.empty()); }
CCarWeapon::CCarWeapon(CPhysicsShellHolder* obj) { m_bActive = false; m_bAutoFire = false; m_object = obj; m_Ammo = xr_new<CCartridge>(); CKinematics* K = smart_cast<CKinematics*>(m_object->Visual()); CInifile* pUserData = K->LL_UserData(); m_rotate_x_bone = K->LL_BoneID (pUserData->r_string("mounted_weapon_definition","rotate_x_bone")); m_rotate_y_bone = K->LL_BoneID (pUserData->r_string("mounted_weapon_definition","rotate_y_bone")); m_fire_bone = K->LL_BoneID (pUserData->r_string("mounted_weapon_definition","fire_bone")); m_min_gun_speed = pUserData->r_float("mounted_weapon_definition","min_gun_speed"); m_max_gun_speed = pUserData->r_float("mounted_weapon_definition","max_gun_speed"); CBoneData& bdX = K->LL_GetData(m_rotate_x_bone); //VERIFY(bdX.IK_data.type==jtJoint); m_lim_x_rot.set (bdX.IK_data.limits[0].limit.x,bdX.IK_data.limits[0].limit.y); CBoneData& bdY = K->LL_GetData(m_rotate_y_bone); //VERIFY(bdY.IK_data.type==jtJoint); m_lim_y_rot.set (bdY.IK_data.limits[1].limit.x,bdY.IK_data.limits[1].limit.y); xr_vector<Fmatrix> matrices; K->LL_GetBindTransform (matrices); m_i_bind_x_xform.invert (matrices[m_rotate_x_bone]); m_i_bind_y_xform.invert (matrices[m_rotate_y_bone]); m_bind_x_rot = matrices[m_rotate_x_bone].k.getP(); m_bind_y_rot = matrices[m_rotate_y_bone].k.getH(); m_bind_x.set (matrices[m_rotate_x_bone].c); m_bind_y.set (matrices[m_rotate_y_bone].c); m_cur_x_rot = m_bind_x_rot; m_cur_y_rot = m_bind_y_rot; m_destEnemyDir.setHP (m_bind_y_rot,m_bind_x_rot); m_object->XFORM().transform_dir (m_destEnemyDir); inheritedShooting::Light_Create (); Load (pUserData->r_string("mounted_weapon_definition","wpn_section")); SetBoneCallbacks (); m_object->processing_activate (); m_weapon_h = matrices[m_rotate_y_bone].c.y; m_fire_norm.set (0,1,0); m_fire_dir.set (0,0,1); m_fire_pos.set (0,0,0); }
bool CEditShape::LoadLTX(CInifile& ini, LPCSTR sect_name) { u32 vers = ini.r_u32(sect_name, "version"); inherited::LoadLTX (ini, sect_name); u32 count = ini.r_u32 (sect_name, "shapes_count"); if(vers>0x0001) m_shape_type = ini.r_u8 (sect_name, "shape_type"); string128 buff; shapes.resize (count); for(u32 i=0; i<count; ++i) { sprintf (buff,"shape_type_%d", i); shapes[i].type = ini.r_u8(sect_name, buff); if(shapes[i].type==CShapeData::cfSphere) { sprintf (buff,"shape_center_%d", i); shapes[i].data.sphere.P = ini.r_fvector3 (sect_name, buff); sprintf (buff,"shape_radius_%d", i); shapes[i].data.sphere.R = ini.r_float (sect_name, buff); }else { R_ASSERT (shapes[i].type==CShapeData::cfBox); sprintf (buff,"shape_matrix_i_%d", i); shapes[i].data.box.i = ini.r_fvector3 (sect_name, buff); sprintf (buff,"shape_matrix_j_%d", i); shapes[i].data.box.j = ini.r_fvector3 (sect_name, buff); sprintf (buff,"shape_matrix_k_%d", i); shapes[i].data.box.k = ini.r_fvector3 (sect_name, buff); sprintf (buff,"shape_matrix_c_%d", i); shapes[i].data.box.c = ini.r_fvector3 (sect_name, buff); } } ComputeBounds(); return true; }
////////////////////////////////////////////////////////////////////////// // environment CEnvironment::CEnvironment () : CurrentEnv (0), m_ambients_config (0) { bNeed_re_create_env = FALSE; bWFX = false; Current[0] = 0; Current[1] = 0; CurrentWeather = 0; CurrentWeatherName = 0; eff_Rain = 0; eff_LensFlare = 0; eff_Thunderbolt = 0; OnDeviceCreate (); #ifdef _EDITOR ed_from_time = 0.f; ed_to_time = DAY_LENGTH; #endif #ifndef _EDITOR m_paused = false; #endif fGameTime = 0.f; fTimeFactor = 12.f; wind_strength_factor = 0.f; wind_gust_factor = 0.f; wind_blast_strength = 0.f; wind_blast_direction.set(1.f,0.f,0.f); wind_blast_strength_start_value = 0.f; wind_blast_strength_stop_value = 0.f; // fill clouds hemi verts & faces const Fvector* verts; CloudsVerts.resize (xrHemisphereVertices(2,verts)); CopyMemory (&CloudsVerts.front(),verts,CloudsVerts.size()*sizeof(Fvector)); const u16* indices; CloudsIndices.resize (xrHemisphereIndices(2,indices)); CopyMemory (&CloudsIndices.front(),indices,CloudsIndices.size()*sizeof(u16)); // perlin noise PerlinNoise1D = xr_new<CPerlinNoise1D>(Random.randI(0,0xFFFF)); PerlinNoise1D->SetOctaves(2); PerlinNoise1D->SetAmplitude(0.66666f); // tsky0 = Device.Resources->_CreateTexture("$user$sky0"); // tsky1 = Device.Resources->_CreateTexture("$user$sky1"); string_path file_name; m_ambients_config = xr_new<CInifile>( FS.update_path( file_name, "$game_config$", "environment\\ambients.ltx" ), TRUE, TRUE, FALSE ); m_sound_channels_config = xr_new<CInifile>( FS.update_path( file_name, "$game_config$", "environment\\sound_channels.ltx" ), TRUE, TRUE, FALSE ); m_effects_config = xr_new<CInifile>( FS.update_path( file_name, "$game_config$", "environment\\effects.ltx" ), TRUE, TRUE, FALSE ); m_suns_config = xr_new<CInifile>( FS.update_path( file_name, "$game_config$", "environment\\suns.ltx" ), TRUE, TRUE, FALSE ); m_thunderbolt_collections_config = xr_new<CInifile>( FS.update_path( file_name, "$game_config$", "environment\\thunderbolt_collections.ltx" ), TRUE, TRUE, FALSE ); m_thunderbolts_config = xr_new<CInifile>( FS.update_path( file_name, "$game_config$", "environment\\thunderbolts.ltx" ), TRUE, TRUE, FALSE ); CInifile* config = xr_new<CInifile>( FS.update_path( file_name, "$game_config$", "environment\\environment.ltx" ), TRUE, TRUE, FALSE ); // params p_var_alt = deg2rad(config->r_float ( "environment","altitude" )); p_var_long = deg2rad (config->r_float ( "environment","delta_longitude" )); p_min_dist = _min (.95f,config->r_float ( "environment","min_dist_factor" )); p_tilt = deg2rad (config->r_float ( "environment","tilt" )); p_second_prop = config->r_float ( "environment","second_propability" ); clamp (p_second_prop,0.f,1.f); p_sky_color = config->r_float ( "environment","sky_color" ); p_sun_color = config->r_float ( "environment","sun_color" ); p_fog_color = config->r_float ( "environment","fog_color" ); xr_delete (config); }
void CEnvDescriptor::load(CEnvironment& environment, CInifile& config) { Ivector3 tm = {0, 0, 0}; sscanf(m_identifier.c_str(), "%d:%d:%d", &tm.x, &tm.y, &tm.z); R_ASSERT3((tm.x >= 0) && (tm.x < 24) && (tm.y >= 0) && (tm.y < 60) && (tm.z >= 0) && (tm.z < 60), "Incorrect weather time", m_identifier.c_str()); exec_time = tm.x*3600.f + tm.y*60.f + tm.z; exec_time_loaded = exec_time; string_path st, st_env; xr_strcpy(st, config.r_string(m_identifier.c_str(), "sky_texture")); strconcat(sizeof(st_env), st_env, st, "#small"); sky_texture_name = st; sky_texture_env_name = st_env; clouds_texture_name = config.r_string(m_identifier.c_str(), "clouds_texture"); LPCSTR cldclr = config.r_string(m_identifier.c_str(), "clouds_color"); float multiplier = 0, save = 0; sscanf(cldclr, "%f,%f,%f,%f,%f", &clouds_color.x, &clouds_color.y, &clouds_color.z, &clouds_color.w, &multiplier); save = clouds_color.w; clouds_color.mul(.5f*multiplier); clouds_color.w = save; sky_color = config.r_fvector3(m_identifier.c_str(), "sky_color"); if (config.line_exist(m_identifier.c_str(), "sky_rotation")) sky_rotation = deg2rad(config.r_float(m_identifier.c_str(), "sky_rotation")); else sky_rotation = 0; far_plane = config.r_float(m_identifier.c_str(), "far_plane"); fog_color = config.r_fvector3(m_identifier.c_str(), "fog_color"); fog_density = config.r_float(m_identifier.c_str(), "fog_density"); fog_distance = config.r_float(m_identifier.c_str(), "fog_distance"); rain_density = config.r_float(m_identifier.c_str(), "rain_density"); clamp(rain_density, 0.f, 1.f); rain_color = config.r_fvector3(m_identifier.c_str(), "rain_color"); wind_velocity = config.r_float(m_identifier.c_str(), "wind_velocity"); wind_direction = deg2rad(config.r_float(m_identifier.c_str(), "wind_direction")); ambient = config.r_fvector3(m_identifier.c_str(), "ambient_color"); hemi_color = config.r_fvector4(m_identifier.c_str(), "hemisphere_color"); sun_color = config.r_fvector3(m_identifier.c_str(), "sun_color"); // if (config.line_exist(m_identifier.c_str(),"sun_altitude")) sun_dir.setHP( deg2rad(config.r_float(m_identifier.c_str(), "sun_altitude")), deg2rad(config.r_float(m_identifier.c_str(), "sun_longitude")) ); R_ASSERT(_valid(sun_dir)); // else // sun_dir.setHP ( // deg2rad(config.r_fvector2(m_identifier.c_str(),"sun_dir").y), // deg2rad(config.r_fvector2(m_identifier.c_str(),"sun_dir").x) // ); //AVO: commented to allow COC run in debug. I belive Cromm set longtitude to negative value in AF3 and that's why it is failing here //VERIFY2(sun_dir.y < 0, "Invalid sun direction settings while loading"); lens_flare_id = environment.eff_LensFlare->AppendDef(environment, environment.m_suns_config, config.r_string(m_identifier.c_str(), "sun")); tb_id = environment.eff_Thunderbolt->AppendDef(environment, environment.m_thunderbolt_collections_config, environment.m_thunderbolts_config, config.r_string(m_identifier.c_str(), "thunderbolt_collection")); bolt_period = (tb_id.size()) ? config.r_float(m_identifier.c_str(), "thunderbolt_period") : 0.f; bolt_duration = (tb_id.size()) ? config.r_float(m_identifier.c_str(), "thunderbolt_duration") : 0.f; env_ambient = config.line_exist(m_identifier.c_str(), "ambient") ? environment.AppendEnvAmb(config.r_string(m_identifier.c_str(), "ambient")) : 0; if (config.line_exist(m_identifier.c_str(), "sun_shafts_intensity")) m_fSunShaftsIntensity = config.r_float(m_identifier.c_str(), "sun_shafts_intensity"); if (config.line_exist(m_identifier.c_str(), "water_intensity")) m_fWaterIntensity = config.r_float(m_identifier.c_str(), "water_intensity"); #ifdef TREE_WIND_EFFECT if (config.line_exist(m_identifier.c_str(), "tree_amplitude_intensity")) m_fTreeAmplitudeIntensity = config.r_float(m_identifier.c_str(), "tree_amplitude_intensity"); #endif C_CHECK(clouds_color); C_CHECK(sky_color); C_CHECK(fog_color); C_CHECK(rain_color); C_CHECK(ambient); C_CHECK(hemi_color); C_CHECK(sun_color); on_device_create(); }
void CCar::Init() { CPHCollisionDamageReceiver::Init(); //get reference wheel radius IKinematics* pKinematics=smart_cast<IKinematics*>(Visual()); CInifile* ini = pKinematics->LL_UserData(); R_ASSERT2(ini,"Car has no description !!! See ActorEditor Object - UserData"); ///SWheel& ref_wheel=m_wheels_map.find(pKinematics->LL_BoneID(ini->r_string("car_definition","reference_wheel")))->second; if(ini->section_exist("air_resistance")) { PPhysicsShell()->SetAirResistance(default_k_l*ini->r_float("air_resistance","linear_factor"),default_k_w*ini->r_float("air_resistance","angular_factor")); } if(ini->line_exist("car_definition","steer")) { m_bone_steer=pKinematics->LL_BoneID(ini->r_string("car_definition","steer")); VERIFY2(fsimilar(DET(pKinematics->LL_GetTransform(m_bone_steer)),1.f,EPS_L),"BBADD MTX"); pKinematics->LL_GetBoneInstance(m_bone_steer).set_callback(bctPhysics,cb_Steer,this); } m_steer_angle=0.f; //ref_wheel.Init(); m_ref_radius=ini->r_float("car_definition","reference_radius");//ref_wheel.radius; b_exploded =false; b_engine_on =false; b_clutch =false; b_starting =false; b_stalling =false; b_transmission_switching =false; m_root_transform.set(bone_map.find(pKinematics->LL_GetBoneRoot())->second.element->mXFORM); m_current_transmission_num=0; m_pPhysicsShell->set_DynamicScales(1.f,1.f); CDamagableItem::Init(GetfHealth(),3); float l_time_to_explosion=READ_IF_EXISTS(ini,r_float,"car_definition","time_to_explosion",120.f); CDelayedActionFuse::Initialize(l_time_to_explosion,CDamagableItem::DamageLevelToHealth(2)); { xr_map<u16,SWheel>::iterator i,e; i=m_wheels_map.begin(); e=m_wheels_map.end(); for(;i!=e;++i) { i->second.Init(); i->second.CDamagableHealthItem::Init(100.f,2); } } { xr_vector<SWheelDrive>::iterator i,e; i=m_driving_wheels.begin(); e=m_driving_wheels.end(); for(;i!=e;++i) i->Init(); } { xr_vector<SWheelBreak>::iterator i,e; i=m_breaking_wheels.begin(); e=m_breaking_wheels.end(); for(;i!=e;++i) i->Init(); } { xr_vector<SWheelSteer>::iterator i,e; i=m_steering_wheels.begin(); e=m_steering_wheels.end(); for(;i!=e;++i) i->Init(); } { xr_vector<SExhaust>::iterator i,e; i=m_exhausts.begin(); e=m_exhausts.end(); for(;i!=e;++i) i->Init(); } { xr_map<u16,SDoor>::iterator i,e; i=m_doors.begin(); e=m_doors.end(); for(;i!=e;++i) { i->second.Init(); i->second.CDamagableHealthItem::Init(100,1); } } if(ini->section_exist("damage_items")) { CInifile::Sect& data = ini->r_section("damage_items"); for (CInifile::SectCIt I=data.Data.begin(); I!=data.Data.end(); I++){ const CInifile::Item& item = *I; u16 index = pKinematics->LL_BoneID(*item.first); R_ASSERT3(index != BI_NONE, "Wrong bone name", *item.first); xr_map <u16,SWheel>::iterator i=m_wheels_map.find(index); if(i!=m_wheels_map.end()) i->second.CDamagableHealthItem::Init(float(atof(*item.second)),2); else { xr_map <u16,SDoor>::iterator i=m_doors.find(index); R_ASSERT3(i!=m_doors.end(),"only wheel and doors bones allowed for damage defs",*item.first); i->second.CDamagableHealthItem::Init(float(atof(*item.second)),1); } } } if(ini->section_exist("immunities")) { LoadImmunities("immunities",ini); } CDamageManager::reload("car_definition","damage",ini); HandBreak(); Transmission(1); }
void CUIGlobalMap::Init (shared_str name, CInifile& gameLtx, LPCSTR sh_name) { inherited::Init (name, gameLtx, sh_name); SetMaxZoom (gameLtx.r_float(m_name,"max_zoom")); }
void CGameFont::Initialize (LPCSTR cShader, LPCSTR cTextureName) { string_path cTexture; LPCSTR _lang = pSettings->r_string("string_table", "font_prefix"); bool is_di = strstr(cTextureName, "ui_font_hud_01") || strstr(cTextureName, "ui_font_hud_02") || strstr(cTextureName, "ui_font_console_02"); if(_lang && !is_di) strconcat (sizeof(cTexture),cTexture, cTextureName, _lang); else strcpy_s (cTexture, sizeof(cTexture), cTextureName); uFlags &=~fsValid; vTS.set (1.f,1.f); // обязательно !!! eCurrentAlignment = alLeft; vInterval.set (1.f,1.f); strings.reserve (128); // check ini exist string_path fn,buf; strcpy_s (buf,cTexture); if (strext(buf)) *strext(buf)=0; R_ASSERT2 (FS.exist(fn,"$game_textures$",buf,".ini"),fn); CInifile* ini = CInifile::Create(fn); nNumChars = 0x100; TCMap = ( Fvector* ) xr_realloc( ( void* ) TCMap , nNumChars * sizeof( Fvector ) ); if ( ini->section_exist( "mb_symbol_coords" ) ) { nNumChars = 0x10000; TCMap = ( Fvector* ) xr_realloc( ( void* ) TCMap , nNumChars * sizeof( Fvector ) ); uFlags |= fsMultibyte; fHeight = ini->r_float( "mb_symbol_coords" , "height" ); fXStep = ceil( fHeight / 2.0f ); // Searching for the first valid character Fvector vFirstValid = {0,0,0}; if ( ini->line_exist( "mb_symbol_coords" , "09608" ) ) { Fvector v = ini->r_fvector3( "mb_symbol_coords" , "09608" ); vFirstValid.set( v.x , v.y , 1 + v[2] - v[0] ); } else for ( u32 i=0 ; i < nNumChars ; i++ ) { sprintf_s( buf ,sizeof(buf), "%05d" , i ); if ( ini->line_exist( "mb_symbol_coords" , buf ) ) { Fvector v = ini->r_fvector3( "mb_symbol_coords" , buf ); vFirstValid.set( v.x , v.y , 1 + v[2] - v[0] ); break; } } // Filling entire character table for ( u32 i=0 ; i < nNumChars ; i++ ) { sprintf_s( buf ,sizeof(buf), "%05d" , i ); if ( ini->line_exist( "mb_symbol_coords" , buf ) ) { Fvector v = ini->r_fvector3( "mb_symbol_coords" , buf ); TCMap[i].set( v.x , v.y , 1 + v[2] - v[0] ); } else TCMap[i] = vFirstValid; // "unassigned" unprintable characters } // Special case for space TCMap[ 0x0020 ].set( 0 , 0 , 0 ); // Special case for ideographic space TCMap[ 0x3000 ].set( 0 , 0 , 0 ); }else if (ini->section_exist("symbol_coords")) { float d = 0.0f; //. if(ini->section_exist("width_correction")) //. d = ini->r_float("width_correction", "value"); fHeight = ini->r_float("symbol_coords","height"); for (u32 i=0; i<nNumChars; i++){ sprintf_s (buf,sizeof(buf),"%03d",i); Fvector v = ini->r_fvector3("symbol_coords",buf); TCMap[i].set (v.x,v.y,v[2]-v[0]+d); } }else{ if (ini->section_exist("char widths")){ fHeight = ini->r_float("char widths","height"); int cpl = 16; for (u32 i=0; i<nNumChars; i++){ sprintf_s (buf,sizeof(buf),"%d",i); float w = ini->r_float("char widths",buf); TCMap[i].set ((i%cpl)*fHeight,(i/cpl)*fHeight,w); } }else{ R_ASSERT(ini->section_exist("font_size")); fHeight = ini->r_float("font_size","height"); float width = ini->r_float("font_size","width"); const int cpl = ini->r_s32 ("font_size","cpl"); for (u32 i=0; i<nNumChars; i++) TCMap[i].set ((i%cpl)*width,(i/cpl)*fHeight,width); } } fCurrentHeight = fHeight; CInifile::Destroy (ini); // Shading pFontRender->Initialize(cShader, cTexture); }
BOOL CPEDef::Load2(CInifile& ini) { //. u16 version = ini.r_u16("_effect", "version"); m_MaxParticles = ini.r_u32("_effect", "max_particles"); m_Flags.assign (ini.r_u32("_effect", "flags")); if (m_Flags.is(dfSprite)) { m_ShaderName = ini.r_string ("sprite", "shader"); m_TextureName = ini.r_string ("sprite", "texture"); } if (m_Flags.is(dfFramed)) { m_Frame.m_fTexSize = ini.r_fvector2 ("frame", "tex_size"); m_Frame.reserved = ini.r_fvector2 ("frame", "reserved"); m_Frame.m_iFrameDimX = ini.r_s32 ("frame", "dim_x"); m_Frame.m_iFrameCount = ini.r_s32 ("frame", "frame_count"); m_Frame.m_fSpeed = ini.r_float ("frame", "speed"); } if (m_Flags.is(dfTimeLimit)) { m_fTimeLimit = ini.r_float ("timelimit", "value"); } if (m_Flags.is(dfCollision)) { m_fCollideOneMinusFriction = ini.r_float ("collision", "one_minus_friction"); m_fCollideResilience = ini.r_float ("collision", "collide_resilence"); m_fCollideSqrCutoff = ini.r_float ("collision", "collide_sqr_cutoff"); } if (m_Flags.is(dfVelocityScale)) { m_VelocityScale = ini.r_fvector3 ("velocity_scale", "value"); } if (m_Flags.is(dfAlignToPath)) { m_APDefaultRotation = ini.r_fvector3 ("align_to_path", "default_rotation"); } #ifdef _EDITOR if(pCreateEAction) { u32 count = ini.r_u32("_effect", "action_count"); m_EActionList.resize(count); u32 action_id = 0; for (EPAVecIt it=m_EActionList.begin(); it!=m_EActionList.end(); ++it,++action_id) { string256 sect; xr_sprintf (sect, sizeof(sect), "action_%04d", action_id); PAPI::PActionEnum type = (PAPI::PActionEnum)(ini.r_u32(sect,"action_type")); (*it) = pCreateEAction(type); (*it)->Load2 (ini, sect); } Compile (m_EActionList); } #endif return TRUE; }
void CCar::ParseDefinitions() { bone_map.clear(); IKinematics* pKinematics=smart_cast<IKinematics*>(Visual()); bone_map.insert(mk_pair(pKinematics->LL_GetBoneRoot(),physicsBone())); CInifile* ini = pKinematics->LL_UserData(); R_ASSERT2(ini,"Car has no description !!! See ActorEditor Object - UserData"); CExplosive::Load(ini,"explosion"); //CExplosive::SetInitiator(ID()); m_camera_position = ini->r_fvector3("car_definition","camera_pos"); ///////////////////////////car definition/////////////////////////////////////////////////// fill_wheel_vector (ini->r_string ("car_definition","driving_wheels"),m_driving_wheels); fill_wheel_vector (ini->r_string ("car_definition","steering_wheels"),m_steering_wheels); fill_wheel_vector (ini->r_string ("car_definition","breaking_wheels"),m_breaking_wheels); fill_exhaust_vector (ini->r_string ("car_definition","exhausts"),m_exhausts); fill_doors_map (ini->r_string ("car_definition","doors"),m_doors); ///////////////////////////car properties/////////////////////////////// m_max_power = ini->r_float("car_definition","engine_power"); m_max_power *= (0.8f*1000.f); m_max_rpm = ini->r_float("car_definition","max_engine_rpm"); m_max_rpm *= (1.f/60.f*2.f*M_PI); m_min_rpm = ini->r_float("car_definition","idling_engine_rpm"); m_min_rpm *= (1.f/60.f*2.f*M_PI); m_power_rpm = ini->r_float("car_definition","max_power_rpm"); m_power_rpm *= (1.f/60.f*2.f*M_PI);// m_torque_rpm = ini->r_float("car_definition","max_torque_rpm"); m_torque_rpm *= (1.f/60.f*2.f*M_PI);// m_power_increment_factor = READ_IF_EXISTS(ini,r_float,"car_definition","power_increment_factor",m_power_increment_factor); m_rpm_increment_factor = READ_IF_EXISTS(ini,r_float,"car_definition","rpm_increment_factor",m_rpm_increment_factor); m_power_decrement_factor = READ_IF_EXISTS(ini,r_float,"car_definition","power_decrement_factor",m_power_increment_factor); m_rpm_decrement_factor = READ_IF_EXISTS(ini,r_float,"car_definition","rpm_decrement_factor",m_rpm_increment_factor); m_power_neutral_factor = READ_IF_EXISTS(ini,r_float,"car_definition","power_neutral_factor",m_power_neutral_factor); R_ASSERT2(m_power_neutral_factor>0.1f&&m_power_neutral_factor<1.f,"power_neutral_factor must be 0 - 1 !!"); if(ini->line_exist("car_definition","exhaust_particles")) { m_exhaust_particles =ini->r_string("car_definition","exhaust_particles"); } b_auto_switch_transmission= !!ini->r_bool("car_definition","auto_transmission"); InitParabola (); m_axle_friction = ini->r_float("car_definition","axle_friction"); m_steering_speed = ini->r_float("car_definition","steering_speed"); if(ini->line_exist("car_definition","break_time")) { m_break_time=ini->r_float("car_definition","break_time"); } /////////////////////////transmission//////////////////////////////////////////////////////////////////////// float main_gear_ratio=ini->r_float("car_definition","main_gear_ratio"); R_ASSERT2(ini->section_exist("transmission_gear_ratio"),"no section transmission_gear_ratio"); m_gear_ratious.push_back(ini->r_fvector3("transmission_gear_ratio","R")); m_gear_ratious[0][0]=-m_gear_ratious[0][0]*main_gear_ratio; string32 rat_num; for(int i=1;true;++i) { xr_sprintf(rat_num,"N%d",i); if(!ini->line_exist("transmission_gear_ratio",rat_num)) break; Fvector gear_rat=ini->r_fvector3("transmission_gear_ratio",rat_num); gear_rat[0]*=main_gear_ratio; gear_rat[1]*=(1.f/60.f*2.f*M_PI); gear_rat[2]*=(1.f/60.f*2.f*M_PI); m_gear_ratious.push_back(gear_rat); } ///////////////////////////////sound/////////////////////////////////////////////////////// m_car_sound->Init(); ///////////////////////////////fuel/////////////////////////////////////////////////// m_fuel_tank=ini->r_float("car_definition","fuel_tank"); m_fuel=m_fuel_tank; m_fuel_consumption=ini->r_float("car_definition","fuel_consumption"); m_fuel_consumption/=100000.f; if(ini->line_exist("car_definition","exhaust_particles")) m_exhaust_particles = ini->r_string("car_definition","exhaust_particles"); ///////////////////////////////lights/////////////////////////////////////////////////// m_lights.Init(this); m_lights.ParseDefinitions(); if(ini->section_exist("animations")) { m_driver_anim_type=ini->r_u16("animations","driver_animation_type"); } if(ini->section_exist("doors")) { m_doors_torque_factor=ini->r_u16("doors","open_torque_factor"); } m_damage_particles.Init(this); }