예제 #1
0
        public override void Init()
        {
            Content.ContentPath = "Data";

            Instance = this;

            Scene = new Scene();
            Scene.View = this;
            Scene.Camera = new LookatCartesianCamera()
            {
                Position = new Vector3(10, 10, 10),
                Lookat = Vector3.Zero,
                ZFar = 100,
                AspectRatio = AspectRatio
            };
            sceneQuadtree = new Common.Quadtree<Entity>(0, 0, 100, 100, 10);
            sbau = new SceneBVHAutoSyncer(Scene, sceneQuadtree);

            StateManager = new Device9StateManager(Device9);

            Graphics.Renderer.IRenderer Renderer = new Graphics.Renderer.Renderer(Device9)
            {
                Scene = Scene,
                StateManager = StateManager,
                Settings = new Graphics.Renderer.Settings()
                {
                    FogDistance = 100,
                    WaterLevel = -55
                }
            };

            SRC = new SortedTestSceneRendererConnector
            {
                Scene = Scene,
                Renderer = Renderer,
            };

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

            Scene.Add(exquemelin = new Entity
            {
                MainGraphic = new Graphics.Content.MetaModel
                {
                    SkinnedMesh = new Graphics.Content.SkinnedMeshFromFile("Models/Units/MainCharacter1.x"),
                    Texture = new Graphics.Content.TextureFromFile("Models/Units/MainCharacter1.png"),
                    World = Matrix.Scaling(0.5f, 0.5f, 0.5f) * Graphics.Content.SkinnedMesh.InitSkinnedMeshFromMaya * Matrix.Translation(0, 0, -4f),
                },
                VisibilityLocalBounding = new Common.Bounding.NonfittableBounding(Vector3.Zero, false, true)

            });

            InputHandler = new WalkaroundCameraInputHandler
            {
                Camera = (LookatCartesianCamera)Scene.Camera,
            };
        }
예제 #2
0
        public override void Init()
        {
            Content.ContentPath = "Data";

            Scene = new Scene();
            Scene.View = this;
            Scene.Camera = new LookatCartesianCamera()
            {
                Position = new Vector3(10, 10, 10),
                Lookat = Vector3.Zero,
                ZFar = 100,
                AspectRatio = AspectRatio
            };
            sceneQuadtree = new Common.Quadtree<Entity>(10);
            sbau = new SceneBVHAutoSyncer(Scene, sceneQuadtree);

            StateManager = new Device9StateManager(Device9);

            Renderer = new Graphics.Renderer.Renderer(Device9) { Scene = Scene, StateManager = StateManager, Settings = new Graphics.Renderer.Settings { ShadowQuality = Graphics.Renderer.Settings.ShadowQualities.NoShadows } };
            Renderer.Initialize(this);
            sceneRendererConnector = new SortedTestSceneRendererConnector
            {
                Scene = Scene,
                Renderer = Renderer
            };
            sceneRendererConnector.Initialize();

            Scene.Add(exquemelin = new Entity
            {
                MainGraphic = new Graphics.Content.MetaModel
                {
                    SkinnedMesh = new Graphics.Content.SkinnedMeshFromFile("Models/Units/Zombie1.x"),
                    Texture = new Graphics.Content.TextureFromFile("Models/Units/Zombie1.png"),
                    World = Graphics.Content.SkinnedMesh.InitSkinnedMeshFromMaya * Matrix.Scaling(0.5f, 0.5f, 0.5f),
                    HasAlpha = false,
                },
                VisibilityLocalBounding = new Common.Bounding.NonfittableBounding(Vector3.Zero, false, true)
            });

            Graphics.Renderer.Renderer.EntityAnimation ea = Scene.View.Content.Peek<Graphics.Renderer.Renderer.EntityAnimation>(exquemelin.MetaEntityAnimation);

            ea.PlayAnimation(new AnimationPlayParameters("Idle1", true));

            InputHandler = new WalkaroundCameraInputHandler
            {
                Camera = (LookatCartesianCamera)Scene.Camera,
            };
        }
