Example #1
0
        /// <summary>
        /// アニメーションプロパティに対応したキーフレームを挿入する
        /// </summary>
        /// <param name="property"></param>
        /// <returns></returns>
        private static AnimationKeyframeData GetKeyframeData(glTFAnimationTarget.AnimationProperties property, int elementCount)
        {
            switch (property)
            {
            case glTFAnimationTarget.AnimationProperties.Translation:
                return(new AnimationKeyframeData(elementCount, (values) =>
                {
                    var temp = new Vector3(values[0], values[1], values[2]);
                    return temp.ReverseZ().ToArray();
                }));

            case glTFAnimationTarget.AnimationProperties.Rotation:
                return(new AnimationKeyframeData(elementCount, (values) =>
                {
                    var temp = new Quaternion(values[0], values[1], values[2], values[3]);
                    return temp.ReverseZ().ToArray();
                }));

            case glTFAnimationTarget.AnimationProperties.Scale:
                return(new AnimationKeyframeData(elementCount, null));

            case glTFAnimationTarget.AnimationProperties.BlendShape:
                return(new AnimationKeyframeData(elementCount, null));

            default:
                return(null);
            }
        }
Example #2
0
 public AnimationCurveData(AnimationUtility.TangentMode tangentMode, glTFAnimationTarget.AnimationProperties property, int samplerIndex, int elementCount)
 {
     TangentMode       = tangentMode;
     AnimationProperty = property;
     SamplerIndex      = samplerIndex;
     ElementCount      = elementCount;
 }
Example #3
0
        public int AddChannelAndGetSampler(int nodeIndex, glTFAnimationTarget.AnimationProperties property)
        {
            // find channel
            var channel = channels.FirstOrDefault(x => x.target.node == nodeIndex && x.target.path == glTFAnimationTarget.GetPathName(property));

            if (channel != null)
            {
                return(channel.sampler);
            }

            // not found. create new
            var samplerIndex = samplers.Count;
            var sampler      = new glTFAnimationSampler();

            samplers.Add(sampler);

            channel = new glTFAnimationChannel
            {
                sampler = samplerIndex,
                target  = new glTFAnimationTarget
                {
                    node = nodeIndex,
                    path = glTFAnimationTarget.GetPathName(property),
                },
            };
            channels.Add(channel);

            return(samplerIndex);
        }