Beispiel #1
0
        public HumanPose(Stream stream, uint version)
        {
            BinaryReader reader = new BinaryReader(stream);

            m_RootX          = new xform(stream, version);
            m_LookAtPosition = version < AssetCabinet.VERSION_5_4_1 ? (object)reader.ReadVector4() : (object)reader.ReadVector3();
            m_LookAtWeight   = reader.ReadVector4();

            int numGoals = reader.ReadInt32();

            m_GoalArray = new List <HumanGoal>(numGoals);
            for (int i = 0; i < numGoals; i++)
            {
                m_GoalArray.Add(new HumanGoal(stream, version));
            }

            m_LeftHandPose  = new HandPose(stream, version);
            m_RightHandPose = new HandPose(stream, version);

            int numDoFs = reader.ReadInt32();

            m_DoFArray = reader.ReadSingleArray(numDoFs);

            if (version >= AssetCabinet.VERSION_5_0_0)
            {
                int numTDof = reader.ReadInt32();
                m_TDoFArray = new object[numTDof];
                for (int i = 0; i < numTDof; i++)
                {
                    m_TDoFArray[i] = version >= AssetCabinet.VERSION_5_4_1 ? (object)reader.ReadVector3() : (object)reader.ReadVector4();
                }
            }
        }
Beispiel #2
0
        public Handle(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            m_X = new xform(stream);
            m_ParentHumanIndex = reader.ReadUInt32();
            m_ID = reader.ReadUInt32();
        }
Beispiel #3
0
        public void LoadFrom(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            m_X       = new xform(stream);
            m_WeightT = reader.ReadSingle();
            m_WeightR = reader.ReadSingle();
        }
Beispiel #4
0
        public void LoadFrom(Stream stream, uint version)
        {
            BinaryReader reader = new BinaryReader(stream);

            m_DeltaPose = new HumanPose(stream, version);
            m_StartX    = new xform(stream, version);
            if (version >= AssetCabinet.VERSION_5_5_0)
            {
                m_StopX = new xform(stream, version);
            }
            m_LeftFootStartX  = new xform(stream, version);
            m_RightFootStartX = new xform(stream, version);
            if (version < AssetCabinet.VERSION_5_0_0)
            {
                m_MotionStartX = new xform(stream, version);
                m_MotionStopX  = new xform(stream, version);
            }
            m_AverageSpeed        = version >= AssetCabinet.VERSION_5_4_1 ? (object)reader.ReadVector3() : (object)reader.ReadVector4();
            m_Clip                = new Clip(stream, version);
            m_StartTime           = reader.ReadSingle();
            m_StopTime            = reader.ReadSingle();
            m_OrientationOffsetY  = reader.ReadSingle();
            m_Level               = reader.ReadSingle();
            m_CycleOffset         = reader.ReadSingle();
            m_AverageAngularSpeed = reader.ReadSingle();

            int numIndices = reader.ReadInt32();

            m_IndexArray = reader.ReadInt32Array(numIndices);

            int numDeltas = reader.ReadInt32();

            m_ValueArrayDelta = new List <ValueDelta>(numDeltas);
            for (int i = 0; i < numDeltas; i++)
            {
                m_ValueArrayDelta.Add(new ValueDelta(stream));
            }
            if (version >= AssetCabinet.VERSION_5_0_0)
            {
                m_ValueArrayReferencePose = reader.ReadSingleArray(reader.ReadInt32());
            }

            m_Mirror               = reader.ReadBoolean();
            m_LoopTime             = reader.ReadBoolean();
            m_LoopBlend            = reader.ReadBoolean();
            m_LoopBlendOrientation = reader.ReadBoolean();
            m_LoopBlendPositionY   = reader.ReadBoolean();
            m_LoopBlendPositionXZ  = reader.ReadBoolean();
            if (version >= AssetCabinet.VERSION_5_5_0)
            {
                m_StartAtOrigin = reader.ReadBoolean();
            }
            m_KeepOriginalOrientation = reader.ReadBoolean();
            m_KeepOriginalPositionY   = reader.ReadBoolean();
            m_KeepOriginalPositionXZ  = reader.ReadBoolean();
            m_HeightFromFeet          = reader.ReadBoolean();
            stream.Position          += version < AssetCabinet.VERSION_5_5_0 ? 2 : 1;
        }