예제 #3
0
        public override void Init()
        {
            Content.ContentPath = "Data";

            Instance = this;

            Scene = new Scene();
            Scene.View = this;
            Scene.Camera = new LookatCartesianCamera()
            {
                Position = new Vector3(10, 10, 10),
                Lookat = Vector3.Zero,
                ZFar = 100,
                AspectRatio = AspectRatio
            };
            sceneQuadtree = new Common.Quadtree<Entity>(-1, -1, 100, 100, 10);
            sbau = new SceneBVHAutoSyncer(Scene, sceneQuadtree);

            StateManager = new Device9StateManager(Device9);

            rand = new Random();

            nBillboards = 2000;
            billboards = new Entity[nBillboards];
            directions = new Vector3[nBillboards];

            for (int i = 0; i < nBillboards; i++)
                directions[i] = new Vector3((float)rand.NextDouble() * 2 - 1, (float)rand.NextDouble() * 2 - 1, (float)rand.NextDouble() * 2 - 1);

            InputHandler = new WalkaroundCameraInputHandler
            {
                Camera = (LookatCartesianCamera)Scene.Camera
            };

            Renderer = new Graphics.Renderer.Renderer(Device9) { Scene = Scene, StateManager = StateManager, Settings = new Graphics.Renderer.Settings { FogDistance = 500 } };
            Renderer.Initialize(this);

            sceneRendererConnector = new SortedTestSceneRendererConnector
            {
                Renderer = Renderer,
                Scene = Scene
            };
            sceneRendererConnector.Initialize();

            for (int i = 0; i < nBillboards; i++)
            {
                Scene.Add(billboards[i] = new Entity
                {
                    MainGraphic = new MetaModel
                    {
                        AlphaRef = 0,
                        BaseTexture = null,
                        CastShadows = Priority.Never,
                        HasAlpha = true,
                        IsBillboard = true,
                        IsWater = false,
                        MaterialTexture = null,
                        Mesh = null,
                        ReceivesAmbientLight = Priority.Never,
                        ReceivesDiffuseLight = Priority.Never,
                        ReceivesShadows = Priority.Never,
                        SkinnedMesh = null,
                        SplatMapped = false,
                        SplatTexutre = null,
                        Texture = new TextureFromFile("checker.png"),
                        Visible = Priority.High,
                        World = Matrix.Identity,
                        XMesh = new MeshConcretize
                        {
                            MeshDescription = new Meshes.IndexedPlane
                            {
                                Facings = Facings.Backside | Facings.Frontside,
                                Position = Vector3.Zero,
                                Size = new Vector2(5, 5),
                                UVMin = Vector2.Zero,
                                UVMax = new Vector2(1, 1)
                            },
                            Layout = global::Graphics.Software.Vertex.PositionNormalTexcoord.Instance
                        }
                    },
                    VisibilityLocalBounding = Vector3.Zero,
                    WorldMatrix = Matrix.Identity
                });
            }
        }
예제 #4
0
        public override void Init()
        {
            Content.ContentPath = "Data";

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

            foreach (var v in scene.AllEntities)
                v.VisibilityLocalBounding = Content.Acquire<Graphics.Content.StructBoxer<BoundingBox>>(v.MainGraphic).Value;

            var stateManager = new Device9StateManager(Device9);
            renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = stateManager };
            renderer.Initialize(this);

            sceneRendererConnector = new SortedTestSceneRendererConnector
            {
                Scene = scene,
                Renderer = renderer
            };
            sceneRendererConnector.Initialize();

            editor = new Graphics.Editors.SceneEditor { Scene = scene };
            editorRenderer = new Graphics.Editors.SceneEditor.Renderer9(editor)
            {
                BoundingVolumesRenderer = new BoundingVolumesRenderer
                {
                    StateManager = stateManager,
                    View = this
                }
            };

            InputHandler = editor;

            Entity e;
            scene.Add(e = new Entity
            {
                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 * Matrix.Translation(1, 0, 0)
                },
            });
            e.VisibilityLocalBounding = CreateBoundingBoxFromModel((MetaModel)e.MainGraphic);
            e.PickingLocalBounding = CreateBoundingMeshFromModel(e, (MetaModel)e.MainGraphic);

            scene.Add(e = new Entity
            {
                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 *
                        Matrix.Translation(3, 0, 0)
                },
            });
            e.VisibilityLocalBounding = CreateBoundingBoxFromModel((MetaModel)e.MainGraphic);
            e.PickingLocalBounding = CreateBoundingMeshFromModel(e, (MetaModel)e.MainGraphic);
        }
