コード例 #1
0
        /// <summary>
        /// Try to apply animation to rig.
        /// </summary>
        public void Apply(Rig rig)
        {
            bones.Clear();
            Vector3Df current;
            for (int i = 0; i < orientations.Count; i++)
            {
                Bone bone = new Bone();
                bones.Add(bone);

                var animBone = currentBones[i];

                var positionVar = animBone.Position;
                CFloat dtPos = positionVar.Dt;
                CUInt32 dataAddrPos = positionVar.DataAddr;
                CUInt32 dataAddrFallbackPos = positionVar.DataAddrFallback;
                CUInt16 numframesPos = positionVar.NumFrames;
                if (dtPos != null)
                    bone.position_dt = dtPos.val;
                if (dataAddrPos != null)
                    bone.position_dataAddr = dataAddrPos.val;
                if (dataAddrFallbackPos != null)
                    bone.position_dataAddrFallback = dataAddrFallbackPos.val;
                if (numframesPos != null)
                    bone.position_numFrames = numframesPos.val;

                var orientationVar = animBone.Orientation;
                CFloat dtRot = orientationVar.Dt;
                CUInt32 dataAddrRot = orientationVar.DataAddr;
                CUInt32 dataAddrFallbackRot = orientationVar.DataAddrFallback;
                CUInt16 numframesRot = orientationVar.NumFrames;
                if (dtRot != null)
                    bone.rotation_dt = dtRot.val;
                if (dataAddrRot != null)
                    bone.rotation_dataAddr = dataAddrRot.val;
                if (dataAddrFallbackRot != null)
                    bone.rotation_dataAddrFallback = dataAddrFallbackRot.val;
                if (numframesRot != null)
                    bone.rotation_numFrames = numframesRot.val;

                var scaleVar = animBone.Scale;
                CFloat dtScale = scaleVar.Dt;
                CUInt32 dataAddrScale = scaleVar.DataAddr;
                CUInt32 dataAddrFallbackScale = scaleVar.DataAddrFallback;
                CUInt16 numframesScale = scaleVar.NumFrames;
                if (dtScale != null)
                    bone.scale_dt = dtScale.val;
                if (dataAddrScale != null)
                    bone.scale_dataAddr = dataAddrScale.val;
                if (dataAddrFallbackScale != null)
                    bone.scale_dataAddrFallback = dataAddrFallbackScale.val;
                if (numframesScale != null)
                    bone.scale_numFrames = numframesScale.val;

                bone.BoneName = rig.meshSkeleton.names[i];
                for (int j = 0; j < positions[i].Count; j++)
                {
                    bone.positionFrames.Add(new Vector(positions[i][j].X, positions[i][j].Y, positions[i][j].Z));
                }

                for (int j = 0; j < orientations[i].Count; j++)
                {
                    current = orientationsEuler[i][j];
                    bone.rotationFrames.Add(orientations[i][j]);
                }

                for (int j = 0; j < scales[i].Count; j++)
                {
                    bone.scaleFrames.Add(new Vector(scales[i][j].X, scales[i][j].Y, scales[i][j].Z));
                }
            }
            exportData.bones = bones;
        }
コード例 #2
0
        /// <summary>
        /// Try to apply animation to rig.
        /// </summary>
        public void Apply(Rig rig)
        {
            bones.Clear();
            Vector3Df current;

            for (int i = 0; i < orientations.Count; i++)
            {
                Bone bone = new Bone();
                bones.Add(bone);

                CVector animBone = currentBones[i];

                CVector positionVar         = animBone.GetVariableByName("position") as CVector;
                CFloat  dtPos               = positionVar.GetVariableByName("dt") as CFloat;
                CUInt32 dataAddrPos         = positionVar.GetVariableByName("dataAddr") as CUInt32;
                CUInt32 dataAddrFallbackPos = positionVar.GetVariableByName("dataAddrFallback") as CUInt32;
                CUInt16 numframesPos        = positionVar.GetVariableByName("numFrames") as CUInt16;
                if (dtPos != null)
                {
                    bone.position_dt = dtPos.val;
                }
                if (dataAddrPos != null)
                {
                    bone.position_dataAddr = dataAddrPos.val;
                }
                if (dataAddrFallbackPos != null)
                {
                    bone.position_dataAddrFallback = dataAddrFallbackPos.val;
                }
                if (numframesPos != null)
                {
                    bone.position_numFrames = numframesPos.val;
                }

                CVector orientationVar      = animBone.GetVariableByName("orientation") as CVector;
                CFloat  dtRot               = orientationVar.GetVariableByName("dt") as CFloat;
                CUInt32 dataAddrRot         = orientationVar.GetVariableByName("dataAddr") as CUInt32;
                CUInt32 dataAddrFallbackRot = orientationVar.GetVariableByName("dataAddrFallback") as CUInt32;
                CUInt16 numframesRot        = orientationVar.GetVariableByName("numFrames") as CUInt16;
                if (dtRot != null)
                {
                    bone.rotation_dt = dtRot.val;
                }
                if (dataAddrRot != null)
                {
                    bone.rotation_dataAddr = dataAddrRot.val;
                }
                if (dataAddrFallbackRot != null)
                {
                    bone.rotation_dataAddrFallback = dataAddrFallbackRot.val;
                }
                if (numframesRot != null)
                {
                    bone.rotation_numFrames = numframesRot.val;
                }

                CVector scaleVar              = animBone.GetVariableByName("scale") as CVector;
                CFloat  dtScale               = scaleVar.GetVariableByName("dt") as CFloat;
                CUInt32 dataAddrScale         = scaleVar.GetVariableByName("dataAddr") as CUInt32;
                CUInt32 dataAddrFallbackScale = scaleVar.GetVariableByName("dataAddrFallback") as CUInt32;
                CUInt16 numframesScale        = scaleVar.GetVariableByName("numFrames") as CUInt16;
                if (dtScale != null)
                {
                    bone.scale_dt = dtScale.val;
                }
                if (dataAddrScale != null)
                {
                    bone.scale_dataAddr = dataAddrScale.val;
                }
                if (dataAddrFallbackScale != null)
                {
                    bone.scale_dataAddrFallback = dataAddrFallbackScale.val;
                }
                if (numframesScale != null)
                {
                    bone.scale_numFrames = numframesScale.val;
                }

                bone.BoneName = rig.meshSkeleton.names[i];
                for (int j = 0; j < positions[i].Count; j++)
                {
                    bone.positionFrames.Add(new Vector(positions[i][j].X, positions[i][j].Y, positions[i][j].Z));
                }

                for (int j = 0; j < orientations[i].Count; j++)
                {
                    current = orientationsEuler[i][j];
                    bone.rotationFrames.Add(orientations[i][j]);
                }

                for (int j = 0; j < scales[i].Count; j++)
                {
                    bone.scaleFrames.Add(new Vector(scales[i][j].X, scales[i][j].Y, scales[i][j].Z));
                }
            }
            exportData.bones = bones;
        }