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 void CreateTextureNode(string filename) { EZMFile ezmFile = EZMFile.Load(filename); ezmFile.LoadTextures(); var rootElement = this.scene.RootNode; for (int i = 0; i < ezmFile.MeshSystem.Meshes.Length; i++) { EZMMesh mesh = ezmFile.MeshSystem.Meshes[i]; EZMAnimation animation = ezmFile.MeshSystem.Animations.Length > 0 ? ezmFile.MeshSystem.Animations[0] : null; var container = new EZMVertexBufferContainer(mesh, animation); for (int j = 0; j < mesh.MeshSections.Length; j++) { var model = new EZMTextureModel(container, mesh.MeshSections[j]); var node = EZMTextureNode.Create(model); rootElement.Children.Add(node); } } }
public EZMVertexBufferContainer(EZMMesh ezmMesh, EZMAnimation animation) { this.ezmMesh = ezmMesh; this.animation = animation; }