2014年12月11日 星期四

[DragonBones]事件觸發

DragonBones可利用Flash中所設定的影格標籤來觸發事件,達成Hit frame等目的,而設定的標籤須符合「@事件名稱」的規則,如:@attack。
事件Label
另外標籤所在的圖層也會造成差異,有以下兩種案例:
  • label圖層
設定在label圖層中的事件,在API中是屬於AnimationEvent,此種事件只能獲取到骨架(armature
AnimationEvent

  • bone圖層(label圖層之外的圖層都是bone圖層)
設定在bone圖層中的事件,在API中是屬於FrameEvent,此種事件可獲取到所屬的骨頭(bone
因此將事件設定在bone圖層中時,可以順便獲取所屬影格中的元件位置來做定位,舉例,當事件發生時會呼叫一個分離特效並產生在角色的手上,那就可以把事件種在手的圖層中,或者是額外的定位圖層中。 
FrameEvent

[Flash]製作Extensions - 建立 SWF Panel

Flash Extension的Panel可以用SWF檔案來呈現,先在Flash中把需要的Panel製作出來,並且撰寫ActionScript進行控制,也可與JSFL做溝通,如此就可呈現一個完整的流程。

在此列出幾項重點:
  • 可利用組件來製作Panel
    Flash組件
  • SWF檔案必須置放在Flash Config目錄中的WindowSWF目錄內

    如此在Flash啟動時才能正確加載面板到Menu>視窗>擴充功能中。

    WindowSWF目錄的所在路徑預設是(Win 7):
    \\Users\user_name\AppData\Local\Adobe\flash_version\language\Configuration\
    如果不是在此可利用JSFL的fl.configDirectory來查找。
  • 讓SWF與JSFL溝通:MMExecute

    MMExecute("fl.runScript(fl.configURI + 'WindowSWF/filename.jsfl', 'function_name';)");

    fl.runScript(fileURI [, funcName [, arg1, arg2, ...]])

    MMExecute可以在ActionScript中實現JSFL指令,再透過JSFL的fl.runScript可以去呼叫指定的JSFL檔案。

    第一個引數,是目標JSFL檔案的路徑,為管理方便一般會將該Extension所用到的JSFL統一集中在一個目錄內並置放在WindowSWF目錄中。在此可透過fl.configURI獲取Flash Config目錄路徑。
    Flash Config WindowSWF目錄路徑(Win 7)
    第二個選擇性引數,是指定執行該JSFL內特定的Function。
    MMExecute
  • Panel及JSFL的更新不需重新啟動Flash

    只有首次的Panel載入需要重新啟動Flash,在這之後只要覆蓋原始檔案即可即時更新。
為組件按鈕增加圖示
預設的組件按鈕只能夠從屬性面板設定Label,想要圖示按鈕的話需要透過Action Script:
 btn.setStyle("icon", as_linkage);
as_linkage為元件庫中Icon元件的AS連結名稱,該元件的註冊點將會對齊按鈕的左上方。

2014年12月9日 星期二

[DragonBones]Design Panel V3.0.0 Release Notes

V3.0.0 Release Notes
V3.0.0 includes High priority bug fixing and improvements.
New Features:
    1. The new Export panel support:
     1)Separate the data format and texture format drop down list.
     2)Export AMF(Binary) data format.
     3)Modifiable skeleton data filename, texture data filename, etc.
    2. Designpanel support drag bones to create bones in armature view.
    3. Animation support gotoAndStop.
    4. Looped Animation support play backward.
    5. Factory and DataParser support delay parse animation data in parse data process.
    6. Improve performance by cache animation and adjust animation sampling rate.
    7. Improve performance by optimize handling still bones.
Improvements:
    1. Designpanel support switch auto tween between key frames in a animation.
    2. Designpanel support quickly play previous and next animation in armature.
    3. Remove DisplayBridge. Use Slot to replace it. Each rendering engine need to extend Slot to integrated with DragonBones.


2014年11月2日 星期日

[Spine] AnimationState Events

在Spine的Runtimes中,AnimationState有幾個Events可以使用。

  • Start
  • Complete
  • End
  • Event
這幾個事件的觸發時機是:
  • Start
    當一個動作開始播放時(在此推測應該是開始Mixing的時候,尚未驗證…)
  • Complete
    當動作(Animation)完成完整的播放時,若是Looping的Animation則會在每個Loop結束時觸發一次。
    • 每個循環結束時觸發
    • 當動作完整的播放完畢時
  • End
    當動作結束時,其他與Complete相同
    • 每個循環結束時觸發
    • 當動作完整的播放完畢時
    • 當動作結束時(例如在動作播放途中被切換成其他動作)
    • 動作被終止或者清除掉時
  • Event
    當Event Track有設置Event時(在此指Spine Editor中設置的Event)(尚未確認)
