예제 #1
0
파일: Game1.cs 프로젝트: himapo/ccm
 /// <summary>
 /// LoadContent はゲームごとに 1 回呼び出され、ここですべてのコンテンツを
 /// 読み込みます。
 /// </summary>
 protected override void LoadContent()
 {
     //モデルをパイプラインより読み込み
     model = MMDXCore.Instance.LoadModel("Miku", Content);
     //サンプルモデルはカリングを行わない。(他のモデルはカリングを行う)
     model.Culling = false;
     //モーションをパイプラインより読み込み
     motion = MMDXCore.Instance.LoadMotion("TrueMyHeart", Content);
     //モデルにモーションをセット
     model.AnimationPlayer.AddMotion("TrueMyHeart", motion, MMDMotionTrackOptions.UpdateWhenStopped);
 }
예제 #2
0
파일: Demo5.cs 프로젝트: himapo/ccm
 protected override void LoadContent()
 {
     //モデルの読み込み
     model = SlimMMDXCore.Instance.LoadModelFromFile("models/Miku.pmd");
     //モーションの読み込み
     motion = SlimMMDXCore.Instance.LoadMotionFromFile("motions/TrueMyHeart.vmd");
     //モーションのセット
     model.AnimationPlayer.AddMotion("TrueMyHeart", motion, MMDMotionTrackOptions.UpdateWhenStopped);
     //モーション終了時のコールバックをセット
     model.AnimationPlayer["TrueMyHeart"].OnMotionEnd += new Action<string>(GotSays);
     base.LoadContent();
 }
예제 #3
0
파일: Game1.cs 프로젝트: himapo/ccm
 /// <summary>
 /// LoadContent はゲームごとに 1 回呼び出され、ここですべてのコンテンツを
 /// 読み込みます。
 /// </summary>
 protected override void LoadContent()
 {
     //モデルの読み込み
     model = MMDXCore.Instance.LoadModel("Miku", Content);
     //サンプルモデルはカリングを行わない。(他のモデルはカリングを行う)
     model.Culling = false;
     //モーションの読み込み
     motion = MMDXCore.Instance.LoadMotion("TrueMyHeart", Content);
     //モーションのセット
     model.AnimationPlayer.AddMotion("TrueMyHeart", motion, MMDMotionTrackOptions.UpdateWhenStopped);
     //モーション終了時のコールバックをセット
     model.AnimationPlayer["TrueMyHeart"].OnMotionEnd+=new Action<string>(GotSays);
 }
예제 #4
0
파일: Demo2.cs 프로젝트: himapo/ccm
 protected override void LoadContent()
 {
     //モデルの読み込み
     model = SlimMMDXCore.Instance.LoadModelFromFile("models/Miku-metal.pmd");
     //モーションの読み込み
     motion = SlimMMDXCore.Instance.LoadMotionFromFile("motions/TrueMyHeart.vmd");
     //モーションの登録
     model.AnimationPlayer.AddMotion("TrueMyHeart", motion, MMDMotionTrackOptions.UpdateWhenStopped);
     //スクリーンマネージャの作成
     screenManager = new ScreenManager(TargetControl.Width, TargetControl.Height);
     //スクリーンマネージャの登録
     SlimMMDXCore.Instance.ScreenManager = screenManager;
     CreateScreenVertex();
     base.LoadContent();
 }
예제 #5
0
파일: Demo6.cs 프로젝트: himapo/ccm
 protected override void LoadContent()
 {
     //モデルの読み込み
     model = SlimMMDXCore.Instance.LoadModelFromFile("models/Miku.pmd");
     //モーションの読み込み
     motion1 = SlimMMDXCore.Instance.LoadMotionFromFile("motions/LeftHand.vmd");
     motion2 = SlimMMDXCore.Instance.LoadMotionFromFile("motions/RightBye.vmd");
     //モーションのセット
     model.AnimationPlayer.AddMotion("LeftHand", motion1, MMDMotionTrackOptions.UpdateWhenStopped | MMDMotionTrackOptions.ExtendedMode);
     model.AnimationPlayer.AddMotion("RightBye", motion2, MMDMotionTrackOptions.UpdateWhenStopped | MMDMotionTrackOptions.ExtendedMode);
     //最初のブレンディングはLeftHandの方を100%にする
     model.AnimationPlayer["LeftHand"].BlendingFactor = 1f;//最初から1なのだが、分り易くするために代入
     model.AnimationPlayer["RightBye"].BlendingFactor = 0f;//ブレンディングファクターを0にする。
     //ループ再生
     model.AnimationPlayer["LeftHand"].Start(true);
     model.AnimationPlayer["RightBye"].Start(true);
     base.LoadContent();
 }