예제 #5
0
        public override void Init()
        {
            Application.Log("Program.Init");

            ClientXmlFormatterBinder.Instance.BindClientTypes();

            LoadControls();
            SignalEvent(ProgramEventType.ProgramStarted);

#if DEBUG
            RedGate.Profiler.UserEvents.ProfilerEvent.SignalEvent("Init start");
#endif
            Content.ContentPath = Program.DataPath;
            Game.Map.GameEntity.ContentPool = Content;
            
            Bitmap b = new Bitmap(Common.FileSystem.Instance.OpenRead(Content.ContentPath + "/Interface/Cursors/MenuCursor1.png"));
            Graphics.Cursors.Arrow = NeutralCursor = Cursor = new System.Windows.Forms.Cursor(b.GetHicon());

            Graphics.Interface.InterfaceScene.DefaultFont = Fonts.Default;

            if (Settings.DeveloperMainMenu)
            {
                MainMenuDefault = MainMenuType.DeveloperMainMenu;
                ProfileMenuDefault = ProfileMenuType.DeveloperMainMenu;
            }
            else if (Settings.ChallengeMapMode)
            {
                MainMenuDefault = MainMenuType.ChallengeMap;
                ProfileMenuDefault = ProfileMenuType.ChallengeMap;
            }
            else
            {
                MainMenuDefault = MainMenuType.MainMenu;
                ProfileMenuDefault = ProfileMenuType.ProfileMenu;
            }

            if (Settings.DisplaySettingsForm)
            {
                OpenDeveloperSettings();
            }
            
            //Graphics.Content.DefaultModels.Load(Content, Device9);
            InterfaceScene = new Graphics.Interface.InterfaceScene();
            InterfaceScene.View = this;
            ((Graphics.Interface.Control)InterfaceScene.Root).Size = new Vector2(Program.Settings.GraphicsDeviceSettings.Resolution.Width, Program.Settings.GraphicsDeviceSettings.Resolution.Height);
            InterfaceScene.Add(Interface);
            InterfaceScene.Add(AchievementsContainer);
            InterfaceScene.Add(PopupContainer);
            InterfaceScene.Add(FeedackOnlineControl);
            if (!String.IsNullOrEmpty(Program.Settings.BetaSurveyLink))
            {
                var u = new Uri(Program.Settings.BetaSurveyLink);
                var s = u.ToString();
                if (!u.IsFile)
                {
                    Button survey = new Button
                    {
                        Text = "Beta survey",
                        Anchor = Orientation.BottomRight,
                        Position = new Vector2(10, 50),
                        Size = new Vector2(110, 30)
                    };
                    survey.Click += new EventHandler((o, e) =>
                    {
                        Util.StartBrowser(s);
                    });
                    InterfaceScene.Add(survey);
                }
            }
            InterfaceScene.Add(Tooltip);
            InterfaceScene.Add(MouseCursor);
            InputHandler = InterfaceManager = new Graphics.Interface.InterfaceManager { Scene = InterfaceScene };

            // Adjust the main char skin mesh; remove the dummy weapons
            var mainCharSkinMesh = Program.Instance.Content.Acquire<SkinnedMesh>(
                new SkinnedMeshFromFile("Models/Units/MainCharacter1.x"));
            mainCharSkinMesh.RemoveMeshContainerByFrameName("sword1");
            mainCharSkinMesh.RemoveMeshContainerByFrameName("sword2");
            mainCharSkinMesh.RemoveMeshContainerByFrameName("rifle");

            try
            {
                SoundManager = new Client.Sound.SoundManager(Settings.SoundSettings.AudioDevice, Settings.SoundSettings.Engine, Settings.SoundSettings.MinMaxDistance.X, Settings.SoundSettings.MinMaxDistance.Y, Common.FileSystem.Instance.OpenRead);
                SoundManager.Settings = Settings.SoundSettings;
                SoundManager.ContentPath = Program.DataPath + "/Sound/";
                SoundManager.Muted = Settings.SoundSettings.Muted;
                SoundManager.LoadSounds(!Settings.ChallengeMapMode);
                if (SoundLoaded != null)
                    SoundLoaded(SoundManager, null);

                SoundManager.Volume = Settings.SoundSettings.MasterVolume;

                SoundManager.GetSoundGroup(Client.Sound.SoundGroups.Ambient).Volume = Settings.SoundSettings.AmbientVolume;
                SoundManager.GetSoundGroup(Client.Sound.SoundGroups.Music).Volume = Settings.SoundSettings.MusicVolume;
                SoundManager.GetSoundGroup(Client.Sound.SoundGroups.SoundEffects).Volume = Settings.SoundSettings.SoundVolume;
                SoundManager.GetSoundGroup(Client.Sound.SoundGroups.Interface).Volume = Settings.SoundSettings.SoundVolume;
            }
            catch (Client.Sound.SoundManagerException ex)
            {
                SendSoundFailureLog(ex);
                SoundManager = new Client.Sound.DummySoundManager();
                System.Windows.Forms.MessageBox.Show(
                    Locale.Resource.ErrorFailInitSoundDevice,
                    Locale.Resource.ErrorFailInitSoundDeviceTitle,
                    System.Windows.Forms.MessageBoxButtons.OK, 
                    System.Windows.Forms.MessageBoxIcon.Error);
            }

            //StateManager = new DummyDevice9StateManager(Device9);
            StateManager = new Device9StateManager(Device9);
            InterfaceRenderer = new Graphics.Interface.InterfaceRenderer9(Device9)
            {
                Scene = InterfaceScene,
                StateManager = StateManager,
#if PROFILE_INTERFACERENDERER
                PeekStart = () => ClientProfilers.IRPeek.Start(),
                PeekEnd = () => ClientProfilers.IRPeek.Stop()
#endif
            };
            InterfaceRenderer.Initialize(this);

            BoundingVolumesRenderer = new BoundingVolumesRenderer
            {
                StateManager = Program.Instance.StateManager,
                View = Program.Instance
            };

#if BETA_RELEASE
            Client.Settings defaultSettings = new Settings();
            ValidateSettings("", defaultSettings, Settings);
#endif

            if (Settings.QuickStartMap != null && Settings.QuickStartMap != "" &&
                Common.FileSystem.Instance.FileExists("Maps/" + Settings.QuickStartMap + ".map"))
            {
                LoadNewState(new Game.Game("Maps/" + Settings.QuickStartMap));
                return;
            }

            UpdateFeedbackOnlineControl();
            
            System.Net.NetworkInformation.Ping p = new System.Net.NetworkInformation.Ping();
            p.PingCompleted += new System.Net.NetworkInformation.PingCompletedEventHandler((o, e) =>
            {
                FeedbackOnline = e.Reply != null && 
                    e.Reply.Status == System.Net.NetworkInformation.IPStatus.Success;
                UpdateFeedbackOnlineControl();
            });
            var statsUri = new Uri(Settings.StatisticsURI);
            p.SendAsync(statsUri.DnsSafeHost, null);

            if (Settings.DeveloperMainMenu)
                InitDeveloperMenu();
            else if (Settings.ChallengeMapMode)
                InitChallengeMapMode();
            else
                InitFullGame();

            EnterMainMenuState(false);

            if(WindowMode == WindowMode.Fullscreen)
                MouseCursor.BringToFront();

            AskAboutUpdate();

            if (!String.IsNullOrEmpty(Program.Settings.StartupMessage))
            {
                Dialog.Show(Program.Settings.StartupMessageTitle ?? "", Program.Settings.StartupMessage);
            }


            fixedFrameStepSW.Start();

            Application.Log("Program.Init completed");
#if DEBUG
            RedGate.Profiler.UserEvents.ProfilerEvent.SignalEvent("Init end");
#endif
        }
