simple render

This commit is contained in:
2016-06-24 02:26:02 +06:00
parent acc406f922
commit 2a5e816f2a
14 changed files with 258 additions and 81 deletions

View File

@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_3_4;UNITY_5_3;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_OSX;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_GAMECENTER;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_LOG_MIXED_STACKTRACE;ENABLE_UNITYWEBREQUEST;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX</DefineConstants>
<DefineConstants>DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_3_5;UNITY_5_3;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_OSX;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_GAMECENTER;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_LOG_MIXED_STACKTRACE;ENABLE_UNITYWEBREQUEST;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
@@ -121,12 +121,27 @@
<Reference Include="UnityEditor.Graphs">
<HintPath>/Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEditor.Graphs.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.Android.Extensions">
<HintPath>/Applications/Unity/PlaybackEngines/AndroidPlayer/UnityEditor.Android.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.iOS.Extensions">
<HintPath>/Applications/Unity/PlaybackEngines/iOSSupport/UnityEditor.iOS.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.AppleTV.Extensions">
<HintPath>/Applications/Unity/PlaybackEngines/AppleTVSupport/UnityEditor.AppleTV.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.Tizen.Extensions">
<HintPath>/Applications/Unity/PlaybackEngines/TizenPlayer/UnityEditor.Tizen.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.SamsungTV.Extensions">
<HintPath>/Applications/Unity/PlaybackEngines/STVPlayer/UnityEditor.SamsungTV.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.WebGL.Extensions">
<HintPath>/Applications/Unity/PlaybackEngines/WebGLSupport/UnityEditor.WebGL.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.LinuxStandalone.Extensions">
<HintPath>/Applications/Unity/PlaybackEngines/LinuxStandaloneSupport/UnityEditor.LinuxStandalone.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.WindowsStandalone.Extensions">
<HintPath>/Applications/Unity/PlaybackEngines/WindowsStandaloneSupport/UnityEditor.WindowsStandalone.Extensions.dll</HintPath>
</Reference>
@@ -134,6 +149,12 @@
<HintPath>/Applications/Unity/PlaybackEngines/MacStandaloneSupport/UnityEditor.OSXStandalone.Extensions.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.iOS.Extensions.Xcode">
<HintPath>/Applications/Unity/PlaybackEngines/AppleTVSupport/UnityEditor.iOS.Extensions.Xcode.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.iOS.Extensions.Common">
<HintPath>/Applications/Unity/PlaybackEngines/AppleTVSupport/UnityEditor.iOS.Extensions.Common.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.iOS.Extensions.Xcode">
<HintPath>/Applications/Unity/PlaybackEngines/iOSSupport/UnityEditor.iOS.Extensions.Xcode.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.iOS.Extensions.Common">

View File

@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_3_4;UNITY_5_3;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_OSX;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_GAMECENTER;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_LOG_MIXED_STACKTRACE;ENABLE_UNITYWEBREQUEST;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX</DefineConstants>
<DefineConstants>DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_3_5;UNITY_5_3;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_OSX;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_GAMECENTER;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_LOG_MIXED_STACKTRACE;ENABLE_UNITYWEBREQUEST;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>

View File

@@ -168,6 +168,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0

View File

@@ -22,6 +22,24 @@ namespace FlashTools.Internal {
ImportAssetOptions.ForceUncompressedImport);
}
void CreateAnimationPrefab() {
}
void CreateAnimationOnScene() {
if ( _asset ) {
var anim_go = new GameObject("SwfAnimation");
var mesh_renderer = anim_go.AddComponent<MeshRenderer>();
mesh_renderer.sharedMaterial = null;
mesh_renderer.useLightProbes = false;
mesh_renderer.receiveShadows = false;
mesh_renderer.shadowCastingMode = ShadowCastingMode.Off;
mesh_renderer.reflectionProbeUsage = ReflectionProbeUsage.Off;
anim_go.AddComponent<MeshFilter>().sharedMesh = null;
anim_go.AddComponent<SwfAnimation>().Asset = _asset;
Undo.RegisterCreatedObjectUndo(anim_go, "Create SwfAnimation");
}
}
// ------------------------------------------------------------------------
//
// Messages
@@ -39,8 +57,10 @@ namespace FlashTools.Internal {
}
GUILayout.BeginHorizontal();
if ( GUILayout.Button("Create animation prefab") ) {
CreateAnimationPrefab();
}
if ( GUILayout.Button("Create animation on scene") ) {
CreateAnimationOnScene();
}
GUILayout.EndHorizontal();
}

