Rendering学習日記

日々3DCGの世界は進歩しているけど、勉強して理解したことをまとめていきたい。RenderMan互換レンダラーやグローバル・イルミネーション。いろんなことに好奇心を持ち面白くなってくる。目指せShader書き!!

TypeError: 'module' object is not callable

別ディレクトリのクラス呼び出しのエラー。
TypeError: 'module' object is not callable

##############

import sys
sys.path.append("C:\prman_sample\lighting\PythonClasses")

from Camera import Camera
from vector import Vector

import prman
・・・・

CameraクラスがあるPythonClassesまでパスを追加しておき、

モジュールの名前.対象のクラス

で呼び出す。

Pythonでは、パッケージ=ディレクトリ、モジュール=ファイルと理解。


・・・
import prman
ri = prman.Ri() # create an instance of the RenderMan interface
rendertarget = "helloworld.rib"

cam=Camera(Vector(0,4,-8,1),Vector(0,0,0,1),Vector(0,1,0,0))
cam.fov=45

ri.Begin(ri.RENDER) # set rendertarget to ri.RENDER to render pixels
ri.Imager ("background", {"color color":(.2, .4, .6)})
ri.Display("teapot3.png", "framebuffer", "rgb")

cam.Format(ri)
#ri.Format(512,480,1)
#ri.Projection(ri.PERSPECTIVE, {ri.FOV: 45}) # standard Ri tokens are available
ri.ShadingRate(0.25)
#ri.Translate(0,0,10)
#ri.Rotate(-33.69, 1.00, 0.00, 0.00)
#ri.Translate(0.00, -4.00, 8)
ri.WorldBegin()

cam.Place(ri)
ri.Scale(-1,1,1)
・・・・


結果が違うのでri.Scale(-1,1,1)を加えた。
Camera(eye, look, up)となっている。

cgkitで確認してみた。

C:\Python26>python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:13:38) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from cgkit.all import *
>>> V=mat4(1).lookAt(pos=(4,0.2,4),target=(0,0,0),up=(0,1,0))
>>> V
[-0.707107, -0.0249844, -0.706665, 4]
[0, 0.999376, -0.0353333, 0.2]
[0.707107, -0.0249844, -0.706665, 4]
[0, 0, 0, 1]
>>> vt=(V.inverse()).transpose()
>>> vt
[-0.707107, -0.0249844, -0.706665, -0]
[-0, 0.999376, -0.0353333, 0]
[0.707107, -0.0249844, -0.706665, -0]
[-0, 0, 5.66039, 1]
>>>
RenderMan | - | -

import prmanでのsearchpath

ri.Begin()の後にOptionのsearchpathは書かないとだめ。
てっきり前に書くもんだと思い込み。

A00002 {WARNING} Unknown unqualified RiOption context: searchpath.

以下は、参考スクリプト

# set PYTHONPATH=C:\Python25;C:\Python25\Scripts;%RMANTREE%\bin # this is where prman.py lives
import prman
ri = prman.Ri() # create an instance of the RenderMan interface
rendertarget = "helloworld.rib"
ri.Option("rib", {"string asciistyle": "indented"})

ri.Begin(ri.RENDER) # set rendertarget to ri.RENDER to render pixels
ri.Option("ribparse", {"string varsubst":["$"]})
ri.Option("searchpath", {"string shader": "RC:&"})

#ri.Imager ("background", {"color color":(.2, .4, .6)})
ri.Display("teapot4.png", "framebuffer", "rgb")
ri.Format(512,480,1)
ri.Projection(ri.PERSPECTIVE, {ri.FOV: 45}) # standard Ri tokens are available
ri.ShadingRate(0.25)
#ri.Translate(0,0,10)
ri.Rotate(-33.69, 1.00, 0.00, 0.00)
ri.Translate(0.00, -4.00, 8)
ri.WorldBegin()

ri.LightSource("shadowdistant",{ri.HANDLEID:"2", "from": [ -10, 10, -10], "to": [ 0, 0, 0], "intensity":[2.0], "string shadowname": ["raytrace"]})
#ri.LightSource( "pointlight",{ri.HANDLEID:"1","from": [-10, 10, -10], "intensity" :[300]})
#ri.LightSource( "pointlight",{ri.HANDLEID:"2","from": [10, 10, -10], "intensity" :[300]})
#ri.LightSource( "pointlight",{ri.HANDLEID:"3","from": [-10, -10, -10], "intensity" :[300]})

ri.AttributeBegin()
size=20.0
ri.Attribute( "visibility", {"trace": [1]})
ri.Attribute( "visibility", {"int transmission": [0]})
ri.TransformBegin()
ri.Color(( .2773, .2855, .6679))
ri.Surface( "DPCloudPlane")
ri.Sphere(size, -size, size,360)
ri.TransformEnd()
ri.AttributeEnd()

ri.AttributeBegin()
ri.Attribute( "visibility", {"trace": [0]})
ri.Attribute( "visibility", {"int transmission": [1]})
ri.TransformBegin()
ri.Color(( 0.9, 0.9, 0.9))
ri.Surface( "shinymetal", {"string texturename": ["raytrace"]})
#ri.Translate( 1, 0, 0)
ri.Translate( -1, -2, 0)
ri.Rotate( -90, 1, 0, 0)
ri.Geometry("teapot")
ri.TransformEnd()
ri.AttributeEnd()

ri.AttributeBegin()
size=1.0
ri.Attribute( "visibility", {"trace": [1]})
ri.Attribute( "visibility", {"int transmission": [1]})
ri.TransformBegin()
ri.Color(( 1, 0.1, 0))
ri.Surface( "plastic")
ri.Translate( 1, -1, -3)
ri.Rotate( -90, 1, 0, 0)
ri.Sphere(size, -size, size,360)
ri.TransformEnd()
ri.AttributeEnd()


ri.AttributeBegin()
ri.Attribute( "visibility", {"trace": [1]})
ri.Attribute( "visibility", {"int transmission": [1]})
ri.TransformBegin()
face=[-5,-2,-5, 5,-2,-5,-5,-2,5, 5,-2,5]
ri.Color(( 0.99, 0.99, 0.99))
#ri.Surface( "checker", {"float Kd":[0.5],"float Ka":[0.1], "float frequency":[6.0], "color blackcolor":[0.2,0.8,0.5]})
ri.Surface( "blue_marble")
ri.Patch("bilinear",{'P':face})
ri.TransformEnd()
ri.AttributeEnd()

ri.WorldEnd()
ri.End()
RenderMan | - | -
1/1