Exemplo n.º 1
0
            public void Render()
            {
                BoundingVolumesRenderer.Begin(editor.Scene.Camera);
                var mouseover = editor.CurrentMouseOverEntity;

                if (mouseover != null)
                {
                    BoundingVolumesRenderer.Draw(Matrix.Identity,
                                                 mouseover.PickingWorldBounding,
                                                 Color.Crimson);
                }

                foreach (var v in editor.selected)
                {
                    BoundingVolumesRenderer.Draw(Matrix.Identity,
                                                 v.PickingWorldBounding,
                                                 Color.Green);
                }
                BoundingVolumesRenderer.End();
                editor.state.Render(this);
            }
Exemplo n.º 2
0
        public override void Init()
        {
            if (DesignMode)
            {
                return;
            }

            Content.ContentPath = "Data(.kel)";
            Client.Game.Map.GameEntity.ContentPool = Content;

            Scene.View   = this;
            Scene.Camera = new LookatSphericalCamera()
            {
                FOV  = 0.5f,
                ZFar = 50,
                SphericalCoordinates = Program.ClientDefaultSettings.CameraSphericalCoordinates,
                AspectRatio          = this.AspectRatio
            };
            Controller = new InteractiveSceneManager {
                Scene = Scene
            };
            StateManager = new DummyDevice9StateManager(Device9);
            InputHandler = inputHandlersRoot;

            cameraInputHandler = new CameraInputHandler
            {
                Camera = (LookatSphericalCamera)Scene.Camera,
                View   = this,
            };
            Scene.Camera.ZFar = 50;
            inputHandlersRoot.InputHandlers.Add(cameraInputHandler);
            cameraInputHandler.InputHandler = Controller;

            if (Program.Settings.UseDummyRenderer)
            {
                throw new NotSupportedException("Dummy renderer is no longer supported.");
                //Renderer = new Graphics.DummyRenderer.Renderer { Scene = Scene, StateManager = StateManager };
            }
            else
            {
                Renderer = new Graphics.Renderer.Renderer(Device9)
                {
                    Scene        = Scene,
                    StateManager = StateManager,
                    Settings     = new Graphics.Renderer.Settings
                    {
                        ShadowQuality   = Graphics.Renderer.Settings.ShadowQualities.Medium,
                        LightingQuality = Graphics.Renderer.Settings.LightingQualities.High
                    }
                };
                SceneRendererConnector = new SortedTestSceneRendererConnector
                {
                    Scene    = Scene,
                    Renderer = Renderer
                };
            }

            Renderer.Settings.TerrainQuality  = Graphics.Renderer.Settings.TerrainQualities.High;
            Renderer.Settings.LightingQuality = Graphics.Renderer.Settings.LightingQualities.High;
            Renderer.Settings.ShadowQuality   = Graphics.Renderer.Settings.ShadowQualities.Low;

            SceneRendererConnector.Initialize();
            Renderer.Initialize(Scene.View);

            if (Program.Settings.DeveloperSettings)
            {
                p1 = new System.Windows.Forms.PropertyGrid {
                    SelectedObject = Renderer.Settings, Dock = System.Windows.Forms.DockStyle.Fill
                };
                form1.Controls.Add(p1);
                form1.Show();
            }

            bvRenderer = new BoundingVolumesRenderer
            {
                StateManager = StateManager,
                View         = this
            };

            tooltip = new System.Windows.Forms.ToolTip();

            StartDefaultMode();
        }
Exemplo n.º 3
0
        public override void Init()
        {
            Content.ContentPath = "Data";

            scene        = new Scene();
            scene.View   = this;
            scene.Camera = new LookatCartesianCamera()
            {
                Position    = new Vector3(-5, 5, 5),
                AspectRatio = AspectRatio
            };


            foreach (var v in scene.AllEntities)
            {
                v.VisibilityLocalBounding = Vector3.Zero;
            }

            Device9StateManager sm = new Device9StateManager(Device9);

            renderer = new Graphics.Renderer.Renderer(Device9)
            {
                Scene = scene, StateManager = sm
            };
            renderer.Initialize(this);
            sceneRendererConnector = new SortedTestSceneRendererConnector
            {
                Scene    = scene,
                Renderer = renderer
            };
            sceneRendererConnector.Initialize();

            bvr = new BoundingVolumesRenderer
            {
                View         = this,
                StateManager = sm
            };

            BVEntity t;

            scene.Add(t = new BVEntity
            {
                MainGraphic = new MetaModel
                {
                    XMesh   = new MeshFromFile("Models/Props/Barrel1.x"),
                    Texture = new TextureFromFile("Models/Props/Barrel1.png"),
                    World   = Matrix.Scaling(0.1f, 0.1f, 0.1f) * SkinnedMesh.InitSkinnedMeshFromMaya,
                },
                WorldMatrix = Matrix.Translation(1, 0, 0)
            });
            t.BoundingVolume = Graphics.Boundings.Transform(new Graphics.MetaBoundingBox {
                Mesh = ((MetaModel)t.MainGraphic).XMesh
            },
                                                            ((MetaModel)t.MainGraphic).World);
            scene.Add(t = new BVEntity
            {
                MainGraphic = new MetaModel
                {
                    SkinnedMesh = new SkinnedMeshFromFile("Models/Props/Bridge1.x"),
                    Texture     = new TextureFromFile("Models/Props/Bridge1.png"),
                    World       = Matrix.Scaling(0.1f, 0.1f, 0.1f) * SkinnedMesh.InitSkinnedMeshFromMaya
                },
                WorldMatrix = Matrix.Translation(3, 0, 0)
            });
            scene.Add(t = new BVEntity
            {
                MainGraphic = new MetaModel
                {
                    SkinnedMesh = new SkinnedMeshFromFile("Models/Props/Bridge1.x"),
                    Texture     = new TextureFromFile("Models/Props/Bridge1.png"),
                    World       = Matrix.Scaling(0.1f, 0.1f, 0.1f) * SkinnedMesh.InitSkinnedMeshFromMaya
                },
                WorldMatrix = Matrix.Translation(-3, -3, 0)
            });
            t.BoundingVolume = Vector3.Zero;
        }