Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #57 from MikalDev/master
Browse files Browse the repository at this point in the history
1.48.0
  • Loading branch information
MikalDev authored Aug 3, 2021
2 parents 9a2a5b8 + e6fb978 commit b3dd76a
Show file tree
Hide file tree
Showing 25 changed files with 507 additions and 147 deletions.
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
- Commisions for specific new features are also accepted, contact Mikal via Twitter @kindeyegames or the Construct Community Discord server (Mikal).

## Important notes for Spine export files:
- Requires Spine version 3.8+ JSON files. See Spine Formatter below to upgrade older JSON files.
- Requires Spine version 3.8.x JSON files.
- Spine 4.0.x files and runtime are not yet supported, but will be done. No ETA yet.
- See Spine Formatter below to upgrade older JSON files.
- In the Spine export dialogue box, under Runtime, set both 'Filter min' and 'Filter mag' to Linear or Nearest.
- In the Packing settings, set Region Padding to 2 or higher (if you see lines around your images, it may be because padding is set to 0).
- Max texture size, 4096x4096. multiple texture sheets supported (use comma separated list on C3 spine object's png path property).
Expand All @@ -17,7 +19,7 @@
- Do not use worker mode for C3 (see below for details.)
- For jumping or large movments, animate Spine character 'in place', don't do large translations in the Spine project.
- Use C3 events and movement to do the large translations in the C3 project instead (e.g. a long jump.)
- If animation is clipping against the bounds of the C3 object, you can use the scale property to make the Spine render smaller
- If animation is clipping against the bounds of the C3 object, you can use the property bbox override and values to control the bounding box size and center offset. The values are based on Spine project coordinates.
- Alternatively create a large transparent image in the Spine project behind your Spine character, this will can be used to set the bounding box size fot the C3 spine render.

## Multiple instances of a C3 Spine Object
Expand Down Expand Up @@ -120,6 +122,12 @@ Useful for Dragon Bones Spine JSON export and earlier Spine versions.
- Preview Spine render in editor (dependent on C3 editor SDK updates)

## Release notes
- 1.48.0 Scripting interface for Apply slot colors, scripting interface for addCustomSkinOutfit (quickly update custom skin from object)
- 1.47.5 Make compatible with ProUI plugin for scroll lists
- 1.47.3 Add bounding box override checkbox (can set bounding box in property, no need for transparent bounding box)
- 1.46.0 More animation scripting interfaces
- 1.45.0 Animation scripting interfaces
- 1.44.0 Palette loading optimization (if only a few palette entries need update, just update those areas of the palette texture, otherwise update entire palette texture.)
- 1.36.1 setTracksListner guard clause (do not crash if skeleton is not initialized or removed.)
- 1.36.0 Init refactor (internal clean up)
- 1.35.0 Fix current time event regression, no apply() in setAnimation (save some CPU)
Expand Down Expand Up @@ -167,3 +175,27 @@ Useful for Dragon Bones Spine JSON export and earlier Spine versions.
- 1.8.0: Instances of a spine object will use the original objects skelton info, reducing texture requirements and faster creation of an instance. Add render quality property. Add TextureHeight and TextureWidth ACEs.
- 1.7.0: Add event trigger ACE (trigger when animation event occurs.)
- 1.6.0: Add Set region action (change region(texture) of an attachment in a slot on the current skin. Useful for character customization.

## Scripting interface

### currentAnimation(trackIndex)
- returns the value of the currentAnimation on trackIndex
- trackIndex: number (track index)
### deleteAnimation(trackIndex, mixDuration)
- trackIndex: number (track index)
- mixDuration: number (mix duration in seconds)
### setAnimation(animationName, loop, start, trackIndex)
- animationName: string (animation name)
- loop: boolean (loop animation)
- start: number (0: beginning, 1: current-time, 2: current-ratio)
- trackIndex: number (track index)
### setAnimationMix(fromName, toName, duration)
- fromName: string (animation name)
- toName: string (animation name)
- duration: number (mix duration in seconds)
### setAnimationSpeed(speed)
- speed: number (speed multiplier)
### setAnimationTime(units, time, trackIndex)
- units: number (0: time in ms, 1: ratio)
- time: number (based on units)
- trackIndex: number (track index)
Binary file added dist/Spine-v1.41.2.c3addon
Binary file not shown.
Binary file added dist/Spine-v1.42.0.c3addon
Binary file not shown.
Binary file added dist/Spine-v1.43.0.c3addon
Binary file not shown.
Binary file added dist/Spine-v1.44.0.c3addon
Binary file not shown.
Binary file added dist/Spine-v1.45.0.c3addon
Binary file not shown.
Binary file added dist/Spine-v1.46.0.c3addon
Binary file not shown.
Binary file added dist/Spine-v1.47.0.c3addon
Binary file not shown.
Binary file added dist/Spine-v1.47.1.c3addon
Binary file not shown.
Binary file added dist/Spine-v1.47.2.c3addon
Binary file not shown.
Binary file added dist/Spine-v1.47.3.c3addon
Binary file not shown.
Binary file added dist/Spine-v1.47.4.c3addon
Binary file not shown.
Binary file added dist/Spine-v1.47.5.c3addon
Binary file not shown.
Binary file added dist/Spine-v1.48.0.c3addon
Binary file not shown.
28 changes: 28 additions & 0 deletions src/aces.json
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,21 @@
}
]
},
{
"id": "set-slot-palette-offset",
"scriptName": "SetSlotPaletteOffset",
"highlight": false,
"params": [
{
"id": "slot-name",
"type": "string"
},
{
"id": "palette-offset",
"type": "number"
}
]
},
{
"id": "set-palette-color",
"scriptName": "SetPaletteColor",
Expand Down Expand Up @@ -1062,6 +1077,19 @@
"returnType": "string",
"params": [
]
},
{
"id": "entry-palette-color-string",
"expressionName": "EntryPaletteColorString",
"scriptName": "EntryPaletteColorString",
"highlight": false,
"returnType": "string",
"params": [
{
"id": "palette-number",
"type": "number"
}
]
}
]
}
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.41.1",
"version": "1.48.0",
"author": "Mikal and Igor Gritsenko",
"website": "https://gritsenko.github.io/c3_spine_plugin",
"documentation": "https://gritsenko.github.io/c3_spine_plugin",
Expand Down
158 changes: 35 additions & 123 deletions src/c3runtime/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,7 @@
},