예제 #6
0
파일: Demo3.cs 프로젝트: himapo/ccm
 protected override void LoadContent()
 {
     //モデルの読み込み
     model = SlimMMDXCore.Instance.LoadModelFromFile("models/Miku.pmd");
     //カメラとライトモーションの読み込み
     camera = SlimMMDXCore.Instance.LoadMotionFromFile("motions/Camera.vmd");
     light = SlimMMDXCore.Instance.LoadMotionFromFile("motions/Light.vmd");
     //ステージプレイヤーにモーションをセット
     SlimMMDXCore.Instance.StageAnimationPlayer.AddMotion("Camera", camera);
     SlimMMDXCore.Instance.StageAnimationPlayer.AddMotion("Light", light);
     //ループ再生
     SlimMMDXCore.Instance.StageAnimationPlayer["Camera"].Start(true);
     SlimMMDXCore.Instance.StageAnimationPlayer["Light"].Start(true);
     //エッジマネージャの作成
     edgeManager = new EdgeManager(TargetControl.Width, TargetControl.Height);
     //エッジマネージャの登録
     SlimMMDXCore.Instance.EdgeManager = edgeManager;
     base.LoadContent();
 }
예제 #7
0
파일: Game1.cs 프로젝트: himapo/ccm
 /// <summary>
 /// LoadContent はゲームごとに 1 回呼び出され、ここですべてのコンテンツを
 /// 読み込みます。
 /// </summary>
 protected override void LoadContent()
 {
     //モデルの読み込み
     model = MMDXCore.Instance.LoadModel("Miku", Content);
     //サンプルモデルはカリングを行わない。(他のモデルはカリングを行う)
     model.Culling = false;
     //カメラとライトモーションの読み込み
     camera = MMDXCore.Instance.LoadMotion("Camera", Content);
     light = MMDXCore.Instance.LoadMotion("Light", Content);
     //ステージプレイヤーにモーションをセット
     MMDXCore.Instance.StageAnimationPlayer.AddMotion("Camera", camera);
     MMDXCore.Instance.StageAnimationPlayer.AddMotion("Light", light);
     //ループ再生
     MMDXCore.Instance.StageAnimationPlayer["Camera"].Start(true);
     MMDXCore.Instance.StageAnimationPlayer["Light"].Start(true);
     //エッジマネージャの作成
     edgeManager = new EdgeManager(Window, GraphicsDevice);
     //エッジマネージャの登録
     MMDXCore.Instance.EdgeManager = edgeManager;
 }
예제 #8
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="motionData">モーションデータ</param>
 /// <param name="options">トラックオプション</param>
 public MMDMotionTrack(MMDMotion motionData, MMDMotionTrackOptions options)
 {
     Options = options;
     //ボーンの配列抜き出し
     boneFrames = motionData.BoneFrames;
     //表情の配列抜き出し
     faceFrames = motionData.FaceFrames;
     //モーションのFPS=30
     FramePerSecond = DefaultFPS;
     //差分一覧を作成
     subPoses = new Dictionary<string, SQTTransform>(motionData.BoneFrames.Count);
     //表情一覧を作成
     faces = new Dictionary<string, float>(motionData.FaceFrames.Count);
     //現在の再生位置を設定&最大フレーム数のチェック
     foreach (var it in motionData.BoneFrames)
     {
         bonePos.Add(it.Key, 0);
         foreach (var it2 in it.Value)
         {
             if (it2.FrameNo > m_MaxFrame)
                 m_MaxFrame = it2.FrameNo;
         }
     }
     foreach (var it in motionData.FaceFrames)
     {
         facePos.Add(it.Key, 0);
         foreach (var it2 in it.Value)
         {
             if (it2.FrameNo > m_MaxFrame)
                 m_MaxFrame = it2.FrameNo;
         }
     }
 }
