Announcement

Collapse
No announcement yet.

Random Hue through scripting

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

  • Random Hue through scripting

    I'm creating a series of lights with the intent of having them be the same intensity, but different hues. I've been able to adjust the RGB values through scripting with no problems, but I'm having difficulty assigning random hues the same way. Is there something I'm missing with this? Any help would be greatly appreciated (and a huge time saver!)

    Thanks

    Jon

    here's what I have in there right now:

    for obj in $ do
    (
    obj.color.h = random 0 100
    )
    ...learning more every day...

  • #2
    Hi Jon,

    hope i have understood the question correctly

    for max standard lights you can use:

    for obj in $ do
    (
    obj.hue = random 0 255
    )

    but for Vray lights... i don't have access to Hue value either.
    i use this way, not very nice but it works for me

    for obj in $ do
    (
    lightDummy=Omnilight rgb: (color(random 0 255) (random 0 255) (random 0 255)) hue: (random 0 255)

    obj.color=lightDummy.color

    delete lightDummy
    )

    Thomas
    Last edited by Thomas_Pardun; 01-03-2010, 10:40 PM.
    Material Preset Manager

    Comment


    • #3
      You can't directly set the hue component of the color value in the light, you have to reference it first, modify, then reassign it.

      Code:
      for i in selection where (classof i==VRayLight) do
      (
      	col=i.color
      	col.hue=random 0 255
      	i.color=col
      )
      Marc Lorenz
      ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___
      www.marclorenz.com
      www.facebook.com/marclorenzvisualization

      Comment


      • #4
        Thomas - That surely isn't the prettiest way to do it, but it worked. Thanks for the help! Manually changing a couple hundred lights would have been a major PITA.

        Marc - I have to say that logically your method makes much more sense to me, but it doesn't seem to work. When I run it, the Maxscript Listener just says "OK" but nothing in the color changes. You have any thoughts on that?

        Thanks to both. Hope this helps others as well!

        Jon
        ...learning more every day...

        Comment


        • #5
          it reads the current light color and changes hue. if there is no saturation in the current color, then it doesn't change anything.
          so it doesn't work when the old color is white, black, gray.
          here is a version that forces a new color:

          Code:
          for i in selection where (classof i==VRayLight) do
          (
          	--col=i.color
          	col=color 255 127 127
          	col.hue=random 0.0 255
          	i.color=col
          )
          Marc Lorenz
          ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___
          www.marclorenz.com
          www.facebook.com/marclorenzvisualization

          Comment


          • #6
            Ah....that is great! Thanks so much for your help. I did what you mentioned and re-adjusted the color, then ran the initial script and it worked.

            Now...on to make multi-colored lights!!

            peakyfreak
            ...learning more every day...

            Comment

            Working...
            X