void CEnvDescriptor::load (LPCSTR exec_tm, LPCSTR S, CEnvironment* parent) { Ivector3 tm ={0,0,0}; sscanf (exec_tm,"%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",S); exec_time = tm.x*3600.f+tm.y*60.f+tm.z; exec_time_loaded = exec_time; string_path st,st_env; strcpy_s (st,pSettings->r_string (S,"sky_texture")); strconcat (sizeof(st_env),st_env,st,"#small" ); sky_texture_name = st; sky_texture_env_name = st_env; clouds_texture_name = pSettings->r_string (S,"clouds_texture"); LPCSTR cldclr = pSettings->r_string (S,"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 = pSettings->r_fvector3 (S,"sky_color"); sky_color.mul(.5f); if (pSettings->line_exist(S,"sky_rotation")) sky_rotation = deg2rad(pSettings->r_float(S,"sky_rotation")); else sky_rotation = 0; far_plane = pSettings->r_float (S,"far_plane"); fog_color = pSettings->r_fvector3 (S,"fog_color"); fog_density = pSettings->r_float (S,"fog_density"); fog_distance = pSettings->r_float (S,"fog_distance"); rain_density = pSettings->r_float (S,"rain_density"); clamp(rain_density,0.f,1.f); rain_color = pSettings->r_fvector3 (S,"rain_color"); wind_velocity = pSettings->r_float (S,"wind_velocity"); wind_direction = deg2rad(pSettings->r_float(S,"wind_direction")); ambient = pSettings->r_fvector3 (S,"ambient"); hemi_color = pSettings->r_fvector4 (S,"hemi_color"); sun_color = pSettings->r_fvector3 (S,"sun_color"); Fvector2 sund = pSettings->r_fvector2 (S,"sun_dir"); sun_dir.setHP (deg2rad(sund.y),deg2rad(sund.x)); VERIFY2 (sun_dir.y<0,"Invalid sun direction settings while loading"); lens_flare_id = parent->eff_LensFlare->AppendDef(pSettings,pSettings->r_string(S,"flares")); tb_id = parent->eff_Thunderbolt->AppendDef(pSettings,pSettings->r_string(S,"thunderbolt")); bolt_period = (tb_id>=0)?pSettings->r_float (S,"bolt_period"):0.f; bolt_duration = (tb_id>=0)?pSettings->r_float (S,"bolt_duration"):0.f; env_ambient = pSettings->line_exist(S,"env_ambient")?parent->AppendEnvAmb (pSettings->r_string(S,"env_ambient")):0; C_CHECK (clouds_color); C_CHECK (sky_color ); C_CHECK (fog_color ); C_CHECK (rain_color ); C_CHECK (ambient ); // C_CHECK (lmap_color ); C_CHECK (hemi_color ); C_CHECK (sun_color ); on_device_create (); }
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(); }