glow filter reader

This commit is contained in:
2016-08-11 23:56:38 +07:00
parent 9d6daa3e02
commit dfd72c169e
7 changed files with 38 additions and 10 deletions

View File

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

View File

@@ -145,7 +145,7 @@ Camera:
far clip plane: 1000 far clip plane: 1000
field of view: 60 field of view: 60
orthographic: 1 orthographic: 1
orthographic size: 2 orthographic size: 6
m_Depth: 0 m_Depth: 0
m_CullingMask: m_CullingMask:
serializedVersion: 2 serializedVersion: 2
@@ -166,7 +166,7 @@ Transform:
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1173114888} m_GameObject: {fileID: 1173114888}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 4.1, y: -1.96, z: -1000} m_LocalPosition: {x: 0, y: 0, z: -1000}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children: [] m_Children: []

View File

@@ -139,8 +139,14 @@ namespace FlashTools.Internal.SwfTools {
return Encoding.UTF8.GetString(bytes.ToArray()); return Encoding.UTF8.GetString(bytes.ToArray());
} }
public float ReadFixedPoint8() { public float ReadFixedPoint_8_8() {
return ReadInt16() / 256.0f; var value = ReadInt16();
return value / 256.0f;
}
public float ReadFixedPoint_16_16() {
var value = ReadInt32();
return value / 65536.0f;
} }
public float ReadFixedPoint16(uint bits) { public float ReadFixedPoint16(uint bits) {

View File

@@ -9,7 +9,7 @@
var header = new SwfLongHeader(); var header = new SwfLongHeader();
header.ShortHeader = SwfShortHeader.Read(reader); header.ShortHeader = SwfShortHeader.Read(reader);
header.FrameSize = SwfRect.Read(reader); header.FrameSize = SwfRect.Read(reader);
header.FrameRate = reader.ReadFixedPoint8(); header.FrameRate = reader.ReadFixedPoint_8_8();
header.FrameCount = reader.ReadUInt16(); header.FrameCount = reader.ReadUInt16();
return header; return header;
} }

View File

@@ -143,7 +143,7 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
reader.ReadByte(); // Ratio reader.ReadByte(); // Ratio
SwfColor.Read(reader, with_alpha); SwfColor.Read(reader, with_alpha);
} }
reader.ReadFixedPoint8(); // FocalPoint reader.ReadFixedPoint_8_8(); // FocalPoint
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@@ -189,7 +189,7 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
reader.ReadBit(); // NoClose reader.ReadBit(); // NoClose
reader.ReadUnsignedBits(2); // EndCapStyle reader.ReadUnsignedBits(2); // EndCapStyle
if ( join_style == 2 ) { if ( join_style == 2 ) {
reader.ReadFixedPoint8(); // MiterLimitFactor reader.ReadFixedPoint_8_8(); // MiterLimitFactor
} }
if ( has_fill_flag ) { if ( has_fill_flag ) {
ReadFillStyle(reader, true); // FillStyle ReadFillStyle(reader, true); // FillStyle

View File

@@ -34,6 +34,14 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
public override FilterType Type { public override FilterType Type {
get { return FilterType.Glow; } get { return FilterType.Glow; }
} }
public SwfColor GlowColor;
public float BlurX;
public float BlurY;
public float Strength;
public bool InnerGlow;
public bool Knockout;
public bool CompositeSource;
public uint Passes;
} }
public class BevelFilter : Filter { public class BevelFilter : Filter {
@@ -131,9 +139,15 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
} }
static Filter ReadConcreteFilter(GlowFilter filter, SwfStreamReader reader) { static Filter ReadConcreteFilter(GlowFilter filter, SwfStreamReader reader) {
//TODO: IMPLME filter.GlowColor = SwfColor.Read(reader, true);
throw new UnityException(string.Format( filter.BlurX = reader.ReadFixedPoint_16_16();
"Unsupported surface filter type: {0}", filter.Type)); filter.BlurY = reader.ReadFixedPoint_16_16();
filter.Strength = reader.ReadFixedPoint_8_8();
filter.InnerGlow = reader.ReadBit();
filter.Knockout = reader.ReadBit();
filter.CompositeSource = reader.ReadBit();
filter.Passes = reader.ReadUnsignedBits(5);
return filter;
} }
static Filter ReadConcreteFilter(BevelFilter filter, SwfStreamReader reader) { static Filter ReadConcreteFilter(BevelFilter filter, SwfStreamReader reader) {