예제 #1
0
        protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
        {
            if (e.KeyCode == System.Windows.Forms.Keys.D1)
            {
                var ent = new Entity
                {
                    MainGraphic = new MetaModel
                    {
                        XMesh   = new MeshFromFile("ramp1.x"),
                        Texture = new TextureFromFile("ramp1.tga"),
                        World   = Matrix.Scaling(0.1f, 0.1f, 0.1f) * SkinnedMesh.InitSkinnedMeshFromMaya * Matrix.Translation(1, 0, 0)
                    }
                };
                ent.VisibilityLocalBounding = Content.Acquire <Graphics.Content.StructBoxer <BoundingBox> >(ent.MainGraphic).Value;
                scene.Add(ent);
                editor.MoveToCursor(ent);
                editor.StartMove(ent);
            }
            if (e.KeyCode == System.Windows.Forms.Keys.D2)
            {
                var ent = new Entity
                {
                    MainGraphic = new MetaModel
                    {
                        SkinnedMesh = new SkinnedMeshFromFile("bridgeph.x"),
                        Texture     = new TextureFromFile("ramp1.tga"),
                        World       = Matrix.Scaling(0.1f, 0.1f, 0.1f) * SkinnedMesh.InitSkinnedMeshFromMaya *
                                      Matrix.Translation(3, 0, 0)
                    },
                    //UseGraphicForPicking = true,

                    /*Animation = "down",
                     * LoopAnimation = true,
                     * AnimationSpeed = 0.1f*/
                };
                ent.VisibilityLocalBounding = Content.Acquire <Graphics.Content.StructBoxer <BoundingBox> >(ent.MainGraphic).Value;
                scene.Add(ent);
                editor.MoveToCursor(ent);
                editor.StartMove(ent);
            }
            if (e.KeyCode == System.Windows.Forms.Keys.Delete)
            {
                foreach (var v in new List <Entity>(editor.Selected))
                {
                    v.Remove();
                }
            }
        }
예제 #2
0
                public void InitializeAnimation()
                {
                    var metaModel = (MetaModel)Entity.AllGraphics.First();

                    if (metaModel.SkinnedMesh != null)
                    {
                        SkinnedMesh = Content.Acquire <SkinnedMesh>(metaModel.SkinnedMesh);

                        if (SkinnedMesh.AnimationController != null)
                        {
                            AnimationController = SkinnedMesh.AnimationController.Clone(
                                SkinnedMesh.AnimationController.MaxAnimationOutputs,
                                SkinnedMesh.AnimationController.MaxAnimationSets,
                                SkinnedMesh.AnimationController.MaxTracks,
                                SkinnedMesh.AnimationController.MaxEvents);
                        }
                    }
                    var constructedModel = Content.Peek <Model9>(metaModel);

                    Update(constructedModel, 0, Matrix.Identity);
                }
 public void Init(Content.ContentPool content)
 {
     XMesh = content.Acquire<SlimDX.Direct3D9.Mesh>(Mesh);
 }
예제 #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);
        }