Ejemplo n.º 1
0
        //①Overrides Form.OnLoad method
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e); //You should call base.Load(e); at first line of this method when you override OnLoad method.

            //Use OpenFileDialog
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "pmx model file(*.pmx)|*.pmx";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                //Load model when ShowDialog result is DialogResult.OK


                //②Load Model
                MMDModel model = MMDModelWithPhysics.OpenLoad(ofd.FileName, RenderContext);//MMDModel MMDModelWithPhysics.OpenLoad(string fileName,RenderContext);
                //When you want to disable physics calclation,you can do that by using the static method below.
                //MMDModel model=MMDModel.OpenLoad(ofd.FileName, RenderContext);
                //RenderContext contains device data,direct2D device data..and so on using for rendering 3DCG world. If the class  extends RenderForm,you can use this field as RenderContext.
                //The method or classes rendering something sometimes require this value.

                //③Add model to world.
                WorldSpace.AddResource(model);
                //WorldSpace manages the models added to world. If you add a drawable obeject to WorldSpace,the object will be rendered.
            }
        }
Ejemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "pmx model file(*.pmx)|*.pmx";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                MMDModel model = MMDModelWithPhysics.OpenLoad(ofd.FileName, RenderContext);

                //OpenFileDialog to select vmd motion file
                OpenFileDialog ofd2 = new OpenFileDialog();
                ofd2.Filter = "vmd motion file(*.vmd)|*.vmd";
                if (ofd2.ShowDialog() == DialogResult.OK)
                {
                    //①Load motion file
                    IMotionProvider motion = model.MotionManager.AddMotionFromFile(ofd2.FileName, true);
                    //You should add your motion file to the model you wanting to apply.
                    //IMotionProvider AddMotionFromFile(string fileName,bool ignoreParentBone);
                    //If you set true in secound argument to the method above,MMF will ignore root bones motion.
                    //For instance,you want to walk by your code and motion with motion file,motion file might move model coordinate.
                    //When MMF ignore parent bone,MMF will not move model coordinate by motion.

                    //②Apply motion to your PMX model
                    model.MotionManager.ApplyMotion(motion, 0, ActionAfterMotion.Replay);
                    //Secound argument:
                    //Start frame number
                    //Third argument:
                    //What MMF should do when motion playing is finished.
                    //If you want MMF to do nothing when motion playing is finished,you should set ActionAfterMotion.Nothing in third argument.

                    //Extra
                    //(1) How to stop motion?
                    //You can stop motion by using the code below.
                    //model.MotionManager.StopMotion();
                    //(2) What frame number is it playing?
                    //You can get form model.MotionManager.CurrentFrame.
                }
                WorldSpace.AddResource(model);
            }
        }
Ejemplo n.º 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            panel.Initialize();
            panel.RenderContext.CurrentTargetContext.CameraMotionProvider = new BasicCameraControllerMotionProvider(panel, this);
            panel.Dock = DockStyle.Fill;
            Controls.Add(panel);

            var grid = new BasicGrid();

            grid.Visibility = true;
            grid.Load(panel.RenderContext);
            panel.RenderContext.CurrentTargetContext.WorldSpace.AddResource(grid);

            var model = MMDModelWithPhysics.OpenLoad("../../res/reimu.pmx", panel.RenderContext);

            panel.RenderContext.CurrentTargetContext.WorldSpace.AddResource(model);

            var currentMotion = model.MotionManager.AddMotionFromFile("../../res/love&joy.vmd", false);

            model.MotionManager.ApplyMotion(currentMotion, 0, ActionAfterMotion.Replay);
        }