2012年3月23日 星期五

MAXscript : 圖檔轉檔

在MAXscript Reference 9.0中有寫並不支援輸出DDS檔
DDS : BitmapIOClass
instances not creatable by MAXScript, no interfaces or properties exposed
不過先用Max來Render輸出1張dds後,就能夠成功的用ms來輸出dds檔案了


sourceImage = openBitMap  "filename_string" --定義來源檔案(.psd ..)
outputImage = bitmap sourceImage.width  sourceImage.height --定義輸出檔案
copy  sourceImage outputImage --拷貝bitmap
outputImage.fileName = "filename_string" --定義檔案路徑
save outputImage --儲存
close sourceImage


但是openBitMap讀取的PSD檔案不包含alpha(只會有空的alpha 囧)

2012年3月16日 星期五

[3dsMax] 開檔時間異常的慢或者檔案容量異常的大的解決方法

  有時會發現Max檔案的容量很大或者是開檔案時會異常的慢,但刪除檔案內所有物件後存檔卻沒有變小,這種檔案是空的卻容量很大的狀況是因為有一些沒有實體的數據資料還殘留在檔案內(例如Motion Mixer, reactor..),在網上找到了解決的方式,第一篇文章說明的很清楚,且有ms檔案可下載:
  1. Scenes that take a long time to open or save and take up a lot of memory
  2. Cleanup of a 3d max file. HELP!!!!! - pietro cunin
    Cleanup of a 3d max file. HELP!!!!! - marcwe
  3. max file grew too big pls HELP - Alex Ayuso

