Exemple #1
0
        public int AddChannelAndGetSampler(int nodeIndex, glTFAnimationTarget.AnimationPropertys 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);
        }
 public AnimationCurveData(AnimationUtility.TangentMode tangentMode, glTFAnimationTarget.AnimationPropertys property, int samplerIndex, int elementCount)
 {
     TangentMode       = tangentMode;
     AnimationProperty = property;
     SamplerIndex      = samplerIndex;
     ElementCount      = elementCount;
 }
        /// <summary>
        /// アニメーションプロパティに対応したキーフレームを挿入する
        /// </summary>
        /// <param name="property"></param>
        /// <returns></returns>
        private static AnimationKeyframeData GetKeyframeData(glTFAnimationTarget.AnimationPropertys property, int elementCount)
        {
            switch (property)
            {
            case glTFAnimationTarget.AnimationPropertys.Translation:
                return(new AnimationKeyframeData(elementCount, (values) =>
                {
                    var temp = new Vector3(values[0], values[1], values[2]);
                    return temp.ReverseZ().ToArray();
                }));

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

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

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

            default:
                return(null);
            }
        }
Exemple #4
0
 public AnimationCurveData(AnimationUtility.TangentMode tangentMode, glTFAnimationTarget.AnimationPropertys property, int samplerIndex, int elementCount)
     : this(tangentMode, glTFAnimationTarget.AnimationPropertysToAnimationProperties(property), samplerIndex, elementCount)
 {
 }
Exemple #5
0
 private static AnimationKeyframeData GetKeyframeData(glTFAnimationTarget.AnimationPropertys property,
                                                      int elementCount)
 {
     return(GetKeyframeData(glTFAnimationTarget.AnimationPropertysToAnimationProperties(property), elementCount));
 }
Exemple #6
0
 public int AddChannelAndGetSampler(int nodeIndex, glTFAnimationTarget.AnimationPropertys property)
 {
     return(AddChannelAndGetSampler(nodeIndex, glTFAnimationTarget.AnimationPropertysToAnimationProperties(property)));
 }