<< Installed python cgkit on Mx Linux21.3 using python2.7 戻る

3Delight nsi viewTransformation

■以下はMayaのPerspのチャンネルボックスのデフォルト位置を例として
Translate X: 28
Translate Y: 21
Translate Z: 28
Rotate X: -27.938
Rotate Y: 45
Rotate Z: 0
Scale X: 1
Scale Y: 1
Scale Z: 1

3Delight nsiでは、
SetAttributeAtTime "|persp" -0.20000000000000001
"transformationmatrix" "doublematrix" 1 [ 0.70710678118654791 0 -0.70710678118654713 0 -0.33129457822453973 0.88345220859877216 -0.33129457822454006 0 0.62469504755442384 0.46852128566581852 0.6246950475544244 0 28 21 28 1 ]

これをpython cgkitで計算してみました。
python cgkitで求めてみます。インタラクティブモードを起動
$ python
Python 2.7.18 (default, Jul 14 2021, 08:11:37)
[GCC 10.2.1 20210110] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from cgkit.all import *
移動位置を入力
>>> tr=mat4(1).translation(vec3(28,21,28))
>>> import math
x軸回転を入力
>>> rx=mat4(1).rotate(-27.938*math.pi/180,vec3(1,0,0))
>>> rx
[1, 0, 0, 0]
[0, 0.883455, 0.468516, 0]
[0, -0.468516, 0.883455, 0]
[0, 0, 0, 1]
y軸回転を入力
>>> ry=mat4(1).rotate(45*math.pi/180,vec3(0,1,0))
>>> ry
[0.707107, 0, 0.707107, 0]
[0, 1, 0, 0]
[-0.707107, 0, 0.707107, 0]
[0, 0, 0, 1]
移動、x軸回転、y軸回転の順で積を求める
>>> v=tr*ry*rx
>>> v
[-0.707107, -0.331291, 0.624697, 28]
[0, 0.883455, 0.468516, 21]
[-0.707107, 0.331291, -0.624697, 28]
[0, 0, 0, 1]
転置行列を求める。
>>> v.transpose()
[0.707107, 0, -0.707107, 0]
[-0.331291, 0.883455, -0.331291, 0]
[0.624697, 0.468516, 0.624697, 0]
[28, 21, 28, 1]
できあがり!


■posとtargetから求めるとしたら、RenderManでのplacecam.cをもとに計算してみます。
----------------------------------------
python placecam.py 3 3 3 0 0 0
position: 3.00, 3.00, 3.00
aim: 0.00, 0.00, 0.00
coneangle: 0.0000
roll: 0.00

RIBでのx軸、y軸の角度がわかります。
Rotate -35.26 1.00 0.00 0.00
Rotate 135.00 0.00 1.00 0.00
Translate -3.00 -3.00 -3.00

Translateの行列は、TX,TX,-TZで求めます。python cgkitで計算します。
インタラクティブモードを起動
>>> from cgkit.all import *
>>> tr=mat4(1).translation(vec3(3,3,-3))
>>> import math
>>> rx=mat4(1).rotate(-35*math.pi/180,vec3(1,0,0))
>>> rx
[1, 0, 0, 0]
[0, 0.819152, 0.573576, 0]
[0, -0.573576, 0.819152, 0]
[0, 0, 0, 1]
>>> ry=mat4(1).rotate(135*math.pi/180,vec3(0,1,0))
>>> ry
[-0.707107, 0, 0.707107, 0]
[0, 1, 0, 0]
[-0.707107, 0, -0.707107, 0]
[0, 0, 0, 1]
>>> v=tr*ry*rx
>>> v
[-0.707107, -0.40558, 0.579228, 3]
[0, 0.819152, 0.573576, 3]
[-0.707107, 0.40558, -0.579228, 3]
[0, 0, 0, 1]
>>> v.transpose()
[-0.707107, 0, -0.707107, 0]
[-0.40558, 0.819152, 0.40558, 0]
[0.579228, 0.573576, -0.579228, 0]
[3, 3, 3, 1]

>>> s2=mat4(1).scaling(vec3(-1,1,1))
>>> s3=mat4(1).scaling(vec3(1,1,-1))
>>> s2*v.transpose()*s3
[0.707107, 0, -0.707107, 0]
[-0.40558, 0.819152, -0.40558, 0]
[0.579228, 0.573576, 0.579228, 0]
[3, 3, 3, 1]
>>>
できあがり!
[0.707107 0 -0.707107 0
-0.40558 0.819152 -0.40558 0
0.579228 0.573576 0.579228 0
3 3 3 1]


