Announcement

Collapse
No announcement yet.

maxscript : VRaySun angle

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • maxscript : VRaySun angle

    Hi,

    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

    Anyone have idea ?

  • #2
    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.

    Comment


    • #3
      Ok here is how to find the angle of the sun above horizon :

      MyVraySun = selection[1] --VraySun selected [test onlt]

      sunPos = MyVraySun.position
      targetPos = MyVraySun.target.position
      sunDistance = distance sunPos targetPos

      vect1 = [sunPos.x,sunPos.y,targetPos.z] - targetPos
      vect2 = targetPos - sunPos
      sunAngle = acos (dot (normalize vect1) (normalize vect2))
      sunAngle = (sunAngle - 180) * -1
      print ("Sun Angle: " + sunAngle as string)

      Now, giving an angle, distance and a point, how to set sun position ??
      Last edited by KiboOst; 29-09-2014, 08:38 AM.

      Comment


      • #4
        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.pe rcent = sltSunHeightsld.value
        sltHeightlbl.caption = (sltSunHeightsld.value) as string
        )

        Attached is a screenshot. Maybe that helps.
        Click image for larger version

Name:	s_sun_system.jpg
Views:	1
Size:	384.9 KB
ID:	854274

        Comment


        • #5
          Thanks. Easy solution here : http://forums.cgsociety.org/showthre...43#post7904843

          Comment


          • #6
            Hurray for Denis

            Comment


            • #7
              yes, definitely

              Comment

              Working...
              X