I’m trying to get and set the VraySun angle (horitonzal angle, between the line sun-target and the horizon).
I see no where to start ! VraySun display this angle in rotate x once moved (the three little box at the bottom) , but with maxscript I can’t access VraySun.rotation
Hmm, since it’s an aim and target type of object I don’t think it’s a rotation thing, you’d be better off just using your position coordinates and a small bit of Pythagoras theorem to get the correct z height for the angle you want.
I´ve done a smilar script in the past. Well the approach is different. Not sure if this is exactly what you are looking for. But maybe it helps.
In my case I used a non targeted direct, but It should also work with a targeted Vray Sun.
Instead of directly setting the position of the sun I linked it to system of two splines. One Circle for the Azimuth and another one for the height.
Those (including the sun) are stored in a scene that I load with “max file merge”. The splines and the sun are linked with path controllers.
So you can change the path percent by script. I also added a scale function that scales this sun system in case I´m working in bigger or smaller
scenes. Like this you´d have a pretty easy control of the sun´s azimuth and height.
So the script for the Azimuth looks like this.
on sltSunAzimuthsld changed val do
(
$_sun_controller_height_dummy.pos.controller.Path_Constraint.controller.percent = sltSunAzimuthsld.value
sltdirectionlbl.caption = (sltSunAzimuthsld.value) as string
)
$_sun_controller_height_dummy is the spline for the heigth wich is linked with a path controller to the Azimuth spline.
The part for the height is basically the same only that I change the percent directly for the sun wich is linked to the height spline.
on sltSunHeightsld changed val do
(
$_Sun.pos.controller.Path_Constraint.controller.percent = sltSunHeightsld.value
sltHeightlbl.caption = (sltSunHeightsld.value) as string
)