示例#1
0
        public mat4[] GetBoneMatrixes()
        {
            mat4[] result = null;

            EZMAnimation animation = this.animation;

            if (animation == null)
            {
                result = DefaultBoneMatrixes();
            }
            else
            {
                if (this.firstRun)
                {
                    lastTime      = DateTime.Now;
                    this.firstRun = false;
                }

                DateTime now           = DateTime.Now;
                var      deltaTime     = now.Subtract(this.lastTime).TotalSeconds;
                float    frameDuration = animation.duration / animation.FrameCount;
                if (deltaTime + passedTime > frameDuration)
                {
                    this.currentFrame = (this.currentFrame + 1) % animation.FrameCount;
                    passedTime        = deltaTime - frameDuration;
                }
                this.currentFrame = 0;
                this.lastTime     = now;

                result = new mat4[animation.AnimTracks.Length];
                foreach (EZMAnimTrack animTrack in animation.AnimTracks)
                {
                    EZMBoneState animState = animTrack.States[this.currentFrame];
                    EZMBone      bone      = animTrack.Bone;
                    bone.state = animState;
                }
                EZMBone rootBone = this.ezmMesh.Skeleton.OrderedBones[0];
                mat4    inverse  = glm.inverse(rootBone.OriginalState.matrix);
                foreach (EZMBone bone in this.ezmMesh.Skeleton.OrderedBones)
                {
                    EZMBone parent = bone.Parent;
                    if (parent == null)
                    {
                        bone.combinedMat = bone.state.matrix;
                    }
                    else
                    {
                        bone.combinedMat = parent.combinedMat * bone.state.matrix;
                    }
                }
                for (int i = 0; i < result.Length; i++)
                {
                    EZMAnimTrack animTrack = animation.AnimTracks[i];
                    EZMBone      bone      = animTrack.Bone;
                    result[i] = bone.combinedMat * bone.offsetMat;
                }
            }

            return(result);
        }
        private vec3[] GetPositions(EZMBone[] bones)
        {
            var positions = new vec3[bones.Length];

            for (int i = 0; i < bones.Length; i++)
            {
                EZMBone bone = bones[i];
                positions[i] = new vec3(bone.combinedMat * new vec4(0, 0, 0, 1));
            }

            return(positions);
        }
示例#3
0
        private vec3[] GetPositions(EZMBone[] bones)
        {
            var list = new List <vec3>();

            for (uint i = 0; i < bones.Length; i++)
            {
                EZMBone bone   = bones[i];
                EZMBone parent = bone.Parent;
                if (parent != null)
                {
                    // a line from parent to child.
                    list.Add(new vec3(parent.combinedMat * new vec4(0, 0, 0, 1)));
                    list.Add(new vec3(bone.combinedMat * new vec4(0, 0, 0, 1)));
                }
            }

            return(list.ToArray());
        }
示例#4
0
        private vec3[] GetColors(EZMBone[] bones)
        {
            var list = new List <vec3>();

            for (uint i = 0; i < bones.Length; i++)
            {
                EZMBone bone   = bones[i];
                EZMBone parent = bone.Parent;
                if (parent != null)
                {
                    // a line from parent to child.
                    list.Add(new vec3(1, 0, 0));
                    list.Add(new vec3(1, 1, 1));
                }
            }

            return(list.ToArray());
        }