Beispiel #5
0
        public void AddBone(Transform parent, Transform bone)
        {
            string parentPath   = BonePath(parent.m_GameObject.instance.m_Name);
            string bonePath     = parentPath + "/" + bone.m_GameObject.instance.m_Name;
            uint   bonePathHash = Animator.StringToHash(bonePath);
            uint   boneHash     = Animator.StringToHash(bone.m_GameObject.instance.m_Name);

            int idx;

            for (idx = 0; idx < m_TOS.Count; idx++)
            {
                var data = m_TOS[idx];
                if (data.Key > bonePathHash)
                {
                    break;
                }
            }
            m_TOS.Insert(idx, new KeyValuePair <uint, string>(bonePathHash, bonePath));

            uint parentHash = BoneHash(parent.m_GameObject.instance.m_Name);

            for (int i = 0; i < m_Avatar.m_AvatarSkeleton.m_ID.Count; i++)
            {
                if (m_Avatar.m_AvatarSkeleton.m_ID[i] == parentHash)
                {
                    int cIdx = i + BoneIndex(parent, bone);
                    m_Avatar.m_AvatarSkeleton.m_Node.Insert(cIdx, new Node(i, -1));
                    m_Avatar.m_AvatarSkeleton.m_ID.Insert(cIdx, bonePathHash);
                    m_Avatar.m_SkeletonNameIDArray.Insert(cIdx, boneHash);
                    Matrix     m = Matrix.Transpose(Matrix.Invert(Transform.WorldTransform(bone)));
                    Vector3    t, s;
                    Quaternion q;
                    m.Decompose(out s, out q, out t);
                    xform boneXform = new xform(new Vector4(t, 0), q, new Vector4(s, 1));
                    m_Avatar.m_AvatarSkeletonPose.m_X.Insert(cIdx, boneXform);
                    m_Avatar.m_DefaultPose.m_X.Insert(cIdx, boneXform);

                    for (int j = cIdx + 1; j < m_Avatar.m_AvatarSkeleton.m_ID.Count; j++)
                    {
                        if (m_Avatar.m_AvatarSkeleton.m_Node[j].m_ParentId >= cIdx)
                        {
                            m_Avatar.m_AvatarSkeleton.m_Node[j].m_ParentId++;
                        }
                    }
                    break;
                }
            }
            if (m_TOS.Count != m_Avatar.m_AvatarSkeleton.m_Node.Count)
            {
                Report.ReportLog("Warning! Parent Transform " + parent.m_GameObject.instance.m_Name + " not found in Avatar member m_ID");
            }
        }
Beispiel #6
0
        public HumanGoal(Stream stream, uint version)
        {
            BinaryReader reader = new BinaryReader(stream);

            m_X       = new xform(stream, version);
            m_WeightT = reader.ReadSingle();
            m_WeightR = reader.ReadSingle();
            if (version >= AssetCabinet.VERSION_5_0_0)
            {
                m_HintT       = version >= AssetCabinet.VERSION_5_4_1 ? (object)reader.ReadVector3() : (object)reader.ReadVector4();
                m_HintWeightT = reader.ReadSingle();
            }
        }
Beispiel #7
0
 public HumanGoal(uint version)
 {
     if (version < AssetCabinet.VERSION_5_4_1)
     {
         m_X     = new xform(new Vector4(), Quaternion.Identity, new Vector4(1, 1, 1, 1));
         m_HintT = new Vector4();
     }
     else
     {
         m_X     = new xform(new Vector3(), Quaternion.Identity, new Vector3(1, 1, 1));
         m_HintT = new Vector3();
     }
 }
Beispiel #8
0
        public Collider(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            m_X           = new xform(stream);
            m_Type        = reader.ReadUInt32();
            m_XMotionType = reader.ReadUInt32();
            m_YMotionType = reader.ReadUInt32();
            m_ZMotionType = reader.ReadUInt32();
            m_MinLimitX   = reader.ReadSingle();
            m_MaxLimitX   = reader.ReadSingle();
            m_MaxLimitY   = reader.ReadSingle();
            m_MaxLimitZ   = reader.ReadSingle();
        }
Beispiel #9
0
        public void LoadFrom(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            m_GrabX = new xform(stream);

            int numDoFs = reader.ReadInt32();

            m_DoFArray = reader.ReadSingleArray(numDoFs);

            m_Override  = reader.ReadSingle();
            m_CloseOpen = reader.ReadSingle();
            m_InOut     = reader.ReadSingle();
            m_Grab      = reader.ReadSingle();
        }