예제 #9
0
        public MMDMotion Load(string filename, float scale)
        {
            filename = Path.GetFullPath(filename);
            MikuMikuDance.Motion.Motion2.MMDMotion2 input;
            input = MotionManager.Read(filename, CoordinateType.RightHandedCoordinate, scale) as MikuMikuDance.Motion.Motion2.MMDMotion2;
            if (input == null)
                return null;
            MMDMotion result = new MMDMotion();
            //ボーンモーションデータの変換
            MMDBoneKeyFrame[] BoneFrames = new MMDBoneKeyFrame[input.Motions.LongLength];
            for (long i = 0; i < input.Motions.LongLength; i++)
            {
                BoneFrames[i] = new MMDBoneKeyFrame();
                BoneFrames[i].BoneName = input.Motions[i].BoneName;
                BoneFrames[i].FrameNo = input.Motions[i].FrameNo;

                BoneFrames[i].Curve = new BezierCurve[4];
                for (int j = 0; j < BoneFrames[i].Curve.Length; j++)
                {
                    BezierCurve curve = new BezierCurve();
                    curve.v1 = new Vector2((float)input.Motions[i].Interpolation[0][0][j] / 128f, (float)input.Motions[i].Interpolation[0][1][j] / 128f);
                    curve.v2 = new Vector2((float)input.Motions[i].Interpolation[0][2][j] / 128f, (float)input.Motions[i].Interpolation[0][3][j] / 128f);
                    BoneFrames[i].Curve[j] = curve;
                }
                BoneFrames[i].Scales = new Vector3(1, 1, 1);
                BoneFrames[i].Location = new Vector3(input.Motions[i].Location[0], input.Motions[i].Location[1], input.Motions[i].Location[2]);
                BoneFrames[i].Quatanion = new Quaternion(input.Motions[i].Quatanion[0], input.Motions[i].Quatanion[1], input.Motions[i].Quatanion[2], input.Motions[i].Quatanion[3]);
                BoneFrames[i].Quatanion.Normalize();
            }
            result.BoneFrames = MotionHelper.SplitBoneMotion(BoneFrames);
            //表情モーションの変換
            MMDFaceKeyFrame[] FaceFrames = new MMDFaceKeyFrame[input.FaceMotions.LongLength];
            for (long i = 0; i < input.FaceMotions.Length; i++)
            {
                FaceFrames[i] = new MMDFaceKeyFrame();
                FaceFrames[i].Rate = input.FaceMotions[i].Rate;
                FaceFrames[i].FaceName = input.FaceMotions[i].FaceName;
                FaceFrames[i].FrameNo = input.FaceMotions[i].FrameNo;
                float temp = input.FaceMotions[i].FrameNo;
            }
            result.FaceFrames = MotionHelper.SplitFaceMotion(FaceFrames);
            //カメラモーションの変換
            MMDCameraKeyFrame[] CameraFrames = new MMDCameraKeyFrame[input.CameraMotions.LongLength];
            for (long i = 0; i < input.CameraMotions.Length; i++)
            {
                CameraFrames[i] = new MMDCameraKeyFrame();
                CameraFrames[i].FrameNo = input.CameraMotions[i].FrameNo;
                CameraFrames[i].Length = input.CameraMotions[i].Length;
                CameraFrames[i].Location = MMDXMath.ToVector3(input.CameraMotions[i].Location);
                CameraFrames[i].Quatanion = MMDXMath.CreateQuaternionFromYawPitchRoll(input.CameraMotions[i].Rotate[1], input.CameraMotions[i].Rotate[0], input.CameraMotions[i].Rotate[2]);
                CameraFrames[i].ViewAngle = MathHelper.ToRadians(input.CameraMotions[i].ViewingAngle);
                CameraFrames[i].Curve = new BezierCurve[6];
                for (int j = 0; j < CameraFrames[i].Curve.Length; j++)
                {
                    BezierCurve curve = new BezierCurve();
                    curve.v1 = new Vector2((float)input.CameraMotions[i].Interpolation[j][0] / 128f, (float)input.CameraMotions[i].Interpolation[j][2] / 128f);
                    curve.v2 = new Vector2((float)input.CameraMotions[i].Interpolation[j][1] / 128f, (float)input.CameraMotions[i].Interpolation[j][3] / 128f);
                    CameraFrames[i].Curve[j] = curve;
                }
            }
            result.CameraFrames = new List<MMDCameraKeyFrame>(CameraFrames);
            //ライトモーションの変換
            MMDLightKeyFrame[] LightFrames = new MMDLightKeyFrame[input.LightMotions.LongLength];
            for (long i = 0; i < input.LightMotions.Length; i++)
            {
                LightFrames[i] = new MMDLightKeyFrame();
                LightFrames[i].FrameNo = input.LightMotions[i].FrameNo;
                LightFrames[i].Color = MMDXMath.ToVector3(input.LightMotions[i].Color);
                LightFrames[i].Location = MMDXMath.ToVector3(input.LightMotions[i].Location);
            }
            result.LightFrames = new List<MMDLightKeyFrame>(LightFrames);
            //変換したデータを返却
            return result;

        }
