Tuesday, 21 November 2023

Using Namespace in Blender

Blender is indeed very clever! 
For users familiar with Maya and MotionBuilder(MoBu), namespaces are an essential tool for naming conventions.
 In my recent search for information on namespaces, I discovered that others have encountered similar issues. 
However, the answers provided did not quite address what I was looking for.
For example:
https://blenderartists.org/t/apending-and-namespaces/1305794
https://blender.stackexchange.com/questions/279191/namespacing-imported-assets

After conducting two consecutive tests, I stumbled upon the solution. 
First, let's understand the purpose of namespaces. In my understanding and experience of using them, they allow for the reuse of the same naming and hierarchical structure in a scene without modifying the original names.


1. Blender allows direct naming using prefixes sperate by colons. However, Blender doesn't explicitly present this concept and usage. Its habitual approach to handling duplicate names is to use a "dot" followed by a "three-digit serial number." 

2. As long as the group name of the skin model matches the namespace, when exporting the skin mesh using FBX, Blender automatically removes the name before the colon. Isn't that clever! 

3. However, if you export only the animations in FBX, it will still include the namespace. Nevertheless, this doesn't affect importing the animations into Unreal Engine, so it's perfectly fine! Note: When importing into MoBu, the namespace will still be present, possibly due to version differences in reading exported FBX files. 

I'm new to Blender, so feel free to leave comments if I make any mistakes.

Blend真的是很聰明! 對於maya跟motion builder的使用者來說 namesapce是個很重要用來規範命名的工具 這幾天在查找namesapce的相關資訊 發現有人有跟我一樣的問題 但是回答的都不算是我想找的解答 
像是:
https://blenderartists.org/t/apending-and-namespaces/1305794
https://blender.stackexchange.com/questions/279191/namespacing-imported-assets

連續兩測試後,誤打誤撞的發現解答 先理解一下ns的用途,在我的理解及使用的經驗中,它是為了能使用同樣的命名及層級結構,能在同一場景中重覆使用,但又不需改動原始名稱。 


1. blender是可以直接用前綴名加上冒號命名,只是在blender裡,並沒有特別提出這樣的概念與用法。它對於重覆名稱的慣性處理方式是用"點"再加"三位數序號"。 
2. 只要skin的模型群組名稱與,ns一樣,在用FBX輸出Skin Mesh時,它會自動的把冒號前的名稱自動刪除,是不是很聰明!!! 
3. 然而若FBX只輸出動作,它還是會帶冒號前的ns,不過這不影響動作滙入到UE裡,所以是很OK的! 註: 但若滙到mobu裡,ns還是會在喲,可能是mobu在讀取輸出FBX的版本差異。

對於Blender我才剛起步,若有任何資訊上的錯誤,歡迎留言糾正我。

Tuesday, 24 May 2022

Animation Exercise 02

 

Reference:

https://www.youtube.com/watch?v=tGh4AAz32vw

https://twitter.com/i/status/1523489023234166784

This is a great movement too! Since this movement is more complicate. I am going to separate it into two parts.

Working progress:
    Key pose collecting: 30 mins
    Idle pose: 15 mins
    key pose block: 90mins hours
    

    timing adjust: 20 mins
    

    spine: about 60 mins

    Total working time : 3.6 hours

Reference:

Reference: https://www.youtube.com/watch?v=tGh4AAz32vw


Tuesday, 10 May 2022

Animation Exercise 01

It is time back to key-frame animation!

This animation took me 3 hours to finish it. If it was mocap data, I can probably clean it up within a half hour.


Rig: Mannequin + HIK

working time:

idle pose: 20 mins
key pose: 50 minis
spine: 50 mins
polish: 60 mins

total: 3 hours


Check out their awesome motion!

Reference: https://twitter.com/i/status/1523636617872764928



Thursday, 21 April 2022

Python 命名規則

 Python 在工作上幫了我很多,不斷的累積後,也進入了思考怎麼樣才是好的命名的階段

在參考了各方大大的分享文章,以及自己使用Maya及Motionbuilder的經驗

確實各家有不同的命名規範:

以下是我自己覺得適合的命名模組

雖然有些知識還有些模糊,但過一陣子再檢視看看,有什麼可以改進的











Krita python export png per layer

 

寫這個工具是因為專案上有需要批次輸出圖層檔案
因為Krita 免費,又可以用Python撰寫
花了一些時間找了一些教學
總總約花了半天,寫出這樣的工具。

