Hi all,
I am trying to measure an object's delta x and delta y values relative to my camera's coordsys but am getting incorrect values for both obj.max.x and obj.min.x
In this little script I am assigning the camera's (camera001's) transform.rotationpart matrix to a variable named c_rot (stands for camera rotation).
I then try measuring the obj.max.x and min.x values in this coordsys.
the delta_x value should be 100 as the box's width, height and length are all 100.
I get the following output from the listener after running the script:
"
C_rot = (matrix3 [0.579717,-0.814818,0] [0.515249,0.366583,0.774684] [-0.631226,-0.449097,0.632349] [0,0,0])
max_x = -16.3928
min_x = 16.3928
delta_x = 32.7856
OK
"
I will be using this for a zoom function in a render script I am working on, should anyone be interested I'd be happy to explain more.
Any help would be greatly appreciated, thank you! :D\
(--start of script scope
if (yesnocancelbox "do you want to reset the scene? \n after reset a box and cam will be created and box size \n (in cam coordsys) will be measured" == #yes) do (resetmaxfile #noprompt )
--declaring initial variables
local c_rot =0, max_x=0, min_x=0
--Create a Targetcamera
-- (I copied the orientation/position from the target cam in my scene)
tcam = targetcamera()
tcam.transform = (matrix3 [0.579717,-0.814818,0] [0.515249,0.366583,0.774684] [-0.631226,-0.449097,0.632349] [0,0,0])
tcam.pos = [ -197.464, -140.085, 197.174 ]
--Assign camera's transform.rotationpart to 'c_rot' variable
c_rot = tcam.transform.rotationpart as matrix3
format "C_rot = % \n" c_rot
--create box (which will be measured by script)
box1 = box length:100 width:100 height:100 --create box
box1.pivot = box1.center --center box's pivot
box1.transform = c_rot --align box to camera
in coordsys c_rot (
max_x = box1.max.x --measure obj.max.x
min_x = box1.min.x --measure obj.min.x
delta_x =abs ( (-1* min_x) + max_x ) --calculate delta_x
format "max_x = % \n min_x = % \n delta_x = % \n" max_x min_x delta_x --print result (check listener/forum post)
)--end in coordsys c_rot do
)--end of script scope