Пример #1
0
        public bool DoCommand(string[] args)
        {
            try
            {
                switch (args[0].ToLower())
                {
                case "clear":
                    // 全て削除する.
                    viewer.ClearFigureList();
                    viewer.MotionEnabled = false;
                    camrotate            = new Vector3(0, 0, 0);
                    break;

                case "load":
                    // ファイルを読み込む.
                    for (int i = 1; i < args.Length; i++)
                    {
                        viewer.LoadAnyFile(args[i]);
                        //viewer.Camera.SetTranslation(0.0f, +10.0f, +44.0f);
                    }
                    break;

                case "run":
                    // アニメーションを実行する.
                    viewer.MotionEnabled = true;
                    break;

                case "translation":
                {
                    float x = float.Parse(args[1]);
                    float y = float.Parse(args[2]);
                    float z = float.Parse(args[3]);
                    viewer.Camera.SetTranslation(x, y, z);
                }
                break;

                case "angle":
                {
                    float x = Geometry.DegreeToRadian(float.Parse(args[1]));
                    float y = Geometry.DegreeToRadian(float.Parse(args[2]));
                    float z = Geometry.DegreeToRadian(float.Parse(args[3]));
                    viewer.Camera.SetAngle(x, y, z);
                }
                break;

                case "camfocus":
                {
                    viewer.Camera.ResetTranslation();
                    Figure fig;
                    if (viewer.TryGetFigure(out fig))
                    {
                        viewer.Camera.SetCenter(fig.Center + fig.Translation);
                    }
                }
                break;

                case "camtrack":
                {
                    float x = Geometry.DegreeToRadian(float.Parse(args[1]));
                    float y = Geometry.DegreeToRadian(float.Parse(args[2]));
                    float z = Geometry.DegreeToRadian(float.Parse(args[3]));
                    camrotate = new Vector3(x, y, z);
                }
                break;

                case "transition":
                    viewer.ReadyTransition();
                    break;

                case "wait":
                    // 次の待ち時間を設定する.
                    nextperiod += int.Parse(args[1]);
                    return(true);

                default:
                    break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("error: " + e.Message);
            }

            return(false);
        }
Пример #2
0
        public void FrameMove()
        {
            if (keysEnabled[keySave] && keys[keySave])
            {
                keysEnabled[keySave] = false;
                viewer.SaveToBitmap("sample.bmp");
            }
            if (keysEnabled[keyMotion] && keys[keyMotion])
            {
                keysEnabled[keyMotion] = false;
                viewer.MotionEnabled   = !viewer.MotionEnabled;
            }
            if (keysEnabled[keyShadow] && keys[keyShadow])
            {
                keysEnabled[keyShadow] = false;
                viewer.ShadowShown     = !viewer.ShadowShown;
            }
            if (keysEnabled[keySprite] && keys[keySprite])
            {
                keysEnabled[keySprite] = false;
                viewer.SpriteShown     = !viewer.SpriteShown;
            }
            if (keysEnabled[keyFigure] && keys[keyFigure])
            {
                keysEnabled[keyFigure] = false;
                viewer.NextFigure();
            }
            if (keysEnabled[keyDelete] && keys[keyDelete])
            {
                keysEnabled[keyDelete] = false;

                if (keys[(int)Keys.ControlKey])
                {
                    viewer.ClearFigureList();
                }
                else
                {
                    viewer.RemoveSelectedFigure();
                }
            }
            if (keysEnabled[keyCameraReset] && keys[keyCameraReset])
            {
                keysEnabled[keyCameraReset] = false;
                viewer.Camera.Reset();
                viewer.Camera.SetTranslation(0.0f, +10.0f, +44.0f);
            }
            if (keysEnabled[keyCenter] && keys[keyCenter])
            {
                keysEnabled[keyCenter] = false;
                viewer.Camera.ResetTranslation();
                Figure fig;
                if (viewer.TryGetFigure(out fig))
                {
                    viewer.Camera.SetCenter(fig.Center + fig.Translation);
                }
            }

            float keyL    = 0.0f;
            float keyR    = 0.0f;
            float keyU    = 0.0f;
            float keyD    = 0.0f;
            float keyPush = 0.0f;
            float keyPull = 0.0f;
            float keyZRol = 0.0f;

            if (keys[(int)Keys.Left])
            {
                keyL = 2.0f;
            }
            if (keys[(int)Keys.Right])
            {
                keyR = 2.0f;
            }
            if (keys[(int)Keys.PageUp])
            {
                keyU = 2.0f;
            }
            if (keys[(int)Keys.PageDown])
            {
                keyD = 2.0f;
            }
            if (keys[(int)Keys.Up])
            {
                keyPush = 1.0f;
            }
            if (keys[(int)Keys.Down])
            {
                keyPull = 1.0f;
            }
            if (keys[(int)Keys.A])
            {
                keyZRol = -2.0f;
            }
            if (keys[(int)Keys.D])
            {
                keyZRol = +2.0f;
            }

            if (Control.ModifierKeys == Keys.Shift)
            {
                Figure fig;
                if (viewer.TryGetFigure(out fig))
                {
                    fig.Move(keyR - keyL, keyU - keyD, keyPull - keyPush);
                }
            }
            else
            {
                viewer.Camera.Move(keyR - keyL, keyU - keyD, keyPull - keyPush);
                viewer.Camera.RotZ(DegreeToRadian(keyZRol));
            }
        }