예제 #10
0
 /// <summary>
 /// モーションの追加
 /// </summary>
 /// <param name="motionKey">モーション識別用のモーション名</param>
 /// <param name="motionData">MikuMikuDance MotionData</param>
 /// <param name="options">トラックオプション</param>
 public void AddMotion(string motionKey, MMDMotion motionData, MMDMotionTrackOptions options)
 {
     motionTracks.Add(motionKey, new MMDMotionTrack(motionData, options));
 }
예제 #11
0
파일: StagePlayer.cs 프로젝트: himapo/ccm
 /// <summary>
 /// モーションの追加
 /// </summary>
 /// <param name="motionKey">モーション識別用のモーション名</param>
 /// <param name="motionData">MikuMikuDance MotionData</param>
 public void AddMotion(string motionKey, MMDMotion motionData)
 {
     motionTracks.Add(motionKey, new MMDStageMotionTrack(motionData));
 }
예제 #12
0
파일: Game1.cs 프로젝트: himapo/ccm
 /// <summary>
 /// LoadContent はゲームごとに 1 回呼び出され、ここですべてのコンテンツを
 /// 読み込みます。
 /// </summary>
 protected override void LoadContent()
 {
     //モデルをパイプラインより読み込み
     model = MMDXCore.Instance.LoadModel("Miku-metal", Content);
     //サンプルモデルはカリングを行わない。(他のモデルはカリングを行う)
     model.Culling = false;
     //モーションをパイプラインより読み込み
     motion = MMDXCore.Instance.LoadMotion("TrueMyHeart", Content);
     //モデルにモーションをセット
     model.AnimationPlayer.AddMotion("TrueMyHeart", motion, MMDMotionTrackOptions.UpdateWhenStopped);
     //エッジマネージャの作成
     edgeManager = new EdgeManager(Window, GraphicsDevice);
     //エッジマネージャの登録
     MMDXCore.Instance.EdgeManager = edgeManager;
     //物理エンジンデバッグの作成
     debugDraw = new PhysicsDebugDraw(GraphicsDevice);
     //MMDXにセット
     MMDXCore.Instance.Physics.DebugDrawer = debugDraw;
     //MMDXのProfileイベントとtimeRulerとを接続
     MMDXProfiler.MMDBeginMark += (bar, name, color) => timerRuler.BeginMark(bar, name, color);
     MMDXProfiler.MMDEndMark += (bar, name) => timerRuler.EndMark(bar, name);
 }