View File

@@ -82,7 +82,7 @@ namespace FlashTools.Internal {
Matrix4x4 parent_matrix, SwfAnimationColorTransform parent_color_transform,
SwfAnimationFrameData frame)
{
foreach ( var inst in dl.Insts.Values ) {
foreach ( var inst in dl.Instances.Values ) {
switch ( inst.Type ) {
case SwfDisplayInstType.Shape:
var shape_def = ctx.Library.FindDefine<SwfLibraryShapeDefine>(inst.Id);
@@ -93,7 +93,7 @@ namespace FlashTools.Internal {
? shape_def.Matrices[i] : SwfMatrix.identity;
var bitmap_def = ctx.Library.FindDefine<SwfLibraryBitmapDefine>(bitmap_id);
if ( bitmap_def != null ) {
frame.Insts.Add(new SwfAnimationInstData{
frame.Instances.Add(new SwfAnimationInstanceData{
Bitmap = bitmap_id,
Matrix = parent_matrix * inst.Matrix.ToUnityMatrix() * bitmap_matrix.ToUnityMatrix(),
ColorTransform = parent_color_transform * inst.ColorTransform.ToAnimationColorTransform()});

View File

@@ -3,45 +3,8 @@ using FlashTools.Internal.SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools {
using LibraryDefines = SortedDictionary<ushort, SwfLibraryDefine>;
//
// SwfDisplayList
//
public enum SwfDisplayInstType {
Shape,
Sprite
}
public abstract class SwfDisplayInst {
public abstract SwfDisplayInstType Type { get; }
public ushort Id;
public ushort Depth;
public SwfMatrix Matrix;
public SwfColorTransform ColorTransform;
}
public class SwfDisplayShapeInst : SwfDisplayInst {
public override SwfDisplayInstType Type {
get { return SwfDisplayInstType.Shape; }
}
}
public class SwfDisplaySpriteInst : SwfDisplayInst {
public int CurrentTag = 0;
public SwfDisplayList DisplayList = new SwfDisplayList();
public override SwfDisplayInstType Type {
get { return SwfDisplayInstType.Sprite; }
}
}
public class SwfDisplayList {
public string FrameName = string.Empty;
public SortedDictionary<ushort, SwfDisplayInst> Insts =
new SortedDictionary<ushort, SwfDisplayInst>();
}
using LibraryDefines = SortedDictionary<ushort, SwfLibraryDefine>;
using DisplayInstances = SortedDictionary<ushort, SwfDisplayInstance>;
//
// SwfLibrary
@@ -85,7 +48,7 @@ namespace FlashTools.Internal.SwfTools {
public LibraryDefines Defines = new LibraryDefines();
public bool HasDefine<T>(ushort define_id) where T : SwfLibraryDefine {
return FindDefine<SwfLibraryDefine>(define_id) != null;
return FindDefine<T>(define_id) != null;
}
public T FindDefine<T>(ushort define_id) where T : SwfLibraryDefine {
@@ -97,6 +60,43 @@ namespace FlashTools.Internal.SwfTools {
}
}
//
// SwfDisplayList
//
public enum SwfDisplayInstType {
Shape,
Sprite
}
public abstract class SwfDisplayInstance {
public abstract SwfDisplayInstType Type { get; }
public ushort Id;
public ushort Depth;
public SwfMatrix Matrix;
public SwfColorTransform ColorTransform;
}
public class SwfDisplayShapeInst : SwfDisplayInstance {
public override SwfDisplayInstType Type {
get { return SwfDisplayInstType.Shape; }
}
}
public class SwfDisplaySpriteInst : SwfDisplayInstance {
public int CurrentTag = 0;
public SwfDisplayList DisplayList = new SwfDisplayList();
public override SwfDisplayInstType Type {
get { return SwfDisplayInstType.Sprite; }
}
}
public class SwfDisplayList {
public string FrameName = string.Empty;
public DisplayInstances Instances = new DisplayInstances();
}
//
// SwfContext
//

View File

@@ -32,7 +32,7 @@ namespace FlashTools.Internal.SwfTools {
MainContex.Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId);
var is_sprite =
MainContex.Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId);
SwfDisplayInst new_inst = null;
SwfDisplayInstance new_inst = null;
if ( is_shape ) {
new_inst = new SwfDisplayShapeInst();
} else if ( is_sprite ) {
@@ -43,7 +43,7 @@ namespace FlashTools.Internal.SwfTools {
new_inst.Depth = tag.Depth;
new_inst.Matrix = tag.Matrix;
new_inst.ColorTransform = tag.ColorTransform;
dl.Insts.Add(new_inst.Depth, new_inst);
dl.Instances.Add(new_inst.Depth, new_inst);
}
return dl;
}
@@ -58,10 +58,10 @@ namespace FlashTools.Internal.SwfTools {
: false;
if ( tag.HasCharacter ) {
if ( tag.Move ) { // replace character
dl.Insts.Remove(tag.Depth);
dl.Instances.Remove(tag.Depth);
}
// new character
SwfDisplayInst new_inst = null;
SwfDisplayInstance new_inst = null;
if ( is_shape ) {
new_inst = new SwfDisplayShapeInst();
} else if ( is_sprite ) {
@@ -72,11 +72,11 @@ namespace FlashTools.Internal.SwfTools {
new_inst.Depth = tag.Depth;
new_inst.Matrix = tag.HasMatrix ? tag.Matrix : SwfMatrix.identity;
new_inst.ColorTransform = tag.HasColorTransform ? tag.ColorTransform : SwfColorTransform.identity;
dl.Insts.Add(new_inst.Depth, new_inst);
dl.Instances.Add(new_inst.Depth, new_inst);
}
} else if ( tag.Move ) { // move character
SwfDisplayInst inst;
if ( dl.Insts.TryGetValue(tag.Depth, out inst) ) {
SwfDisplayInstance inst;
if ( dl.Instances.TryGetValue(tag.Depth, out inst) ) {
if ( tag.HasMatrix ) {
inst.Matrix = tag.Matrix;
}
@@ -95,19 +95,19 @@ namespace FlashTools.Internal.SwfTools {
public SwfDisplayList Visit(RemoveObjectTag tag, SwfDisplayList dl) {
Debug.Log(tag);
dl.Insts.Remove(tag.Depth);
dl.Instances.Remove(tag.Depth);
return dl;
}
public SwfDisplayList Visit(RemoveObject2Tag tag, SwfDisplayList dl) {
Debug.Log(tag);
dl.Insts.Remove(tag.Depth);
dl.Instances.Remove(tag.Depth);
return dl;
}
public SwfDisplayList Visit(ShowFrameTag tag, SwfDisplayList dl) {
Debug.LogError(tag);
var sprites = dl.Insts.Values
var sprites = dl.Instances.Values
.Where (p => p.Type == SwfDisplayInstType.Sprite)
.Select(p => p as SwfDisplaySpriteInst);
foreach ( var sprite in sprites ) {

View File

@@ -1,6 +1,5 @@
using UnityEngine;
using System.IO;
using FlashTools.Internal.SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools.SwfTypes {
public struct SwfShortHeader {

View File

@@ -1,4 +1,6 @@
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
namespace FlashTools {
[ExecuteInEditMode]
@@ -6,7 +8,15 @@ namespace FlashTools {
public class SwfAnimation : MonoBehaviour {
public SwfAnimationAsset Asset = null;
int _current_frame = 0;
int _current_frame = 0;
float _frame_timer = 0.0f;
string _last_asset_path = string.Empty;
List<Vector2> _uvs = new List<Vector2>();
List<Color> _mulcolors = new List<Color>();
List<Vector4> _addcolors = new List<Vector4>();
List<Vector3> _vertices = new List<Vector3>();
List<int> _triangles = new List<int>();
public int frameCount {
get { return Asset ? Asset.Data.Frames.Count : 0; }
@@ -22,5 +32,127 @@ namespace FlashTools {
// Messages
//
// ------------------------------------------------------------------------
void Start() {
if ( Asset && Asset.Atlas ) {
var material = new Material(Shader.Find("FlashTools/FlashAnim"));
material.SetTexture("_MainTex", Asset.Atlas);
GetComponent<MeshRenderer>().sharedMaterial = material;
}
}
void Update() {
if ( Asset ) {
_frame_timer += Asset.Data.FrameRate * Time.deltaTime;
while ( _frame_timer > 1.0f ) {
_frame_timer -= 1.0f;
++_current_frame;
if ( _current_frame > frameCount - 1 ) {
_current_frame = 0;
}
}
} else {
OnValidate();
}
}
void OnValidate() {
if ( Asset ) {
_last_asset_path = AssetDatabase.GetAssetPath(Asset);
} else {
if ( !string.IsNullOrEmpty(_last_asset_path) ) {
Asset = AssetDatabase.LoadAssetAtPath<SwfAnimationAsset>(_last_asset_path);
EditorUtility.SetDirty(this);
}
}
}
SwfAnimationBitmapData FindBitmap(int bitmap_id) {
if ( Asset ) {
for ( var i = 0; i < Asset.Data.Bitmaps.Count; ++i ) {
var bitmap = Asset.Data.Bitmaps[i];
if ( bitmap.Id == bitmap_id ) {
return bitmap;
}
}
}
return null;
}
void OnRenderObject() {
if ( Asset ) {
_vertices.Clear();
_triangles.Clear();
_uvs.Clear();
_mulcolors.Clear();
_addcolors.Clear();
var current_z = 0.0f;
var frame = Asset.Data.Frames[currentFrame];
foreach ( var inst in frame.Instances ) {
var bitmap = FindBitmap(inst.Bitmap);
if ( bitmap != null ) {
var width = bitmap.RealSize.x;
var height = bitmap.RealSize.y;
var v0 = new Vector3( 0, 0, current_z);
var v1 = new Vector3( width, 0, current_z);
var v2 = new Vector3( width, height, current_z);
var v3 = new Vector3( 0, height, current_z);
current_z -= 20f;
var matrix =
Matrix4x4.Scale(new Vector3(
1.0f / Asset.PixelsPerUnit,
-1.0f / Asset.PixelsPerUnit,
1.0f / Asset.PixelsPerUnit)) * inst.Matrix;
_vertices.Add(matrix.MultiplyPoint3x4(v0));
_vertices.Add(matrix.MultiplyPoint3x4(v1));
_vertices.Add(matrix.MultiplyPoint3x4(v2));
_vertices.Add(matrix.MultiplyPoint3x4(v3));
_triangles.Add(_vertices.Count - 4 + 2);
_triangles.Add(_vertices.Count - 4 + 1);
_triangles.Add(_vertices.Count - 4 + 0);
_triangles.Add(_vertices.Count - 4 + 0);
_triangles.Add(_vertices.Count - 4 + 3);
_triangles.Add(_vertices.Count - 4 + 2);
var source_rect = bitmap.SourceRect;
_uvs.Add(new Vector2(source_rect.xMin, source_rect.yMax));
_uvs.Add(new Vector2(source_rect.xMax, source_rect.yMax));
_uvs.Add(new Vector2(source_rect.xMax, source_rect.yMin));
_uvs.Add(new Vector2(source_rect.xMin, source_rect.yMin));
_mulcolors.Add(inst.ColorTransform.Mul);
_mulcolors.Add(inst.ColorTransform.Mul);
_mulcolors.Add(inst.ColorTransform.Mul);
_mulcolors.Add(inst.ColorTransform.Mul);
_addcolors.Add(inst.ColorTransform.Add);
_addcolors.Add(inst.ColorTransform.Add);
_addcolors.Add(inst.ColorTransform.Add);
_addcolors.Add(inst.ColorTransform.Add);
}
}
var mesh_filter = GetComponent<MeshFilter>();
if ( mesh_filter ) {
var mesh = mesh_filter.sharedMesh
? mesh_filter.sharedMesh
: new Mesh();
mesh.Clear();
mesh.SetVertices(_vertices);
mesh.SetTriangles(_triangles, 0);
mesh.SetUVs(0, _uvs);
mesh.SetUVs(1, _addcolors);
mesh.SetColors(_mulcolors);
mesh.RecalculateNormals();
mesh_filter.sharedMesh = mesh;
}
}
}
}
}

View File

@@ -37,38 +37,38 @@ namespace FlashTools {
}
[System.Serializable]
public class SwfAnimationInstData {
public ushort Bitmap = 0;
public Matrix4x4 Matrix = Matrix4x4.identity;
public SwfAnimationColorTransform ColorTransform = SwfAnimationColorTransform.identity;
public class SwfAnimationInstanceData {
public ushort Bitmap = 0;
public Matrix4x4 Matrix = Matrix4x4.identity;
public SwfAnimationColorTransform ColorTransform = SwfAnimationColorTransform.identity;
}
[System.Serializable]
public class SwfAnimationFrameData {
public string Name = string.Empty;
public List<SwfAnimationInstData> Insts = new List<SwfAnimationInstData>();
public string Name = string.Empty;
public List<SwfAnimationInstanceData> Instances = new List<SwfAnimationInstanceData>();
}
[System.Serializable]
public class SwfAnimationBitmapData {
public int Id = 0;
public Vector2 RealSize = Vector2.zero;
public Rect SourceRect = new Rect();
public int Id = 0;
public Vector2 RealSize = Vector2.zero;
public Rect SourceRect = new Rect();
}
[System.Serializable]
public class SwfAnimationData {
public float FrameRate = 0.0f;
public List<SwfAnimationFrameData> Frames = new List<SwfAnimationFrameData>();
public List<SwfAnimationBitmapData> Bitmaps = new List<SwfAnimationBitmapData>();
public float FrameRate = 0.0f;
public List<SwfAnimationFrameData> Frames = new List<SwfAnimationFrameData>();
public List<SwfAnimationBitmapData> Bitmaps = new List<SwfAnimationBitmapData>();
}
public class SwfAnimationAsset : ScriptableObject {
//[HideInInspector]
public SwfAnimationData Data = new SwfAnimationData();
public Texture2D Atlas = null;
public int MaxAtlasSize = 1024;
public int AtlasPadding = 1;
public int PixelsPerUnit = 100;
public SwfAnimationData Data = new SwfAnimationData();
public Texture2D Atlas = null;
public int MaxAtlasSize = 1024;
public int AtlasPadding = 1;
public int PixelsPerUnit = 100;
}
}

View File

@@ -117,6 +117,8 @@ PlayerSettings:
m_Bits: 238
iPhoneSdkVersion: 988
iPhoneTargetOSVersion: 22
tvOSSdkVersion: 0
tvOSTargetOSVersion: 900
uIPrerenderedIcon: 0
uIRequiresPersistentWiFi: 0
uIRequiresFullScreen: 1
@@ -196,6 +198,7 @@ PlayerSettings:
wiiUSystemHeapSize: 128
wiiUTVStartupScreen: {fileID: 0}
wiiUGamePadStartupScreen: {fileID: 0}
wiiUDrcBufferDisabled: 0
wiiUProfilerLibPath:
actionOnDotNetUnhandledException: 1
enableInternalProfiler: 0
@@ -263,6 +266,7 @@ PlayerSettings:
ps4DownloadDataSize: 0
ps4GarlicHeapSize: 2048
ps4Passcode: BlQ9wQj99nsQzldVI5ZuGXbEWRK5RhRX
ps4UseDebugIl2cppLibs: 0
ps4pnSessions: 1
ps4pnPresence: 1
ps4pnFriends: 1
@@ -328,6 +332,7 @@ PlayerSettings:
psp2UseLibLocation: 0
psp2InfoBarOnStartup: 0
psp2InfoBarColor: 0
psp2UseDebugIl2cppLibs: 0
psmSplashimage: {fileID: 0}
spritePackerPolicy:
scriptingDefineSymbols: {}

View File

@@ -1,2 +1,2 @@
m_EditorVersion: 5.3.4f1
m_EditorVersion: 5.3.5f1
m_StandardAssetsVersion: 0

View File

@@ -2,16 +2,15 @@
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="Unity.Instance.Unity Editor" />
<MonoDevelop.Ide.Workbench>
<Files>
<File FileName="Assets/FlashTools/Scripts/FlashAnim.cs" Line="1" Column="1" />
<File FileName="Assets/FlashTools/Scripts/Internal/Editor/FlashAnimAssetPostprocessor.cs" Line="1" Column="1" />
<File FileName="Assets/FlashTools/Scripts/Internal/Editor/FlashAnimFtaPostprocessor.cs" Line="1" Column="1" />
<File FileName="Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfContextExecuter.cs" Line="1" Column="1" />
<File FileName="Assets/FlashTools/Scripts/Internal/Editor/SwfPostprocessor.cs" Line="1" Column="1" />
<File FileName="Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfTypes/SwfMatrix.cs" Line="1" Column="1" />
<File FileName="Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfContext.cs" Line="1" Column="1" />
<File FileName="Assets/FlashTools/Scripts/FlashAnim.cs" Line="1" Column="1" NotebookId="1" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore>
<Breakpoint file="/Users/matov/Programming/Projects/unityflash/Assets/FlashTools/Scripts/FlashAnim.cs" line="86" column="1" />
<Breakpoint file="/Users/matov/Programming/Projects/unityflash/Assets/FlashTools/Scripts/FlashAnim.cs" line="82" column="33" />
</BreakpointStore>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
</Properties>