Skip to content

Commit

Permalink
Merge pull request #3 from MikalDev/bone-control
Browse files Browse the repository at this point in the history
1.33.0 Add expressions and condition for bone control
  • Loading branch information
MikalDev authored Feb 1, 2021
2 parents af1e1ee + 79a7f81 commit 3d35436
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 8 deletions.
Binary file added dist/Spine-v1.33.0.c3addon
Binary file not shown.
94 changes: 94 additions & 0 deletions src/aces.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,30 @@
"initial-value": 0
}
]
},
{
"id": "is-bone-control-property-active",
"scriptName": "IsBoneControlPropertyActive",
"isTrigger": false,
"params": [
{
"id": "bone",
"type": "string",
"initialValue" : "\"\""
},
{
"id": "property",
"type": "combo",
"items": [
"x",
"y",
"rotation",
"scale-x",
"scale-y"
],
"initialValue" : "x"
}
]
}
],
"actions": [
Expand Down Expand Up @@ -695,6 +719,76 @@
"type": "string"
}
]
},
{
"id": "bone-x",
"expressionName": "BoneX",
"scriptName": "BoneX",
"highlight": false,
"returnType": "number",
"params": [
{
"id": "bone",
"type": "string",
"initialValue" : "\"\""
}
]
},
{
"id": "bone-y",
"expressionName": "BoneY",
"scriptName": "BoneY",
"highlight": false,
"returnType": "number",
"params": [
{
"id": "bone",
"type": "string",
"initialValue" : "\"\""
}
]
},
{
"id": "bone-rotation",
"expressionName": "BoneRotation",
"scriptName": "BoneRotation",
"highlight": false,
"returnType": "number",
"params": [
{
"id": "bone",
"type": "string",
"initialValue" : "\"\""
}
]
},
{
"id": "bone-scale-x",
"expressionName": "BoneScaleX",
"scriptName": "BoneScaleX",
"highlight": false,
"returnType": "number",
"params": [
{
"id": "bone",
"type": "string",
"initialValue" : "\"\""
}
]
},
{
"id": "bone-scale-y",
"expressionName": "BoneScaleY",
"scriptName": "BoneScaleY",
"highlight": false,
"returnType": "number",
"params": [
{
"id": "bone",
"type": "string",
"initialValue" : "\"\""
}
]
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion src/addon.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "plugin",
"name": "Spine",
"id": "Gritsenko_Spine",
"version": "1.32.0",
"version": "1.33.0",
"author": "Mikal and Igor Gritsenko",
"website": "https://gritsenko.github.io/c3_spine_plugin",
"documentation": "https://gritsenko.github.io/c3_spine_plugin",
Expand Down
10 changes: 10 additions & 0 deletions src/c3runtime/conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@
},
OnEvent(eventName, trackIndex) {
return (this.completeEventName === eventName) && (this.completeEventTrackIndex === trackIndex);
},

IsBoneControlPropertyActive(bone, propertyIndex) {
let properties=['x','y','rotation','scaleX','scaleY'];
let property = properties[propertyIndex];

if (!this.spineBoneControl.bones.hasOwnProperty(bone)) return false;
if (!this.spineBoneControl.bones[bone].hasOwnProperty(property)) return false;

return true;
}
};
}
33 changes: 32 additions & 1 deletion src/c3runtime/expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,37 @@
}
}
return JSON.stringify(points);
}
},

