Ejemplo n.º 1
0
ResourceCache::ResourceCache(const std::string& res_dir, const int res_x, const int res_y)
   : mResDir(res_dir)
   , mResX(res_x)
   , mResY(res_y)
{
   if (0 == IMG_Init(IMG_INIT_JPG | IMG_INIT_PNG)) {
       throw "Failed to initialize SDL_image";
   }

   LoadWallResources();
//   LoadCeilingResources();
   LoadFloorResources();
   LoadSkyResources();
}
Ejemplo n.º 2
0
/** Renders the sky */
XRESULT GSky::RenderSky()
{
	if(!SkyDome)
	{
		XLE(LoadSkyResources());
	}

	//return XR_SUCCESS;

	D3DXVECTOR3 camPos = Engine::GAPI->GetCameraPosition();
	D3DXVECTOR3 LightDir;

	if(Engine::GAPI->GetRendererState()->RendererSettings.ReplaceSunDirection)
	{
		LightDir = Atmosphere.LightDirection;
	}else
	{
		zCSkyController_Outdoor* sc = oCGame::GetGame()->_zCSession_world->GetSkyControllerOutdoor();
		if(sc)
		{
			LightDir = sc->GetSunWorldPosition(Atmosphere.SkyTimeScale);
			Atmosphere.LightDirection = LightDir;
		}
	}
	D3DXVec3Normalize(&LightDir, &LightDir);

	//Atmosphere.SpherePosition.y = -Atmosphere.InnerRadius;

	Atmosphere.SpherePosition.x = 0;//Engine::GAPI->GetLoadedWorldInfo()->MidPoint.x;
	Atmosphere.SpherePosition.z = 0;//Engine::GAPI->GetLoadedWorldInfo()->MidPoint.y;
	Atmosphere.SpherePosition.y = 0;//Engine::GAPI->GetLoadedWorldInfo()->LowestVertex - Atmosphere.InnerRadius;

	D3DXVECTOR3 sp = camPos;
	sp.y += Atmosphere.SphereOffsetY;

	// Fill atmosphere buffer for this frame
	AtmosphereCB.AC_CameraPos = D3DXVECTOR3(0, -Atmosphere.SphereOffsetY, 0);
	AtmosphereCB.AC_Time = Engine::GAPI->GetTimeSeconds();
	AtmosphereCB.AC_LightPos = LightDir;
	AtmosphereCB.AC_CameraHeight = -Atmosphere.SphereOffsetY;
	AtmosphereCB.AC_InnerRadius = Atmosphere.InnerRadius;
	AtmosphereCB.AC_OuterRadius = Atmosphere.OuterRadius;
	AtmosphereCB.AC_nSamples = Atmosphere.Samples;
	AtmosphereCB.AC_fSamples = (float)AtmosphereCB.AC_nSamples;

	AtmosphereCB.AC_Kr4PI = Atmosphere.Kr * 4 * (float)D3DX_PI;
	AtmosphereCB.AC_Km4PI = Atmosphere.Km * 4 * (float)D3DX_PI;
	AtmosphereCB.AC_KrESun = Atmosphere.Kr * Atmosphere.ESun;
	AtmosphereCB.AC_KmESun = Atmosphere.Km * Atmosphere.ESun;

	AtmosphereCB.AC_Scale = 1.0f / (AtmosphereCB.AC_OuterRadius - AtmosphereCB.AC_InnerRadius);
	AtmosphereCB.AC_RayleighScaleDepth = Atmosphere.RayleightScaleDepth;
	AtmosphereCB.AC_RayleighOverScaleDepth = AtmosphereCB.AC_Scale / AtmosphereCB.AC_RayleighScaleDepth;
	AtmosphereCB.AC_g = Atmosphere.G;
	AtmosphereCB.AC_Wavelength = Atmosphere.WaveLengths;
	AtmosphereCB.AC_SpherePosition = sp;
	AtmosphereCB.AC_SceneWettness = Engine::GAPI->GetSceneWetness();
	AtmosphereCB.AC_RainFXWeight = Engine::GAPI->GetRainFXWeight();

	//Engine::GraphicsEngine->DrawSky();

	// Extract fog settings
	/*zCSkyController_Outdoor* sky = oCGame::GetGame()->_zCSession_world->GetSkyControllerOutdoor();
	Engine::GAPI->GetRendererState()->GraphicsState.FF_FogColor = float3(sky->GetMasterState()->FogColor / 255.0f);
	Engine::GAPI->GetRendererState()->GraphicsState.FF_FogNear = 0.3f * sky->GetMasterState()->FogDist; // That 0.3f is hardcoded in gothic
	Engine::GAPI->GetRendererState()->GraphicsState.FF_FogFar = sky->GetMasterState()->FogDist;
	*/
	return XR_SUCCESS;
}