在使用End事件時需要注意,不可在End事件中做SetAnimation的動作,因為SetAnimation後動作被打斷又會再觸發End事件,造成無限迴圈的狀況。

Complete與End是Pharan在Spine Forum中所做的說明,來源如下

2014年10月29日 星期三

[Spine] 動作進入Runtimes時,發生動作互相干擾的問題

使用Spine應該都會遇到一個狀況,就是A動作結束之後進入B動作,卻發現B動作的某些骨頭的動態有問題,看起來是受到A動作干擾,這是因為Spine的設計是當該Track不帶有Keyframes時,就會延續上一個動作的資訊!所以解決方式就是在動作的起始幀對每一個Track上Key。

詳見官網文件:
http://esotericsoftware.com/spine-using-runtimes#Animation-changes
An animation only affects the bones and slots for which it has keyframes.
When animations are applied in sequence, a previous animation may have made changes to bones or slots that a subsequent animation does not have keyframes for.
This can be solved be keying everything at the start of the second animation that the first animation affects.
文件有提到對每個Track打上key是會造成額外的運算負擔,但若是增加的幅度很小,其實也可以無視了。
With many animations this quickly leads to everything being keyed at the start of every animation. This is suboptimal because each property that is keyed adds a small amount of overhead when the animation is applied each frame.
文件也提出第二種解決方式,就是歸回SetupPose,但造成的負面影響是動作可能會發生不順暢、無法crossfading的狀況。 
Another solution is to call setToSetupPose, setBonesToSetupPose, or setSlotsToSetupPose on the skeleton when the current animation is changed (or otherwise write code that changes the slots and bones as needed).
However, this will cause bones that aren't keyed in the second animation to be instantly set to the setup pose state. AnimationState won't be able to do crossfading for those bones.

[Spine] 熱鍵


2014年9月5日 星期五

2014年4月4日 星期五

[3dsMax] Customize Shortcut

Next/Previous Key Mode Toggle
Alt + ,

Select and Manipulate
Alt + M

Select Object
Q

Scale
R

Layer Manager
Alt + ;

Curve Editor
Alt + '

Save File As
Ctrl + Shift + S

2013年11月25日 星期一

[Python] Photoshop 檔案輸出工具 : Export files with each layer set (Python + comtypes + PyQt)

  Photoshop檔案輸出工具試作,以Python 2.7 + comtypes + PyQt 4作成。其中使用comtypes是由於win32com無法處理2維陣列(參考:Python and photoshop- code snippets by Pete Hanshaw)。

  功能是自動的將所有的layers及每個layerSet(group)各別輸出成一個檔案(如下圖),另外還有layerSet的名稱過濾功能以及可自訂的輸出路徑,輸出的檔案名稱依據layerSet的name。


  寫到到目前為止遇到一個奇怪的問題無法解決,就是會無法獲得layerSets的length(app.activeDocument.layerSets.length),會出現NameError: Name length not found的錯誤訊息,另外看到有人使用len(layerSets)獲取length(參考:Photoshop scripting with Python @ Tech Art Tiki),但我用起來一樣會返回錯誤訊息(TypeError: object of type 'Dispatch' has no len()),也許是因為comtypes的關係吧?改天再來繼續完善。

目前完成的code
以下則是最單純的輸出功能的code供參考


參考資料:

2013年11月18日 星期一

[MAXScript] check edge length and face verts count (editable_poly)

檢查邊的長度是否小於輸入值以及面的點數是否大於輸入值,僅適用Editable_Poly。
Help查詢polyOp (Editable_Poly Geometry Methods (polyOp struct))

Code snippet - check editable_poly edge length and face verts count.
on Snipplr

2013年10月31日 星期四

[MAXScript] 利用script快速進行parameter wiring

Help可搜尋關鍵字paramWire
// 進行單向連結
// paramWire.connect [value]fromParam [value]toParam [string]toExpr

paramWire.connect $foo.baseObject[#radius] $baz.bend[#angle] "radius / 2"

// 進行雙向連結
// paramWire.connect2Way [value]leftParam [value]rightParam [string]leftExpr [string]rightExpr

2013年10月7日 星期一

[Unity] Particle System使用Mesh時,在畫面外不會Render的解決方式

  近日在幫忙解決一個Particle System(Shuriken)的particle消失的問題,遇到的情況是當Particle System的Render Mode使用Mesh,且Particle System的pivot是在畫面外時,mesh不會被render。這是Particle System本身的一個bug,理應要有個Always Render之類的選項來避免off-screen的時候被cull掉。(舊版的particle系統中則是沒有這個問題)

  在經過測試之後,得出兩種解決方式:
  1. Simulation Space - World
    在Particle System的基本設定中,把Simulation Space設定為World。而必須使用Local Space的particle就可使用第二種方式。
  2. Sub Emitters
    啟用Sub Emitters Module,在Birth新增一個sub emitter,這個sub emitter可以是deactive的。