Beispiel #10
0
        public HandPose(Stream stream, uint version)
        {
            BinaryReader reader = new BinaryReader(stream);

            m_GrabX = new xform(stream, version);

            int numDoFs = reader.ReadInt32();

            m_DoFArray = reader.ReadSingleArray(numDoFs);

            m_Override  = reader.ReadSingle();
            m_CloseOpen = reader.ReadSingle();
            m_InOut     = reader.ReadSingle();
            m_Grab      = reader.ReadSingle();
        }
Beispiel #11
0
        public AvatarConstant(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            m_AvatarSkeleton     = new Skeleton(stream);
            m_AvatarSkeletonPose = new SkeletonPose(stream);
            m_DefaultPose        = new SkeletonPose(stream);

            int numIDs = reader.ReadInt32();

            m_SkeletonNameIDArray = new List <uint>(numIDs);
            for (int i = 0; i < numIDs; i++)
            {
                m_SkeletonNameIDArray.Add(reader.ReadUInt32());
            }

            m_Human = new Human(stream);

            int numIndexes = reader.ReadInt32();

            m_HumanSkeletonIndexArray = new List <int>(numIndexes);
            for (int i = 0; i < numIndexes; i++)
            {
                m_HumanSkeletonIndexArray.Add(reader.ReadInt32());
            }

            int numReverseIndexes = reader.ReadInt32();

            m_HumanSkeletonReverseIndexArray = new List <int>(numReverseIndexes);
            for (int i = 0; i < numReverseIndexes; i++)
            {
                m_HumanSkeletonReverseIndexArray.Add(reader.ReadInt32());
            }

            m_RootMotionBoneIndex    = reader.ReadInt32();
            m_RootMotionBoneX        = new xform(stream);
            m_RootMotionSkeleton     = new Skeleton(stream);
            m_RootMotionSkeletonPose = new SkeletonPose(stream);

            int numMotionIndexes = reader.ReadInt32();

            m_RootMotionSkeletonIndexArray = new List <int>(numMotionIndexes);
            for (int i = 0; i < numMotionIndexes; i++)
            {
                m_RootMotionSkeletonIndexArray.Add(reader.ReadInt32());
            }
        }
Beispiel #12
0
        public void LoadFrom(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            m_DeltaPose           = new HumanPose(stream);
            m_StartX              = new xform(stream);
            m_LeftFootStartX      = new xform(stream);
            m_RightFootStartX     = new xform(stream);
            m_MotionStartX        = new xform(stream);
            m_MotionStopX         = new xform(stream);
            m_AverageSpeed        = reader.ReadVector4();
            m_Clip                = new Clip(stream);
            m_StartTime           = reader.ReadSingle();
            m_StopTime            = reader.ReadSingle();
            m_OrientationOffsetY  = reader.ReadSingle();
            m_Level               = reader.ReadSingle();
            m_CycleOffset         = reader.ReadSingle();
            m_AverageAngularSpeed = reader.ReadSingle();

            int numIndices = reader.ReadInt32();

            m_IndexArray = reader.ReadInt32Array(numIndices);

            int numDeltas = reader.ReadInt32();

            m_ValueArrayDelta = new List <ValueDelta>(numDeltas);
            for (int i = 0; i < numDeltas; i++)
            {
                m_ValueArrayDelta.Add(new ValueDelta(stream));
            }

            m_Mirror                  = reader.ReadBoolean();
            m_LoopTime                = reader.ReadBoolean();
            m_LoopBlend               = reader.ReadBoolean();
            m_LoopBlendOrientation    = reader.ReadBoolean();
            m_LoopBlendPositionY      = reader.ReadBoolean();
            m_LoopBlendPositionXZ     = reader.ReadBoolean();
            m_KeepOriginalOrientation = reader.ReadBoolean();
            m_KeepOriginalPositionY   = reader.ReadBoolean();
            m_KeepOriginalPositionXZ  = reader.ReadBoolean();
            m_HeightFromFeet          = reader.ReadBoolean();
            reader.ReadBytes(2);
        }
