Beispiel #1
0
 private void StereoModeChoiceAction(ChoiceItem selected)
 {
     if (stereoModes.ContainsKey(selected.Label))
     {
         CurrentStereoMode = stereoModes[selected.Label];
     }
 }
Beispiel #2
0
 private void AddStereoModes()
 {
     CurrentStereoMode = stereoModes["Mono"] = new StereoMode(null);
     if (Configuration.stereo)
     {
         stereoModes["R/C"] = new StereoMode(renderer.Programs["Anachrome"]);
         stereoModes["G/M"] = new StereoMode(renderer.Programs["triochrome"]);
         stereoModes["B/A"] = new StereoMode(renderer.Programs["ColorCode"]);
         stereoModes["Mix"] = new StereoMode(renderer.Programs["Blend"]);
     }
 }
Beispiel #3
0
        public void Render(StereoMode mode)
        {
#if true
            float[]      offset           = { -1.0f, 1.0f };
            float        stereoSeparation = sceneManager.Camera.Projection.StereoParameters.EyeSeparation[0];
            IFramebuffer framebuffer      = views[0];
            for (int viewIndex = 0; viewIndex < 2; ++viewIndex)
            {
                framebuffer = views[viewIndex];

                renderer.Requested.Camera   = sceneManager.Camera;
                renderer.Requested.Viewport = framebuffer.Viewport;
                framebuffer.Begin();
                //framebufferManager.Default.Begin();

                sceneManager.Camera.Projection.StereoParameters.EyeSeparation[0] = offset[viewIndex] * stereoSeparation;
                mainSceneRenderer.Render(viewIndex);
                framebuffer.End();
            }
            sceneManager.Camera.Projection.StereoParameters.EyeSeparation[0] = stereoSeparation;
#endif

#if true
            Debug.WriteLine("=== Render Stereo Combine");

            renderer.Requested.Viewport = highLevelRenderer.WindowViewport;
            renderer.Requested.Camera   = sceneManager.Camera;
            renderer.RenderCurrentClear();

            highLevelRenderer.Use2DCamera();

            renderer.Requested.Mesh     = quadRenderer.Mesh;
            renderer.Requested.Material = stereoMerge;
            renderer.Requested.Program  = (mode != null && mode.Program != null) ? mode.Program : blend;
            renderer.Requested.MeshMode = MeshMode.PolygonFill;
            renderer.SetFrame(renderer.DefaultFrame);
            renderer.SetTexture("t_left", views[0][FramebufferAttachment.ColorAttachment0]);
            renderer.SetTexture("t_right", views[1][FramebufferAttachment.ColorAttachment0]);
            renderer.RenderCurrent();
#endif
        }
