pymel사용시 모듈을 import하면 위와 같은 debug log가 출력된다.
이를 안보이게하려면
../pymel/pymel.conf 에서
[logger_root]
level=NOTSET -> WARNING 으로 수정
2012년 1월 8일 일요일
2011년 12월 13일 화요일
MScritUtil example - vol.2
oCmdResult = MCommandResult()
MGlobal.executeCommand('currentTime -q', oCmdResult)
scriptUtil = MScriptUtil()
ptr = scriptUtil.asDoublePtr()
oCmdResult.getResult(ptr)
frame = scriptUtil.getDouble(ptr)
executeCommand의 내용에 따라 그 결과 값을 가져오는 방법은 다르지만 이와 같은 방법으로 MScriptUtil을 사용할수 있다.
2011년 12월 12일 월요일
MScritUtil example - vol.1
image = MImage() image.readFromFile( filename ) scriptUtil = MScriptUtil() widthPtr = scriptUtil.asUintPtr() heightPtr = scriptUtil.asUintPtr() scriptUtil.setUint( widthPrt, 0 ) scriptUtil.setUint( heightPtr, 0 ) image.getSize( widthPtr, heightPtr ) ix = scriptUtil.getUint( widthPtr ) iy = scriptUtil.getUint( heightPtr )
Python API 의 한계인가? vol.1
MPxLocatorNode를 만들때 OpenGL에 관한 내용이다.
C style
GLuint txid; glGenTextures(1, &txid);python style의 경우 opengl 라이브러리를 사용
txid = glGenTextures(1)Maya Python API에서는
glRenderer = MHardwareRenderer.theRenderer() glFT = glRenderer.glFunctionTable() txid = glFT.glGenTextures( 1 )위의 경우 // Error: TypeError: MGLFunctionTable_glGenTextures expected 3 arguments, got 2 // 와 같은 에러를 출력한다. 해서 c-style로 수정하면 // Error: TypeError: in method 'MGLFunctionTable_glGenTextures', argument 3 of type 'MGLuint *' // 와 같은 에러를 출력한다. python을 경우 변수타입을 지정할수 없다. 일반적인 경우 MScriptUtil을 이용하여 변수타입을 정해서 포인터로 받는 형태를 취하는데 MGLuint로 변수타입을 정할수는 없다. 이와 같은 에러의 주 원인은 glFunctionTable를 사용하려 함이다. 이를 사용하지 않고 python opengl라이브러리를 바로 사용한다면 이와 같은 에러는 발생하지 않는다.
2011년 12월 6일 화요일
Python Rif Layer - 3
import prman
import sys
class myRif(prman.Rif):
def __init__(self, ri, shadingrate):
prman.Rif.__init__(self, ri)
self.m_shadingrate = int(shadingrate)
def ShadingRate(self, size):
self.m_ri.ShadingRate(self.m_shadingrate)
if len(sys.argv) == 4:
infile = sys.argv[1]
outfile = sys.argv[2]
shadingrate = sys.argv[3]
prman.Init(["-catrib", outfile, "-progress"])
ri = prman.Ri()
rif1 = myRif(ri, shadingrate)
prman.RifInit([rif1])
ri.Option("rib", {"string asciistyle": "indented"})
ri.Begin(ri.RENDER)
prman.ParseFile(infile)
ri.End()
Python Rif Layer - 2
import prman
import sys
class myRif(prman.Rif):
def __init__(self, ri):
prman.Rif.__init__(self, ri)
def Option(self, name, plist):
if name == 'user':
if 'uniform float linearize' in plist:
self.m_ri.Option('user', {'uniform float linearize': 0})
else:
self.m_ri.Option('user', plist)
else:
self.m_ri.Option(name, plist)
if len(sys.argv) == 3:
infile = sys.argv[1]
outfile = sys.argv[2]
prman.Init(["-catrib", outfile, "-progress"])
ri = prman.Ri()
rif1 = myRif(ri)
prman.RifInit([rif1])
ri.Option("rib", {"string asciistyle": "indented"})
ri.Begin(ri.RENDER)
prman.ParseFile(infile)
ri.End()
Python Rif Layer - 1
import prman
import sys
class myRif(prman.Rif):
def __init__(self, ri):
prman.Rif.__init__(self, ri)
self.m_nsubdivs = 0
def HierarchicalSubdivisionMesh(self, mask, nverts, verts, tags, nargs, intargs, floatargs, stringargs, plist):
nloops = [1 for i in range(len(nverts))]
self.m_ri.PointsGeneralPolygons(nloops, nverts, verts, plist)
self.m_nsubdivs += 1
if len(sys.argv) == 3:
infile = sys.argv[1]
outfile = sys.argv[2]
prman.Init(["-catrib", outfile, "-progress"])
ri = prman.Ri()
rif1 = myRif(ri)
prman.RifInit([rif1])
ri.Begin(ri.RENDER)
prman.ParseFile(infile)
ri.End()
print ("Converted %d subdivs to polys from %s into %s" % (rif1.m_nsubdivs, infile, outfile))
else:
print ("usage: %s infile.rib outfile.rib" % sys.argv[0])
2011년 8월 18일 목요일
2011년 7월 9일 토요일
varying Normal vs facevarying Normal
varying Normal
: per vertex normal in polymesh
facevarying Normal
: per vertex normal in polyface
varying normal의 경우 normal soften edge, harden edge 를 표현할수 없다.
interpolation에 의해 항상 soft하게 랜더된다.
: per vertex normal in polymesh
facevarying Normal
: per vertex normal in polyface
varying normal의 경우 normal soften edge, harden edge 를 표현할수 없다.
interpolation에 의해 항상 soft하게 랜더된다.
2011년 7월 2일 토요일
Field of View
def fov(filmaperture, focallength):
rad_fov = 2.8 * math.atan((filmaperture*25.4) / (focallength*2.0))
return math.degrees(rad_fov)
filmaperture는 screenwindow를 어떻게 설정하느냐에 따라
horizontal 또는 vertical 값을 사용한다.
2011년 6월 29일 수요일
2011년 6월 20일 월요일
Get Attribute
def nameToNodePlug( attrName, nodeObject ):
depNodeFn = OpenMaya.MFnDependencyNode( nodeObject )
attrObject = depNodeFn.attribute( attrName )
plug = OpenMaya.MPlug( MObject, attrName )
return plug
nodeObject = MObject typeMDagPath를 MObject type으로 변환하려면 MDagPath.node() Function을 사용.
dagPath = OpenMaya.MDagPath()
depFn = OpenMaya.MFnDependencyNode()
dagIt = OpenMaya.MItDag(OpenMaya.MItDag.kBreadthFirst, OpenMaya.MFn.kSurface)
while not dagIt.isDone():
dagIt.getPath(dagPath)
depFn.setObject(dagPath.node())
arrtObject = depFn.attribute('intermediateObject')
plug = OpenMaya.MPlug(dagPath.node(), arrtObject)
print plug.asInt()
dagIt.next()
뭐 대충 으런식으로 object shape attribute을 가져온다.
2011년 6월 19일 일요일
Scripted plug-in initialization
When a scripted plug-in is loaded, Maya searches for an initializePlugin() function in its definition. Within this function, all proxy nodes are registered:
# Initialize the script plug-in
def initializePlugin(mobject):
mplugin = OpenMayaMPx.MFnPlugin(mobject)
try:
mplugin.registerCommand( kPluginCmdName, cmdCreator )
except:
sys.stderr.write( "Failed to register command: %s\n" % kPluginCmdName )
raise
Writing a scripted plug-in
Writing a scripted plug-in requires the definition of some specialized functions within the plug-in. The scripted plug-in must:
Define initializePlugin and uninitializePlugin entry points.
Register and unregister the proxy class within these entry points.
Implement creator and initialize methods (as required) which Maya calls to build the proxy class.
Implement the required functionality of the proxy class. This requires importing the necessary modules.
Writing scripts
The Maya Python API modules contain the classes that are available for Python programming. These classes are separated into different categories and have appropriate naming conventions to signify their association. Classes include:
MFn
Any class with this prefix is a function set used to operate on MObjects of a particular type.
MIt
These classes are iterators and work on MObjects similar to the way a function set does. For example, MItCurveCV is used to operate on an individual NURBS curve CV (there is no MFnNurbsCurveCV), or, iteratively, on all the CVs of a curve.
MPx
Classes with this prefix are all "Proxies", that is, API classes designed for you to derive from and create your own object types.
2011년 6월 14일 화요일
Slim Tcl Expression for color, vector, point
Color and Point Functions
rgb(r,g,b), rgbi(ir,ig,ib)
Allow the specification of color (vector) parameters. r,g,b in the range [0,1], ir,ig,ib in the range [0,255].
hsv(h,s,v), hsvi(ih,is,iv)
Allow the specification of color (vector) parameters in the HSV color space. h,s,v in the range [0,1], ih,is,iv in the range [0,255]. Note that this will immediately convert the hsv values to rgb values.
xyz(x,y,z)
Allow the specification of point (vector) parameters.
2011년 6월 9일 목요일
2011년 5월 24일 화요일
ImageMagick Convert colorspace
ImageMagick Convert 명령어는 정말 강력하다.
hdr, exr, pfm 내가원가는 모든것을 지원한다. 특히 colorspace convert는 환상적이다. ㅋㅋㅋ
ex. linear to sRGB
convert -set colorspace sRGB -colorspace RGB inputfile outputfile
심각한 버그 발견!
colorspace 옵션이 붙으면 float이미지가 integer처럼 clipping된다.
해서... 직접 수식을 입력하여 colorspace를 변환 했다.
[linear to sRGB]
convert -fx "(p <= 0.0031308) ? 12.92*p : pow(1.055*p, 1.0/2.4)-0.055" inputfile outputfile
[srgb to linear]
convert -fx "(p <= 0.04045) ? 1/12.92*p : pow((p+0.055)/1.055, 2.4)" inputfile outputfile
hdr, exr, pfm 내가원가는 모든것을 지원한다. 특히 colorspace convert는 환상적이다. ㅋㅋㅋ
ex. linear to sRGB
convert -set colorspace sRGB -colorspace RGB inputfile outputfile
심각한 버그 발견!
colorspace 옵션이 붙으면 float이미지가 integer처럼 clipping된다.
해서... 직접 수식을 입력하여 colorspace를 변환 했다.
[linear to sRGB]
convert -fx "(p <= 0.0031308) ? 12.92*p : pow(1.055*p, 1.0/2.4)-0.055" inputfile outputfile
[srgb to linear]
convert -fx "(p <= 0.04045) ? 1/12.92*p : pow((p+0.055)/1.055, 2.4)" inputfile outputfile
2011년 3월 6일 일요일
Slim.ini 설정팁 1
slim.ini파일에서
RMS_SCRIPT_PATHS를 환경변수로 가져올때 OS에 따라 설정이 다르다.
# 예제
set getenvpath [GetEnv RMS_SCRIPT_PATHS]
if {$pf(platform) == "windows"} {
set extpath [string map {"\\" "/"} $getenvpath]
} else {
set extpath $getenvpath
}
RMS_SCRIPT_PATHS를 환경변수로 가져올때 OS에 따라 설정이 다르다.
# 예제
set getenvpath [GetEnv RMS_SCRIPT_PATHS]
if {$pf(platform) == "windows"} {
set extpath [string map {"\\" "/"} $getenvpath]
} else {
set extpath $getenvpath
}
피드 구독하기:
글 (Atom)