SetAnimation(animationName, loop, start, trackIndex){
if (!this.skeletonInfo || !this.skeletonInfo.skeleton)
{
if (this.debug) console.warn('[Spine] SetAnimation, no skeleton.', animationName, loop, start, trackIndex, this.uid, this.runtime.GetTickCount());
return;
}

this.animationName = animationName;

this.updateCurrentAnimation(loop, start, trackIndex, animationName);
this.SetRenderOnce(1.0, true, this.uid);
this._setAnimation(animationName, loop, start, trackIndex);
},

SetAlpha(alpha, trackIndex){
Expand All @@ -55,19 +46,7 @@
},

DeleteAnimation(trackIndex, mixDuration) {
if (!this.skeletonInfo || !this.skeletonInfo.skeleton)
{
if (this.debug) console.warn('[Spine] DeleteAnimation, no skelton.', trackIndex, mixDuration, this.uid, this.runtime.GetTickCount());
return;
}

const state = this.skeletonInfo.state;
if(!state || !state.tracks) return;
const track = state.tracks[trackIndex];
if(!track) return;

state.setEmptyAnimation(trackIndex, mixDuration);
this.SetRenderOnce(1.0, true, this.uid);
this._deleteAnimation(trackIndex, mixDuration);
},

Play(){
Expand All @@ -84,7 +63,7 @@
this.updateBounds();
},
SetAnimationSpeed(speed){
this.animationSpeed = speed;
this._setAnimationSpeed(speed);
},

SetRegion(slotName, attachmentName, regionName){
Expand Down Expand Up @@ -144,8 +123,14 @@
}

const skeleton = this.skeletonInfo.skeleton;

this.customSkins[skinName] = new spine.Skin(skinName);
// If already exists, just clear
if (this.customSkins[skinName])
{
this.customSkins[skinName].clear();
} else
{
this.customSkins[skinName] = new spine.Skin(skinName);
}
},

