Announcement

Collapse
No announcement yet.

LeleLights Toolset - Advanced Light Creation Tools

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • LeleLights Toolset - Advanced Light Creation Tools

    Short description:
    The script creates 4 plug-in lights that allow for different creation modes than the standard ones.
    Besides allowing to pick light type before having created it (much like the toolbar does), the modes ought to aid in their positioning, reducing mouse clicking and improving placement accuracy.
    Notice that the script is personal, not a Chaos-Group sanctioned one, nor is supported, besides bug fixing, and listening to requests.
    Implementation of said requests will only happen if and when time constraints will allow it, so please use them as they are, for what they are, and feel free to suggest for changes, but EXPECT nothing of them.

    Installation:
    Put the scripts into

    %MaxRoot%\scripts\Startup\
    (usually C:\Program Files\Autodesk\3ds Max 20xx\scripts\Startup)

    On next max run, you'll find four more buttons in the V-Ray lights panel.

    Click image for larger version  Name:	buttons.png Views:	1 Size:	9.5 KB ID:	884712

    Usage:
    Undo is supported.

    For all light types BUT the dome:
    NO Modifier Key = Standard light creation, inscribed into and centered on the creation Bounding Box.
    SHIFT Key = Viewport-Aligned creation toggle: when on, the transform matrix used to create the light will be the view one. Having just Shift pressed while clicking, instantly creates a light, sized as the frustum 10 units into the view.
    CTRL key = Sizing mode toggle: for grid-aligned creation it switches to symmetrical sizing and center on the clicked point; for view-aligned creation it allows to drag to size the light.
    ALT Key = Target creation toggle: in grid creation mode it also allows for target positioning before ending the light's creation action, in viewport-aligned mode it simply creates a target for the light at the view focal point (or ten units further than the light if the view is orthogonal).

    For the Dome:
    NO Modifier Key = Light creation at the origin.
    If an environment map is present AND active, it's instanced into the dome texture, the environment map use is turned off (ie. just the checkbox), and the environment color is set to black.
    If no environment map was present, or active, the background color only is reset to black.
    SHIFT Key = Creation like above, but on mouse projection on the grid.
    CTRL key = Creation like above, but it also DELETES all Domelights from the scene (whether they were on or off).
    ALT Key = Creation like above, but it also TURNS OFF all Domelights in the scene

    Combinations work (the ctrl key in realtime, too, when grid-creating).

    Limitations and Usage Notes:
    *)The view-creation mode (shift+click) currently doesn't support safe frames at all. The sizing of your light is done on the original, non-masked, viewport.
    It may or may not change in the future: i can't seem to find a way to access the masked viewport size directly (there is none.), so the workaround would be to mimic the safe-frames code.
    *)The view creation mode should change, i think, to move the lights back to the view origin, rather than 10 units in front (something clearly visible when creating them in ortho views.). While this would work NP for said ortho views, it would break the look of light creation when from a perspective view (the light would then be bigger than the frame, and all the user would see would be the cross in the middle). Thoughts?

    Technical notes for TDs:
    The plug-in simply encapsulates a vrayLight class to implement the new creation modes through a mouse Tool.
    Usage is entirely safe, as at the moment the light is created it returns to its original class, and any script error is self-contained and won't spill into the Max session.
    In other words, saving a file after having created the lights with the plugin will be identical to one where the lights were created normally.
    Not having the plugin lights on a system when opening the scene will incur in absolutely no penalty.

    Updates and Changelog:
    05-06-2016: Removed garbage test code from the arealight.
    08-06-2016: Added undo Support to lights' creation and new modes to the DomeLight.

    Re-download and overwrite with Max closed if you have already installed them.
    Attached Files
    Last edited by ^Lele^; 07-12-2023, 04:00 AM.
    Lele
    Trouble Stirrer in RnD @ Chaos
    ----------------------
    emanuele.lecchi@chaos.com

    Disclaimer:
    The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

  • #2
    A beer with your name on it is sitting in a pub in Holland.
    Maxscript made easy....
    davewortley.wordpress.com
    Follow me here:
    facebook.com/MaxMadeEasy

    If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

    Comment


    • #3
      I'll hold you to this one!
      Lele
      Trouble Stirrer in RnD @ Chaos
      ----------------------
      emanuele.lecchi@chaos.com

      Disclaimer:
      The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

      Comment


      • #4
        thank you Lele. very cool

        Comment


        • #5
          Originally posted by ^Lele^ View Post
          I'll hold you to this one!
          I'll get Joep to write your name on the bottle!
          Maxscript made easy....
          davewortley.wordpress.com
          Follow me here:
          facebook.com/MaxMadeEasy

          If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

          Comment


          • #6
            08-06-2016: Added undo Support to lights' creation and new modes to the DomeLight. )
            Read more and download in the first post.
            Last edited by ^Lele^; 08-06-2016, 08:27 AM.
            Lele
            Trouble Stirrer in RnD @ Chaos
            ----------------------
            emanuele.lecchi@chaos.com

            Disclaimer:
            The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

            Comment


            • #7
              thanks for update

              Comment


              • #8
                Only comment is that VRayRect Light should be VRayPlane Light.... for consistency with the rest of the UI.
                Maxscript made easy....
                davewortley.wordpress.com
                Follow me here:
                facebook.com/MaxMadeEasy

                If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

                Comment


                • #9
                  The button says VRayRect but it makes VrayAreaLights....

                  I've made the code more consistent here.....

                  Code:
                  plugin light VRayPlaneLight name:"VRayPlane" category:"VRay"
                  (
                  	tool create
                  	(
                  		local p1=[0,0,0]
                  		local p2=[0,0,0]
                   		local theLight
                  		local theTarget
                  		local isTargeted = false
                  		local viewTransformed = false
                  		local theTM
                  		local hadSafeFrames = false
                  		
                  
                  			on mousePoint click do
                  			(
                  				with undo on
                  				(
                  					if click == 1 do 
                  					(
                  						if keyboard.shiftPressed then	--View creation mode
                  						(
                  							theLight=VRayLight type:0 name:(uniquename("VRayPlaneLight")) multiplier:30 size0:0 invisible:true			
                  							theTM=inverse(viewport.getTM())
                  							theLight.transform=theTM
                  							in coordsys Local move theLight [0,0,-10]
                  							if not keyboard.controlPressed do
                  							(						
                  		-- 						in coordsys Local move theLight [0,0,9.99]
                  								theSize = (mapScreenToView (getViewSize()) -10)
                  								theLight.size0 = abs ( theSize[1] )
                  								theLight.size1 = abs ( theSize[2] ) 
                  								theLight.multiplier = ((distance [0,0,0] theLight.pos)) * ((distance [0,0,0] theLight.pos)/10)
                  							)	
                  							if keyboard.altPressed do
                  							(
                  								theLight.targeted =true
                  								theLight.Target.pos = theLight.pos
                  								if viewport.getType()== #view_persp_user or viewport.getType()== #view_camera then
                  								(
                  									in coordsys Local move theLight.target [0,0,-viewport.getFocalDistance()]
                  								)
                  								else
                  								(
                  									in coordsys Local move theLight.target [0,0,-10]							
                  								)
                  								select theLight
                  							)
                  							if keyboard.controlPressed then 
                  							(
                  								viewTransformed=true
                  								select theLight
                  							)
                  							else
                  							(
                  								select theLight
                  								displaySafeFrames = hadSafeFrames
                  								#stop
                  							)					
                  						)
                  						
                  						else
                  						(
                  							coordsys grid
                  							(
                  								p1=gridPoint
                  								if keyboard.altPressed then
                  								(
                  									theLight=VRayLight type:0 pos:p1 size0:0 name:(uniquename("VRayPlaneLight")) multiplier:30 
                  									isTargeted=true
                  								)
                  								else
                  								(
                  									theLight=VRayLight type:0 pos:p1 size0:0 name:(uniquename("VRayPlaneLight")) multiplier:30 targeted:false
                  									isTargeted=false
                  								)
                  							)
                  						)
                  					)
                  				)
                  			)
                  			on mouseMove click do
                  			(
                  				
                  				if click == 2 then
                  				(
                  					if viewTransformed then
                  					(
                  						coordSys (viewport.getTM())
                  						(
                  							viewSize=getViewSize()
                  							viewCenter=viewSize/2
                  							screenSizePercent=[(abs (mouse.pos.x-viewCenter.x)/viewCenter.x as float), (abs (mouse.pos.y-viewCenter.y)/viewCenter.y as float)]
                  							screenSize=(mapScreenToView (getViewSize()) -10 )
                  							theLight.size0=abs(screenSize.x*screenSizePercent.x)
                  							theLight.size1=abs(screenSize.y*screenSizePercent.y)
                  
                  						)
                  					)
                  					else
                  					(
                  						coordsys grid
                  						(
                  							p2=gridPoint
                  							diff=p2-p1
                  							if keyboard.controlPressed then
                  							(
                  								theLight.size0=abs(diff.x)
                  								theLight.size1=abs(diff.y)
                  								theLight.pos=p1
                  							)
                  							else
                  							(
                  								theLight.size0=abs(diff.x)/2
                  								theLight.size1=abs(diff.y)/2
                  								theLight.pos=(diff/2)+p1
                  							)							
                  						)
                  					)
                  				)
                  				
                  				else if click == 3 then 
                  				(
                  	-- 				print "isTargeted"
                  	-- 				print isTargeted
                  					if viewTransformed then
                  					(
                  						viewTransformed=false
                  						displaySafeFrames = hadSafeFrames
                  						#stop					
                  					)
                  					else
                  					(
                  						if isTargeted then
                  						(
                  	-- 						print "targeted!"
                  							theLight.targeted=true
                  							theTarget=theLight.target
                  							coordsys grid
                  							(
                  								p3=gridPoint
                  								theTarget.pos=p3
                  							)
                  						)
                  						else
                  						(
                  							select theLight
                  							theLight=p1=p2=isTargeted=undefined
                  							displaySafeFrames = hadSafeFrames						
                  							#stop
                  						)
                  					)
                  				)
                  				else if click == 4 do 
                  				(
                  					select theLight
                  					theLight=p1=p2=isTargeted=undefined
                  					displaySafeFrames = hadSafeFrames
                  					#stop
                  				)
                  			)
                  	)
                  )
                  Maxscript made easy....
                  davewortley.wordpress.com
                  Follow me here:
                  facebook.com/MaxMadeEasy

                  If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

                  Comment


                  • #10
                    You just overrode Vlado's preference there... :P
                    Jokes aside, yes, the naming has been laborious: i realised while choosing the names that "area" light isn't "plane" area light, implicitly. -.-'

                    It's an Area,subtended to a plane, which is rectangular in nature.

                    What's it going to be? :P
                    Lele
                    Trouble Stirrer in RnD @ Chaos
                    ----------------------
                    emanuele.lecchi@chaos.com

                    Disclaimer:
                    The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

                    Comment


                    • #11
                      I reckon this matter can only be solved with a fight to the death. Cafe de zaak next wednesday night?

                      Comment


                      • #12
                        You got it.
                        Are you coming as referee, then? London tower keeping your shackles cold for you while away?
                        Lele
                        Trouble Stirrer in RnD @ Chaos
                        ----------------------
                        emanuele.lecchi@chaos.com

                        Disclaimer:
                        The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

                        Comment


                        • #13
                          Nah I won't get out unfortunately - aiming for an end of june delivery so it's the pointy end of it for me. Must find some other way to catch up though whether on a trip to sofia or germany!

                          Comment


                          • #14
                            Thank you very much for sharing! Very nice!

                            Cheers!

                            Comment

                            Working...
                            X