示例#1
0
        /// <summary>
        /// Creates the default scene
        /// </summary>
        public void CreateNewScene()
        {
            //
            // Create Startup Scene
            //
            SceneGraph = new SceneGraph(SlimDX.Matrix.Identity);
            SceneGraph.AttachChild("Menu", new SceneGraph(SlimDX.Matrix.Identity));
            SceneGraph.Children["Menu"].Renderable = Builders.MenuFactory.BuildMainMenu();

            Unsubscribe(Camera);

            SceneGraph defaultScene;

            NewSceneCreator = new CreateNewDefaultScene();
            NewSceneCreator.CreateNewScene(out Camera, out defaultScene);
            SceneGraph.AttachChild("Scene", defaultScene);
        }
示例#2
0
        /// <summary>
        /// Initialize the scene, that's pretty much it.
        /// </summary>
        public void CreateNewScene(out Camera o_Camera, out SceneGraph o_SceneGraph)
        {
            if (!IsExecuted)
            {
                // Create the scene graph
                SceneGraph = new SceneGraph(SlimDX.Matrix.Identity);
                IsExecuted = true;

                // Attach default terrain
                var TerrainThing = new SceneGraph(
                    SlimDX.Matrix.Transformation(SlimDX.Vector3.Zero, SlimDX.Quaternion.Identity, new SlimDX.Vector3(1.0f, 1.0f, 1.0f), SlimDX.Vector3.Zero, SlimDX.Quaternion.Identity, new SlimDX.Vector3(0.0f, 0.0f, 1.0f))
                    );
                TerrainThing.Renderable = new TerrainRenderable(100.0f, 100.0f, 5, 5);

                SceneGraph.AttachChild("TerrainThing", TerrainThing);

                // Attach test object
                var CubeThing = new SceneGraph(
                    SlimDX.Matrix.Transformation(SlimDX.Vector3.Zero, SlimDX.Quaternion.Identity, new SlimDX.Vector3(1.0f, 1.0f, 1.0f), SlimDX.Vector3.Zero, SlimDX.Quaternion.Identity, new SlimDX.Vector3(38.0f, 1.0f, 1.0f))
                    );
                CubeThing.Renderable = new TestRenderable();

                SceneGraph.AttachChild("CubeThing", CubeThing);

                // Create default camera
                var testCamera = new FlightCamera(new SlimDX.Vector3(10.0f, 8.0f, 0.0f));
                Camera = testCamera;
            }
            else
            {
                Debug.WriteLine("Already performed action CreateNewScene");
            }

            o_Camera     = Camera;
            o_SceneGraph = SceneGraph;
        }
示例#3
0
        /// <summary>
        ///  Load the scene from a file
        /// </summary>
        public void LoadScene()
        {
            var loadDialog = new OpenFileDialog();

            loadDialog.Filter = "Outside Simulator Scene (*.oss)|*.oss";

            var dr = loadDialog.ShowDialog();

            if (dr != DialogResult.OK)
            {
                MessageBox.Show("LoadScene aborted", "Outside Simulator");
                return;
            }

            var sr = new System.IO.StreamReader(loadDialog.FileName);

            var xe = XElement.Parse(sr.ReadToEnd());

            if (xe.Name != "OutsideSimulatorScene")
            {
                MessageBox.Show("LoadScene failed - file is not a valid OutsideSimulatorScene", "Outside Simulator");
                return;
            }

            var sg = SceneGraph.Deserialize(
                (xe.Nodes().First((x) => (x as XElement).Name == "SceneGraph") as XElement).Nodes().First((x) => (x as XElement).Name == "SceneGraph").ToString()
                );

            // I will add this back in... Maybe.
            //var cs = CommandStack.Deserialize(
            //    (xe.Nodes().First((x) => (x as XElement).Name == "CommandStack") as XElement).Nodes().First((x) => (x as XElement).Name == "CommandStack").ToString()
            //);

            SceneGraph.Children.Remove("Scene");
            SceneGraph.AttachChild("Scene", sg);
            //CommandStack = cs;
            CommandStack = new CommandStack();
        }