override public void UpdateSkeleton() { if (useAnimationName) { // Keep AnimationState in sync with animationName and loop fields. if (animationName == null || animationName.Length == 0) { if (state.Animation != null) { state.ClearAnimation(); } } else if (state.Animation == null || animationName != state.Animation.Name) { Spine.Animation animation = skeleton.Data.FindAnimation(animationName); if (animation != null) { state.SetAnimation(animation, loop); } } state.Loop = loop; } // Apply the animation. state.Update(Time.deltaTime * timeScale); state.Apply(skeleton); // Call overridden method to call skeleton Update and UpdateWorldTransform. base.UpdateSkeleton(); }
public override void Render(float deltaTime) { // Update the animation state and apply the animations // to the skeleton state.Update(deltaTime); state.Apply(skeleton); // Update the transformations of bones and other parts of the skeleton skeleton.UpdateWorldTransform(); // Clear the screen and setup the projection matrix of the skeleton renderer game.GraphicsDevice.Clear(Color.Black); ((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0); // Draw the skeletons skeletonRenderer.Begin(); skeletonRenderer.Draw(skeleton); skeletonRenderer.End(); // Check if the mouse button was clicked and switch scene if (mouseClicked) { game.currentScreen = new TankScreen(game); } }
private void UpdateAnimation() { // Check if we need to stop current animation if (state.Animation != null && animationName == null) { state.ClearAnimation(); } // Check for different animation name or animation end else if (state.Animation == null || animationName != state.Animation.Name) { Spine.Animation animation = cachedSpineSkeleton.skeleton.Data.FindAnimation(animationName); if (animation != null) { state.SetAnimation(animation, loop); } } state.Loop = loop; // Update animation cachedSpineSkeleton.skeleton.Update(Time.deltaTime * animationSpeed); state.Update(Time.deltaTime * animationSpeed); state.Apply(cachedSpineSkeleton.skeleton); }
public virtual void Update(float deltaTime) { if (!valid) { return; } deltaTime *= timeScale; skeleton.Update(deltaTime); state.Update(deltaTime); state.Apply(skeleton); if (UpdateLocal != null) { UpdateLocal(this); } skeleton.UpdateWorldTransform(); if (UpdateWorld != null) { UpdateWorld(this); skeleton.UpdateWorldTransform(); } if (UpdateComplete != null) { UpdateComplete(this); } }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); state.Update(gameTime.ElapsedGameTime.Milliseconds / 1000f); state.Apply(skeleton); skeleton.UpdateWorldTransform(); skeletonRenderer.Begin(); skeletonRenderer.Draw(skeleton); skeletonRenderer.End(); bounds.Update(skeleton, true); MouseState mouse = Mouse.GetState(); if (headSlot != null) { headSlot.G = 1; headSlot.B = 1; if (bounds.AabbContainsPoint(mouse.X, mouse.Y)) { BoundingBoxAttachment hit = bounds.ContainsPoint(mouse.X, mouse.Y); if (hit != null) { headSlot.G = 0; headSlot.B = 0; } } } base.Draw(gameTime); }
// UPDATING ========================================================================================== // updates the sprite / skeleton public void Update() { TrackEntry track = animation.GetCurrent(0); // is the animation currently playing? then update the bone positions and slot data if (track != null) { // only update if were looping, or if or time is less then the end time for non looping tracks. if (track.loop || (!track.loop && track.time <= track.EndTime)) { animation.Update(Time.deltaTime * animationTimeScale); animation.Apply(skeleton); _isSpineDirty = true; } } // if the skeleton is dirty then refresh all the slots. if (_isSpineDirty) { _isSpineDirty = false; skeleton.UpdateWorldTransform(); for (int i = 0; i < skeleton.DrawOrder.Count; i++) { slots[i].Update(skeleton.DrawOrder[i]); } } }
public void UpdateAnimation() { skeleton.Update(Time.deltaTime * timeScale); state.Update(Time.deltaTime * timeScale); state.Apply(skeleton); skeleton.UpdateWorldTransform(); }
override public void UpdateSkeleton(float deltaTime) { // Apply the animation. state.Update(deltaTime * timeScale); state.Apply(skeleton); // Call overridden method to call skeleton Update and UpdateWorldTransform. base.UpdateSkeleton(deltaTime); }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); state.Update(gameTime.ElapsedGameTime.Milliseconds / 1000f); state.Apply(skeleton); skeleton.UpdateWorldTransform(); skeletonRenderer.Begin(); skeletonRenderer.Draw(skeleton); skeletonRenderer.End(); base.Draw(gameTime); }
static int Update(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); Spine.AnimationState obj = (Spine.AnimationState)ToLua.CheckObject(L, 1, typeof(Spine.AnimationState)); float arg0 = (float)LuaDLL.luaL_checknumber(L, 2); obj.Update(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public virtual void Update(float deltaTime) { if (!valid) { return; } deltaTime *= timeScale; skeleton.Update(deltaTime); state.Update(deltaTime * timeScale); state.Apply(skeleton); if (UpdateBones != null) { UpdateBones(this); } skeleton.UpdateWorldTransform(); }
public override void Render(float deltaTime) { state.Update(deltaTime); state.Apply(skeleton); skeleton.UpdateWorldTransform(); game.GraphicsDevice.Clear(Color.Black); ((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0); skeletonRenderer.Begin(); skeletonRenderer.Draw(skeleton); skeletonRenderer.End(); if (mouseClicked) { game.currentScreen = new RaptorScreen(game); } }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); state.Update(gameTime.ElapsedGameTime.Milliseconds / 1000f); state.Apply(skeleton); skeleton.UpdateWorldTransform(); if (skeletonRenderer.Effect is BasicEffect) { ((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 1, 0); } else { skeletonRenderer.Effect.Parameters["Projection"].SetValue(Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 1, 0)); } skeletonRenderer.Begin(); skeletonRenderer.Draw(skeleton); skeletonRenderer.End(); skeletonDebugRenderer.Effect.Projection = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 1, 0); skeletonDebugRenderer.Begin(); skeletonDebugRenderer.Draw(skeleton); skeletonDebugRenderer.End(); bounds.Update(skeleton, true); MouseState mouse = Mouse.GetState(); if (headSlot != null) { headSlot.G = 1; headSlot.B = 1; if (bounds.AabbContainsPoint(mouse.X, mouse.Y)) { BoundingBoxAttachment hit = bounds.ContainsPoint(mouse.X, mouse.Y); if (hit != null) { headSlot.G = 0; headSlot.B = 0; } } } base.Draw(gameTime); }
public override void ProcessFrame(Playable playable, FrameData info, object playerData) { if (playerData == null) { return; } //Debug.Log($"Track time {playable.GetTime()}"); AnimationState animationState = InitializeAnimationState(playable, playerData); var skeletonAnimation = playerData as SkeletonAnimation; var skeletonGraphic = playerData as SkeletonGraphic; var skeletonComponent = playerData as ISkeletonComponent; float playTime = (float)playable.GetTime(); var skel = skeletonComponent.Skeleton; //Unfreeze for update, then freeze back immediately. if (isSkeletonGraphic) { skeletonGraphic.freeze = false; } skel.SetToSetupPose(); skel.Time = playTime; animationState.Update(0); animationState.Apply(skeletonComponent.Skeleton); skel.UpdateWorldTransform(); if (isSkeletonGraphic) { skeletonGraphic.LateUpdate(); if (isSkeletonGraphic) { skeletonGraphic.freeze = true; } } else { skeletonAnimation.LateUpdate(); } }
public override void Render(float deltaTime) { state.Update(deltaTime); state.Apply(skeleton); skeleton.UpdateWorldTransform(); // Clear the screen and setup the projection matrix of the custom effect through the // "Projection" parameter. game.GraphicsDevice.Clear(Color.Black); skeletonRenderer.Effect.Parameters["Projection"].SetValue(Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0)); skeletonRenderer.Begin(); skeletonRenderer.Draw(skeleton); skeletonRenderer.End(); if (mouseClicked) { game.currentScreen = new SpineboyScreen(game); } }
// UPDATING ========================================================================================== // updates the sprite / skeleton public void Update() { // is the animation currently playing? then update the bone positions and slot data if (!animation.IsComplete() || animation.Loop) { animation.Update(Time.deltaTime * animationTimeScale); animation.Apply(skeleton); _isSpineDirty = true; } // if the skeleton is dirty then refresh all the slots. if (_isSpineDirty) { _isSpineDirty = false; skeleton.UpdateWorldTransform(); for (int i = 0; i < skeleton.DrawOrder.Count; i++) { slots[i].Update(skeleton.DrawOrder[i]); } } }
public void Update() { // Clear fields if missing information to render. if (skeletonDataAsset == null || skeletonDataAsset.GetSkeletonData(false) == null) { Clear(); return; } // Initialize fields. if (skeleton == null || skeleton.Data != skeletonDataAsset.GetSkeletonData(false)) { Initialize(); } // Keep AnimationState in sync with animationName and loop fields. if (animationName == null && state.Animation != null) { state.Clear(); } else if (state.Animation == null || animationName != state.Animation.Name) { Spine.Animation animation = skeleton.Data.FindAnimation(animationName); if (animation != null) { state.SetAnimation(animation, loop); } } state.Loop = loop; // Apply animation. skeleton.Update(Time.deltaTime * timeScale); state.Update(Time.deltaTime * timeScale); state.Apply(skeleton); skeleton.UpdateWorldTransform(); // Count quads. int quadCount = 0; List <Slot> drawOrder = skeleton.DrawOrder; for (int i = 0, n = drawOrder.Count; i < n; i++) { Slot slot = drawOrder[i]; Attachment attachment = slot.Attachment; if (attachment is RegionAttachment) { quadCount++; } } // Ensure mesh data is the right size. if (quadCount != this.quadCount) { this.quadCount = quadCount; vertices = new Vector3[quadCount * 4]; uvs = new Vector2[quadCount * 4]; triangles = new int[quadCount * 6]; } // Setup mesh. int quadIndex = 0; for (int i = 0, n = drawOrder.Count; i < n; i++) { Slot slot = drawOrder[i]; Attachment attachment = slot.Attachment; if (attachment is RegionAttachment) { RegionAttachment regionAttachment = (RegionAttachment)attachment; regionAttachment.UpdateVertices(slot.Bone); float[] regionVertices = regionAttachment.Vertices; int vertexIndex = quadIndex * 4; vertices[vertexIndex] = new Vector3(regionVertices[RegionAttachment.X1], regionVertices[RegionAttachment.Y1], 0); vertices[vertexIndex + 1] = new Vector3(regionVertices[RegionAttachment.X4], regionVertices[RegionAttachment.Y4], 0); vertices[vertexIndex + 2] = new Vector3(regionVertices[RegionAttachment.X2], regionVertices[RegionAttachment.Y2], 0); vertices[vertexIndex + 3] = new Vector3(regionVertices[RegionAttachment.X3], regionVertices[RegionAttachment.Y3], 0); float[] regionUVs = regionAttachment.UVs; uvs[vertexIndex] = new Vector2(regionUVs[RegionAttachment.X1], 1 - regionUVs[RegionAttachment.Y1]); uvs[vertexIndex + 1] = new Vector2(regionUVs[RegionAttachment.X4], 1 - regionUVs[RegionAttachment.Y4]); uvs[vertexIndex + 2] = new Vector2(regionUVs[RegionAttachment.X2], 1 - regionUVs[RegionAttachment.Y2]); uvs[vertexIndex + 3] = new Vector2(regionUVs[RegionAttachment.X3], 1 - regionUVs[RegionAttachment.Y3]); int index = quadIndex * 6; triangles[index] = vertexIndex; triangles[index + 1] = vertexIndex + 2; triangles[index + 2] = vertexIndex + 1; triangles[index + 3] = vertexIndex + 2; triangles[index + 4] = vertexIndex + 3; triangles[index + 5] = vertexIndex + 1; quadIndex++; } } mesh.vertices = vertices; mesh.uv = uvs; mesh.triangles = triangles; renderer.sharedMaterial = skeletonDataAsset.atlasAsset.material; }
void Run(float incr, float endTime, TestListener listener) { Skeleton skeleton = new Skeleton(skeletonData); state.Apply(skeleton); while (time < endTime) { time += incr; skeleton.Update(incr); state.Update(incr); // Reduce float discrepancies for tests. foreach (TrackEntry entry in state.Tracks) { if (entry == null) { continue; } entry.TrackTime = Round(entry.TrackTime, 6); entry.Delay = Round(entry.Delay, 3); if (entry.MixingFrom != null) { entry.MixingFrom.TrackTime = Round(entry.MixingFrom.TrackTime, 6); } } state.Apply(skeleton); // Apply multiple times to ensure no side effects. if (expected.Count > 0) { stateListener.UnregisterFromAnimationState(state); } state.Apply(skeleton); state.Apply(skeleton); if (expected.Count > 0) { stateListener.RegisterAtAnimationState(state); } if (listener != null) { listener.Frame(time); } } state.ClearTracks(); // Expecting more than actual is a failure. for (int i = actual.Count, n = expected.Count; i < n; i++) { Log(string.Format("{0,-29}", "<none>") + "FAIL: " + expected[i]); fail = true; } actual.Clear(); expected.Clear(); Log(""); if (fail) { string message = "TEST " + test + " FAILED!"; Log(message); FailTestRun(message); } }