執行位置: 工具>指令稿>指令稿工具






基本用途:
依開始的圖檔位置,自動建立一個存放輸出圖片的資料夾,並依圖層名層為檔案名稱。
目前每處理一個圖層都要按一次確定,因為管方文件好像有問題無法使用,所以也不確定要如何解決,但比起要手動一張一張輸出圖片,還是要方便跟輕鬆多了吧。

Python code: 下載位置

 '''  
 @Jiapei Lu 2022  
 This tool is to export png per layer with baselayer, and make a folder for store all those exported pics.  
 It applys the name of the layer as a filename automatically.  
 Exported folder will be created under where the opened file is.  
 '''  
 from krita import *  
 import os  
 export_png_folder_name = 'export_png' # you can change the folder name here.  
 #Krita.instance().action('python_scripter').trigger()  
 doc = Krita.instance().activeDocument()#access to current file  
 doc_dir = os.path.dirname( doc.fileName( ))#get the file path  
 exportDir = os.path.join( doc_dir, export_png_folder_name)# building the path for exporting  
 #If folder doesn't exist then create the folder for export pics  
 if not os.path.isdir( exportDir):  
   os.makedirs( exportDir)  
 batchNodes = []#this for containing all the layer nodes  
 #First: Go over all layer turn off it's visible except basic layer.  
 for node in doc.topLevelNodes()[ 1:] :  
     node.setVisible( 0)   
     batchNodes.append( node )  
 #Second: Trun on the visible of the layers one by one then exporting it.  
 for node in batchNodes:  
   node.setVisible( 1)  
   doc.refreshProjection() #This is supper imported to refresh view. Otherwise the exported pic could be wrong.  
   info = InfoObject()# InfoObject is a dictionary with specific export options  
   info.setProperty( "alpha", True)  
   info.setProperty( "compression", 9)  
   info.setProperty( "forceSRGB", False)  
   info.setProperty( "indexed", False)  
   info.setProperty( "interlaced", False)  
   info.setProperty( "saveSRGBProfile", False)  
   info.setProperty( "transparencyFillcolor", [0,0,0])     
   path = os.path.join(exportDir, node.name() + ".png")  
   #node.save(path, doc.resolution(), doc.resolution(), info)  
   doc.setActiveNode( node)  
   doc.exportImage( path, info)    
   node.setVisible( 0)  
   doc.refreshProjection( )   
 Application.setBatchmode( False)  
 QMessageBox.information( Application.activeWindow().qwindow(), "Done and Done", "All done!")  

2022 Animation Demo

 

Porject: 《Marvel's Avengers Game》
Response for : 
    Kate/ Black Panther Gameplay Animations.
    Clean-up Character Body Mocap Aniamtions.
    Building up the animation tool.
    Tranning Animators to meeting the AAA Game Quality.

https://vimeo.com/697820338

JiapeiShowcase_2022.mp4 from Jiapei Lu on Vimeo.



Python2.X json.load() unicode utf-8 Issue ( Sloved )

 

發生問題:

在mobu 2020利用os 連接路徑報錯,發現以Json.load()的字典格式,為unicode

而mobu無法辨識,需先將用到字串利用string.encode('utf-8')

才能使用

後來想想覺得應是在open()時,就可以先轉換,就不用對個案一個一個轉換

在網路查了相關的關鍵字"python2.x,  json.load, dict, unicode, utf-8, open"

試了多個覺得可行的方式

像是open加入encoding

或是json.dump()加入encoding

import io

都沒什麼用

最後找到這個解最簡單,原網址https://www.jianshu.com/p/90ecc5987a18


Python2.x Code Sample:

 def Read_Dict_Data( Dict_Data ):  
   import json  
   def byteify(input, encoding='utf-8'):  
     if isinstance(input, dict):  
       return {byteify(key): byteify(value) for key, value in input.iteritems()}  
     elif isinstance(input, list):  
       return [byteify(element) for element in input]  
     elif isinstance(input, unicode):  
       return input.encode(encoding)  
     else:  
       return input  
   with open ( Dict_Data )as f:  
     data = json.load(f, encoding = 'UTF-8')# it is useless adding encoding when use json.load()  
     return byteify(data)  

如果是Python3就沒有以上問題

多數網頁都沒清楚的說明python2與3的差別,所以記錄一下