Beispiel #13
0
 public HumanPose(uint version)
 {
     if (version < AssetCabinet.VERSION_5_4_1)
     {
         m_RootX          = new xform(new Vector4(), Quaternion.Identity, new Vector4(1, 1, 1, 1));
         m_LookAtPosition = new Vector4();
     }
     else
     {
         m_RootX          = new xform(new Vector3(), Quaternion.Identity, new Vector3(1, 1, 1));
         m_LookAtPosition = new Vector3();
     }
     m_LookAtWeight  = new Vector4();
     m_GoalArray     = new List <HumanGoal>(new HumanGoal[] { new HumanGoal(version), new HumanGoal(version), new HumanGoal(version), new HumanGoal(version) });
     m_LeftHandPose  = new HandPose(version);
     m_RightHandPose = new HandPose(version);
     m_DoFArray      = new float[52];
     m_TDoFArray     = new object[7];
 }
Beispiel #14
0
        public ClipMuscleConstant(uint version)
        {
            m_DeltaPose = new HumanPose(version);
            if (version >= AssetCabinet.VERSION_5_4_1)
            {
                m_StartX = new xform(new Vector3(), Quaternion.Identity, new Vector3(1, 1, 1));
                if (version >= AssetCabinet.VERSION_5_5_0)
                {
                    m_StopX = new xform(new Vector3(), Quaternion.Identity, new Vector3(1, 1, 1));
                }
                m_LeftFootStartX  = new xform(new Vector3(), Quaternion.Identity, new Vector3(1, 1, 1));
                m_RightFootStartX = new xform(new Vector3(), Quaternion.Identity, new Vector3(1, 1, 1));
                m_AverageSpeed    = new Vector3();
            }
            else
            {
                m_StartX          = new xform(new Vector4(), Quaternion.Identity, new Vector4(1, 1, 1, 1));
                m_LeftFootStartX  = new xform(new Vector4(), Quaternion.Identity, new Vector4(1, 1, 1, 1));
                m_RightFootStartX = new xform(new Vector4(), Quaternion.Identity, new Vector4(1, 1, 1, 1));
                if (version < AssetCabinet.VERSION_5_0_0)
                {
                    m_MotionStartX = new xform(new Vector4(), Quaternion.Identity, new Vector4(1, 1, 1, 1));
                    m_MotionStopX  = new xform(new Vector4(), Quaternion.Identity, new Vector4(1, 1, 1, 1));
                }
                m_AverageSpeed = new Vector4();
            }
            m_Clip = new Clip();

            int indexArrayLength =
                version < AssetCabinet.VERSION_5_0_0 ? 134 :
                version < AssetCabinet.VERSION_5_6_2 ? 155
                                : 161;

            m_IndexArray = new int[indexArrayLength];
            for (int i = 0; i < m_IndexArray.Length; i++)
            {
                m_IndexArray[i] = -1;
            }

            m_ValueArrayDelta         = new List <ValueDelta>();
            m_ValueArrayReferencePose = new float[0];
        }
Beispiel #15
0
        public void LoadFrom(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            m_RootX          = new xform(stream);
            m_LookAtPosition = reader.ReadVector4();
            m_LookAtWeight   = reader.ReadVector4();

            int numGoals = reader.ReadInt32();

            m_GoalArray = new List <HumanGoal>(numGoals);
            for (int i = 0; i < numGoals; i++)
            {
                m_GoalArray.Add(new HumanGoal(stream));
            }

            m_LeftHandPose  = new HandPose(stream);
            m_RightHandPose = new HandPose(stream);

            int numDoFs = reader.ReadInt32();

            m_DoFArray = reader.ReadSingleArray(numDoFs);
        }
