fix scale bugs

This commit is contained in:
2016-07-18 00:21:14 +06:00
parent 050b7cb6ec
commit 2888fb64da
5 changed files with 29 additions and 27 deletions

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: 3 orthographic size: 512
m_Depth: -1 m_Depth: -1
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: 0, y: 0, z: -10} 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

@@ -58,8 +58,11 @@ namespace FlashTools.Internal.SwfTools {
? MainContex.Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId) ? MainContex.Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId)
: false; : false;
if ( tag.HasCharacter ) { if ( tag.HasCharacter ) {
SwfDisplayInstance old_inst = null;
if ( tag.Move ) { // replace character if ( tag.Move ) { // replace character
dl.Instances.Remove(tag.Depth); if ( dl.Instances.TryGetValue(tag.Depth, out old_inst) ) {
dl.Instances.Remove(tag.Depth);
}
} }
// new character // new character
SwfDisplayInstance new_inst = null; SwfDisplayInstance new_inst = null;
@@ -72,8 +75,8 @@ namespace FlashTools.Internal.SwfTools {
new_inst.Id = tag.CharacterId; new_inst.Id = tag.CharacterId;
new_inst.Depth = tag.Depth; new_inst.Depth = tag.Depth;
new_inst.Visible = true; new_inst.Visible = true;
new_inst.Matrix = tag.HasMatrix ? tag.Matrix : SwfMatrix.identity; new_inst.Matrix = tag.HasMatrix ? tag.Matrix : (old_inst != null ? old_inst.Matrix : SwfMatrix.identity );
new_inst.ColorTransform = tag.HasColorTransform ? tag.ColorTransform : SwfColorTransform.identity; new_inst.ColorTransform = tag.HasColorTransform ? tag.ColorTransform : (old_inst != null ? old_inst.ColorTransform : SwfColorTransform.identity);
dl.Instances.Add(new_inst.Depth, new_inst); dl.Instances.Add(new_inst.Depth, new_inst);
} }
} else if ( tag.Move ) { // move character } else if ( tag.Move ) { // move character
@@ -99,8 +102,11 @@ namespace FlashTools.Internal.SwfTools {
? MainContex.Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId) ? MainContex.Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId)
: false; : false;
if ( tag.HasCharacter ) { if ( tag.HasCharacter ) {
SwfDisplayInstance old_inst = null;
if ( tag.Move ) { // replace character if ( tag.Move ) { // replace character
dl.Instances.Remove(tag.Depth); if ( dl.Instances.TryGetValue(tag.Depth, out old_inst) ) {
dl.Instances.Remove(tag.Depth);
}
} }
// new character // new character
SwfDisplayInstance new_inst = null; SwfDisplayInstance new_inst = null;
@@ -112,9 +118,9 @@ namespace FlashTools.Internal.SwfTools {
if ( new_inst != null ) { if ( new_inst != null ) {
new_inst.Id = tag.CharacterId; new_inst.Id = tag.CharacterId;
new_inst.Depth = tag.Depth; new_inst.Depth = tag.Depth;
new_inst.Visible = tag.HasVisible ? tag.Visible : true; new_inst.Visible = tag.HasVisible ? tag.Visible : (old_inst != null ? old_inst.Visible : true );
new_inst.Matrix = tag.HasMatrix ? tag.Matrix : SwfMatrix.identity; new_inst.Matrix = tag.HasMatrix ? tag.Matrix : (old_inst != null ? old_inst.Matrix : SwfMatrix.identity );
new_inst.ColorTransform = tag.HasColorTransform ? tag.ColorTransform : SwfColorTransform.identity; new_inst.ColorTransform = tag.HasColorTransform ? tag.ColorTransform : (old_inst != null ? old_inst.ColorTransform : SwfColorTransform.identity);
dl.Instances.Add(new_inst.Depth, new_inst); dl.Instances.Add(new_inst.Depth, new_inst);
} }
} else if ( tag.Move ) { // move character } else if ( tag.Move ) { // move character

View File

@@ -26,8 +26,8 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
var has_scale = reader.ReadBit(); var has_scale = reader.ReadBit();
if ( has_scale ) { if ( has_scale ) {
var bits = (byte)reader.ReadUnsignedBits(5); var bits = (byte)reader.ReadUnsignedBits(5);
matrix.ScaleX = reader.ReadFixedPoint16(bits) * (fill_style ? 1.0f / 20.0f : 1.0f); matrix.ScaleX = reader.ReadFixedPoint16(bits);
matrix.ScaleY = reader.ReadFixedPoint16(bits) * (fill_style ? 1.0f / 20.0f : 1.0f); matrix.ScaleY = reader.ReadFixedPoint16(bits);
} else { } else {
matrix.ScaleX = matrix.ScaleX =
matrix.ScaleY = 1.0f; matrix.ScaleY = 1.0f;
@@ -35,8 +35,8 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
var has_rotate = reader.ReadBit(); var has_rotate = reader.ReadBit();
if ( has_rotate ) { if ( has_rotate ) {
var bits = (byte)reader.ReadUnsignedBits(5); var bits = (byte)reader.ReadUnsignedBits(5);
matrix.RotateSkew0 = reader.ReadFixedPoint16(bits) / 20.0f; matrix.RotateSkew0 = reader.ReadFixedPoint16(bits);
matrix.RotateSkew1 = reader.ReadFixedPoint16(bits) / 20.0f; matrix.RotateSkew1 = reader.ReadFixedPoint16(bits);
} else { } else {
matrix.RotateSkew0 = matrix.RotateSkew0 =
matrix.RotateSkew1 = 0.0f; matrix.RotateSkew1 = 0.0f;

View File

@@ -37,27 +37,23 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
switch ( style_type ) { switch ( style_type ) {
case ShapeStyleType.Shape: case ShapeStyleType.Shape:
shapes.FillStyles = ReadFillStyles(reader, false, false); shapes.FillStyles = ReadFillStyles(reader, false, false);
//SkipLineStyles(reader, false, false, false); SkipLineStyles(reader, false, false, false);
//SkipShapeRecords(reader, false, false, false); SkipShapeRecords(reader, false, false, false);
//reader.AlignToByte();
break; break;
case ShapeStyleType.Shape2: case ShapeStyleType.Shape2:
shapes.FillStyles = ReadFillStyles(reader, true, false); shapes.FillStyles = ReadFillStyles(reader, true, false);
//SkipLineStyles(reader, true, false, false); SkipLineStyles(reader, true, false, false);
//SkipShapeRecords(reader, true, false, false); SkipShapeRecords(reader, true, false, false);
//reader.AlignToByte();
break; break;
case ShapeStyleType.Shape3: case ShapeStyleType.Shape3:
shapes.FillStyles = ReadFillStyles(reader, true, true); shapes.FillStyles = ReadFillStyles(reader, true, true);
//SkipLineStyles(reader, true, true, false); SkipLineStyles(reader, true, true, false);
//SkipShapeRecords(reader, true, true, false); SkipShapeRecords(reader, true, true, false);
//reader.AlignToByte();
break; break;
case ShapeStyleType.Shape4: case ShapeStyleType.Shape4:
shapes.FillStyles = ReadFillStyles(reader, true, true); shapes.FillStyles = ReadFillStyles(reader, true, true);
//SkipLineStyles(reader, true, true, true); SkipLineStyles(reader, true, true, true);
//SkipShapeRecords(reader, true, true, true); SkipShapeRecords(reader, true, true, true);
//reader.AlignToByte();
break; break;
default: default:
throw new UnityException(string.Format( throw new UnityException(string.Format(

View File

@@ -93,8 +93,8 @@ namespace FlashTools {
foreach ( var inst in frame.Instances ) { foreach ( var inst in frame.Instances ) {
var bitmap = FindBitmap(inst.Bitmap); var bitmap = FindBitmap(inst.Bitmap);
if ( bitmap != null ) { if ( bitmap != null ) {
var width = bitmap.RealSize.x; var width = bitmap.RealSize.x / 20.0f;
var height = bitmap.RealSize.y; var height = bitmap.RealSize.y / 20.0f;
var v0 = new Vector3( 0, 0, current_z); var v0 = new Vector3( 0, 0, current_z);
var v1 = new Vector3( width, 0, current_z); var v1 = new Vector3( width, 0, current_z);