Refactoring: changed references to "bind pose" to "setup pose".

This better matches "setup mode" in the editor and we can be consistent in code and docs from now on.
This commit is contained in:
NathanSweet 2013-05-05 12:38:06 +02:00
parent 80fdba02a1
commit 7f69300bcc
35 changed files with 1203 additions and 98 deletions

View File

@ -27,7 +27,7 @@ public class Bone {
throw new ArgumentError("data cannot be null.");
_data = data;
_parent = parent;
setToBindPose();
setToSetupPose();
}
/** Computes the world SRT using the parent bone and the local SRT. */
@ -66,7 +66,7 @@ public class Bone {
}
}
public function setToBindPose () : void {
public function setToSetupPose () : void {
x = _data.x;
y = _data.y;
rotation = _data.rotation;

View File

@ -42,20 +42,20 @@ public class Skeleton {
bone.updateWorldTransform(flipX, flipY);
}
/** Sets the bones and slots to their bind pose values. */
public function setToBindPose () : void {
setBonesToBindPose();
setSlotsToBindPose();
/** Sets the bones and slots to their setup pose values. */
public function setToSetupPose () : void {
setBonesToSetupPose();
setSlotsToSetupPose();
}
public function setBonesToBindPose () : void {
public function setBonesToSetupPose () : void {
for each (var bone:Bone in _bones)
bone.setToBindPose();
bone.setToSetupPose();
}
public function setSlotsToBindPose () : void {
public function setSlotsToSetupPose () : void {
for each (var slot:Slot in _slots)
slot.setToBindPose();
slot.setToSetupPose();
}
public function get data () : SkeletonData {

View File

@ -4,7 +4,7 @@ import spine.animation.Animation;
public class SkeletonData {
public var name:String;
public var bones:Vector.<BoneData> = new Vector.<BoneData>(); // Ordered parents first.
public var slots:Vector.<SlotData> = new Vector.<SlotData>(); // Bind pose draw order.
public var slots:Vector.<SlotData> = new Vector.<SlotData>(); // Setup pose draw order.
public var skins:Vector.<Skin> = new Vector.<Skin>();
public var defaultSkin:Skin;
public var animations:Vector.<Animation> = new Vector.<Animation>();

View File

@ -22,7 +22,7 @@ public class Slot {
_data = data;
_skeleton = skeleton;
_bone = bone;
setToBindPose();
setToSetupPose();
}
public function get data () : SlotData {
@ -58,7 +58,7 @@ public class Slot {
return skeleton.time - _attachmentTime;
}
public function setToBindPose () : void {
public function setToSetupPose () : void {
var slotIndex:int = skeleton.data.slots.indexOf(data);
r = _data.r;
g = _data.g;

View File

@ -53,7 +53,7 @@ void Bone_setYDown (int/*bool*/yDown);
Bone* Bone_create (BoneData* data, Bone* parent);
void Bone_dispose (Bone* self);
void Bone_setToBindPose (Bone* self);
void Bone_setToSetupPose (Bone* self);
void Bone_updateWorldTransform (Bone* self, int/*bool*/flipX, int/*bool*/flipY);

View File

@ -58,9 +58,9 @@ void Skeleton_dispose (Skeleton* self);
void Skeleton_updateWorldTransform (const Skeleton* self);
void Skeleton_setToBindPose (const Skeleton* self);
void Skeleton_setBonesToBindPose (const Skeleton* self);
void Skeleton_setSlotsToBindPose (const Skeleton* self);
void Skeleton_setToSetupPose (const Skeleton* self);
void Skeleton_setBonesToSetupPose (const Skeleton* self);
void Skeleton_setSlotsToSetupPose (const Skeleton* self);
/* Returns 0 if the bone was not found. */
Bone* Skeleton_findBone (const Skeleton* self, const char* boneName);

View File

@ -54,7 +54,7 @@ void Slot_setAttachment (Slot* self, Attachment* attachment);
void Slot_setAttachmentTime (Slot* self, float time);
float Slot_getAttachmentTime (const Slot* self);
void Slot_setToBindPose (Slot* self);
void Slot_setToSetupPose (Slot* self);
#ifdef __cplusplus
}

View File

@ -43,7 +43,7 @@ typedef struct {
SlotData* SlotData_create (const char* name, BoneData* boneData);
void SlotData_dispose (SlotData* self);
/* @param attachmentName May be 0 for no bind pose attachment. */
/* @param attachmentName May be 0 for no setup pose attachment. */
void SlotData_setAttachmentName (SlotData* self, const char* attachmentName);
#ifdef __cplusplus

View File

@ -41,7 +41,7 @@ Bone* Bone_create (BoneData* data, Bone* parent) {
Bone* self = NEW(Bone);
CONST_CAST(BoneData*, self->data) = data;
CONST_CAST(Bone*, self->parent) = parent;
Bone_setToBindPose(self);
Bone_setToSetupPose(self);
return self;
}
@ -49,7 +49,7 @@ void Bone_dispose (Bone* self) {
FREE(self);
}
void Bone_setToBindPose (Bone* self) {
void Bone_setToSetupPose (Bone* self) {
self->x = self->data->x;
self->y = self->data->y;
self->rotation = self->data->rotation;

View File

@ -104,21 +104,21 @@ void Skeleton_updateWorldTransform (const Skeleton* self) {
Bone_updateWorldTransform(self->bones[i], self->flipX, self->flipY);
}
void Skeleton_setToBindPose (const Skeleton* self) {
Skeleton_setBonesToBindPose(self);
Skeleton_setSlotsToBindPose(self);
void Skeleton_setToSetupPose (const Skeleton* self) {
Skeleton_setBonesToSetupPose(self);
Skeleton_setSlotsToSetupPose(self);
}
void Skeleton_setBonesToBindPose (const Skeleton* self) {
void Skeleton_setBonesToSetupPose (const Skeleton* self) {
int i;
for (i = 0; i < self->boneCount; ++i)
Bone_setToBindPose(self->bones[i]);
Bone_setToSetupPose(self->bones[i]);
}
void Skeleton_setSlotsToBindPose (const Skeleton* self) {
void Skeleton_setSlotsToSetupPose (const Skeleton* self) {
int i;
for (i = 0; i < self->slotCount; ++i)
Slot_setToBindPose(self->slots[i]);
Slot_setToSetupPose(self->slots[i]);
}
Bone* Skeleton_findBone (const Skeleton* self, const char* boneName) {

View File

@ -41,7 +41,7 @@ Slot* Slot_create (SlotData* data, Skeleton* skeleton, Bone* bone) {
CONST_CAST(SlotData*, self->data) = data;
CONST_CAST(Skeleton*, self->skeleton) = skeleton;
CONST_CAST(Bone*, self->bone) = bone;
Slot_setToBindPose(self);
Slot_setToSetupPose(self);
return self;
}
@ -62,7 +62,7 @@ float Slot_getAttachmentTime (const Slot* self) {
return self->skeleton->time - SUB_CAST(_Internal, self) ->attachmentTime;
}
void Slot_setToBindPose (Slot* self) {
void Slot_setToSetupPose (Slot* self) {
Attachment* attachment = 0;
self->r = self->data->r;
self->g = self->data->g;

View File

@ -56,9 +56,9 @@ Draws a skeleton.
// --- Convenience methods for common Skeleton_* functions.
- (void) updateWorldTransform;
- (void) setToBindPose;
- (void) setBonesToBindPose;
- (void) setSlotsToBindPose;
- (void) setToSetupPose;
- (void) setBonesToSetupPose;
- (void) setSlotsToSetupPose;
/* Returns 0 if the bone was not found. */
- (Bone*) findBone:(NSString*)boneName;

View File

@ -240,14 +240,14 @@
Skeleton_updateWorldTransform(_skeleton);
}
- (void) setToBindPose {
Skeleton_setToBindPose(_skeleton);
- (void) setToSetupPose {
Skeleton_setToSetupPose(_skeleton);
}
- (void) setBonesToBindPose {
Skeleton_setBonesToBindPose(_skeleton);
- (void) setBonesToSetupPose {
Skeleton_setBonesToSetupPose(_skeleton);
}
- (void) setSlotsToBindPose {
Skeleton_setSlotsToBindPose(_skeleton);
- (void) setSlotsToSetupPose {
Skeleton_setSlotsToSetupPose(_skeleton);
}
- (Bone*) findBone:(NSString*)boneName {

View File

@ -229,14 +229,14 @@ void CCSkeleton::updateWorldTransform () {
Skeleton_updateWorldTransform(skeleton);
}
void CCSkeleton::setToBindPose () {
Skeleton_setToBindPose(skeleton);
void CCSkeleton::setToSetupPose () {
Skeleton_setToSetupPose(skeleton);
}
void CCSkeleton::setBonesToBindPose () {
Skeleton_setBonesToBindPose(skeleton);
void CCSkeleton::setBonesToSetupPose () {
Skeleton_setBonesToSetupPose(skeleton);
}
void CCSkeleton::setSlotsToBindPose () {
Skeleton_setSlotsToBindPose(skeleton);
void CCSkeleton::setSlotsToSetupPose () {
Skeleton_setSlotsToSetupPose(skeleton);
}
Bone* CCSkeleton::findBone (const char* boneName) const {

View File

@ -59,9 +59,9 @@ public:
// --- Convenience methods for common Skeleton_* functions.
void updateWorldTransform ();
void setToBindPose ();
void setBonesToBindPose ();
void setSlotsToBindPose ();
void setToSetupPose ();
void setBonesToSetupPose ();
void setSlotsToSetupPose ();
/* Returns 0 if the bone was not found. */
Bone* findBone (const char* boneName) const;

View File

@ -20,7 +20,7 @@ skeleton.flipX = false
skeleton.flipY = false
skeleton.debug = true -- Omit or set to false to not draw debug lines on top of the images.
if name == "goblins" then skeleton:setSkin("goblingirl") end
skeleton:setToBindPose()
skeleton:setToSetupPose()
local lastTime = 0
local animationTime = 0

View File

@ -52,7 +52,7 @@ namespace Spine {
if (data == null) throw new ArgumentNullException("data cannot be null.");
Data = data;
Parent = parent;
SetToBindPose();
SetToSetupPose();
}
/** Computes the world SRT using the parent bone and the local SRT. */
@ -92,7 +92,7 @@ namespace Spine {
}
}
public void SetToBindPose () {
public void SetToSetupPose () {
BoneData data = Data;
X = data.X;
Y = data.Y;

View File

@ -80,22 +80,22 @@ namespace Spine {
bones[i].UpdateWorldTransform(flipX, flipY);
}
/** Sets the bones and slots to their bind pose values. */
public void SetToBindPose () {
SetBonesToBindPose();
SetSlotsToBindPose();
/** Sets the bones and slots to their setup pose values. */
public void SetToSetupPose () {
SetBonesToSetupPose();
SetSlotsToSetupPose();
}
public void SetBonesToBindPose () {
public void SetBonesToSetupPose () {
List<Bone> bones = this.Bones;
for (int i = 0, n = bones.Count; i < n; i++)
bones[i].SetToBindPose();
bones[i].SetToSetupPose();
}
public void SetSlotsToBindPose () {
public void SetSlotsToSetupPose () {
List<Slot> slots = this.Slots;
for (int i = 0, n = slots.Count; i < n; i++)
slots[i].SetToBindPose(i);
slots[i].SetToSetupPose(i);
}
/** @return May be null. */

View File

@ -30,7 +30,7 @@ namespace Spine {
public class SkeletonData {
public String Name { get; set; }
public List<BoneData> Bones { get; private set; } // Ordered parents first.
public List<SlotData> Slots { get; private set; } // Bind pose draw order.
public List<SlotData> Slots { get; private set; } // Setup pose draw order.
public List<Skin> Skins { get; private set; }
/** May be null. */
public Skin DefaultSkin;

View File

@ -64,10 +64,10 @@ namespace Spine {
Data = data;
Skeleton = skeleton;
Bone = bone;
SetToBindPose();
SetToSetupPose();
}
internal void SetToBindPose (int slotIndex) {
internal void SetToSetupPose (int slotIndex) {
R = Data.R;
G = Data.G;
B = Data.B;
@ -75,8 +75,8 @@ namespace Spine {
Attachment = Data.AttachmentName == null ? null : Skeleton.GetAttachment(slotIndex, Data.AttachmentName);
}
public void SetToBindPose () {
SetToBindPose(Skeleton.Data.Slots.IndexOf(Data));
public void SetToSetupPose () {
SetToSetupPose(Skeleton.Data.Slots.IndexOf(Data));
}
override public String ToString () {

1
spine-js/index.html Normal file
View File

@ -0,0 +1 @@
<script src="spine.js"></script>

1104
spine-js/spine.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -47,7 +47,7 @@ public class Bone {
if (data == null) throw new IllegalArgumentException("data cannot be null.");
this.data = data;
this.parent = parent;
setToBindPose();
setToSetupPose();
}
/** Copy constructor.
@ -95,7 +95,7 @@ public class Bone {
}
}
public void setToBindPose () {
public void setToSetupPose () {
BoneData data = this.data;
x = data.x;
y = data.y;

View File

@ -101,22 +101,22 @@ public class Skeleton {
bones.get(i).updateWorldTransform(flipX, flipY);
}
/** Sets the bones and slots to their bind pose values. */
public void setToBindPose () {
setBonesToBindPose();
setSlotsToBindPose();
/** Sets the bones and slots to their setup pose values. */
public void setToSetupPose () {
setBonesToSetupPose();
setSlotsToSetupPose();
}
public void setBonesToBindPose () {
public void setBonesToSetupPose () {
Array<Bone> bones = this.bones;
for (int i = 0, n = bones.size; i < n; i++)
bones.get(i).setToBindPose();
bones.get(i).setToSetupPose();
}
public void setSlotsToBindPose () {
public void setSlotsToSetupPose () {
Array<Slot> slots = this.slots;
for (int i = 0, n = slots.size; i < n; i++)
slots.get(i).setToBindPose(i);
slots.get(i).setToSetupPose(i);
}
public SkeletonData getData () {

View File

@ -30,7 +30,7 @@ import com.badlogic.gdx.utils.Array;
public class SkeletonData {
String name;
final Array<BoneData> bones = new Array(); // Ordered parents first.
final Array<SlotData> slots = new Array(); // Bind pose draw order.
final Array<SlotData> slots = new Array(); // Setup pose draw order.
final Array<Skin> skins = new Array();
Skin defaultSkin;
final Array<Animation> animations = new Array();

View File

@ -52,7 +52,7 @@ public class Slot {
this.skeleton = skeleton;
this.bone = bone;
color = new Color();
setToBindPose();
setToSetupPose();
}
/** Copy constructor. */
@ -105,13 +105,13 @@ public class Slot {
return skeleton.time - attachmentTime;
}
void setToBindPose (int slotIndex) {
void setToSetupPose (int slotIndex) {
color.set(data.color);
setAttachment(data.attachmentName == null ? null : skeleton.getAttachment(slotIndex, data.attachmentName));
}
public void setToBindPose () {
setToBindPose(skeleton.data.slots.indexOf(data, true));
public void setToSetupPose () {
setToSetupPose(skeleton.data.slots.indexOf(data, true));
}
public String toString () {

View File

@ -68,7 +68,7 @@ public class MixTest extends ApplicationAdapter {
jumpAnimation = skeletonData.findAnimation("jump");
skeleton = new Skeleton(skeletonData);
skeleton.setToBindPose();
skeleton.setToSetupPose();
final Bone root = skeleton.getRootBone();
root.x = -50;

View File

@ -88,7 +88,7 @@ public class SkeletonTest extends ApplicationAdapter {
skeleton = new Skeleton(skeletonData);
if (name.equals("goblins")) skeleton.setSkin("goblin");
skeleton.setToBindPose();
skeleton.setToSetupPose();
skeleton = new Skeleton(skeleton);
Bone root = skeleton.getRootBone();
@ -103,7 +103,7 @@ public class SkeletonTest extends ApplicationAdapter {
if (keycode == Keys.SPACE) {
if (name.equals("goblins")) {
skeleton.setSkin(skeleton.getSkin().getName().equals("goblin") ? "goblingirl" : "goblin");
skeleton.setSlotsToBindPose();
skeleton.setSlotsToSetupPose();
}
}
return true;

View File

@ -41,7 +41,7 @@ skeleton.flipX = false
skeleton.flipY = false
skeleton.debugBones = true -- Omit or set to false to not draw debug lines on top of the images.
skeleton.debugSlots = false
skeleton:setToBindPose()
skeleton:setToSetupPose()
local animationTime = 0
function love.update (delta)

View File

@ -65,7 +65,7 @@ function Bone.new (data, parent)
end
end
function self:setToBindPose ()
function self:setToSetupPose ()
local data = self.data
self.x = data.x
self.y = data.y

View File

@ -44,20 +44,20 @@ function Skeleton.new (skeletonData)
end
end
function self:setToBindPose ()
self:setBonesToBindPose()
self:setSlotsToBindPose()
function self:setToSetupPose ()
self:setBonesToSetupPose()
self:setSlotsToSetupPose()
end
function self:setBonesToBindPose ()
function self:setBonesToSetupPose ()
for i,bone in ipairs(self.bones) do
bone:setToBindPose()
bone:setToSetupPose()
end
end
function self:setSlotsToBindPose ()
function self:setSlotsToSetupPose ()
for i,slot in ipairs(self.slots) do
slot:setToBindPose()
slot:setToSetupPose()
end
end

View File

@ -55,7 +55,7 @@ function Slot.new (slotData, skeleton, bone)
return self.skeleton.time - self.attachmentTime
end
function self:setToBindPose ()
function self:setToSetupPose ()
local data = self.data
self:setColor(data.r, data.g, data.b, data.a)
@ -67,7 +67,7 @@ function Slot.new (slotData, skeleton, bone)
self:setAttachment(attachment)
end
self:setToBindPose()
self:setToSetupPose()
return self
end

View File

@ -50,7 +50,7 @@ void spineboy () {
Skeleton* skeleton = drawable->skeleton;
skeleton->flipX = false;
skeleton->flipY = false;
Skeleton_setToBindPose(skeleton);
Skeleton_setToSetupPose(skeleton);
skeleton->root->x = 320;
skeleton->root->y = 420;
@ -108,7 +108,7 @@ void goblins () {
skeleton->flipX = false;
skeleton->flipY = false;
Skeleton_setSkinByName(skeleton, "goblin");
Skeleton_setSlotsToBindPose(skeleton);
Skeleton_setSlotsToSetupPose(skeleton);
// Skeleton_setAttachment(skeleton, "left hand item", "dagger");
skeleton->root->x = 320;

View File

@ -96,11 +96,11 @@ public class SkeletonComponent : MonoBehaviour {
if (skinName == null || skinName.Length == 0) {
if (skeleton.Skin != null) {
skeleton.SetSkin((Skin)null);
skeleton.SetSlotsToBindPose();
skeleton.SetSlotsToSetupPose();
}
} else if (skeleton.Skin == null || skinName != skeleton.Skin.Name) {
skeleton.SetSkin(skinName);
skeleton.SetSlotsToBindPose();
skeleton.SetSlotsToSetupPose();
}
UpdateAnimation();

View File

@ -64,7 +64,7 @@ namespace Spine {
SkeletonJson json = new SkeletonJson(atlas);
skeleton = new Skeleton(json.ReadSkeletonData("data/" + name + ".json"));
if (name == "goblins") skeleton.SetSkin("goblingirl");
skeleton.SetSlotsToBindPose(); // Without this the skin attachments won't be attached. See SetSkin.
skeleton.SetSlotsToSetupPose(); // Without this the skin attachments won't be attached. See SetSkin.
// Define mixing between animations.
AnimationStateData stateData = new AnimationStateData(skeleton.Data);