2012年11月13日 星期二
2012年5月25日 星期五
利用nvidia DDS Utilities - nvDXT進行DDS轉檔
最近嘗試了幾種dds轉檔的方式,用maxScript的缺陷是在於無法產生alpha,用python透過com操作photoshop則是運行耗時、且我找不到dds的save option,利用nvidia DDS Utilities來進行dds轉檔看來是目前最好的方法。
nvidia DDS Utilities是什麼?nvidia的說明是:
included are a set of utilities for manipulating DDS image files, including:
nvDXT, a command-line binary version of the nvDXT library,
detach, a tool that extracts MIP levels from a DDS file,
stitch, a tool that recombines MIP levels into a single DDS file and
readDXT, which reads compressed images and writes TGA files.
Download DDS Utilities >> http://developer.nvidia.com/legacy-texture-tools
利用nvDXT即可用command-line的方式來輸出.dds檔案,最簡單的命令如下
nvdxt -profile profile -file file -outdir outdir
nvdxt -profile profile -file file -outsamedir
很方便,可以讀取.psd,-file可運用萬用字元,還可指定profile(由photoshop產生)
----------以下是nvDXT本身的說明內容----------
This program
compresses images
creates normal maps from color or alpha
creates DuDv map
creates cube maps
writes out .dds file
does batch processing
reads .tga, .bmp, .gif, .ppm, .jpg, .tif, .cel, .dds, .png, .psd, .rgb, *.bw and .rgba
filters MIP maps
Options:
-profile
-quick : use fast compression method
-quality_normal : normal quality compression
-quality_production : production quality compression
-quality_highest : highest quality compression (this can be very slow)
-rms_threshold
-prescale
-rescale
-rel_scale
Optional Filtering for rescaling. Default cube filter:
-RescalePoint
-RescaleBox
-RescaleTriangle
-RescaleQuadratic
-RescaleCubic
-RescaleCatrom
-RescaleMitchell
-RescaleGaussian
-RescaleSinc
-RescaleBessel
-RescaleHanning
-RescaleHamming
-RescaleBlackman
-RescaleKaiser
-clamp
-clampScale
-window
-nomipmap : don't generate MIP maps
-nmips
-rgbe : Image is RGBE format
-dither : add dithering
-sharpenMethod
None
Negative
Lighter
Darker
ContrastMore
ContrastLess
Smoothen
SharpenSoft
SharpenMedium
SharpenStrong
FindEdges
Contour
EdgeDetect
EdgeDetectSoft
Emboss
MeanRemoval
UnSharp
XSharpen
Custom
-pause : wait for keyboard on error
-flip : flip top to bottom
-timestamp : Update only changed files
-list
-cubeMap : create cube map .
Cube faces specified with individual files with -list option
positive x, negative x, positive y, negative y, positive z, negative z
Use -output option to specify filename
Cube faces specified in one file. Use -file to specify input filename
-volumeMap : create volume texture.
Volume slices specified with individual files with -list option
Use -output option to specify filename
Volume specified in one file. Use -file to specify input filename
-all : all image files in current directory
-outdir
-deep [directory]: include all subdirectories
-outsamedir : output directory same as input
-overwrite : if input is .dds file, overwrite old file
-forcewrite : write over readonly files
-file
-output
-append
-8
-16
-24
-32
-swapRB : swap rb
-swapRG : swap rg
-gamma
-outputScale
-outputBias
-outputWrap : wraps overflow values modulo the output format
-inputScale
-inputBias
-binaryalpha : treat alpha as 0 or 1
-alpha_threshold
-alphaborder : border images with alpha = 0
-alphaborderLeft : border images with alpha (left) = 0
-alphaborderRight : border images with alpha (right)= 0
-alphaborderTop : border images with alpha (top) = 0
-alphaborderBottom : border images with alpha (bottom)= 0
-fadeamount
-fadecolor : fade map (color, normal or DuDv) over MIP levels
-fadetocolor
-custom_fade
-fadealpha : fade alpha over MIP levels
-fadetoalpha
-border : border images with color
-bordercolor
-force4 : force DXT1c to use always four colors
-weight
-luminance : convert color values to luminance for L8 formats
-greyScale : Convert to grey scale
-greyScaleWeights
-brightness
-contrast
Texture Format Default DXT3:
-dxt1c : DXT1 (color only)
-dxt1a : DXT1 (one bit alpha)
-dxt3 : DXT3
-dxt5 : DXT5n
-u1555 : uncompressed 1:5:5:5
-u4444 : uncompressed 4:4:4:4
-u565 : uncompressed 5:6:5
-u8888 : uncompressed 8:8:8:8
-u888 : uncompressed 0:8:8:8
-u555 : uncompressed 0:5:5:5
-p8c : paletted 8 bit (256 colors)
-p8a : paletted 8 bit (256 colors with alpha)
-p4c : paletted 4 bit (16 colors)
-p4a : paletted 4 bit (16 colors with alpha)
-a8 : 8 bit alpha channel
-cxv8u8 : normal map format
-v8u8 : EMBM format (8, bit two component signed)
-v16u16 : EMBM format (16 bit, two component signed)
-A8L8 : 8 bit alpha channel, 8 bit luminance
-fp32x4 : fp32 four channels (A32B32G32R32F)
-fp32 : fp32 one channel (R32F)
-fp16x4 : fp16 four channels (A16B16G16R16F)
-dxt5nm : dxt5 style normal map
-3Dc : 3DC
-g16r16 : 16 bit in, two component
-g16r16f : 16 bit float, two components
Mip Map Filtering Options. Default box filter:
-Point
-Box
-Triangle
-Quadratic
-Cubic
-Catrom
-Mitchell
-Gaussian
-Sinc
-Bessel
-Hanning
-Hamming
-Blackman
-Kaiser
***************************
To make a normal or dudv map, specify one of
-n4 : normal map 4 sample
-n3x3 : normal map 3x3 filter
-n5x5 : normal map 5x5 filter
-n7x7 : normal map 7x7 filter
-n9x9 : normal map 9x9 filter
-dudv : DuDv
and source of height info:
-alpha : alpha channel
-rgb : average rgb
-biased : average rgb biased
-red : red channel
-green : green channel
-blue : blue channel
-max : max of (r,g,b)
-colorspace : mix of r,g,b
-norm : normalize mip maps (source is a normal map)
-toHeight : create a height map (source is a normal map)
Normal/DuDv Map dxt:
-aheight : store calculated height in alpha field
-aclear : clear alpha channel
-awhite : set alpha channel = 1.0
-scale
-wrap : wrap texture around. Default off
-minz
***************************
To make a depth sprite, specify:
-depth
and source of depth info:
-alpha : alpha channel
-rgb : average rgb (default)
-red : red channel
-green : green channel
-blue : blue channel
-max : max of (r,g,b)
-colorspace : mix of r,g,b
Depth Sprite dxt:
-aheight : store calculated depth in alpha channel
-aclear : store 0.0 in alpha channel
-awhite : store 1.0 in alpha channel
-scale
-alpha_modulate : multiplies color by alpha during filtering
-pre_modulate : multiplies color by alpha before processing
Examples
nvdxt -cubeMap -list cubemapfile.lst -output cubemap.dds
nvdxt -cubeMap -file cubemapfile.tga
nvdxt -file test.tga -dxt1c
nvdxt -file *.tga
nvdxt -file c:\temp\*.tga
nvdxt -file temp\*.tga
nvdxt -file height_field_in_alpha.tga -n3x3 -alpha -scale 10 -wrap
nvdxt -file grey_scale_height_field.tga -n5x5 -rgb -scale 1.3
nvdxt -file normal_map.tga -norm
nvdxt -file image.tga -dudv -fade -fadeamount 10
nvdxt -all -dxt3 -gamma -outdir .\dds_dir -time
nvdxt -file *.tga -depth -max -scale 0.5
Send comments, bug fixes and feature requests to texturetools@nvidia.com
2012年5月9日 星期三
Regular Expressions
Regular Expressions 可簡稱 re / regex / regexp
中文則為:正則表示式、正規表示式...
下面的連結對RE有詳細的解說
http://www.regular-expressions.info/reference.html
Regular-Expressions.info
石頭閒語 : RE in JavaScript
RE JavaScript Tester
MAXscript不支援RE(至少Max9是),但是可以藉由dotNet來實行,請見下面連結
For obj in $ do : RE with MAXscript
中文則為:正則表示式、正規表示式...
下面的連結對RE有詳細的解說
http://www.regular-expressions.info/reference.html
Regular-Expressions.info
石頭閒語 : RE in JavaScript
RE JavaScript Tester
MAXscript不支援RE(至少Max9是),但是可以藉由dotNet來實行,請見下面連結
For obj in $ do : RE with MAXscript
rx = dotNetClass "System.Text.RegularExpressions.RegEx"
pattern = "^([A-Za-z0-9]+_){2}\d{3}"
s = "robot_leftArm_001"
if (((rx.match s pattern).success) == true) then (print "success") else (print "fail!")
2012年5月3日 星期四
MAXscript : Find biped
想要在max檔案中找出所有的biped有什麼方法比較好?
主要是透過取得Biped的根骨架就能夠判別出有幾組biped骨架,而方法有好幾種...
主要是透過取得Biped的根骨架就能夠判別出有幾組biped骨架,而方法有好幾種...
- 利用RootNode這個Property
bipedNode.controller.rootNode
這個方式是從網上看到的(影片來源),透過能從所有biped骨頭中獲取的rootNode這個property,可取得biped根骨架 。另外也可使用rootName這個property直接獲取rootNode的name。// for o in geometry where classof o == Biped_Object and o.controller.rootNode == o do print o
- 透過Controller的類型
classof bipedNode.controller
利用判別controller的類型來尋找,root的controller類型為Vertical_Horizontal_Turn,root外的biped parts都會是BipSlave_Control,Footsteps即為Footsteps。// for o in geometry where classof o.controller == Vertical_Horizontal_Turn do print o
- 透過biped.getNode這個指令
biped.getNode [bipedNode | bipedCtrl] [limbName | index]
只要知道固定部位的limb name或者index即可用biped.getNode傳回該node,而根骨架的limb name是#vertical、#horizontal、#turn,index為13~15。詳見MAXScript Reference:Biped Node Hierarchy
2012年4月27日 星期五
MAXscript : constraints appendTarget
近日用MAXscript來做批次處理,其中有個步驟是先切biped的FigureMode為true,然後Merge物件並appendTarget $Bip01,但是發現取消FigureMode之後物件的座標點仍是merge時的座標,並未依據$Bip01的位移改變。後來發現在appendTarget後必需要取用物件的position(或者直接取用transform)資訊才會正常。不過若是一步一步手動執行,就沒有這個問題,也不是因為使用disableSceneRedraw、undo off、用fn進行addConstraint所導致。
2012年4月18日 星期三
MAXscript : Skin Copy/Paste
-- --選擇已Skin物件執行Copy, 自動記錄bones和存出env, 再選擇要套用Skin的物件執行Paste套回 --需要設定tempDir供存出env檔案用 --by JanusHaung skinBonesArray = #() tempDir = "D:/MaxProject/export/" envFilename = "" rollout skinCopyPaste "Skin Copy Paste" width:185 height:50 ( button btn_copy "Copy" across:2 button btn_paste "Paste" label lbl1 "" on btn_copy pressed do ( -- 選擇已skin好的物件並執行 if $.modifiers[#Skin] != undefined do ( skinBonesArray = for i in 1 to skinops.getnumberbones $.skin collect skinops.getbonename $.skin i 0 envFilename = tempDir + $.name + ".env" skinOps.saveEnvelope $.skin envFilename lbl1.caption = "Skin copied." ) ) on btn_paste pressed do ( max modify mode if skinBonesArray.count > 0 do ( -- 選擇尚未skin好的模型執行 if $.modifiers[#Skin] == undefined do addmodifier $ (Skin()) for i in 1 to skinBonesArray.count do skinOps.addbone $.skin ( getNodeByName skinBonesArray[i] ) 0 --先執行completeRedraw()才可成功LoadEnvlope completeRedraw() skinOps.LoadEnvelope $.skin envFilename lbl1.caption = "Skin pasted." ) ) ) createDialog skinCopyPaste
[MAXscript] 將所選擇物件轉為物件陣列形式
可將選擇中的物件名稱以#( $node1, $node2, ... )物件陣列的方式印出來
-- 將所選擇的物件名稱輸出成物件陣列形式 by Janus Huang
-- 紀錄下所有物件的名稱
tmp = for o in selection collect o.name
out = "#( "
--把物件名稱去除掉空白格
for i in 1 to tmp.count where matchpattern tmp[i] pattern:"* *" do (
strNew = ""
--留下space外的字串成array
strTmp = filterString tmp[i] " "
--將array結合成string後重新丟回
for s in strTmp do strNew += s
tmp[i] = strNew
)
for i in 1 to tmp.count do (
--把物件名稱去除掉()
if matchpattern tmp[i] pattern:"*(*)*" then
(
strNew = "getNodeByName \""+tmp[i]+"\""
tmp[i] = strNew
) else (
tmp[i]="$"+tmp[i]
)
if i != tmp.count then out += tmp[i]+", " else out += tmp[i]+" )"
)
print out
2012年3月23日 星期五
MAXscript : 圖檔轉檔
在MAXscript Reference 9.0中有寫並不支援輸出DDS檔
sourceImage = openBitMap "filename_string" --定義來源檔案(.psd ..)
outputImage = bitmap sourceImage.width sourceImage.height --定義輸出檔案
copy sourceImage outputImage --拷貝bitmap
outputImage.fileName = "filename_string" --定義檔案路徑
save outputImage --儲存
close sourceImage
DDS : BitmapIOClass不過先用Max來Render輸出1張dds後,就能夠成功的用ms來輸出dds檔案了
instances not creatable by MAXScript, no interfaces or properties exposed
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檔案可下載:
簡而言之:
- Scenes that take a long time to open or save and take up a lot of memory
- Cleanup of a 3d max file. HELP!!!!! - pietro cunin
Cleanup of a 3d max file. HELP!!!!! - marcwe - max file grew too big pls HELP - Alex Ayuso
簡而言之:
- 以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執行 - 在只需要Objects及Hierarchy的狀況下,只需要File>New>Keep Objects and Hierarchy,就可存出乾淨的檔案
- 也有可能只是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
透過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
.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分享了這個方法,另外在這邊也有相關討論。
這個callback是case sensitive
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
訂閱:
文章 (Atom)