nicloay / unity-spine-importer

Bring data from spine (EsotericSoftware) in to the unity3d
BSD 3-Clause "New" or "Revised" License
37 stars 14 forks source link

Is this importer support the blendmode "additive" in spine? #17

Closed yilog closed 10 years ago

yilog commented 10 years ago

Hi , I found a problem that i need a slot blending is Additive, It`s work in spine preview. but when i import to unity use your importer. there is no add effect.
please check it , tnk

nicloay commented 10 years ago

I think it's not supported in current version. It looks like a quite complex task.

yilog commented 10 years ago

Thank you for reply, If this function in progress?

------------------ 原始邮件 ------------------ 发件人: "Nikolay"notifications@github.com; 发送时间: 2014年9月2日(星期二) 晚上6:31 收件人: "nicloay/unity-spine-importer"unity-spine-importer@noreply.github.com; 抄送: "olone_yilog"yilog@qq.com; 主题: Re: [unity-spine-importer] Is this importer support the blendmode"additive" in spine? (#17)

I think it's not supported in current version. It looks like a quite complex task.

— Reply to this email directly or view it on GitHub.

nicloay commented 10 years ago

I don't think so, Right now I'm not working on this project, just fix bugs. Last features has been done by https://github.com/abraksil (slot order animation). you can ask him.

abraksil commented 10 years ago

I'm not working on that one too. Right now I'm just adding minor functionalists and fixes.

yilog commented 10 years ago

Thank you very much for reply, Is it possible your exporter support spine mash animation in the furture?

------------------ 原始邮件 ------------------ 发件人: "abraksil"notifications@github.com; 发送时间: 2014年9月3日(星期三) 上午7:27 收件人: "nicloay/unity-spine-importer"unity-spine-importer@noreply.github.com; 抄送: "olone_yilog"yilog@qq.com; 主题: Re: [unity-spine-importer] Is this importer support the blendmode"additive" in spine? (#17)

I'm not working on that one too. Right now I'm just adding minor functionalists and fixes.

— Reply to this email directly or view it on GitHub.

nicloay commented 10 years ago

If Unity will add mesh animation, we will ad this support here. The goal of this package is to create model with native unity objects (animator, sprite renderers, etc..) Just one exception here is skin shifting.

yilog commented 10 years ago

The goal of this package is to create model with native unity objects. I cant agree with it any more. Spine official sdk dosent support unity native 2d objects. Your exporter is my hope

yilog commented 10 years ago

sorry for my pool english The goal of this package is to create model with native unity objects. I can `t agree with it more. Spine official sdk dosen t support unity native 2d objects. Your exporter is my hope

nicloay commented 10 years ago

Don't worry about your english, just use translate.google.com to check what did you wrote, english is not my first language as well.

anyway. if you tried to realize how to make mesh animation in unity, you can find, that just one way to do that, to work with mesh vertices directly, but to make it works with animation curves you have to create some sort of wrapper which will have a variables bonded to vertices position, and it's not a straight forward, and result would be quite complex and ugly, and i'm not really sure how would it work with animator, when you need to blend several states. I think it's one of the reason why unity doesn't support mesh animation.

yilog commented 10 years ago

I find a bug in exporter. In file "\Scripts\Editor\Util\SpineUtil.cs" line 682. The main logic of that code is add color curve to a animation in unity. The bug is the key of color in zero frame create by spine will not apply to unity curve . This is my fix code.

//modify by yilog //bug: the key of color in zero frame create by spine will not apply to unity curve bool bNeedStart = true; if(slotAnimation.color.Count>0){ SpineSlotColorAnimation color = slotAnimation.color[ 0 ]; if((float) (color.time)==0){ bNeedStart = false; } } if(bNeedStart){ Keyframe startKeyFrame = new Keyframe( 0.0f, 1.0f ); Curv_R.AddKey( startKeyFrame ); Curv_G.AddKey( startKeyFrame ); Curv_B.AddKey( startKeyFrame ); Curv_A.AddKey( startKeyFrame ); } JsonData[] curveData = new JsonData[ slotAnimation.color.Count ]; for( int i = 0 ; i != slotAnimation.color.Count ;i++ ) { SpineSlotColorAnimation color = slotAnimation.color[ i ]; uint col = Convert.ToUInt32( color.color, 16 ); uint r = ( col ) >> 24; uint g = (col & 0xff0000) >> 16; uint b = (col & 0xff00) >> 8; uint a = (col & 0xff); float t = ( (float) (color.time) ); Keyframe keyFrame_R = new Keyframe( t, r / 255.0f ); Keyframe keyFrame_G = new Keyframe( t, g / 255.0f ); Keyframe keyFrame_B = new Keyframe( t, b / 255.0f ); Keyframe keyFrame_A = new Keyframe( t, a / 255.0f ); Curv_R.AddKey( keyFrame_R ); Curv_G.AddKey( keyFrame_G ); Curv_B.AddKey( keyFrame_B ); Curv_A.AddKey( keyFrame_A ); curveData[ i ] = color.curve; }

------------------ 原始邮件 ------------------ 发件人: "Nikolay"notifications@github.com; 发送时间: 2014年9月15日(星期一) 下午4:26 收件人: "nicloay/unity-spine-importer"unity-spine-importer@noreply.github.com; 抄送: "olone_yilog"yilog@qq.com; 主题: Re: [unity-spine-importer] Is this importer support the blendmode"additive" in spine? (#17)

Don't worry about your english, just use translate.google.com to check what did you wrote, english is not my first language as well.

anyway. if you tried to realize how to make mesh animation in unity, you can find, that just one way to do that, to work with mesh vertices directly, but to make it works with animation curves you have to create some sort of wrapper which will have a variables bonded to vertices position, and it's not a straight forward, and result would be quite complex and ugly, and i'm not really sure how would it work with animator, when you need to blend several states. I think it's one of the reason why unity doesn't support mesh animation.

— Reply to this email directly or view it on GitHub.

nicloay commented 10 years ago

yilog Thanks, i'll try to include this to the next patch.