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 XmlSceneParser::Parse (const ParseNode& decl, Light& node, Node& parent, SceneContext& context) { try { //предварительный разбор LightDeclPtr node_decl = impl->PrepareLight (decl); //настройка узла if (node_decl->light_color.state) node.SetLightColor (node_decl->light_color.value); if (node_decl->attenuation.state) node.SetAttenuation (node_decl->attenuation.value); if (node_decl->intensity.state) node.SetIntensity (node_decl->intensity.value); if (node_decl->range.state) node.SetRange (node_decl->range.value); //разбор родительских параметров Parse (decl, static_cast<Entity&> (node), parent, context); } catch (xtl::exception& e) { e.touch ("scene_graph::XmlSceneParser::Parse(const ParseNode&,Light&,Node&,SceneContext&)"); throw; } }
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++; } } }