Beispiel #4
0
        public void Render()
        {
            int px, py;

            MouseInScreen(out px, out py);

            Debug.WriteLine("=== Render");

            HandleResize();

            renderer.Global.Floats("add_color").Set(0.0f, 0.0f, 0.0f);
            renderer.Global.Floats("alpha").Set(1.0f);
            renderer.Global.Sync();

            // \todo LineRenderer should have Clear()
            if (lineRenderer != null)
            {
                lineRenderer.Begin();
                lineRenderer.End();
            }

            if (true)
            {
                #region Id
                if (
                    (selectionManager != null) &&
                    (RuntimeConfiguration.disableReadPixels == false)
                    )
                {
                    if (Configuration.idBuffer && (idRenderer != null))
                    {
                        using (var t = new TimerScope(timers.ID))
                        {
                            idRenderer.Render(px, py);
                            selectionManager.ProcessIdBuffer(idRenderer.Hover, px, py);
                        }
                    }

                    selectionManager.Update(px, py);
                }
                #endregion
                #region Shadowmaps
                if (sceneManager.UpdateShadowMap && (RenderStack.Graphics.Configuration.useGl1 == false))
                {
                    using (var t = new TimerScope(timers.Shadow))
                    {
                        shadowRenderer.UpdateShadowMaps();
                    }
                }
                #endregion
                #region CurveTool RenderT
                if ((curveTool != null) && curveTool.Enabled)
                {
                    if (RenderStack.Graphics.Configuration.useGl1 == false)
                    {
                        curveTool.RenderT(px, py, sceneManager.Camera);
                    }
                    curveTool.CheckForUpdates();
                }
                #endregion
                #region Main scene mono/stereo
                using (var t = new TimerScope(timers.Render3D))
                {
                    renderer.PartialGLStateResetToDefaults();
                    if (RenderStack.Graphics.Configuration.useGl1 == false)
                    {
                        renderer.SetTexture("t_shadowmap", shadowRenderer.ShadowMap);
                    }

                    StereoMode mode = (userInterfaceManager != null) ? userInterfaceManager.CurrentStereoMode : null;
                    if ((mode != null) && (mode.Program != null) && (mode.Program.Valid == true))
                    {
                        stereoscopicRenderer.Render(mode);
                    }
                    else
                    {
                        renderer.Requested.Viewport = windowViewport;
                        renderer.Requested.Camera   = sceneManager.Camera;
                        renderer.Requested.Viewport = windowViewport;
                        if (RenderStack.Graphics.Configuration.canUseFramebufferObject)
                        {
                            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
                        }
                        mainSceneRenderer.Render(0);
                    }
                }
                #endregion
                #region voxelTest
                if (Configuration.voxelTest)
                {
                    voxelEditor.RenderCubes(px, py, sceneManager.Camera);
                }
                #endregion
            }
            else
            {
                #region Alternative path without normal 3d scene
                // path without normal 3d scene
                renderer.Requested.Viewport = windowViewport;
                renderer.Requested.Camera   = sceneManager.Camera;
                renderer.Requested.Viewport = windowViewport;
                if (RenderStack.Graphics.Configuration.canUseFramebufferObject)
                {
                    GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
                }
                renderer.RenderCurrentClear();
                renderer.ApplyViewport();
                #endregion
            }

            renderer.Requested.Viewport = windowViewport;
            renderer.Requested.Camera   = sceneManager.Camera;
            renderer.Requested.Viewport = windowViewport;
            renderer.ApplyViewport();

            if (RuntimeConfiguration.debugInfo && Configuration.graphicalUserInterface)
            {
                using (var t = new TimerScope(timers.GUI))
                {
                    userInterfaceManager.Render();
                }
            }

            window.SwapBuffers();
        }
Beispiel #5
0
        private void SceneChoiceAction(ChoiceItem selected)
        {
            System.Console.WriteLine("SceneChoiceAction " + selected.Label);
            if (CurrentScene == selected.Label)
            {
                return;
            }

            CurrentScene = selected.Label;

            // Reset these as game / tree scene will mess around with them..
            RuntimeConfiguration.gameTest  = false;
            RuntimeConfiguration.curveTool = false;
            Configuration.idBuffer         = true;
            userControls = sceneManager.CameraControls;
            sceneManager.Camera.Projection.ProjectionType = ProjectionType.PerspectiveVertical;
            CurrentStereoMode = stereoModes["Mono"];

            System.Diagnostics.Stopwatch time = new System.Diagnostics.Stopwatch();
            time.Start();
            if (selectionManager != null)
            {
                selectionManager.ClearSelection();
            }
            if (selected.Label == "Stereoscopic")
            {
                sceneManager.MakeStereoscopicScene();
                CurrentStereoMode = stereoModes["R/C"];
                sceneManager.Camera.Projection.ProjectionType = ProjectionType.StereoscopicVertical;
            }
            else if (selected.Label == "Polyhedra")
            {
                sceneManager.MakeBrushScene();
            }
            else if (selected.Label == "Game")
            {
                sceneManager.MakeGameScene();
            }
            else if (selected.Label == "Curve")
            {
                sceneManager.MakeCurveScene();
            }
            else if (selected.Label == "Stereo")
            {
                sceneManager.MakeStereoscopicScene();
            }
            else if (selected.Label == "Simple")
            {
                //sceneManager.MakeFloorOnlyScene();
                sceneManager.MakeSimpleScene();
            }
            else if (selected.Label == "Noise")
            {
                sceneManager.MakeNoiseScene();
                CurrentMaterial = "noisy";
                // Reset() will do this: ChooseMaterial();
                //sceneManager.MakeSuperEllipsoidScene();
            }
            else if (selected.Label == "Boxes")
            {
                sceneManager.MakeBoxScene();
            }
            else if (selected.Label == "Trees")
            {
                sceneManager.MakeTreeScene();
            }
            else if (selected.Label == "LightWave")
            {
                sceneManager.MakeLightWaveScene();
            }
            AddLights();
            time.Stop();
            Reset();
            System.Console.WriteLine("Scene change to " + selected.Label + " time: " + time.Elapsed.ToString());
        }