experimental support movie clips

This commit is contained in:
2016-03-07 21:12:51 +06:00
parent a37a53bff2
commit 8785559257
11 changed files with 112 additions and 6 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 689b957cddf114eaeadf8b24f4248012
timeCreated: 1457104688
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f50ce2cf5fd054e11abbf783d224ef6a
timeCreated: 1457118722
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 738db8825096841bb9606d1072b4e213
timeCreated: 1457105253
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -145,7 +145,7 @@ Camera:
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic size: 1
orthographic size: 3
m_Depth: -1
m_CullingMask:
serializedVersion: 2

View File

@@ -39,6 +39,11 @@ namespace FlashTools {
Symbol
}
public enum FlashAnimSymbolType {
Graphic,
MovieClip
}
[System.Serializable]
public struct FlashAnimColorTransform {
public Vector4 Mul;
@@ -90,6 +95,7 @@ namespace FlashTools {
public class FlashAnimInstData {
public FlashAnimInstType Type = FlashAnimInstType.Bitmap;
public FlashAnimBlendMode BlendMode = FlashAnimBlendMode.Normal;
public FlashAnimSymbolType SymbolType = FlashAnimSymbolType.Graphic;
public string Asset = string.Empty;
public bool Visible = true;
public int FirstFrame = 0;

View File

@@ -54,6 +54,7 @@ namespace FlashTools.Internal {
LoadFlashAnimStageFromFtaRootElem (root_elem, data);
LoadFlashAnimLibraryFromFtaRootElem(root_elem, data);
LoadFlashAnimStringsFromFtaRootElem(root_elem, data);
ConfigureMovieClips(data);
data.FrameRate = SafeLoadIntFromElemAttr(
root_elem, "frame_rate", data.FrameRate);
return data;
@@ -130,6 +131,7 @@ namespace FlashTools.Internal {
var instance = new FlashAnimInstData();
instance.Type = SafeLoadEnumFromElemAttr(inst_elem, "type" , instance.Type);
instance.BlendMode = SafeLoadEnumFromElemAttr(inst_elem, "blend_mode" , instance.BlendMode);
instance.SymbolType = SafeLoadEnumFromElemAttr(inst_elem, "symbol_type" , instance.SymbolType);
instance.Asset = SafeLoadStrFromElemAttr (inst_elem, "asset" , instance.Asset);
instance.Visible = SafeLoadBoolFromElemAttr(inst_elem, "visible" , instance.Visible);
instance.FirstFrame = SafeLoadIntFromElemAttr (inst_elem, "first_frame" , instance.FirstFrame);
@@ -157,6 +159,68 @@ namespace FlashTools.Internal {
}
}
static void ConfigureMovieClips(FlashAnimData data) {
ConfigureSymbol(data.Stage);
foreach ( var symbol in data.Library.Symbols ) {
ConfigureSymbol(symbol);
}
}
static void ConfigureSymbol(FlashAnimSymbolData data) {
foreach ( var layer in data.Layers ) {
ConfigureLayer(layer);
}
}
static void ConfigureLayer(FlashAnimLayerData data) {
ResetMovieClipsOnLayer(data);
for ( var i = 0; i < data.Frames.Count; ++i ) {
var frame = data.Frames[i];
foreach ( var elem in frame.Elems ) {
if ( IsInstanceMovieClip(elem.Instance) && elem.Instance.FirstFrame == -1 ) {
elem.Instance.FirstFrame = 0;
int count = 0;
for ( var i2 = i + 1; i2 < data.Frames.Count; ++i2 ) {
var frame2 = data.Frames[i2];
var has_elem = false;
foreach ( var elem2 in frame2.Elems ) {
if ( IsInstanceMovieClip(elem2.Instance) && elem2.Instance.FirstFrame == -1 ) {
if ( elem.Id == elem2.Id && elem.Instance.Asset == elem2.Instance.Asset ) {
Debug.LogFormat("Bingo: {0} - {1}", i, i2);
elem2.Instance.FirstFrame = ++count;
has_elem = true;
break;
}
}
}
if ( !has_elem ) {
break;
}
}
}
}
}
}
static bool IsInstanceMovieClip(FlashAnimInstData instance) {
return
instance.Type == FlashAnimInstType.Symbol &&
instance.SymbolType == FlashAnimSymbolType.MovieClip;
}
static void ResetMovieClipsOnLayer(FlashAnimLayerData data) {
foreach ( var frame in data.Frames ) {
foreach ( var elem in frame.Elems ) {
if (
elem.Instance.Type == FlashAnimInstType.Symbol &&
elem.Instance.SymbolType == FlashAnimSymbolType.MovieClip )
{
elem.Instance.FirstFrame = -1;
}
}
}
}
// -----------------------------
// Common
// -----------------------------

View File

@@ -64,7 +64,6 @@ Shader "FlashTools/FlashAnim" {
return color;
}
fixed4 frag(v2f IN) : SV_Target {
fixed4 c = SampleSpriteTexture(IN.uv);
if ( c.a > 0.01 ) {

View File

@@ -858,6 +858,22 @@ if (typeof Object.create != 'function') {
SymbolInst.prototype = Object.create(ElementInst.prototype);
SymbolInst.prototype.get_symbol_type = function () {
var symbol_type = this.inst.symbolType;
if ( symbol_type == "movie clip" ) {
return "movieclip";
} else if ( symbol_type == "graphic" ) {
return "graphic";
} else {
throw "Unsupported symbol type ({0})!"
.format(symbol_type);
}
};
SymbolInst.prototype.get_first_frame = function () {
return this.inst.firstFrame !== undefined ? this.inst.firstFrame : 0;
};
SymbolInst.prototype.get_looping_mode = function () {
var looping_type = this.inst.loop !== undefined ? this.inst.loop : "single frame";
if ( looping_type == "loop" ) {
@@ -871,10 +887,6 @@ if (typeof Object.create != 'function') {
.format(looping_type);
}
};
SymbolInst.prototype.get_first_frame = function () {
return this.inst.firstFrame !== undefined ? this.inst.firstFrame : 0;
};
SymbolInst.prototype.export_description = function (xml_node) {
ft.type_assert(xml_node, XmlNode);
@@ -884,6 +896,7 @@ if (typeof Object.create != 'function') {
.attr("asset" , this.uniqueIds.get_string_id(this.inst.libraryItem.name))
.attr("visible" , this.inst.visible)
.attr("blend_mode" , this.inst.blendMode)
.attr("symbol_type" , this.get_symbol_type())
.attr("first_frame" , this.get_first_frame())
.attr("looping_mode", this.get_looping_mode());
if (this.inst.colorMode !== "none") {