mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-22 10:16:01 +08:00
Fixed animations with no bone keys.
This commit is contained in:
parent
ff66231378
commit
803a8ab045
@ -114,7 +114,7 @@ namespace Spine {
|
|||||||
|
|
||||||
// Skins.
|
// Skins.
|
||||||
if (root.ContainsKey("skins")) {
|
if (root.ContainsKey("skins")) {
|
||||||
Dictionary<String, Object> skinMap = (Dictionary<String, Object>)root["skins"];
|
var skinMap = (Dictionary<String, Object>)root["skins"];
|
||||||
foreach (KeyValuePair<String, Object> entry in skinMap) {
|
foreach (KeyValuePair<String, Object> entry in skinMap) {
|
||||||
Skin skin = new Skin(entry.Key);
|
Skin skin = new Skin(entry.Key);
|
||||||
foreach (KeyValuePair<String, Object> slotEntry in (Dictionary<String, Object>)entry.Value) {
|
foreach (KeyValuePair<String, Object> slotEntry in (Dictionary<String, Object>)entry.Value) {
|
||||||
@ -133,7 +133,7 @@ namespace Spine {
|
|||||||
|
|
||||||
// Animations.
|
// Animations.
|
||||||
if (root.ContainsKey("animations")) {
|
if (root.ContainsKey("animations")) {
|
||||||
Dictionary<String, Object> animationMap = (Dictionary<String, Object>)root["animations"];
|
var animationMap = (Dictionary<String, Object>)root["animations"];
|
||||||
foreach (KeyValuePair<String, Object> entry in animationMap)
|
foreach (KeyValuePair<String, Object> entry in animationMap)
|
||||||
ReadAnimation(entry.Key, (Dictionary<String, Object>)entry.Value, skeletonData);
|
ReadAnimation(entry.Key, (Dictionary<String, Object>)entry.Value, skeletonData);
|
||||||
}
|
}
|
||||||
@ -185,68 +185,70 @@ namespace Spine {
|
|||||||
var timelines = new List<Timeline>();
|
var timelines = new List<Timeline>();
|
||||||
float duration = 0;
|
float duration = 0;
|
||||||
|
|
||||||
var bonesMap = (Dictionary<String, Object>)map["bones"];
|
if (map.ContainsKey("bones")) {
|
||||||
foreach (KeyValuePair<String, Object> entry in bonesMap) {
|
var bonesMap = (Dictionary<String, Object>)map["bones"];
|
||||||
String boneName = entry.Key;
|
foreach (KeyValuePair<String, Object> entry in bonesMap) {
|
||||||
int boneIndex = skeletonData.FindBoneIndex(boneName);
|
String boneName = entry.Key;
|
||||||
if (boneIndex == -1)
|
int boneIndex = skeletonData.FindBoneIndex(boneName);
|
||||||
throw new Exception("Bone not found: " + boneName);
|
if (boneIndex == -1)
|
||||||
|
throw new Exception("Bone not found: " + boneName);
|
||||||
|
|
||||||
Dictionary<String, Object> timelineMap = (Dictionary<String, Object>)entry.Value;
|
var timelineMap = (Dictionary<String, Object>)entry.Value;
|
||||||
foreach (KeyValuePair<String, Object> timelineEntry in timelineMap) {
|
foreach (KeyValuePair<String, Object> timelineEntry in timelineMap) {
|
||||||
List<Object> values = (List<Object>)timelineEntry.Value;
|
var values = (List<Object>)timelineEntry.Value;
|
||||||
String timelineName = (String)timelineEntry.Key;
|
String timelineName = (String)timelineEntry.Key;
|
||||||
if (timelineName.Equals(TIMELINE_ROTATE)) {
|
if (timelineName.Equals(TIMELINE_ROTATE)) {
|
||||||
RotateTimeline timeline = new RotateTimeline(values.Count);
|
RotateTimeline timeline = new RotateTimeline(values.Count);
|
||||||
timeline.BoneIndex = boneIndex;
|
timeline.BoneIndex = boneIndex;
|
||||||
|
|
||||||
int frameIndex = 0;
|
int frameIndex = 0;
|
||||||
foreach (Dictionary<String, Object> valueMap in values) {
|
foreach (Dictionary<String, Object> valueMap in values) {
|
||||||
float time = (float)valueMap["time"];
|
float time = (float)valueMap["time"];
|
||||||
timeline.SetFrame(frameIndex, time, (float)valueMap["angle"]);
|
timeline.SetFrame(frameIndex, time, (float)valueMap["angle"]);
|
||||||
ReadCurve(timeline, frameIndex, valueMap);
|
ReadCurve(timeline, frameIndex, valueMap);
|
||||||
frameIndex++;
|
frameIndex++;
|
||||||
}
|
}
|
||||||
timelines.Add(timeline);
|
timelines.Add(timeline);
|
||||||
duration = Math.Max(duration, timeline.Frames[timeline.FrameCount * 2 - 2]);
|
duration = Math.Max(duration, timeline.Frames[timeline.FrameCount * 2 - 2]);
|
||||||
|
|
||||||
} else if (timelineName.Equals(TIMELINE_TRANSLATE) || timelineName.Equals(TIMELINE_SCALE)) {
|
} else if (timelineName.Equals(TIMELINE_TRANSLATE) || timelineName.Equals(TIMELINE_SCALE)) {
|
||||||
TranslateTimeline timeline;
|
TranslateTimeline timeline;
|
||||||
float timelineScale = 1;
|
float timelineScale = 1;
|
||||||
if (timelineName.Equals(TIMELINE_SCALE))
|
if (timelineName.Equals(TIMELINE_SCALE))
|
||||||
timeline = new ScaleTimeline(values.Count);
|
timeline = new ScaleTimeline(values.Count);
|
||||||
else {
|
else {
|
||||||
timeline = new TranslateTimeline(values.Count);
|
timeline = new TranslateTimeline(values.Count);
|
||||||
timelineScale = Scale;
|
timelineScale = Scale;
|
||||||
}
|
}
|
||||||
timeline.BoneIndex = boneIndex;
|
timeline.BoneIndex = boneIndex;
|
||||||
|
|
||||||
int frameIndex = 0;
|
int frameIndex = 0;
|
||||||
foreach (Dictionary<String, Object> valueMap in values) {
|
foreach (Dictionary<String, Object> valueMap in values) {
|
||||||
float time = (float)valueMap["time"];
|
float time = (float)valueMap["time"];
|
||||||
float x = valueMap.ContainsKey("x") ? (float)valueMap["x"] : 0;
|
float x = valueMap.ContainsKey("x") ? (float)valueMap["x"] : 0;
|
||||||
float y = valueMap.ContainsKey("y") ? (float)valueMap["y"] : 0;
|
float y = valueMap.ContainsKey("y") ? (float)valueMap["y"] : 0;
|
||||||
timeline.SetFrame(frameIndex, time, (float)x * timelineScale, (float)y * timelineScale);
|
timeline.SetFrame(frameIndex, time, (float)x * timelineScale, (float)y * timelineScale);
|
||||||
ReadCurve(timeline, frameIndex, valueMap);
|
ReadCurve(timeline, frameIndex, valueMap);
|
||||||
frameIndex++;
|
frameIndex++;
|
||||||
}
|
}
|
||||||
timelines.Add(timeline);
|
timelines.Add(timeline);
|
||||||
duration = Math.Max(duration, timeline.Frames[timeline.FrameCount * 3 - 3]);
|
duration = Math.Max(duration, timeline.Frames[timeline.FrameCount * 3 - 3]);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
throw new Exception("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")");
|
throw new Exception("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map.ContainsKey("slots")) {
|
if (map.ContainsKey("slots")) {
|
||||||
Dictionary<String, Object> slotsMap = (Dictionary<String, Object>)map["slots"];
|
var slotsMap = (Dictionary<String, Object>)map["slots"];
|
||||||
foreach (KeyValuePair<String, Object> entry in slotsMap) {
|
foreach (KeyValuePair<String, Object> entry in slotsMap) {
|
||||||
String slotName = entry.Key;
|
String slotName = entry.Key;
|
||||||
int slotIndex = skeletonData.FindSlotIndex(slotName);
|
int slotIndex = skeletonData.FindSlotIndex(slotName);
|
||||||
Dictionary<String, Object> timelineMap = (Dictionary<String, Object>)entry.Value;
|
var timelineMap = (Dictionary<String, Object>)entry.Value;
|
||||||
|
|
||||||
foreach (KeyValuePair<String, Object> timelineEntry in timelineMap) {
|
foreach (KeyValuePair<String, Object> timelineEntry in timelineMap) {
|
||||||
List<Object> values = (List<Object>)timelineEntry.Value;
|
var values = (List<Object>)timelineEntry.Value;
|
||||||
String timelineName = (String)timelineEntry.Key;
|
String timelineName = (String)timelineEntry.Key;
|
||||||
if (timelineName.Equals(TIMELINE_COLOR)) {
|
if (timelineName.Equals(TIMELINE_COLOR)) {
|
||||||
ColorTimeline timeline = new ColorTimeline(values.Count);
|
ColorTimeline timeline = new ColorTimeline(values.Count);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user