Esempio n. 1
0
    void TerrainManager::Initialize()
    {
        if( !this->Initialized )
        {
            WorldManager::Initialize();

            this->TheEntresol->GetScheduler().AddWorkUnitMain( this->TerrainUpdateWork, "TerrainUpdateWork" );
            Physics::PhysicsManager* PhysicsMan = static_cast<Physics::PhysicsManager*>( this->ParentWorld->GetManager(ManagerBase::MT_PhysicsManager) );
            if( PhysicsMan ) {
                this->TerrainUpdateWork->AddDependency( PhysicsMan->GetSimulationWork() );
            }

            this->Initialized = true;
        }
    }
Esempio n. 2
0
void CreateDemoWorld()
{
    Physics::ManagerConstructionInfo Info;
    Info.PhysicsFlags = Physics::ManagerConstructionInfo::PCF_LimitlessWorld | Physics::ManagerConstructionInfo::PCF_SoftRigidWorld | Physics::ManagerConstructionInfo::PCF_Multithreaded;

    // Create World and all it's lovely Managers
    DemoWorld = TheEntresol->CreateWorld( "DemoWorld", Info, "DefaultSceneManager" );

    if( DemoWorld == NULL ) {
        throw RuntimeAssertionException(
            "Failed to Create New Demo World",
            __func__,
            __FILE__,
            __LINE__
        );
    }

    DemoWorld->Initialize();

    AreaEffectManager* AreaEffectMan = static_cast<AreaEffectManager*>( DemoWorld->GetManager(ManagerBase::MT_AreaEffectManager) );
    EventManager* EventMan = static_cast<EventManager*>( TheEntresol->GetManager(ManagerBase::MT_EventManager) );
    Graphics::GraphicsManager* GraphMan = static_cast<Graphics::GraphicsManager*>( TheEntresol->GetManager(ManagerBase::MT_GraphicsManager) );
    Graphics::SceneManager* SceneMan = static_cast<Graphics::SceneManager*>( DemoWorld->GetManager(ManagerBase::MT_SceneManager) );
    Input::InputManager* InputMan = static_cast<Input::InputManager*>( TheEntresol->GetManager(ManagerBase::MT_InputManager) );
    Physics::PhysicsManager* PhysMan = static_cast<Physics::PhysicsManager*>( DemoWorld->GetManager(ManagerBase::MT_PhysicsManager) );

    MainCam = SceneMan->CreateCamera();
    MainCam->SetLocation(Vector3(0.0,200.0,1000.0));
    MainCam->LookAt(Vector3(0,0,0));

    CamControl = new CameraController(MainCam);
    //CamControl->SetMovementMode(CameraController::CCM_Walk);
    //CamControl->SetHoverHeight(75);

    // Create the window(s)!
    FirstWindow = GraphMan->CreateGameWindow("First",1024,768,0);
    FirstWindow->CreateViewport(MainCam,0);

    // Setup our workunits
    DemoPreEventWork = new DemoPreEventWorkUnit();
    EventMan->GetEventPumpWork()->AddDependency( DemoPreEventWork );
    TheEntresol->GetScheduler().AddWorkUnitMain( DemoPreEventWork, "DemoPreEventWork" );

    DemoPostInputWork = new DemoPostInputWorkUnit(DemoWorld);
    DemoPostInputWork->AddDependency( InputMan->GetDeviceUpdateWork() );
    TheEntresol->GetScheduler().AddWorkUnitMain( DemoPostInputWork, "DemoPostInputWork" );

    DemoPostRenderWork = new DemoPostRenderWorkUnit();
    DemoPostRenderWork->AddDependency( GraphMan->GetRenderWork() );
    DemoPostRenderWork->AddDependency( AreaEffectMan->GetAreaEffectUpdateWork() );
    TheEntresol->GetScheduler().AddWorkUnitMain( DemoPostRenderWork, "DemoPostRenderWork" );

    DemoPostPhysicsWork = new DemoPostPhysicsWorkUnit();
    DemoPostPhysicsWork->AddDependency( PhysMan->GetSimulationWork() );
    TheEntresol->GetScheduler().AddWorkUnitMain( DemoPostPhysicsWork, "DemoPostPhysicsWork" );

    // Configure Shadows
    SceneMan->SetSceneShadowTechnique(Graphics::SceneManager::SST_Stencil_Additive);
    SceneMan->SetShadowFarDistance(3000);

    //Set up polling for the letter Q
    EventMan->AddPollingCheck( Input::MetaCode(0, Input::KEY_Q) );

    //Actually Load the game stuff
    LoadContent();

    // Configure the wireframe Drawer
    //TheEntresol->GetPhysicsManager()->SetDebugRenderingMode(Physics::DDM_DrawWireframe);
    //TheEntresol->GetPhysicsManager()->SetSimulationSubstepModifier(3);

    Graphics::LightProxy* Headlight = SceneMan->CreateLightProxy(Graphics::LT_Directional);
    Vector3 LightLoc(200,300,0);
    Headlight->SetLocation(LightLoc);
    LightLoc.X = -LightLoc.X;
    LightLoc.Y = -LightLoc.Y;
    LightLoc.Normalize();
    Headlight->SetDirection(LightLoc);
    Headlight->SetDiffuseColour(ColourValue(0.7,0.7,0.7,1.0));
    Headlight->SetSpecularColour(ColourValue(0.7,0.7,0.7,1.0));
    Headlight->SetLocation(Vector3(0,150,0));
    Headlight->AddToWorld();
    //Headlight->SetAttenuation(1000.0, 0.0, 1.0, 0.0);         //I couldn't get these to work
    // CameraNode->AttachObject(Headlight);

    std::cerr << "Finished Creating World\n";
}