2012年1月29日 星期日
2012年1月11日 星期三
Bone-Gimbal & Gimbal Lock
在3dsMax創bone的時候,座標系的旋轉值會因為創bone時的軸向而異(viewport也有關聯),會造成錯誤的gimbal軸向(Euler Controller的問題,x跟z軸會重疊),導致調curves的時候會異常困難,動態也有問題。在網路上搜到了一個討論串提到了解決方法:
- 建立一個dummy對齊bone的pivot,將bone link給dummy,對dummy上key
- 創好bone之後,選取bone後alt+RMB執行Freeze transform
在搜尋解決方式時也發現了Gimbal Lock一詞,這個現象的相關資料:
Gimbal Lock到底該怎麼稱呼?
Wikipedia:Gimbal Lock
Gimbal Lock 萬向鎖 (內文有滿深入的講解跟有用的連結)
Gimbal Lock到底該怎麼稱呼?
Wikipedia:Gimbal Lock
Gimbal Lock 萬向鎖 (內文有滿深入的講解跟有用的連結)
2011年12月26日 星期一
MAXscript : 新創同樣BoneList的Skin
從現有已加完Bones的Skin中,抓取Bone List到新的Skin中
--從已有的Skin中抓取骨骼的Name
bonesAry = for i in 1 to skinOps.getNumberBones $.skin collect skinOps.getBoneName $.skin i 0
--加入到新的Skin中
for i in 1 to boneAry.count do skinOps.addBone $.skin (getNodeByName boneAry[i]) 0
--從已有的Skin中抓取骨骼的Name
bonesAry = for i in 1 to skinOps.getNumberBones $.skin collect skinOps.getBoneName $.skin i 0
--加入到新的Skin中
for i in 1 to boneAry.count do skinOps.addBone $.skin (getNodeByName boneAry[i]) 0
2011年12月4日 星期日
Maxscript : Writing Better and Faster Scripts
( Frequently Asked Questions in MAXscript help)
Disable Viewport Redraws when making changes to scene objects
You can use the with redraw off() context or a pair of disableSceneRedraw() and enableSceneRedraw() calls to speed up you code. The former method is the preferred one.
Disable Undo system when possible
ondo off( ... ) ; ondo on( ... ) ; with undo off
print (et-st) --print the resulting time
gc() --call Garbage Collection &endash; you will needed it!
Modify Panel can be slow - change to Create Panel when possible
In 3ds Max 7 and higher, you can also completely disable Modify Panel updates using the suspendEditing() and resumeEditing() methods
Only calculate once if possible
Try to avoid running the same calculation more than once, or interrogating the same value in the same node more than once.
Cache frequently used functions and objects
You can store frequently used functions and objects in user variables to faster access.
Pre-initialize arrays when final size is known
When adding elements to an array using the append method, a copy of the original array is being created in memory before the new array is created. When the size of an array is known before the array is actually used, it is a good practice to pre-initialize the array in memory by assigning the last element of the array to some temporary value. This will create an array of the desired size in memory and will let you simply assign values to any element of the array using indexed access without the memory overhead of the append method.
MyArray = #()
MyArray[100] = 0 --initialize a 100 elements array in memory
for i = 1 to 100 do MyArray[i] = random 1 100 --assign to predefined array
matchPattern is faster than findString
When searching for a substring inside a string, using the matchPattern() method is faster than using findString().
Executing the same method one million times on the same PC resulted in:
3.7 seconds execution time for matchPattern
5.9 seconds execution time for findString
5.0 seconds execution time for subString when comparing the first 3 characters.
Do not use return, break, exit or continue
Return, break, exit, continue and throw are implemented using C++ exception.
C++ exceptions are SLOW!
Use StringStream to build large strings
If building strings, use a StringStream value to accumulate the string and then convert to a string.
fn test5d =
(
local ss = stringstream"",fmt ="%"
for i = 1 to 100 do format fmt ito:ss
ss as string
)
Using Bsearch For Fast Table Lookup
The bsearch() method available in 3ds Max 2009 and higher allows for very fast table lookup operations in sorted arrays.
The bsearch() method available in 3ds Max 2009 and higher allows for very fast table lookup operations in sorted arrays.
2011年12月2日 星期五
Maxscript : Right-Handed to Left-Handed
正解!!Right to Left or Left to Right:by cmann
Let me try to explain it a little better. I need to export from Blender, in which the z axis is facing, to OpenGL where the y axis is facing up.
For every coordinate (x, y, z) it's simple, swap the y and z values: (x, z, y).
Because I have swapped the all of the y and z values any matrix that I use also needs to be flipped so that it has the same affect .
Because I have swapped the all of the y and z values any matrix that I use also needs to be flipped so that it has the same affect .
After a lot of searching I've eventually found a solution here:
http://www.gamedev.net/community/forums/topic.asp?topic_id=537664
If your matrix looks like this:
http://www.gamedev.net/community/forums/topic.asp?topic_id=537664
If your matrix looks like this:
{ rx, ry, rz, 0 }
{ ux, uy, uz, 0 }
{ lx, ly, lz, 0 }
{ px, py, pz, 1 }
To change it from left to right or right to left, flip it like this:
{ rx, rz, ry, 0 }
{ lx, lz, ly, 0 }
{ ux, uz, uy, 0 }
{ px, pz, py, 1 }2011年11月30日 星期三
Maxscript : isValidNode
isValidNode
Returns true if is a node value, and the node has not been deleted. Otherwise, it returns false.
Returns true if is a node value, and the node has not been deleted. Otherwise, it returns false.
isValidNode $
等同於
fn isValidNodeFn = ( if $!=undefined then return true else return false )
getSavePath()
getSavePath [caption:] [initialDir:]
(MAXscript Reference : Standard Open and Save File Dialogs)
This function displays a folder selection browser for the user to select a folder. Returns a string path name for the selected folder or the value undefined if the user presses Cancel in the folder browser.
If the initialDir: keyword argument is specified, the Browse For Folder dialog will be opened at the specified directory. Symbolic pathnames are acceptable as the pathname. Available in 3ds Max 8 and higher.
Try Expression
The try expression lets you bracket a piece of code and catch any runtime errors.
This allows you to respond appropriately or take corrective action, rather than let MAXScript halt the execution of your script and print an error message.
try ... catch ...
throw ... ; throw()
getNodeByName
getNodeByName "Box01"
等同於
theName = "Box01"
theObject = Execute ("$'"+theName+"'")
displayTempPrompt
displayTempPrompt
Displays the specified string on the Prompt Line for the specified number of milliseconds. After the time elapses, the string is popped from the stack. This may be used to put up a temporary error message for example. Control is returned to MAXScript immediately after the call, that is, MAXScript execution continues even while the temporary prompt is displayed.
snapshot
This function provides functionality similar to the SnapShot tool in 3ds Max. It generates a new node that contains a copy of the world-state mesh of the source at the time that the
snapshot is made. Any existing modifiers are collapsed out of the new node and
the mesh snapshot accounts for any space warps currently applied. As with the
clone methods (copy, reference and instance,) you can add any of the standard
node creation keyword arguments, such as pos:, name:, etc.
等同於
fn isValidNodeFn = ( if $!=undefined then return true else return false )
getSavePath()
getSavePath [caption:
(MAXscript Reference : Standard Open and Save File Dialogs)
This function displays a folder selection browser for the user to select a folder. Returns a string path name for the selected folder or the value undefined if the user presses Cancel in the folder browser.
If the initialDir: keyword argument is specified, the Browse For Folder dialog will be opened at the specified directory. Symbolic pathnames are acceptable as the pathname. Available in 3ds Max 8 and higher.
Try Expression
The try expression lets you bracket a piece of code and catch any runtime errors.
This allows you to respond appropriately or take corrective action, rather than let MAXScript halt the execution of your script and print an error message.
try ... catch ...
throw ... ; throw()
getNodeByName
getNodeByName "Box01"
等同於
theName = "Box01"
theObject = Execute ("$'"+theName+"'")
displayTempPrompt
displayTempPrompt
Displays the specified string on the Prompt Line for the specified number of milliseconds. After the time elapses, the string is popped from the stack. This may be used to put up a temporary error message for example. Control is returned to MAXScript immediately after the call, that is, MAXScript execution continues even while the temporary prompt is displayed.
snapshot
This function provides functionality similar to the SnapShot tool in 3ds Max. It generates a new node that contains a copy of the world-state mesh of the source
2011年11月10日 星期四
2011年9月1日 星期四
[Lua] 筆記 to 28
-- Example 18 -- if elseif else statement
c=3
if c==1 then
print("c is 1")
elseif c==2 then
print("c is 2")
else
print("c isn't 1 or 2, c is "..tostring(c))
end
-- Example 19 -- Conditional assignment.
-- value = test and x or y
a=1
b=(a==1) and "one" or "not one"
print(b)
-- is equivalent to
a=1
if a==1 then
b = "one"
else
b = "not one"
end
print(b)
-------- Output ------
one
one
-------- Output ------
c isn't 1 or 2, c is 3
-- Example 20 -- while statement.
a=1
while a~=5 do -- Lua uses ~= to mean not equal
a=a+1
io.write(a.." ")
end
-------- Output ------
2 3 4 5
Press 'Enter' key for next example
-- Example 20 -- while statement.
a=1
while a~=5 do -- Lua uses ~= to mean not equal
a=a+1
io.write(a.." ")
end
-------- Output ------
2 3 4 5
-- Example 22 -- for statement.
-- Numeric iteration form.
-- Count from 1 to 4 by 1.
for a=1,4 do io.write(a) end
print()
-- Count from 1 to 6 by 3.
for a=1,6,3 do io.write(a) end
-------- Output ------
1234
14
-- Example 23 -- More for statement.
-- Sequential iteration form.
for key,value in pairs({1,2,3,4}) do print(key, value) end
-------- Output ------
1 1
2 2
3 3
4 4
-- Example 24 -- Printing tables.
-- Simple way to print tables.
a={1,2,3,4,"five","elephant", "mouse"}
for i,v in pairs(a) do print(i,v) end
-------- Output ------
1 1
2 2
3 3
4 4
5 five
6 elephant
7 mouse
c=3
if c==1 then
print("c is 1")
elseif c==2 then
print("c is 2")
else
print("c isn't 1 or 2, c is "..tostring(c))
end
-- Example 19 -- Conditional assignment.
-- value = test and x or y
a=1
b=(a==1) and "one" or "not one"
print(b)
-- is equivalent to
a=1
if a==1 then
b = "one"
else
b = "not one"
end
print(b)
-------- Output ------
one
one
-------- Output ------
c isn't 1 or 2, c is 3
-- Example 20 -- while statement.
a=1
while a~=5 do -- Lua uses ~= to mean not equal
a=a+1
io.write(a.." ")
end
-------- Output ------
2 3 4 5
Press 'Enter' key for next example
-- Example 20 -- while statement.
a=1
while a~=5 do -- Lua uses ~= to mean not equal
a=a+1
io.write(a.." ")
end
-------- Output ------
2 3 4 5
-- Example 22 -- for statement.
-- Numeric iteration form.
-- Count from 1 to 4 by 1.
for a=1,4 do io.write(a) end
print()
-- Count from 1 to 6 by 3.
for a=1,6,3 do io.write(a) end
-------- Output ------
1234
14
-- Example 23 -- More for statement.
-- Sequential iteration form.
for key,value in pairs({1,2,3,4}) do print(key, value) end
-------- Output ------
1 1
2 2
3 3
4 4
-- Example 24 -- Printing tables.
-- Simple way to print tables.
a={1,2,3,4,"five","elephant", "mouse"}
for i,v in pairs(a) do print(i,v) end
-------- Output ------
1 1
2 2
3 3
4 4
5 five
6 elephant
7 mouse
2011年8月29日 星期一
Cry - Flow Graph 筆記
Done與Succeed/Fail的差別:Done是不管Succeed/Fail都會送出
在system.cfg中加速g_tpview_force_goc=1可防止攝影機穿越物件
在system.cfg中加速g_tpview_force_goc=1可防止攝影機穿越物件
2011年7月22日 星期五
Bodypaint : 直接把圖貼到模型上
假設模型上已有一部分貼圖是可以移植到另一個部位上,或者有圖片想直接貼到模型貼圖上
可先將設些部份Ctrl+C至剪貼簿,開啟Bodypaint後,切到你要的角度Ctrl+V,
就會把剪貼簿裏面的圖像直接貼到模型上,此時Bodypaint會進入投影模式,
要繼續繪製時記得取消,否則接縫處會有縫隙。
可先將設些部份Ctrl+C至剪貼簿,開啟Bodypaint後,切到你要的角度Ctrl+V,
就會把剪貼簿裏面的圖像直接貼到模型上,此時Bodypaint會進入投影模式,
要繼續繪製時記得取消,否則接縫處會有縫隙。
2011年7月19日 星期二
2011年7月18日 星期一
Maxscript : 把Rollout顯示出來, script加入介面中
把Rollout顯示出來
rf = newRolloutFloater "Title" 500 520
addRollout rolloutname rf
script加入介面中
macroScript name category:"category" toolTip:"tooltip"
(on Execute do
fileIn "$Scripts\script.ms"
)
rf = newRolloutFloater "Title" 500 520
addRollout rolloutname rf
script加入介面中
macroScript name category:"category" toolTip:"tooltip"
(on Execute do
fileIn "$Scripts\script.ms"
)
訂閱:
文章 (Atom)