Beispiel #16
0
        public void AddBone(Transform parent, Transform bone)
        {
            string bonePath     = bone.GetTransformPath();
            uint   bonePathHash = Animator.StringToHash(bonePath);
            uint   boneHash     = Animator.StringToHash(bone.m_GameObject.instance.m_Name);

            int idx;

            for (idx = 0; idx < m_TOS.Count; idx++)
            {
                var data = m_TOS[idx];
                if (data.Key >= bonePathHash)
                {
                    if (data.Key == bonePathHash)
                    {
                        return;
                    }
                    break;
                }
            }
            m_TOS.Insert(idx, new KeyValuePair <uint, string>(bonePathHash, bonePath));

            if (m_Avatar.m_AvatarSkeleton.m_ID.Count > 0)
            {
                uint parentHash = BoneHash(parent.GetTransformPath());
                for (int i = 0; i < m_Avatar.m_AvatarSkeleton.m_ID.Count; i++)
                {
                    if (m_Avatar.m_AvatarSkeleton.m_ID[i] == parentHash)
                    {
                        int cIdx = i + BoneIndex(parent, bone);
                        if (cIdx > m_Avatar.m_AvatarSkeleton.m_Node.Count)
                        {
                            m_TOS.RemoveAt(idx);
                            Report.ReportLog("Error in Avatar - cant add bone " + bone.m_GameObject.instance.m_Name);
                            return;
                        }
                        m_Avatar.m_AvatarSkeleton.m_Node.Insert(cIdx, new Node(i, -1));
                        m_Avatar.m_AvatarSkeleton.m_ID.Insert(cIdx, bonePathHash);
                        m_Avatar.m_SkeletonNameIDArray.Insert(cIdx, boneHash);
                        xform boneXform = file.VersionNumber < AssetCabinet.VERSION_5_4_1
                                                        ? new xform(new Vector4(bone.m_LocalPosition, 0), bone.m_LocalRotation, new Vector4(bone.m_LocalScale, 1))
                                                        : new xform(bone.m_LocalPosition, bone.m_LocalRotation, bone.m_LocalScale);
                        m_Avatar.m_AvatarSkeletonPose.m_X.Insert(cIdx, boneXform);
                        m_Avatar.m_DefaultPose.m_X.Insert(cIdx, boneXform);

                        for (int j = cIdx + 1; j < m_Avatar.m_AvatarSkeleton.m_ID.Count; j++)
                        {
                            if (m_Avatar.m_AvatarSkeleton.m_Node[j].m_ParentId >= cIdx)
                            {
                                m_Avatar.m_AvatarSkeleton.m_Node[j].m_ParentId++;
                            }
                        }
                        break;
                    }
                }
                if (m_TOS.Count != m_Avatar.m_AvatarSkeleton.m_Node.Count)
                {
                    m_TOS.RemoveAt(idx);
                    Report.ReportLog("Warning! Parent Transform " + parent.m_GameObject.instance.m_Name + " not found in Avatar member m_ID");
                }
            }
        }
Beispiel #17
0
        public Human(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            m_RootX        = new xform(stream);
            m_Skeleton     = new Skeleton(stream);
            m_SkeletonPose = new SkeletonPose(stream);
            m_LeftHand     = new Hand(stream);
            m_RightHand    = new Hand(stream);

            int numHandles = reader.ReadInt32();

            m_Handles = new List <Handle>(numHandles);
            for (int i = 0; i < numHandles; i++)
            {
                m_Handles.Add(new Handle(stream));
            }

            int numColliders = reader.ReadInt32();

            m_ColliderArray = new List <Collider>(numColliders);
            for (int i = 0; i < numColliders; i++)
            {
                m_ColliderArray.Add(new Collider(stream));
            }

            int numIndexes = reader.ReadInt32();

            m_HumanBoneIndex = new List <int>(numIndexes);
            for (int i = 0; i < numIndexes; i++)
            {
                m_HumanBoneIndex.Add(reader.ReadInt32());
            }

            int numMasses = reader.ReadInt32();

            m_HumanBoneMass = new List <float>(numMasses);
            for (int i = 0; i < numMasses; i++)
            {
                m_HumanBoneMass.Add(reader.ReadSingle());
            }

            int numColliderIndexes = reader.ReadInt32();

            m_ColliderIndex = new List <int>(numColliderIndexes);
            for (int i = 0; i < numColliderIndexes; i++)
            {
                m_ColliderIndex.Add(reader.ReadInt32());
            }

            m_Scale         = reader.ReadSingle();
            m_ArmTwist      = reader.ReadSingle();
            m_ForeArmTwist  = reader.ReadSingle();
            m_UpperLegTwist = reader.ReadSingle();
            m_LegTwist      = reader.ReadSingle();
            m_ArmStretch    = reader.ReadSingle();
            m_LegStretch    = reader.ReadSingle();
            m_FeetSpacing   = reader.ReadSingle();
            m_HasLeftHand   = reader.ReadBoolean();
            m_HasRightHand  = reader.ReadBoolean();
            reader.ReadBytes(2);
        }