예제 #1
0
void EnvironmentLight::UpdateSignals()
{
    if (!ViewEnabled())
        return;

    Entity* parent = ParentEntity();
    if (!parent)
        return;

    if (parent->ParentScene())
        world_ = parent->ParentScene()->Subsystem<GraphicsWorld>();

    if (world_)
    {
        Urho3D::Scene* urhoScene = world_->UrhoScene();
        node_ = urhoScene->CreateChild("EnvironmentLight");
        light_ = node_->CreateComponent<Urho3D::Light>();
        light_->SetLightType(Urho3D::LIGHT_DIRECTIONAL);
        
        Urho3D::Zone* zone = world_->UrhoZone();
        if (zone)
            zone->SetAmbientColor(ambientColor.Get());

        node_->SetDirection(sunDirection.Get());
        light_->SetColor(sunColor.Get());
        light_->SetBrightness(brightness.Get());
        light_->SetCastShadows(sunCastShadows.Get());
        // Setup basic shadow cascade for desktops
        #ifndef ANDROID
        light_->SetShadowBias(Urho3D::BiasParameters(0.00025f, 0.5f));
        // Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
        light_->SetShadowCascade(Urho3D::CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f));
        #endif
    }
}
예제 #2
0
void Sky::CreateSkyboxNode()
{
    if (world_.Expired() || urhoNode_)
        return;

    Urho3D::Scene* urhoScene = world_->UrhoScene();

    urhoNode_ = urhoScene->CreateChild("Skybox");
    Urho3D::Skybox* skybox = urhoNode_->CreateComponent<Urho3D::Skybox>();

    Urho3D::ResourceCache* cache = GetSubsystem<Urho3D::ResourceCache>();
    skybox->SetModel(cache->GetResource<Urho3D::Model>("Models/Box.mdl"));
}