■視野変換をする。3Delight nsiでは、
-----------------------------------------------------------------------
SetAttributeAtTime "|persp" -0.20000000000000001
"transformationmatrix" "doublematrix" 1 [ 0.57928117234268439 -5.5511151231257827e-17 -0.81512779572855032 0 -0.59748736723752183 0.68023036589218888 -0.42461217046824468 0 0.55447467873732514 0.73299839653179255 0.39404464381712034 0 3.2762530755722121 4.6062003801361309 2.8864228342103333 1 ]

MayaのPerspの位置
Translate X: 3.276
Translate Y: 4.606
Translate Z: 2.886
Rotate X: -47.138
Rotate Y: 54.6
Rotate Z: 0
Scale X: 1
Scale Y: 1
Scale Z: 1

python cgkitで求めてみます。
tr=mat4(1).translation(vec3(3.276,4.606,2.886))
rx=mat4(1).rotate(-47.138*math.pi/180,vec3(1,0,0))
ry=mat4(1).rotate(54.6*math.pi/180,vec3(0,1,0))
v=tr*ry*rx
v.transpose()

インタラクティブモードを起動
Python 2.7.18 (default, Jul 14 2021, 08:11:37)
[GCC 10.2.1 20210110] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from cgkit.all import *
>>> import math
>>> tr=mat4(1).translation(vec3(3.276,4.606,2.886))
>>> tr
[1, 0, 0, 3.276]
[0, 1, 0, 4.606]
[0, 0, 1, 2.886]
[0, 0, 0, 1]
>>> rx=mat4(1).rotate(-47.138*math.pi/180,vec3(1,0,0))
>>> rx
[1, 0, 0, 0]
[0, 0.680235, 0.732994, 0]
[0, -0.732994, 0.680235, 0]
[0, 0, 0, 1]
>>> ry=mat4(1).rotate(54.6*math.pi/180,vec3(0,1,0))
>>> ry
[0.579281, 0, 0.815128, 0]
[0, 1, 0, 0]
[-0.815128, 0, 0.579281, 0]
[0, 0, 0, 1]
>>> v=tr*ry*rx
>>> v
[0.579281, -0.597484, 0.554478, 3.276]
[0, 0.680235, 0.732994, 4.606]
[-0.815128, -0.42461, 0.394047, 2.886]
[0, 0, 0, 1]
>>> v.transpose()
[0.579281, 0, -0.815128, 0]
[-0.597484, 0.680235, -0.42461, 0]
[0.554478, 0.732994, 0.394047, 0]
[3.276, 4.606, 2.886, 1]
>>>


■directionalLightを求める
--------------------------------------------------------------
SetAttributeAtTime "|directionalLight1" 0.20000000000000001
"transformationmatrix" "doublematrix" 1 [ 0.70710678118654746 5.5511151231257827e-17 0.70710678118654746 0 0.5 0.70710678118654746 -0.49999999999999994 0 -0.49999999999999994 0.70710678118654746 0.49999999999999989 0 0 0 0 1 ]

Translate X: 0
Translate Y: 0
Translate Z: 0
Rotate X: -45
Rotate Y: -45
Rotate Z: 0
Scale X: 1
Scale Y: 1
Scale Z: 1

>>> rx2=mat4(1).rotate(-45*math.pi/180,vec3(1,0,0))
>>> rx2
[1, 0, 0, 0]
[0, 0.707107, 0.707107, 0]
[0, -0.707107, 0.707107, 0]
[0, 0, 0, 1]
>>> ry2=mat4(1).rotate(-45*math.pi/180,vec3(0,1,0))
>>> ry2
[0.707107, 0, -0.707107, 0]
[0, 1, 0, 0]
[0.707107, 0, 0.707107, 0]
[0, 0, 0, 1]
>>> v2=ry2*rx2
>>> v2
[0.707107, 0.5, -0.5, 0]
[0, 0.707107, 0.707107, 0]
[0.707107, -0.5, 0.5, 0]
[0, 0, 0, 1]
>>>
>>> v2.transpose()
[0.707107, 0, 0.707107, 0]
[0.5, 0.707107, -0.5, 0]
[-0.5, 0.707107, 0.5, 0]
[0, 0, 0, 1]

ren05_dlRenderSettings1_0001.jpg
  • -
  • -

<< Installed python cgkit on Mx Linux21.3 using python2.7 戻る