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

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

            case GLTFAnimationTarget.AnimationProperty.Scale:
                return(new AnimationKeyframeData(elementCount, null));

            case GLTFAnimationTarget.AnimationProperty.BlendShape:
                return(new AnimationKeyframeData(elementCount, null));

            case GLTFAnimationTarget.AnimationProperty.Active:
                return(new AnimationKeyframeData(elementCount, null));

            default:
                return(null);
            }
        }
示例#2
0
 public AnimationCurveData(AnimationUtility.TangentMode tangentMode, GLTFAnimationTarget.AnimationProperty property, int samplerIndex, int elementCount)
 {
     this.tangentMode  = tangentMode;
     animationProperty = property;
     this.samplerIndex = samplerIndex;
     this.elementCount = elementCount;
 }
示例#3
0
        public int AddChannelAndGetSampler(int nodeIndex, GLTFAnimationTarget.AnimationProperty 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);
        }