gree / lwf

LWF - Lightweight SWF
http://gree.github.com/lwf/
zlib License
627 stars 167 forks source link

Tutorial about conversion from swf to lwf #5

Closed camelot10 closed 11 years ago

camelot10 commented 11 years ago

i tryed by myself but got plenty of ruby errors. only detect that flash version 7 supported for converting

HiroyukiHaga commented 11 years ago

I've uploaded a FLASH production guideline doc. Can you please take a look this documentation?

http://gree.github.com/lwf-demo/pdf/FLASHforLWFproductionguideline.pdf

HiroyukiHaga commented 11 years ago

You can verify your FLASH scene in FLASH environment by using LWF_Publish.jsfl. LWF_Publish.jsfl is available in the "tools/flash" directory.

https://github.com/gree/lwf/blob/master/tools/flash/LWF_Publish.jsfl

Installing JSFL Scripts http://summitprojectsflashblog.wordpress.com/how-tos/installing-jsfl-scripts/

phamvanan commented 11 years ago

I try to bulid project tools swf2lwf but errors. Can you post tutorial install detail that project, please?

Thanks and Regards.

camelot10 commented 11 years ago

tested. seems like export works. my animations works in unity

Adamcbrz commented 11 years ago

I agree with having a tutorial. I can't seem to get sprite atlas to work with the animation. I can't seem to find any tutorials on this besides swf2lwf command line but I can't seem to get that to work. If any one has had success on this PLEASE help me out.

Thanks!

HiroyukiHaga commented 11 years ago

Thank you Adamcbrz. Sprite atlas works perfectly with LWF. Actually, we prefer to use atlas for reducing number of draw calls. The swf2lwf supports json file that is exported from Texture Packer (http://www.codeandweb.com/texturepacker).

Can you please take a look Texture Packer.

Anyway, a tutorial for converting swf by using Texture Packer's json data would be required... I'd like to take a look it.

HiroyukiHaga commented 11 years ago

Here is a quick tutorial for making sprite atlas for LWF:) The tutorial file has been added to "flash" folder under https://github.com/gree/lwf-demo/ project. If you have any questions for following step, please feel free to ask.

  1. Extract png files from the swf file.

ruby swf2lwf.rb sprite_atlas.swf

  1. All png files are extracted and stored in sprite_atlas.lwfdata folder.
  2. Create texture sheet with exporting placement information to json file

/Applications/TexturePacker.app/Contents/MacOS/TexturePacker --format json --data sprite_atlas.json --sheet "sprite_atlas_texture.png" sprite_atlas.lwfdata/*.png

  1. A texture atlas "sprite_atlas_texture.png" and json data " sprite_atlas.json" are generated.
  2. Re-convert swf into lwf with json data.

ruby swf2lwf.rb sprite_atlas.swf sprite_atlas.json

Adamcbrz commented 11 years ago

First thanks for getting back to me!

Thats what I had figured out but when I run through this process and import it to Unity I see the animation on meshes but the atlas doesn't show correctly. Every Mesh shows the entire atlas. My process is as follows:

1) Publish swf using LWF_Publish.jsfl (No Errors) 2) Use the LWFS to convert to lwf and extract the images. 3) Use those images in Texture Packer to generate an Atlas save as JSON (Hash) 4) Run ruby script "ruby swf2lwf.rb Jake.swf Jake.json" (outputs with no errors) 5) Include the files in the Unity Project 6) In unity I have a script from your Unity Video demo and put the path to the text.bytes and path to the images. 7) I debug some of your code and realized that its expecting the atlas name to be TeethBitmap.png so I renamed my image to that. 8) I hit play and I see the animation but all the meshes have the entire atlas instead of the UV location of the appropriate altas item

I will include the flash file and unity project to see if you can see what I am doing wrong.

Drop box link: https://www.dropbox.com/s/4d5es1xv74efc80/LWFTest.zip

Edit: I am using Unity 4.0.1

Thanks, Adam

HiroyukiHaga commented 11 years ago

It seems swf2lwf.rb didn't handle given json file properly when images in Flash file has AS linkage... I could have right lwf by removing some AS linkage in Flash files. See following screen shot.

I'd like to take a look processes of swf2lwf.rb, please wait for a moment.

Jake_in_Unity

HiroyukiHaga commented 11 years ago

Image file names that used for TexturePacker have to be as same as Linkage names. In your process 2), LWFS extracts images with "_#.png" like "Jake_0.png" instead of Linkage name"Bitmap1.png". You can generate right lwf file with removing process 2).

1) Publish swf using LWF_Publish.jsfl This process extract all images from Flash, and save to ".bitmap" folder with Linkage name. In your case, "Jake.bitmap" will be generated.

2) Generate TexturePack by using ".bitmap".

/Applications/TexturePacker.app/Contents/MacOS/TexturePacker --opt RGBA4444 --scale 1.0 --format json --data Jake.json --sheet "Jake_texture.png" Jake.bitmap/*.png

3) Generate LWF file. swf2lwf Jake.swf Jake.json

4) Open unity/basic2 project in https://github.com/gree/lwf-demo/ .

5) Copy your resources to Resources/LWF/Jake folder, and rename Jake.lwf into Jake.bytes.

6) Update OnGUI() method in "SampleMenu.cs" with following code.

void OnGUI()
{
    GUI.Box(new Rect(10,10,100,120), "Menu");
    if (GUI.Button(new Rect(20,40,80,20), "Sample 1"))
        PlaySample("sample1_normal");
    if (GUI.Button(new Rect(20,70,80,20), "Sample 2"))
        PlaySample("sample2_normal");
    if (GUI.Button(new Rect(20,100,80,20), "Sample 3"))
        PlaySample("sample3_normal");
    if (GUI.Button(new Rect(20,130,80,20), "Jake"))
        PlaySample("Jake");
}

7) Click Play, and then click"Jake" button.

Adamcbrz commented 11 years ago

Thanks worked great!