public void Draw(Renderer renderer) { int s = SyncSystem.GetSingleton().Scene; if (s == mountainsNumber) { DrawStarSky(renderer); renderer.ActivateLight(mountainLight, 0); renderer.RenderMesh(mountains); DrawTelescope(renderer, mainTelescopePosition); DrawTelescopeArray(renderer); // Transparent things last! DrawGreets(renderer, title); } else if (s == moonNumber) { DrawStarSky(renderer); renderer.ActivateLight(mountainLight, 0); DrawMonolith(renderer); DrawGreets(renderer, group_greetings); } else if (s == bunnyNumber) { DrawStarSky(renderer); DrawLightMeshList(renderer, bunnyLights); DrawBunny(renderer); } else if (s == warpNumber) { DrawStarSky(renderer, true); DrawLightMeshList(renderer, bunnyLights); DrawBunny(renderer); } else if (s == seaNumber || s == crystalsNumber) { DrawPlanetSkybox(renderer); renderer.ActivateLight(planetLight, 0); renderer.RenderObject(planetMountains); DrawSea(renderer); DrawMonolith(renderer); DrawGreets(renderer, credits); } if (s == crystalsNumber) { DrawCrystals(renderer); } if (fadeAlpha > 0.0f) { DrawFadeout(renderer, fadeAlpha); } Error.checkGLError("BunnyDemo Draw"); }
public void SyncCameraFrame() { if (cameraFrames != null && !camera.FreeMode) { int frame = SyncSystem.GetSingleton().Frame; float frameProg = SyncSystem.GetSingleton().FrameProgress; camera.SetFrame(frame, frameProg, cameraFrames); } }
private void DrawStarSky(Renderer renderer, bool warp = false) { renderer.SetActiveSkybox(starSkyboxMaterial); renderer.SetSkyboxRotation(starSkyBox.Transform.CreateRotationMatrixFromAxisAngle()); if (warp) { CameraComponent cam = renderer.GetCamera(); float prevFOV = cam.FOV; cam.FOV = 90 + SyncSystem.GetSingleton().GetTrackValue(warpFOV); cam.CreateMatrices(); renderer.RenderSky(starSkyBox); cam.FOV = prevFOV; cam.CreateMatrices(); } else { renderer.RenderSky(starSkyBox); } }
protected override void OnLoad(EventArgs e) { PauseSyncButton = new Button(Key.Space); PrevSceneButton = new Button(Key.F3); NextSceneButton = new Button(Key.F4); ReloadDemoButton = new Button(Key.F5); RestartDemoOrRetreatSceneButton = new Button(Key.F6); AdvanceSceneButton = new Button(Key.F7); InputEnabledButton = new Button(Key.F8); CameraModeButton = new Button(Key.F9); CameraSpeedDownButton = new Button(Key.F10); CameraSpeedUpButton = new Button(Key.F11); PrintFrameButton = new Button(Key.F12); tunableManager = TunableManager.GetSingleton(); syncSystem = SyncSystem.GetSingleton(); renderer = Renderer.GetSingleton(); string dataFolder = "data"; AssetManager.WorkingDir = dataFolder; AssetManager assetManager = AssetManager.GetSingleton(); Logger.LogPhase("Asset manager is created"); assetManager.LoadAll(); assetManager.printLoadedAssets(); Logger.LogPhase("Assets have been loaded"); tunableManager.ReloadValues(); Logger.LogPhase("Config file have been loaded"); demoWrapper = new DemoWrapper(); demoWrapper.Create(); demoSettings = demoWrapper.Demo.GetDemoSettings(); // Audio .................................... Logger.LogPhase("Initializing audio system"); if (demoSettings.AudioEngineSetting == DemoSettings.AudioEngine.System) { audioSystem = new SystemAudio(); } if (demoSettings.AudioEngineSetting == DemoSettings.AudioEngine.Dummy) { if (demoSettings.AudioEnabled == true) { Logger.LogError(Logger.ErrorState.User, "Initialized dummy audio when Audio is enabled."); } audioSystem = new DummyAudioSystem(); } bool audioInitOk = audioSystem.Initialize(); if (!audioInitOk) { Logger.LogError(Logger.ErrorState.Critical, "Audio system failed to initialize."); return; } Logger.LogPhase("Audio has been initialized"); demoWrapper.SetAudioSystem(audioSystem); // Sync............................. if (demoSettings.SyncEnabled) { syncSystem.Start(demoSettings.SyncFilePrefix); } else { syncSystem.StartManual(); } // Rendering ................. Size windowSize = new Size((int)demoSettings.Resolution.X, (int)demoSettings.Resolution.Y); base.Size = windowSize; if (demoSettings.Fullscreen) { base.WindowState = WindowState.Fullscreen; } renderer.ResizeScreen((int)demoSettings.Resolution.X, (int)demoSettings.Resolution.Y); CursorVisible = false; testScene = new TestScene(); testScene.Load(assetManager); loadingScene = new LoadingScene(); loadingScene.Load(assetManager); applicationTime = new Stopwatch(); LoadDemo(); Logger.LogPhase("OnLoad complete"); loadCompleted = true; running = true; applicationTime.Start(); }