BoneX(bone){
if (!this.spineBoneControl.bones.hasOwnProperty(bone)) return 0;
if (!this.spineBoneControl.bones[bone].hasOwnProperty('x')) return 0;

return this.spineBoneControl.bones[bone].x;
},
BoneY(bone){
if (!this.spineBoneControl.bones.hasOwnProperty(bone)) return 0;
if (!this.spineBoneControl.bones[bone].hasOwnProperty('y')) return 0;

return this.spineBoneControl.bones[bone].y;
},
BoneRotation(bone){
if (!this.spineBoneControl.bones.hasOwnProperty(bone)) return 0;
if (!this.spineBoneControl.bones[bone].hasOwnProperty('rotation')) return 0;

return this.spineBoneControl.bones[bone].rotation;
},
BoneScaleX(bone){
if (!this.spineBoneControl.bones.hasOwnProperty(bone)) return 0;
if (!this.spineBoneControl.bones[bone].hasOwnProperty('scaleX')) return 0;

return this.spineBoneControl.bones[bone].scaleX;
},
BoneScaleY(bone){
if (!this.spineBoneControl.bones.hasOwnProperty(bone)) return 0;
if (!this.spineBoneControl.bones[bone].hasOwnProperty('scaleY')) return 0;

return this.spineBoneControl.bones[bone].scaleY;
},
};
}
8 changes: 4 additions & 4 deletions src/c3runtime/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,14 @@
this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnEvent);
}
};
state.apply(skeleton);
skeleton.updateWorldTransform();
// state.apply(skeleton);
// skeleton.updateWorldTransform();

} else
// If starting later, apply time, then enable listeners so they do not trigger on past events
{
state.apply(skeleton);
skeleton.updateWorldTransform();
// state.apply(skeleton);
// skeleton.updateWorldTransform();
state.tracks[trackIndex].listener = {
complete: (trackEntry, count) => {
this.completeAnimationName = this.trackAnimations[trackEntry.trackIndex];
Expand Down
2 changes: 1 addition & 1 deletion src/c3runtime/spine-draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,6 @@ class SpineBatch {

if (!globalThis.spineBatcher)
{
console.log('[Spine] SpineBatcher init, 1.32.0');
console.log('[Spine] SpineBatcher init, 1.33.0');
globalThis.spineBatcher = new SpineBatch();
}
72 changes: 72 additions & 0 deletions src/lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,28 @@
"desc": "Track index"
}
}
},
"is-bone-control-property-active": {
"list-name": "Is bone control property active",
"display-text": "Is {0} {1} control active",
"description": "Is bone control property active.",
"params": {
"bone": {
"name": "Bone",
"desc": "Name of bone."
},
"property": {
"name": "Property",
"desc": "Property to control.",
"items": {
"x": "X",
"y": "Y",
"rotation": "Rotation",
"scale-x": "Scale X",
"scale-y": "Scale Y"
}
}
}
}
},
"actions": {
Expand Down Expand Up @@ -704,6 +726,56 @@
"desc": "Name of spine bounding box attachment."
}
}
},
"bone-x": {
"description": "Bone control x",
"translated-name": "BoneX",
"params": {
"bone": {
"name": "Bone",
"desc": "Name of bone."
}
}
},
"bone-y": {
"description": "Bone control y",
"translated-name": "BoneY",
"params": {
"bone": {
"name": "Bone",
"desc": "Name of bone."
}
}
},
"bone-rotation": {
"description": "Bone control rotation",
"translated-name": "BoneRotation",
"params": {
"bone": {
"name": "Bone",
"desc": "Name of bone."
}
}
},
"bone-scale-x": {
"description": "Bone control scale x",
"translated-name": "BoneScaleX",
"params": {
"bone": {
"name": "Bone",
"desc": "Name of bone."
}
}
},
"bone-scale-y": {
"description": "Bone control scale y",
"translated-name": "BoneScaleY",
"params": {
"bone": {
"name": "Bone",
"desc": "Name of bone."
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const C3 = self.C3;

const PLUGIN_ID = "Gritsenko_Spine";
const PLUGIN_VERSION = "1.32.0";
const PLUGIN_VERSION = "1.33.0";
const PLUGIN_CATEGORY = "general";

const PLUGIN_CLASS = SDK.Plugins.Gritsenko_Spine = class SpinePlugin extends SDK.IPluginBase {
Expand Down

0 comments on commit 3d35436

Please sign in to comment.