bool EDetail::Update (LPCSTR name) { m_sRefs = name; // update link CEditableObject* R = Lib.CreateEditObject(name); if (!R){ ELog.Msg (mtError,"Can't load detail object '%s'.", name); return false; } if(R->SurfaceCount()!=1){ ELog.Msg (mtError,"Object must contain 1 material."); Lib.RemoveEditObject(R); return false; } if(R->MeshCount()==0){ ELog.Msg (mtError,"Object must contain 1 mesh."); Lib.RemoveEditObject(R); return false; } Lib.RemoveEditObject(m_pRefs); m_pRefs = R; // fill geometry CEditableMesh* M = *m_pRefs->FirstMesh(); U16Vec inds; // fill vertices bv_bb.invalidate(); u32 idx = 0; for (u32 f_id=0; f_id<M->GetFCount(); f_id++){ st_Face& F = M->GetFaces()[f_id]; u16 ind[3]; for (int k=0; k<3; k++,idx++){ Fvector& P = M->GetVerts()[F.pv[k].pindex]; st_VMapPt&vm= M->GetVMRefs()[F.pv[k].vmref].pts[0]; Fvector2& uv= M->GetVMaps()[vm.vmap_index]->getUV(vm.index); ind[k] = _AddVert (P,uv.x,uv.y); bv_bb.modify(vertices[ind[k]].P); } if (isDegenerated(ind)) continue; if (isEqual(inds,ind)) continue; inds.push_back(ind[0]); inds.push_back(ind[1]); inds.push_back(ind[2]); } number_indices = inds.size(); indices = (u16*)xr_malloc(number_indices*sizeof(u16)); Memory.mem_copy (indices,inds.begin(),number_indices*sizeof(u16)); bv_bb.getsphere (bv_sphere.P,bv_sphere.R); OnDeviceCreate (); return true; }
void CResourceManager::OnDeviceCreate (LPCSTR shName) { #ifdef _EDITOR if (!FS.exist(shName)) return; #endif // Check if file is compressed already string32 ID = "shENGINE"; string32 id; IReader* F = FS.r_open(shName); R_ASSERT2 (F,shName); F->r (&id,8); if (0==strncmp(id,ID,8)) { FATAL ("Unsupported blender library. Compressed?"); } OnDeviceCreate (F); FS.r_close (F); }
void CLensFlareDescriptor::load(CInifile* pIni, LPCSTR sect) { section = sect; m_Flags.set (flSource,pIni->r_bool(sect,"source" )); if (m_Flags.is(flSource)){ LPCSTR S= pIni->r_string ( sect,"source_shader" ); LPCSTR T= pIni->r_string ( sect,"source_texture" ); float r = pIni->r_float ( sect,"source_radius" ); BOOL i = pIni->r_bool ( sect,"source_ignore_color" ); SetSource(r,i,T,S); } m_Flags.set (flFlare,pIni->r_bool ( sect,"flares" )); if (m_Flags.is(flFlare)){ LPCSTR S= pIni->r_string ( sect,"flare_shader" ); LPCSTR T= pIni->r_string ( sect,"flare_textures" ); LPCSTR R= pIni->r_string ( sect,"flare_radius" ); LPCSTR O= pIni->r_string ( sect,"flare_opacity"); LPCSTR P= pIni->r_string ( sect,"flare_position"); u32 tcnt= _GetItemCount(T); string256 name; for (u32 i=0; i<tcnt; i++){ _GetItem(R,i,name); float r=(float)atof(name); _GetItem(O,i,name); float o=(float)atof(name); _GetItem(P,i,name); float p=(float)atof(name); _GetItem(T,i,name); AddFlare(r,o,p,name,S); } } m_Flags.set (flGradient,CInifile::IsBOOL(pIni->r_string( sect, "gradient"))); if (m_Flags.is(flGradient)){ LPCSTR S= pIni->r_string ( sect,"gradient_shader" ); LPCSTR T= pIni->r_string ( sect,"gradient_texture" ); float r = pIni->r_float ( sect,"gradient_radius" ); float o = pIni->r_float ( sect,"gradient_opacity" ); SetGradient(r,o,T,S); } m_StateBlendUpSpeed = 1.f/(_max(pIni->r_float( sect,"blend_rise_time" ),0.f)+EPS_S); m_StateBlendDnSpeed = 1.f/(_max(pIni->r_float( sect,"blend_down_time" ),0.f)+EPS_S); OnDeviceCreate(); }
////////////////////////////////////////////////////////////////////////// // environment CEnvironment::CEnvironment () { 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 fGameTime = 0.f; fTimeFactor = 12.f; wind_strength_factor = 0.f; wind_gust_factor = 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"); }
//------------------------------------------------------------------------------ CLensFlare::CLensFlare() { // Device dwFrame = 0xfffffffe; fBlend = 0.f; LightColor.set ( 0xFFFFFFFF ); fGradientValue = 0.f; hGeom = 0; m_Current = 0; m_State = lfsNone; m_StateBlend = 0.f; #ifndef _EDITOR m_ray_cache.verts[0].set (0,0,0); m_ray_cache.verts[1].set (0,0,0); m_ray_cache.verts[2].set (0,0,0); #endif OnDeviceCreate (); }
void CGlow::Render(int priority, bool strictB2F) { if ((1==priority)&&(true==strictB2F)){ if (!m_bDefLoad) OnDeviceCreate(); ESceneGlowTools* gt = dynamic_cast<ESceneGlowTools*>(ParentTools); VERIFY(gt); RCache.set_xform_world(Fidentity); if (gt->m_Flags.is(ESceneGlowTools::flTestVisibility)){ Fvector D; D.sub(Device.vCameraPosition,PPosition); float dist = D.normalize_magn(); if (!Scene->RayPickObject(dist,PPosition,D,OBJCLASS_SCENEOBJECT,0,0)){ if (m_GShader){ Device.SetShader(m_GShader); }else{ Device.SetShader(Device.m_WireShader);} m_RenderSprite.Render(PPosition,m_fRadius,m_Flags.is(gfFixedSize)); DU.DrawRomboid(PPosition, VIS_RADIUS, 0x00FF8507); }else{ // рендерим bounding sphere Device.SetShader(Device.m_WireShader); DU.DrawRomboid(PPosition, VIS_RADIUS, 0x00FF8507); } }else{ if (m_GShader){ Device.SetShader(m_GShader); }else{ Device.SetShader(Device.m_WireShader);} m_RenderSprite.Render(PPosition,m_fRadius,m_Flags.is(gfFixedSize)); } if( Selected() ){ Fbox bb; GetBox(bb); u32 clr = Locked()?0xFFFF0000:0xFFFFFFFF; Device.SetShader(Device.m_WireShader); DU.DrawSelectionBox(bb,&clr); if (gt->m_Flags.is(ESceneGlowTools::flDrawCross)){ Fvector sz; bb.getradius(sz); DU.DrawCross(PPosition,sz.x,sz.y,sz.z, sz.x,sz.y,sz.z,0xFFFFFFFF,false); } } } }
////////////////////////////////////////////////////////////////////////// // 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 CEnvironment::ED_Reload() { OnDeviceDestroy (); OnDeviceCreate (); }
void ESceneToolBase::OnCreate() { OnDeviceCreate (); CreateControls (); }
void ESceneCustomMTools::OnCreate() { OnDeviceCreate (); CreateControls (); }
CMainMenu::CMainMenu () { m_Flags.zero (); m_startDialog = NULL; m_screenshotFrame = u32(-1); g_pGamePersistent->m_pMainMenu = this; if (Device.b_is_Ready) OnDeviceCreate(); ReadTextureInfo (); CUIXmlInit::InitColorDefs (); g_btnHint = NULL; g_statHint = NULL; m_deactivated_frame = 0; m_sPatchURL = ""; m_pGameSpyFull = NULL; m_account_mngr = NULL; m_login_mngr = NULL; m_profile_store = NULL; m_stats_submitter = NULL; m_atlas_submit_queue = NULL; m_sPDProgress.IsInProgress = false; m_downloaded_mp_map_url._set (""); //------------------------------------------- m_NeedErrDialog = ErrNoError; m_start_time = 0; GetPlayerName (); GetCDKeyFromRegistry (); m_demo_info_loader = NULL; if(!g_dedicated_server) { g_btnHint = xr_new<CUIButtonHint>(); g_statHint = xr_new<CUIButtonHint>(); m_pGameSpyFull = xr_new<CGameSpy_Full>(); for (u32 i=0; i<u32(ErrMax); i++) { CUIMessageBoxEx* pNewErrDlg; INIT_MSGBOX (pNewErrDlg, ErrMsgBoxTemplate[i]); m_pMB_ErrDlgs.push_back (pNewErrDlg); } m_pMB_ErrDlgs[PatchDownloadSuccess]->AddCallbackStr("button_yes", MESSAGE_BOX_YES_CLICKED, CUIWndCallback::void_function(this, &CMainMenu::OnRunDownloadedPatch)); m_pMB_ErrDlgs[PatchDownloadSuccess]->AddCallbackStr("button_yes", MESSAGE_BOX_OK_CLICKED, CUIWndCallback::void_function(this, &CMainMenu::OnConnectToMasterServerOkClicked)); m_pMB_ErrDlgs[DownloadMPMap]->AddCallbackStr("button_copy", MESSAGE_BOX_COPY_CLICKED, CUIWndCallback::void_function(this, &CMainMenu::OnDownloadMPMap_CopyURL)); m_pMB_ErrDlgs[DownloadMPMap]->AddCallbackStr("button_yes", MESSAGE_BOX_YES_CLICKED, CUIWndCallback::void_function(this, &CMainMenu::OnDownloadMPMap)); m_account_mngr = xr_new<gamespy_gp::account_manager> (m_pGameSpyFull->GetGameSpyGP()); m_login_mngr = xr_new<gamespy_gp::login_manager> (m_pGameSpyFull); m_profile_store = xr_new<gamespy_profile::profile_store> (m_pGameSpyFull); m_stats_submitter = xr_new<gamespy_profile::stats_submitter> (m_pGameSpyFull); m_atlas_submit_queue = xr_new<atlas_submit_queue> (m_stats_submitter); } Device.seqFrame.Add (this,REG_PRIORITY_LOW-1000); }