예제 #6
0
        public override void Init()
        {
            Content.ContentPath = "Data";

            Instance = this;

            Scene = new Scene();
            Scene.View = this;
            Scene.Camera = new LookatCartesianCamera()
            {
                Position = new Vector3(10, 10, 10),
                Lookat = Vector3.Zero,
                ZFar = 10000,
                AspectRatio = AspectRatio
            };
            sceneQuadtree = new Common.Quadtree<Entity>(-1, -1, 100, 100, 10);
            sbau = new SceneBVHAutoSyncer(Scene, sceneQuadtree);

            StateManager = new Device9StateManager(Device9);

            arrow = new MetaModel
            {
                HasAlpha = true,
                IsAxialBillboard = true,
                AxialDirection = new Vector3(0.5f, 0.5f, 0),
                XMesh = new Graphics.Content.MeshFromFile("Arrow.x"),
                Texture = new TextureFromFile("green.png"),
                Visible = Priority.High,
                World = Matrix.Identity,
            };

            direction = new Vector3(1, 0, 0);

            axialBillboard = new MetaModel
            {
                HasAlpha = true,
                IsAxialBillboard = true,
                AxialDirection = direction,
                XMesh = new MeshConcretize
                {
                    MeshDescription = new Graphics.Software.Meshes.IndexedPlane
                    {
                        Facings = Facings.Frontside | Facings.Backside,
                        Position = new Vector3(-0.5f, -0.5f, 0),
                        Size = new Vector2(1, 1),
                        UVMin = Vector2.Zero,
                        UVMax = new Vector2(1, 1)
                    },
                    Layout = global::Graphics.Software.Vertex.PositionNormalTexcoord.Instance
                },
                Texture = new TextureFromFile("Models/Effects/MuzzleFlash1.png"),
                World = Matrix.RotationX((float) Math.PI /2.0f) * Matrix.RotationY((float)Math.PI / 2.0f) * Matrix.Translation(direction * 0.5f)
            };

            rand = new Random();

            //axialBillboard.World.Invert();

            nBillboards = 1;
            billboards = new Entity[nBillboards];
            directions = new Vector3[nBillboards];

            for (int i = 0; i < nBillboards; i++)
                directions[i] = new Vector3((float)rand.NextDouble() * 2 - 1, (float)rand.NextDouble() * 2 - 1, (float)rand.NextDouble() * 2 - 1);

            InputHandler = new WalkaroundCameraInputHandler
            {
                Camera = (LookatCartesianCamera)Scene.Camera
            };

            Renderer = new Graphics.Renderer.Renderer(Device9) { Scene = Scene, StateManager = StateManager, Settings = new Graphics.Renderer.Settings { FogDistance = 50000, WaterLevel = 0 } };
            Renderer.Initialize(this);

            sceneRendererConnector = new SortedTestSceneRendererConnector
            {
                Renderer = Renderer,
                Scene = Scene
            };
            sceneRendererConnector.Initialize();

            for (int i = 0; i < nBillboards; i++)
            {
                Scene.Add(billboards[i] = new Entity
                {
                    MainGraphic = axialBillboard,
                    VisibilityLocalBounding = Vector3.Zero,
                    WorldMatrix = Matrix.Identity
                });
            }
        }
