public override void OnEnter()
 {
     Editor = new Graphics.Editors.SceneEditor
     {
         Scene       = view.Scene,
         GroundProbe = view.GroundProbe
     };
     Editor.IsClickableCallback = (e) =>
     {
         var ge = e as Client.Game.Map.GameEntity;
         if (ge != null && ge.EditorSelectable)
         {
             if (GameEntitiesList.SelectedItems.Count == 0)
             {
                 return(true);
             }
             foreach (System.Windows.Forms.ListViewItem v in GameEntitiesList.SelectedItems)
             {
                 if (((Type)v.Tag) == ge.GetType())
                 {
                     return(true);
                 }
             }
         }
         return(false);
     };
     Editor.GetTranslationCallback = (e) => ((Client.Game.Map.GameEntity)e).Position;
     Editor.SetTranslationCallback = (e, v) => ((Client.Game.Map.GameEntity)e).Position = v;
     editorRenderer = new Graphics.Editors.SceneEditor.Renderer9(Editor)
     {
         BoundingVolumesRenderer = view.bvRenderer
     };
     Editor.SelectionChanged += new EventHandler(Editor_SelectionChanged);
     InputHandler             = Editor;
     GameEntitiesList.SelectedItems.Clear();
     defaultStatePanel.GameEntityList = GameEntitiesList;
 }
        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);
        }
 public override void OnEnter()
 {
     Editor = new Graphics.Editors.SceneEditor
     {
         Scene = view.Scene,
         GroundProbe = view.GroundProbe
     };
     Editor.IsClickableCallback = (e) =>
     {
         var ge = e as Client.Game.Map.GameEntity;
         if (ge != null && ge.EditorSelectable)
         {
             if (GameEntitiesList.SelectedItems.Count == 0) return true;
             foreach (System.Windows.Forms.ListViewItem v in GameEntitiesList.SelectedItems)
                 if (((Type)v.Tag) == ge.GetType()) return true;
         }
         return false;
     };
     Editor.GetTranslationCallback = (e) => ((Client.Game.Map.GameEntity)e).Position;
     Editor.SetTranslationCallback = (e, v) => ((Client.Game.Map.GameEntity)e).Position = v;
     editorRenderer = new Graphics.Editors.SceneEditor.Renderer9(Editor)
     {
         BoundingVolumesRenderer = view.bvRenderer
     };
     Editor.SelectionChanged += new EventHandler(Editor_SelectionChanged);
     InputHandler = Editor;
     GameEntitiesList.SelectedItems.Clear();
     defaultStatePanel.GameEntityList = GameEntitiesList;
 }
Esempio n. 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);
        }