void LightAnimation::CreateLightsWithAnimStatic() { const float3 SponzaExtentInner[] = { float3(750, 10, -120), float3(750, 10, 230), float3(-950, 10, 230), float3(-950, 10, -100) }; SceneManager* sceneMan = Environment::GetSingleton().GetSceneManager(); const int NumLightX = 40; const int NumLightZ = 12; for (int i = 0; i < NumLightZ; ++i) { float t = float(i) / NumLightZ; float3 start = Lerp(SponzaExtentInner[0], SponzaExtentInner[1], t); float3 end = Lerp(SponzaExtentInner[3], SponzaExtentInner[2], t); for (int j = 0; j < NumLightX; ++j) { Light* light = sceneMan->CreateLight("", LT_PointLight); light->SetPosition(Lerp(start, end, float(j)/NumLightX)); float3 color = IntensityDist(rng) * HueToRGB(HueDist(rng)); light->SetLightColor(color); light->SetLightIntensity(1.0); light->SetAttenuation(1.0f, 0.0f); light->SetRange(25.0f); sceneMan->GetRootSceneNode()->AttachObject(light); mNumTotalLights++; } } }
void LoadContent() { FileSystem& fileSys = FileSystem::GetSingleton(); ResourceManager& resMan = ResourceManager::GetSingleton(); SceneManager* sceneMan = Environment::GetSingleton().GetSceneManager(); RenderFactory* factory = Environment::GetSingleton().GetRenderFactory(); LoadDudeEntity(); mFont = resMan.GetResourceByName<Font>(RT_Font, "Consolas Regular", "General"); auto mSDFEffect = resMan.GetResourceByName<Effect>(RT_Effect, "Font.effect.xml", "General") ; mSpriteBatch = sceneMan->CreateSpriteBatch(mSDFEffect); // Set as default camera auto screenFB = Environment::GetSingleton().GetRenderDevice()->GetScreenFrameBuffer(); screenFB->SetCamera(mCamera); Light* mDirLight = sceneMan->CreateLight("Sun", LT_DirectionalLight); mDirLight->SetDirection(float3(1, -0.5, 0)); mDirLight->SetLightColor(float3(1, 1, 1)); mDirLight->SetLightIntensity(1.0); mDirLight->SetCastShadow(false); mDirLight->SetShadowCascades(4); sceneMan->GetRootSceneNode()->AttachObject(mDirLight); }
void LightAnimation::CreateLightsWithAnimLine() { SceneManager* sceneMan = Environment::GetSingleton().GetSceneManager(); const int NumBandLights[] = { 10, 20 }; for (int iFloor = 0; iFloor < 2; ++iFloor) { for (int iLine = 0; iLine < 4; ++iLine) { const int NumLight = NumBandLights[iLine & 0x1]; const float3 LeftPos = SponzaExtent[iLine]; const float3 RightPos = SponzaExtent[(iLine+1)%4]; for (int32_t iLight = 0; iLight < NumLight; ++iLight) { float3 position = Lerp(LeftPos, RightPos, float(iLight) / NumLight); position.Y() = SponzaFloorHeightRange[iFloor][0]; //position.Y() = Lerp(SponzaFloorHeightRange[iFloor][0], SponzaFloorHeightRange[iFloor][1], NormDist(rng)); float3 color = IntensityDist(rng) * HueToRGB(HueDist(rng)); Light* light = sceneMan->CreateLight("", LT_PointLight); light->SetPosition(position); light->SetLightColor(color); light->SetLightIntensity(1.0); light->SetAttenuation(1.0f, 0.0f); light->SetRange(100); sceneMan->GetRootSceneNode()->AttachObject(light); LineAnimatedLight aminLight; aminLight.Light = light; aminLight.LineIndex = iLine; aminLight.FloorIndex = iFloor; mLineAnimatedLights.push_back(aminLight); mNumTotalLights++; } } } }
void LightAnimation::CreateLightsWithAnimEllipse() { SceneManager* sceneMan = Environment::GetSingleton().GetSceneManager(); const int NumEllipses = 10; const int NumLightsEllipse = 40; for (int i = 0; i < NumEllipses; ++i) { for (int j = 0; j < NumLightsEllipse; ++j) { EllipseAnimatedLight aminLight; aminLight.EllipseWidth = 950.0f; aminLight.EllipseHeight = 175.0f; aminLight.Height = Lerp(100.0f, 1000.0f, float(i) / NumEllipses); //aminLight.Angle = Mathf::TWO_PI / NumLightsEllipse * j; aminLight.Angle = AngleDist(rng); aminLight.AnimationSpeed = (AnimationDirection(rng) * 2 - 1) * AnimationSpeedDist(rng); float3 pos(aminLight.EllipseWidth * cosf(aminLight.Angle), aminLight.Height, aminLight.EllipseHeight * sinf(aminLight.Angle)); float3 color = IntensityDist(rng) * HueToRGB(HueDist(rng)); Light* light = sceneMan->CreateLight("", LT_PointLight); light->SetPosition(pos); light->SetLightColor(color); light->SetLightIntensity(1.0); light->SetAttenuation(1.0f, 0.0f); light->SetRange(100); sceneMan->GetRootSceneNode()->AttachObject(light); aminLight.Light = light; mEllipseAnimatedLights.push_back(aminLight); mNumTotalLights++; } } }