<?xml version="1.0" encoding="utf-8"?>
        <?xml-stylesheet type="text/css" href="http://studentpages.scad.edu/~yimchu20/weblog/styles/feed.css"?>
<rss version="2.0"
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:admin="http://webns.net/mvcb/"
>
<channel>
<title>Wesly is dreaming.</title>
<link>http://studentpages.scad.edu/~yimchu20/weblog</link>
<description>news, diary, journal, whatever, 個人外部記憶，怎樣都行....</description>
<dc:language>en-us</dc:language>
<dc:creator>Wesly Chu</dc:creator>
<dc:date>2008-11-22T00:44:05-06:00</dc:date>
<admin:generatorAgent rdf:resource="http://nanoblogger.sourceforge.net" />
<item>
<link>http://studentpages.scad.edu/~yimchu20/weblog/archives/2008/11/22/index.html#e2008-11-22T00_44_00.txt</link>
<title>使用wxGlCanvas的心得</title>
<dc:date>2008-11-22T00:44:00-06:00</dc:date>
<dc:creator>Wesly Chu</dc:creator>
<dc:subject>3D CG</dc:subject>
<description><![CDATA[<p>
wxPython中的wxGLCanvas可以用OpenGL來顯示3D影像或是利用硬體加速影像的顯示。預設是使用single buffer，要使用double buffer需要在參數裡指定。
<pre>
attribList = (glcanvas.WX_GL_RGBA, # RGBA
    glcanvas.WX_GL_DOUBLEBUFFER, # Double Buffered
    glcanvas.WX_GL_STENCIL_SIZE,1) # 24 bit
glcanvas.GLCanvas.__init__(self, -1,attribList=attribList)
</pre>
</p>
<p>
OpenGL中的glDrawPixels()是用來將某矩陣中的資訊，畫到frame buffer的方法。這個矩陣中的資料通常是一個影像圖片，以RGBRGBRGB...的形式存放。當這個影像的寬度不是4的倍數時，螢幕上畫出來的圖片會有奇怪的偏移現象。這可能是由於glDrawPixels要求每行像素是4 Bytes的倍數。如果在影像寬度不是4的倍數的狀況時，glDrawPixels會在一行的最後跳過最後一個像素，而造成每行的像素沒有對齊的情形。簡單的修正方法如下(以python為例)。
<pre>
image = wx.Image()
w = image.GetWidth()
h = image.GetHeight()
if w % 4 == 1:
    w = w -1
elif w % 4 == 2:
    w = w -2
elif w % 4 == 3:
    w = w -3
glDrawPixels(w, h, GL_RGB, GL_UNSIGNED_BYTE, image.GatData())
</pre>
</p>
<p>
參考資料:<br>
<a href="http://wiki.wxpython.org/GLCanvas">http://wiki.wxpython.org/GLCanvas</a><br>
<a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=297351">http://www.gamedev.net/community/forums/topic.asp?topic_id=297351</a>
</p>]]></description>
</item>
<item>
<link>http://studentpages.scad.edu/~yimchu20/weblog/archives/2008/11/03/index.html#e2008-11-03T21_59_08.txt</link>
<title>Mental Ray Shade習作</title>
<dc:date>2008-11-03T21:59:08-06:00</dc:date>
<dc:creator>Wesly Chu</dc:creator>
<dc:subject>3D CG</dc:subject>
<description><![CDATA[<p>
由於個人目前實在沒有用Renderman的機會，於是我想利用閒暇時間，將以前寫過的Renderman shader改寫為Mental Ray shader。目前做完兩個，還有一堆需要改寫並加強。希望能把當初畢業製作用的所有shader都改為Mental Ray版本，這樣要重新算圖也比較有可能。
</p>
<p>
<a
href="http://studentpages.scad.edu/~yimchu20/prman/st_coloration/st_coloration_mr.html">ST Coloration shader</a>
<br>
<a href="http://studentpages.scad.edu/~yimchu20/prman/image_process/image_filter.html">Image filter shader</a>
</p>]]></description>
</item>
<item>
<link>http://studentpages.scad.edu/~yimchu20/weblog/archives/2008/10/18/index.html#e2008-10-18T01_55_20.txt</link>
<title>用來編譯Maya pluign 和Mentalray shader的SCons script</title>
<dc:date>2008-10-18T01:55:20-06:00</dc:date>
<dc:creator>Wesly Chu</dc:creator>
<dc:subject>Linux Script Note</dc:subject>
<description><![CDATA[<p>
上週末利用<a href="http://www.fundza.com">Cutter</a>練習寫Mentalray shader時，發現實在很難用預設的功能來編譯shader。於是就嘗試自己寫<a href="http://www.scons.org/">Scons</a>用的script來輔助編譯，順便也寫了一個編Maya plugin用的。其實用Eclipse寫plugin或shader時就可以直接用它C++專案的Makefile方式下去編譯，寫這兩個script這純粹是練功兼拿到沒有Eclipse 3.3的環境下用。
</p>
<p>
簡單的使用步驟：
<li>先確認系統有安裝Python和Scons
<li>修改必要的欄位以符合要編譯的東西名稱，如pluginName或shaderName的參數要改
<li>修改安裝的目錄欄位以符合最終要安裝的目錄，這是指installDir
<li>把改好的script改名為SConstruct並和所有的源碼放在同一個目錄下
<li>執行命令scons或scons install(這會在編完後同時安裝)
</p>
<p>
還有要注意的是，Sconscript.mentalray可以讓你在Win32的環境下編譯，但是預設是使用VC9。同時，它也需要裝Microsoft Platform SDK。預設都是搭配Maya 8.5 devkit。
</p>
<a href="http://studentpages.scad.edu/~yimchu20/prman/Sconscript.maya.html">Sconscript.maya<a>
<br>
<a href="http://studentpages.scad.edu/~yimchu20/prman/Sconscript.mentalray.html">Sconscript.mentalray<a>]]></description>
</item>
<item>
<link>http://studentpages.scad.edu/~yimchu20/weblog/archives/2008/09/18/index.html#e2008-09-18T03_14_49.txt</link>
<title>改變fluxbox下移動視窗的預設熱鍵 </title>
<dc:date>2008-09-18T03:14:49-06:00</dc:date>
<dc:creator>Wesly Chu</dc:creator>
<dc:subject>Linux Note</dc:subject>
<description><![CDATA[<p>
使用Maya時，通常使用Alt鍵搭配滑鼠以改變攝影機視角。但是這個組合技會和X window預設的移動視窗功能相衝。一般使用Gnome或KDE者，可方便的利用圖形介面去修改預設熱鍵。使用fluxbox則可修改使用者目錄下的設定檔：
<pre>
vi ~/.fluxbox/init
</pre>
將其中的
<pre>
session.modKey: Mod1
</pre>
修改為
<pre>
session.modKey: Mod4
</pre>
即可改由視窗鍵取代Alt鍵。
</p>]]></description>
</item>
<item>
<link>http://studentpages.scad.edu/~yimchu20/weblog/archives/2008/08/22/index.html#e2008-08-22T13_51_35.txt</link>
<title>如何使用gnome-mount </title>
<dc:date>2008-08-22T13:51:35-06:00</dc:date>
<dc:creator>Wesly Chu</dc:creator>
<dc:subject>Linux Note</dc:subject>
<description><![CDATA[<p>
在比較新的Linux發行版裡，Gnome桌面環境下掛載硬碟磁區的方式和以往稍有不同。傳統的mount指令還是可以使用，不過一般桌面環境下可以用gnome-mount使用HAL代替。掛載可使用以下例子：
<pre>
gnome-mount -d /dev/sda1 -m DISK1
</pre>
卸載則是：
<pre>
gnome-mount -u -d /dev/sda1
</pre>
在Fedora Core
8預設的環境下，這樣作會把/dev/sda1掛載到/media/DISK1。也不用切換成root以使用mount。
</p>]]></description>
</item>
<item>
<link>http://studentpages.scad.edu/~yimchu20/weblog/archives/2008/07/23/index.html#e2008-07-23T19_57_24.txt</link>
<title>使用DrQueue 0.64.3搭配Maya8.5與Linux架設Render Farm </title>
<dc:date>2008-07-23T19:57:24-06:00</dc:date>
<dc:creator>Wesly Chu</dc:creator>
<dc:subject>Linux Note</dc:subject>
<description><![CDATA[<p>
利用DrQueue架設Render Farm時，可搭配各種網路磁碟服務（NFS or
Samba）來達成。我利用Fedora Core
8內裝好的NFS來進行架設。當作檔案共享的主機設定好exports檔之外，要注意防火牆與目錄基本權限的設定。務必確定連線順暢。DrQueue的安裝只要按照安裝文件一步步進行即可。使用Fedore
Core可以很方便的裝好GCC，Python與Scons等套件以進行編譯。DrQueue本身具備跨平台的特性，利用Cygwin也可在Windows的環境下編譯。不過，安裝時有很多地方得自行手動執行，並不如Linux環境方便。
<p>
</p>
DrQueue預設的設定檔位置是先搜尋以下目錄
<pre>
/etc/drqueue
/usr/local/drqueue/etc
</pre>
其中的.conf檔案多半是告訴相關程式如何找分享的logs,tmp,db這些子目錄。重點是，logs和tmp這兩個子目錄必須讓所有的master和slave機器都能讀取寫入，tmp子目錄也必須讓每台slave機器能執行其中所暫存的script。因此在利用NFS進行分享檔案時，就要注意exports的寫法。此外，logs子目錄是用來收集所有機器運算後產生log檔，因此也必須讓所有Render
Farm裡的機器有寫入的權限。
</p>
<p>
在搭配Maya8.5使用DrQueue時，預設的樣板script會去呼叫
<pre>
/usr/aw/maya/bin/Render
</pre>
這個指令。不過因為Maya的預設安裝路徑已改為
<pre>
/usr/autodesk/maya8.5
</pre>
所以簡單的解法便是
<pre>
ln -s /usr/aw/maya /usr/autodesk/maya8.5
</pre>
</p>
<p>
當然，為了放置要執行算圖的檔案和專案，還要有一個目錄是開放給所有機器都能讀寫的。這個目錄在每個slave機器上用的掛載點必須相同。一般使用者要算圖時，只要將專案檔放置在這個目錄下，再利用drqman即可方便的使用。
</p>]]></description>
</item>
<item>
<link>http://studentpages.scad.edu/~yimchu20/weblog/archives/2008/07/15/index.html#e2008-07-15T01_10_14.txt</link>
<title>在Maya一啟動時立刻執行MEL指令的方法 </title>
<dc:date>2008-07-15T01:10:14-06:00</dc:date>
<dc:creator>Wesly Chu</dc:creator>
<dc:subject>MEL script</dc:subject>
<description><![CDATA[<p>
Maya在圖形模式啟動時會去執行任何寫在userSetup.mel裡的MEL指令。這個userSetup.mel通常是藉由在Maya.env裡設定MAYA_SCRIPT_PATH來搜尋。如果想重載預設的MEL指令函式，一樣可以在這邊寫入或是利用source 的方式達成。例如要使用自訂的mentalrayCustomNodeClass.mel時，即可在userSetup.mel寫入：
<pre>
source "/path/to/your/mentalrayCustomNodeClass.mel"
</pre>
如此每次啟動Maya便會自動載入修改過的版本。
</p>]]></description>
</item>
<item>
<link>http://studentpages.scad.edu/~yimchu20/weblog/archives/2008/07/15/index.html#e2008-07-15T00_45_16.txt</link>
<title>如何在Maya增加自訂mentalray shader時顯示樣本圖片</title>
<dc:date>2008-07-15T00:45:16-06:00</dc:date>
<dc:creator>Wesly Chu</dc:creator>
<dc:subject>MEL script</dc:subject>
<description><![CDATA[<p>
依據<a href="file:///usr/autodesk/maya/docs/Maya8.5/en_US/Rendering/Swatch_rendering_in_mental_ray_for_Maya.html">Swatch rendering in mental ray for Maya</a>，所需修改的檔案為
<pre>
/usr/autodesk/maya8.5-x64/scripts/others/mentalrayCustomNodeClass.mel
</pre>
將自訂的shader名稱，加入node type的判斷，並選擇使用file
swatch或者是interactive swatch即可。這個樣本圖示會在hypershade和attribute
editor中顯示。
</p>
<p>
使用自訂shader時，其他相關檔案還包括mentalrayCustomNodeID.mel等等。
</p>]]></description>
</item>
<item>
<link>http://studentpages.scad.edu/~yimchu20/weblog/archives/2008/04/13/index.html#e2008-04-13T11_23_04.txt</link>
<title>使用Eclipse開發Maya plugin時關於除錯的一些設定</title>
<dc:date>2008-04-13T11:23:04-06:00</dc:date>
<dc:creator>Wesly Chu</dc:creator>
<dc:subject>3D CG</dc:subject>
<description><![CDATA[<p>
在試著找過文件並且請教朋友之後，終於找到應該設定Degugger的參數的種類。首先，由於我們要進行除錯的Maya plugin是個shared library，這其實表示我們要除錯的應用程式是Maya本身。在使用Eclipse的CDT時，新增一個給Maya的Debug設定，並且是使用C/C++ Local Application的預設設定來修改。以下條列應該修改的設定和環境參數，其餘設定可用預設值。
<li>Main的部份，將C/C++
Application的部份由預設的.so(就是你的plugin)
<pre>
Debug/yourplugin.so
</pre>
改為maya.bin的位置。例如：
<pre>
/usr/autodesk/maya8.5-x64/bin/maya.bin
</pre>
</li>
<li>
在Environment的部份，加入以下Environment variables及其對應的值：
<pre>
LD_LIBRARY_PATH                 /usr/autodesk/maya8.5-x64/lib
MAYA_DEBUG_NO_SIGNAL_HANDLERS   1
MAYA_LOCATION                   /usr/autodesk/maya8.5-x64
</pre>
</li>
</p>
<p>
以上是必要的基本設定，其他部份的設定可參考自己需求修改。<br>參考資料
<a href="file:///usr/autodesk/maya/docs/Maya8.5/en_US/DeveloperResources/Using_a_debugger_to_debug_your_plugins.html">Using a debugger to debug your plug-ins</a>
</p>]]></description>
</item>
<item>
<link>http://studentpages.scad.edu/~yimchu20/weblog/archives/2008/04/09/index.html#e2008-04-09T01_14_21.txt</link>
<title>使用Eclipse開發Maya plugin的一些設定</title>
<dc:date>2008-04-09T01:14:21-06:00</dc:date>
<dc:creator>Wesly Chu</dc:creator>
<dc:subject>3D CG</dc:subject>
<description><![CDATA[<p>
在Linux的環境下，藉由Eclipe也可以直接設定程式專案來開發Maya
plug-in。對程式專案所需要的修改的設定和進行OpenGL專案的部份也很類似，但是稍微複雜些。這是因為在Compiler和Linker的部份參數較多。以下條列我目前發現需要修改的部份。需要注意的是，這只是針對單一plugin的撰寫，並不是建立一個build system。
</p>
<p>
首先當然要新增一個C++程式專案，並選擇專案型態為Shared
Library。在這個新專案中，修改其Project Properties中關於C/C++ Build的Settings部份。主要要增加的有：
<br>
C/C++ Build -> Settings -> GCC C++ Compiler -> Preprocessor:
在Defined symbols(-D)內加入_BOOL，LINUX, REQUIRE_IOSTREAM
<br>
C/C++ Build -> Settings -> GCC C++ Compiler -> Directories:
在Include paths (-I) 內加入Maya include
path（如：/usr/autodesk/maya8.5-x64/include）
<br>
C/C++ Build -> Settings -> GCC C++ Compiler -> Optimization:
在Other optimization flags欄位可加入"-pthread"或其他旗標
<br>
C/C++ Build -> Settings -> GCC C++ Compiler -> Miscellaneous:
在Other flags欄位，要加入"-fPIC"及"-fno-gnu-keywords"
<br>
以上這些是針對Compiler部份。以下則是針對Linker的部份<br>
<br>
C/C++ Build -> Settings -> GCC C++ Linker -> Libraries:
在Libraries(-l)這裡需要增加的項目其實是可多可少。全部都寫上也無不可。目前發現需要加入的有
<pre>
OpenMaya
OpenMayaRender
OpenMayaAnim
OpenMayaUI
OpenMayaFX
GL
GLU
glut
</pre>
在Library serach path(-L)的部份一樣需要加入Maya library
path（如：/usr/autodesk/maya8.5-x64/lib）
<br>
C/C++ Build -> Settings -> GCC C++ Linker -> Miscellaneous:
加入"-D_BOOL -DLINUX -DREQUIRE_IOSTREAM"
</p>
<p>
值得注意的是Debug的部份目前還沒找到好的作法。在Maya官方文件當中所提及的只有利用
<pre>
maya -d ddd
</pre>
的方式來使用ddd作為除錯的工具。
</p>
<p>
參考資料<a href="file:///usr/autodesk/maya/docs/Maya8.5/en_US/DeveloperResources/Writing_a_simple_plugin.html">Writing a Plugin</a>
</p>]]></description>
</item>
</channel>
</rss>
