Chaos Corona Forum
Chaos Corona for 3ds Max => [Max] General Discussion => Topic started by: 3dwannab on 2019-09-07, 12:50:19
-
Hi anyone out there that can help with a mathematical / maxscript question.
I need to translate Corona sun and target lights pos and rotations to get me the yaw and pitch.
How can I do this? "It times like these - Dave Grohl" I wish I paid more attention in Maths class!!
Is this even close?
(
/* x,y,z,roll,pitch,yaw */
sun = selection[1]
roll = sun.rotInParent[1]
pitch = sun.rotInParent[2]
yaw = sun.rotInParent[3]
)
There's multiple different ways people are viewing this. This is just one page I found:
https://www.quora.com/How-do-you-represent-Roll-Pitch-Yaw-in-terms-of-X-Y-Z-axes-in-space (https://www.quora.com/How-do-you-represent-Roll-Pitch-Yaw-in-terms-of-X-Y-Z-axes-in-space)
Cheers!
-
I would use a sun without a target (as suns position is irrelevant in corona), and just worry about the 3 axis rotation.
Try the below:
sun =Coronasun()
sun.name = "scriptedSun2"
sun.position = [0,0,300]
sun.targeted =false
fn easyRotation obj x y z =
(
try(obj.rotation.x_rotation = 90-x)catch() -- Invert the height as 90 should be up and 0 should be down for the sun
try(obj.rotation.y_rotation = y)catch()
try(obj.rotation.z_rotation = z)catch()
)
easyRotation Sun 0 0 0
-
That's not what I was after. I managed to sort it out.
/*
convertDirectionToYawPitchAsPoint2Value function
Translates any items point3 direction and returns it as
yaw and pitch in degrees as a point2 value.
Usage: convertDirectionToYawPitchAsPoint2Value <selection>[1]
Returns: [<expr>, <expr>]
*/
fn convertDirectionToYawPitchAsPoint2Value theItem =
(
direction = theItem.dir
yaw = atan2(direction.x) (direction.y)
pitch = asin(-direction.z)
return [yaw, pitch]
)
-- print ((convertDirectionToYawPitchAsPoint2Value $)[1] as string + " yaw")
-- print ((convertDirectionToYawPitchAsPoint2Value $)[2] as string + " pitch")
-
OK i see!
Glad you sorted.