예제 #7
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;
        }
예제 #8
0
        public override void Init()
        {
            Content.ContentPath = "Data";

            StateManager = new Device9StateManager(Device9);

            Scene.View = this;

            Renderer = new Graphics.Renderer.Renderer(Device9) { Scene = Scene, StateManager = StateManager };
            Renderer.Initialize(this);

            sceneRendererConnector = new SortedTestSceneRendererConnector
            {
                Renderer = Renderer,
                Scene = Scene
            };
            sceneRendererConnector.Initialize();

            Scene.Camera = new LookatCartesianCamera()
            {
                Position = new Vector3(10, 10, 10),
                Lookat = Vector3.Zero,
                AspectRatio = AspectRatio
            };
            Scene.Add(donutEntity = new Entity
            {
                MainGraphic = new Graphics.Content.MetaModel
                {
                    SkinnedMesh = new SkinnedMeshFromFile("Models/Props/Palmtree1.x"),
                    Texture = new TextureFromFile("Models/Props/Palmtree1.png"),
                    World = Graphics.Content.SkinnedMesh.InitSkinnedMeshFromMaya
                }
            });
            Scene.Add(goblinEntity = new Entity
            {
                MainGraphic = new Graphics.Content.MetaModel
                {
                    SkinnedMesh = new Graphics.Content.SkinnedMeshFromFile("Models/Units/Brute1.x"),
                    Texture = new Graphics.Content.TextureFromFile("Models/Units/Brute1.png"),
                    World = Graphics.Content.SkinnedMesh.InitSkinnedMeshFromMaya * Matrix.Translation(4, 4, 0),
                }
            });
            InputHandler = new WalkaroundCameraInputHandler
            {
                Camera = (LookatCartesianCamera)Scene.Camera,
            };

            //donutEntity.PlayAnimation("idle1", 1, true, 0);

            Renderer.Initialize(this);

            System.Windows.Forms.PropertyGrid p1;
            System.Windows.Forms.PropertyGrid p2;

            System.Windows.Forms.Form form1 = new System.Windows.Forms.Form();
            System.Windows.Forms.Form form2 = new System.Windows.Forms.Form();
            form1.Controls.Add(p1 = new System.Windows.Forms.PropertyGrid { SelectedObject = Renderer.Settings, Dock = System.Windows.Forms.DockStyle.Fill });
            form2.Controls.Add(p2 = new System.Windows.Forms.PropertyGrid { SelectedObject = GraphicsDevice.Settings, Dock = System.Windows.Forms.DockStyle.Fill });

            form1.Show();
            form2.Show();
        }
