1/1

Metasequoia PythonのバージョンはPython2.2

だから、python2.2のインタラクティブモードで

>>> a="hacker"
>>> a
'hacker'
>>> "a" in a
1
>>> "hac" in a
Traceback (most recent call last):
File "", line 1, in ?
TypeError: 'in ' requires character as left operand

とエラーが出てしまう。
日ごろ、python2.5を使っていて、

>>> a="hacker"
>>> "c" in a
True
>>> "hac" in a
True

が当たり前と思って、メタセコイアpythonで組もうとしたら、
TypeError: 'in ' requires character as left operand
のエラーでした。
検索したら、ヒントがありました。ありがとうございます。
以下、python2.2のインタラクティブモードで

>>> class S(str):
... def __contains__(self,x):
... for i in range(len(self)):
... if self.startswith(x,i): return 1
...
>>> s=S("hacker")
>>> "ack" in s
1
>>> "tac" in s
0

助かります。ベスト尽くします。
ありがとうございます。
  • -
  • -

直線の始点、終点の座標を求める

Metasequoia Pythonで
メタセコイアの「面の作成」で「辺」をクリックし、一本の直線を描画する。オブジェクトパネルで、オブジェクト名をobj1_lightとする。
この直線がRenderManのライトの向きにしようかと検討中。
それで、始点と終点の座標を出力するスクリプトを作ってみた。
ありがとうございます。
助かります。
以下はMetasequoia Pythonスクリプトです。
オブジェクト名にlightを含む文字列であること。頂点は2個以内であること。で、座標を出力します。

#face_index22.py
class S(str):
def __contains__(self,x):
for i in range(len(self)):
if self.startswith(x,i): return 1



doc=MQSystem.getDocument()
out=MQSystem.println

#obj=doc.object[doc.currentObjectIndex]
#out(str(obj.numFace))
#out(str(obj.numVertex))
#out(str(obj.name))

num = doc.numObject

for n in range(0,num):
obj = doc.object[n]
out(str(obj.name))
if obj is None: continue

for face in obj.face:
for aIndex in face.index:
out(str(aIndex))

if obj.numVertex>2: continue
if "light" in S(str(obj.name)):
for k in range(0,obj.numVertex):
out(str(obj.vertex[k].pos.x)+","+str(obj.vertex[k].pos.y)+","+str(obj.vertex[k].pos.z))

  • -
  • -

メタセコイアからRIB出力 ライト設定

メタセコイアからRenderManのRIB形式へ、metasequoia pythonを使って出力検証。
今回は、直線を引っ張り、distantlightライトの位置として出力するようにpythonスクリプトを書き換えた。ライト位置、RIBではZ位置に-1をかけて出力している。
後、オブジェクト名に"no_"がついたら頂点法線は計算しないようにしてみた。実験君です。
今後は、オブジェクト名にspotlightと入れたら、スポットライトを出すように追加できるように工夫していきたいところです。
ありがとうございます。
out_scene2.jpg

##Renderman RIB-Structure 1.0

MakeTexture "00tex_master.tif" "00tex_master.tdl" "periodic" "periodic" "gaussian" 1 1


Display "out_scene2.tif" "file" "rgba"
Format 640 480 1
PixelSamples 4 4
PixelFilter "catmull-rom" 3 3
ShadingRate 1

Imager "background" "background" [0.2 0.4 0.6]

Sides 1
Orientation "rh"
Projection "perspective" "fov" [15.7411862756]
ConcatTransform [
0.989678789967 -0.0703824392657 -0.124828702357 0
0 0.87107923842 -0.49114250518 0
-0.143303498523 -0.486073320228 -0.862088646645 0
120.757968634 -292.714072303 3702.46738861 1
]
Scale 1 1 -1
WorldBegin
Attribute "visibility" "trace" [1]
Attribute "visibility" "transmission" ["Os"]
Attribute "visibility" "transmission" "opaque"
Attribute "light" "shadows" "on"
LightSource "distantlight" 1
"from" [714.900024414 688.590026855 -50.0]
"to" [0.0 286.878967285 -0.0]
"lightcolor" [0.800 0.800 0.800]
LightSource "ambientlight" 2
"lightcolor" [0.300 0.300 0.300]
Color 1.0 1.0 1.0
Surface "supertexmap" "string Csmapname" "00tex_master.tdl"
AttributeBegin
Scale 1 1 -1
Declare "st" "facevarying float[2]"
Attribute "identifier" "name" ["no_obj1"]
PointsPolygons
[ 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 以下省略・・・・
  • -
  • -

1/1