AddCustomSkin(skinName,addSkinName)
Expand All @@ -163,7 +148,7 @@
let addSkin = skeleton.data.findSkin(addSkinName);
if (addSkin)
{
this.customSkins[skinName].addSkin(skeleton.data.findSkin(addSkinName));
this.customSkins[skinName].addSkin(addSkin);
} else
{
if (this.debug) console.warn('[Spine] AddCustomSkin, add skin does not exist',skinName,addSkinName, this.uid, this.runtime.GetTickCount());
Expand All @@ -185,7 +170,6 @@

this.skinName = skinName
const skeleton = this.skeletonInfo.skeleton;
this.customSkins[this.skinName]
skeleton.setSkin(this.customSkins[this.skinName]);
skeleton.setSlotsToSetupPose();

Expand Down Expand Up @@ -235,53 +219,7 @@

ApplySlotColors()
{
if (!this.skeletonInfo || !this.skeletonInfo.skeleton)
{
if (this.debug) console.warn('[Spine] ApplySlotColors, no skeleton.', this.uid, this.runtime.GetTickCount());
return;
}

const skeleton = this.skeletonInfo.skeleton;
// Set regular colors to slots
let slotName;
for(slotName in this.slotColors)
{
let slot = skeleton.findSlot(slotName);
if (slot === null)
{
console.warn("[Spine] ApplySlotColors, slot not found: ",slotName,this.uid,this.runtime.GetTickCount());
continue;
}
let color = this.slotColors[slotName];
slot.color.set(
spineBatcher.getRValue(color),
spineBatcher.getGValue(color),
spineBatcher.getBValue(color),
spineBatcher.getAValue(color));
}

// Set dark colors to slots
for(slotName in this.slotDarkColors)
{
let slot = skeleton.findSlot(slotName);
if (slot === null)
{
console.warn("[Spine] ApplySlotColors dark color, slot not found: ",slotName,this.uid,this.runtime.GetTickCount());
continue;
}
// Set only if dark Color is available, (Tint Black must be applied to the slot in the project.)
if (slot.darkColor)
{
let color = this.slotDarkColors[slotName];
slot.darkColor.set(
spineBatcher.getRValue(color),
spineBatcher.getGValue(color),
spineBatcher.getBValue(color),
spineBatcher.getAValue(color));
}
}

this.SetRenderOnce(1.0, true, this.uid);
this._applySlotColors()
},

ResetSlotColors()
Expand All @@ -302,39 +240,7 @@

SetAnimationTime(units, time, trackIndex)
{
if (!this.skeletonInfo || !this.skeletonInfo.state)
{
if (this.debug) console.warn('[Spine] SetAninationTime, no state.',units, time, trackIndex, this.uid, this.runtime.GetTickCount());
return;
}

const state = this.skeletonInfo.state;
if(!state || !state.tracks) return;

const track = state.tracks[trackIndex];
if(!track) return;

if (units == 0)
// time in ms
{
if (time < track.animationStart || time > track.animationEnd)
{
if (this.debug) console.warn('[Spine] SetAnimationTime time out of bounds:', units, time, trackIndex, this.uid, this.runtime.GetTickCount());
return;
}
track.trackTime = time;
} else
// time in ratio
{
if (time < 0 || time > 1)
{
if (this.debug) console.warn('[Spine] SetAnimationTime ratio out of bounds:', units, time, trackIndex, this.uid, this.runtime.GetTickCount());
return;
}
track.trackTime = time * (track.animationEnd - track.animationStart);
}

this.SetRenderOnce(1.0, true, this.uid);
this._setAnimationTime(units, time, trackIndex);
},

UpdateBBoxes()
Expand All @@ -344,21 +250,7 @@

SetAnimationMix(fromName, toName, duration)
{
if (!this.skeletonInfo || !this.skeletonInfo.stateData)
{
if (this.debug) console.warn('[Spine] SetAnimationMix, no stateData.', fromName, toName, duration, this.uid, this.runtime.GetTickCount());
return;
}

const stateData = this.skeletonInfo.stateData;
try
{
stateData.setMix(fromName, toName, duration);
}
catch (error)
{
console.error('[Spine] SetAnimationMix:', error);
}
this._setAnimationMix(fromName, toName, duration);
},

SetObjectRenderRate(renderRate)
Expand Down Expand Up @@ -409,6 +301,7 @@

SetSkeletondataRenderQuality(renderQuality)
{
this.sdkType._skeletonRenderQuality = renderQuality;
const assetManager = this._sdkType._assetManager;
const assetTag = this._sdkType._assetTag;
this._sdkType._skeletonJson.scale = renderQuality;
Expand Down Expand Up @@ -491,6 +384,11 @@
this.palette.setSlotPalette(slotName, paletteNumber);
},

SetSlotPaletteOffset(slotName, paletteOffset)
{
this.palette.setSlotPaletteOffset(slotName, paletteOffset);
},

SetPaletteDefaultColors(paletteNumber)
{
if (!this.skeletonInfo || !this.skeletonInfo.skeleton)
Expand All @@ -500,6 +398,9 @@
}

this.palette.setDefaultColors(paletteNumber, 1.0, 1.0);

this.palette.entryUploadNeeded[paletteNumber] = true;
this.palette.uploadNeeded = true;
},

SetPaletteColor(paletteNumber, index, color)
Expand All @@ -512,6 +413,7 @@

this.palette.setColor(paletteNumber, index, color)

this.palette.entryUploadNeeded[paletteNumber] = true;
this.palette.uploadNeeded = true;
},

Expand All @@ -526,6 +428,8 @@
{
this.palette.palette[i/2] = parseInt(value.substring(i,i+2), 16);
}

this.palette.entryUploadNeeded.fill(true);
this.palette.uploadNeeded = true;
},

Expand All @@ -541,7 +445,15 @@
{
this.palette.palette[indexSize*paletteNumber*4+i/2] = parseInt(value.substring(i,i+2), 16);
}

this.palette.entryUploadNeeded[paletteNumber] = true;
this.palette.uploadNeeded = true;
},

// For ProUI scrollview control of object blend mode
SetEffect(effect) {
this.GetWorldInfo().SetBlendMode(effect);
this.runtime.UpdateRender()
}
}
}
Loading

0 comments on commit b3dd76a

Please sign in to comment.