예제 #9
0
        public override void Init()
        {
            Content.ContentPath = "Data";

            Instance = this;

            Scene = new Scene();
            Scene.View = this;
            Scene.Camera = new LookatCartesianCamera()
            {
                Position = new Vector3(10, 10, 10),
                Lookat = Vector3.Zero,
                ZFar = 10000,
                AspectRatio = AspectRatio
            };
            sceneQuadtree = new Common.Quadtree<Entity>(0, 0, 100, 100, 10);
            sbau = new SceneBVHAutoSyncer(Scene, sceneQuadtree);

            StateManager = new Device9StateManager(Device9);

            int nVertices = 10;
            int nFaces = nVertices*2 - 4;
            int nIndices = nFaces * 3;

            List<int> indices = new List<int>();
            List<Graphics.Software.Vertex.Position3Normal3Texcoord3> vertices = new List<Graphics.Software.Vertex.Position3Normal3Texcoord3>();

            for (int i = 0; i < (nVertices / 2) - 1; i++)
            {
                indices.Add(i * 2);
                indices.Add(i * 2 + 2);
                indices.Add(i * 2 + 1);

                indices.Add(i * 2 + 1);
                indices.Add(i * 2 + 2);
                indices.Add(i * 2 + 3);

                indices.Add(i * 2 + 0);
                indices.Add(i * 2 + 1);
                indices.Add(i * 2 + 3);

                indices.Add(i * 2 + 0);
                indices.Add(i * 2 + 3);
                indices.Add(i * 2 + 2);
            }

            for (int i = 0; i < nVertices / 2; i++)
            {
                float texturecoord = 1 - ((float)i / (float)nVertices);

                if (texturecoord > 0.99f)
                    texturecoord = 0.99f;

                vertices.Add(new Graphics.Software.Vertex.Position3Normal3Texcoord3(Vector3.UnitX * i, Vector3.Zero, new Vector3(texturecoord, 1, 0)));
                vertices.Add(new Graphics.Software.Vertex.Position3Normal3Texcoord3(Vector3.UnitX * i + Vector3.UnitY*4.0f, Vector3.Zero, new Vector3(texturecoord, 0, 0)));
            }

            arrow = new MetaModel
            {
                HasAlpha = true,
                Opacity = 0.4f,
                XMesh = new MeshConcretize
                {
                    Mesh = new Graphics.Software.Mesh
                    {
                        IndexBuffer = new Graphics.Software.IndexBuffer(indices.ToArray()),
                        VertexBuffer = new VertexBuffer<Graphics.Software.Vertex.Position3Normal3Texcoord3>(vertices.ToArray()),
                        NVertices = nVertices,
                        NFaces = nFaces,
                        VertexStreamLayout = global::Graphics.Software.Vertex.Position3Normal3Texcoord3.Instance,
                    },
                    Layout = global::Graphics.Software.Vertex.PositionNormalTexcoord.Instance
                },
                Texture = new TextureFromFile("green.png"),
            };

            InputHandler = new WalkaroundCameraInputHandler
            {
                Camera = (LookatCartesianCamera)Scene.Camera
            };

            Renderer = new Graphics.Renderer.Renderer(Device9) { Scene = Scene, StateManager = StateManager, Settings = new Graphics.Renderer.Settings { FogDistance = 50000, WaterLevel = 0 } };
            Renderer.Initialize(this);

            sceneRendererConnector = new SortedTestSceneRendererConnector
            {
                Renderer = Renderer,
                Scene = Scene
            };
            sceneRendererConnector.Initialize();

            Scene.Add(new Entity
            {
                MainGraphic = arrow,
                VisibilityLocalBounding = Vector3.Zero,
            });
        }