예제 #1
0
    /// <summary>Qumarion側のボーン情報と親ボーンを指定してインスタンスを初期化します。</summary>
    /// <param name="bone">Qumarion側のボーン</param>
    /// <param name="boneType">Qumarion側のボーンが標準ボーンのどれに該当するか</param>
    /// <param name="parent">親ボーン(ルートのボーンを生成する場合nullを指定)</param>
    public QumaBone2Humanoid(Bone bone, StandardPSBones boneType, QumaBone2Humanoid parent)
    {
        _bone   = bone;
        _parent = parent;

        QumaBoneType = boneType;
        //StandardPSBones -> HumanBodyBoneの対応付けがあれば登録し、無い場合は無いことを確認。
        try
        {
            HumanBodyBone        = QmBoneToAnimatorBone.GetHumanBodyBone(boneType);
            IsValidHumanBodyBone = true;
        }
        catch (KeyNotFoundException)
        {
            HumanBodyBone        = HumanBodyBones.Hips;
            IsValidHumanBodyBone = false;
        }

        InitialRotation = MatrixToQuaternionWithCoordinateModify(_bone.InitialLocalMatrix);

        //ゼロ回転状態での固定座標軸を参照するため親のワールド座標を確認: ルート(Hips)はワールド座標直下。
        Matrix4f initMat = (_bone.Parent != null) ?
                           _bone.Parent.InitialWorldMatrix :
                           Matrix4f.Unit;


        //疑似座標系の初期化: Qumarion側の行列は右手系(左-上-前)なので正負補正が必要な事に注意。
        //NOTE: Qumarionの場合ルートが原点、回転は無しとみなすと次のように簡単化される
        xAxis = new Vector3(initMat.M11, -initMat.M21, -initMat.M31);
        yAxis = new Vector3(-initMat.M12, initMat.M22, initMat.M32);
        zAxis = new Vector3(-initMat.M13, initMat.M23, initMat.M33);

        //再帰的に子ボーンを初期化。
        _childs = bone
                  .Childs
                  .Select(b => new QumaBone2Humanoid(b, StandardPSBonesUtil.GetStandardPSBone(b.Name), this))
                  .ToArray();
    }
예제 #2
0
        /// <summary>Qumarion側のボーン情報と親ボーンを指定してインスタンスを初期化します。</summary>
        /// <param name="bone">Qumarion側のボーン</param>
        /// <param name="boneType">Qumarion側のボーンが標準ボーンのどれに該当するか</param>
        /// <param name="parent">親ボーン(ルートのボーンを生成する場合nullを指定)</param>
        public QumaBone2MikuMikuMoving(Bone bone, StandardPSBones boneType, QumaBone2MikuMikuMoving parent)
        {
            _bone   = bone;
            _parent = parent;

            QumaBoneType = boneType;
            //StandardPSBones -> MMDBoneの対応確認
            try
            {
                MMDBone     = QumaBone2MMDBone.GetMMDBone(boneType);
                IsValidBone = true;
            }
            catch (KeyNotFoundException)
            {
                MMDBone     = MMDStandardBone.Hip;
                IsValidBone = false;
            }

            InitialRotation = CreateQuaternion(_bone.InitialLocalMatrix);

            //ゼロ回転状態での固定座標軸を参照するため親のワールド座標を確認: ルート(Hips)はワールド座標直下。
            Matrix4f initMat = (_bone.Parent != null) ?
                               _bone.Parent.InitialWorldMatrix :
                               Matrix4f.Unit;

            //疑似座標系の初期化: QumarionもMMMも右手系(左-上-前)で一緒なのでほぼそのまま使ってOK
            xAxis = new Vector3(initMat.M11, initMat.M21, initMat.M31);
            yAxis = new Vector3(initMat.M12, initMat.M22, initMat.M32);
            zAxis = new Vector3(initMat.M13, initMat.M23, initMat.M33);

            //再帰的に子ボーンを初期化。
            _childs = bone
                      .Childs
                      .Select(b => new QumaBone2MikuMikuMoving(b, StandardPSBonesUtil.GetStandardPSBone(b.Name), this))
                      .ToArray();
        }
예제 #3
0
 //public static string GetMMDBoneName(StandardPSBones qumaBone) => _quma2mmd[qumaBone];
 public static MMDStandardBone GetMMDBone(StandardPSBones qumaBone) => _quma2mmd[qumaBone];
 public static HumanBodyBones GetHumanBodyBone(StandardPSBones qmBone)
 {
     return(_qm2human[qmBone]);
 }