簡而言之:
  1. 以Maxscript清除trackview nodes的資訊
    // 請Copy下面這一行指令在Max中執行
    t=trackviewnodes; n=t[#Max_MotionClip_Manager]; deleteTrackViewController t n.controller; gc()
    // 如果執行後有-- Unknown property: "controller" in undefined 的錯誤訊息代表此方式可能幫不了你了
    
    // 下面將此行指令分行方便瀏覽
    t=trackviewnodes
    n=t[#Max_MotionClip_Manager]
    deleteTrackViewController t n.controller
    gc()
    
    
    如果不會使用Maxscript的話請看下面: 
    開啟Maxscript Listener,熱鍵F11
    或者直接用左下角的Listener
    貼上指令之後按下九宮格鍵盤區的Enter執行
  2. 在只需要Objects及Hierarchy的狀況下,只需要File>New>Keep Objects and Hierarchy,就可存出乾淨的檔案
  3. 也有可能只是Biped骨架系統的Copy Collections造成,刪除掉即可
    有時會重覆載入過多的collections,刪除掉即可

2012年3月6日 星期二

MAXScript : 讓Max說話

在網路上發現的有趣東西XD

透過OLE使用語音功能
theVoice = CreateOLEObject "SAPI.SpVoice"
theVoice.Speak "Hello"
如此就能讓MAX說話了 : D

來源 http://www.cnblogs.com/sitt/archive/2011/11/22/2258834.html

2012年3月2日 星期五

MAXscript : Display Layer

Interface: LayerManager

.count
Get the number of layers in the scene
.current
Returns a LayerProperties MixinInterface to the current layer.

getLayerFromName #name
Returns a LayerProperties MixinInterface to the layer with the given name.

選取Layer中的物件
layer = layerManager.getLayerFromName #name
--Returns true on success, and an array of all nodes on the layer in the by-reference Out parameter.
layer.nodes &theNodes
select theNodes

2012年2月14日 星期二

MAXscript : 如何自動觸發Dialog中的按鈕

在Max中有許多不被MAXscript直接支援的東西,譬如說Load Envelopes等等的Dialog,此時可靠一個callback function來解決,CGS的Bobo分享了這個方法,另外在這邊也有相關討論。

fn ANoon_EnvelopeCallbackFunction =
(
    WindowHandle = DialogMonitorOPS.GetWindowHandle()
    theDialogName = UIAccessor.GetWindowText WindowHandle
    if theDialogName != undefined and matchpattern theDialogName pattern:"*Load Envelopes*" do
    UIAccessor.PressButtonByName WindowHandle "OK" true
)

DialogMonitorOPS.RegisterNotification ANoon_EnvelopeCallbackFunction ID:#ANoon_Envelopes
DialogMonitorOPS.Enabled = true

這個callback是case sensitive

2012年2月9日 星期四

MAXscript : Skinops Methods

今天想寫個merge已綁定模型的同時也自動將skin加上去的script,但是當寫到給merge進來的模型add bone的時候就是一直** system exception **,搞了好久一直找不到原因,上網搜了一下找到答案了,原來是skinops的methods一定要在該skin modifier可以被選取的狀態下才可以使用!!真是太不人性化了...

Help裡面就有寫著,一直被我無視...
The following methods require that the Skin modifier be the displayed modifier in the Modify panel, and that the Modify panel is active.
addbone後要執行load envlope時,又遇到一個問題,load envlope雖然成功執行,但是卻沒有load到envlope,咕狗後發現解決辦法(還有如何執行load envlope dialog的按鈕的方法),一為執行load envlope兩次,二為在load envlope之前加入completeRedraw()。

2012年2月7日 星期二

MAXscript : 控制外部文件

MAXscript 控制外部文件的函數 (適用於max檔案及非max檔案)


getFiles "wild_card_filename_string"
Returns an array of file names that match the given wild-card path name. The following example gets an array of all the .max scene files in c:\foo and then loops over the array, opening each file and printing the objects in each:
files = getFiles "c:\\foo\\*.max"
for f in files do (loadMAXFile f; print objects)
getFiles() can also be used to determine if a file exists.


getDirectories "wild_card_directory_name_string"
Returns an array of directory paths that match the given wild-card directory path name.


makeDir "directorypath_string" all:
Return false on failure (either because the path could not be created or because the path already existed).


deleteFile "filename_string"
Fails if the file is open in MAXScript.


renameFile "old_filename_string" "new_filename_string"
Renames the old file to the new file. This can also be used to move a file between directories. Fails if new file already exists or if the old file is open in MAXScript. Returns true on success, false on failure.


copyFile "existing_filename_string" "new_filename_string"
Copies the existing file to the new file. Fails if the new file already exists, the new file cannot be created, or the existing file is open in MAXScript. Returns true on success, false on failure.


getFileSize "filename_string"
Returns the size of the specified file in bytes. Returns 0 if the file could not be found.


getFileAttribute "filename_string" "attribute"
setFileAttribute "filename_string" "attribute"
The valid values are:
#readOnly #hidden #system #directory #archive #temporary #normal


getFileModDate "filename_string"
getFileCreateDate "filename_string"


getFileVersion "filename_string"
This data is typically specified only for executable and application extension (i.e., .dll) files.


FileStream Values


createFile


openFile [ mode: ]


close filepath


Standard Open and Save File Dialogs


getOpenFileName
getSaveFileName
Both functions return a fully-specified file path name or undefined if the user cancels out.
When the optional keyword filename: is supplied, the string is used to define the path and file name of the file to be loaded or saved. The dialog automatically navigates to the specified path (if available on the disk/network), displays its content in the browsing area and suggests the file name in the "File name" field. If the path does not exist, the current path is used and only the file name is displayed as requested.

getMAXFileObjectNames
傳回該檔案內物件的字串陣列


checkForSave()
儲存確認視窗


shellLaunch "notepad.exe" filepath
執行外部程式 eg. Notepad


File Name Parsing 檔名的解析
filenameFromPath "filename_string"
從完整的檔案路徑中擷取檔名(包含副檔名)


getFilenamePath " filename_string "
getFilenameFile " filename_string "
getFilenameType " filename_string "
從完整的檔案路徑中獲得目錄路徑、檔案檔名(不含副檔名)、副檔名


doesFileExist " filename_string "
return True or False

2012年2月3日 星期五

關於遊戲開發資料收集

The Anatomy of a Design Document, Part 1: Documentation Guidelines for the Game Concept and Proposal (1999)
The Anatomy of a Design Document, Part 2: Documentation Guidelines for the Functional and Technical Specifications(1999)
Game Production TimeLine - Game Production TimeLine

Python 資訊收集

fcamel's blog: 學 Python 的入門書: 常看到有人問這問題,想說來寫篇心得,省得重覆回一樣的問題。 我在學 Python 前已學過別的程式語言,所以想找針對已學過程式的人的書。一開始翻許多人推薦的《Learning Python》,發現它是針對沒學過程式的人,有太多篇幅在介紹基本觀念 (如 if 是什麼 ),翻沒幾...

fcamel's blog: Python 的特別之處 (1): 從新手的眼中來看 Python,比較能看出 Python 和其它語言不同之處。最近有機會幫別人快速上手 Python,就順便整理一下我從中發覺 Python 較為突出的優點。 list、dictionary and string 平時 coding 最常用到的 container...


blur-devBlur Studio API's, Libraries and Tools : Python and 3dsMax

Dive Into PythonPython from novice to pro: Dive Into Python is a free Python book for experienced programmers. It was originally hosted at DiveIntoPython.org, but the author has pulled down all copies. It is being mirrored here. You can read the book online, or download it in a variety of formats. It is also available in multiple languages.

2012年1月11日 星期三

Bone-Gimbal & Gimbal Lock


在3dsMax創bone的時候,座標系的旋轉值會因為創bone時的軸向而異(viewport也有關聯),會造成錯誤的gimbal軸向(Euler Controller的問題,x跟z軸會重疊),導致調curves的時候會異常困難,動態也有問題。在網路上搜到了一個討論串提到了解決方法:
  1. 建立一個dummy對齊bone的pivot,將bone link給dummy,對dummy上key
  2. 創好bone之後,選取bone後alt+RMB執行Freeze transform
在搜尋解決方式時也發現了Gimbal Lock一詞,這個現象的相關資料:
Gimbal Lock到底該怎麼稱呼?
Wikipedia:Gimbal Lock
Gimbal Lock 萬向鎖 (內文有滿深入的講解跟有用的連結)