Example #1
0
        private void OnPaint(object sender, RenderEventArgs e)
        {
            Scene.MainCamera = e.Camera;
            Scene.Update(e.FrameTime);

            if (ShowBaseGrid)
            {
                baseGrid.Render(e.Camera, RenderPass.Both);
            }

            if (ShowSkybox && SkyboxScene != null)
            {
                skyboxCamera.CopyFrom(e.Camera);
                skyboxCamera.SetLocation(e.Camera.Location - SkyboxOrigin);
                skyboxCamera.SetScale(SkyboxScale);

                SkyboxScene.MainCamera = skyboxCamera;
                SkyboxScene.Update(e.FrameTime);
                SkyboxScene.RenderWithCamera(skyboxCamera);

                GL.Clear(ClearBufferMask.DepthBufferBit);
            }

            Scene.RenderWithCamera(e.Camera, lockedCullFrustum);

            if (showStaticOctree)
            {
                staticOctreeRenderer.Render(e.Camera, RenderPass.Both);
            }

            if (showDynamicOctree)
            {
                dynamicOctreeRenderer.Render(e.Camera, RenderPass.Both);
            }
        }
Example #2
0
        public static Camera FromBoundingBox(Vector3 minBounds, Vector3 maxBounds, string name = "Default")
        {
            // Calculate center of bounding box
            var bboxCenter = (minBounds + maxBounds) * 0.5f;

            // Set initial position based on the bounding box
            var location = new Vector3(maxBounds.Z, 0, maxBounds.Z) * 1.5f;

            var camera = new Camera();

            camera.SetLocation(location);
            camera.LookAt(bboxCenter);

            return(camera);
        }