Announcement

Collapse
No announcement yet.

auto region - BB

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

  • auto region - BB

    I have a job where auto region would be the best solution to render, but it doesn't work over BB...
    it has been discussed on area. http://area.autodesk.com/forum/autod...et-render-mode

    I have no knowledge in coding and making scripts. can anybody help to make such a script? I have not to render an animation, so the region has not to follow anything.

    thanks.

    best regards
    themaxxer
    Pixelschmiede GmbH
    www.pixelschmiede.ch

  • #2
    Not exactly sure what you are doing, but sounds like it's something VraySphereFade could handle.
    www.suurland.com
    www.cg-source.com
    www.hdri-locations.com

    Comment


    • #3
      Originally posted by suurland View Post
      Not exactly sure what you are doing, but sounds like it's something VraySphereFade could handle.
      thanks for helping. but auto region is better for this I have tried the vrayspherefade.
      I have made "mask" objects for the regions, so the only thing is missing is the script to select the object before rendering.

      if someone could help I am willing to pay for the work. pm me, please

      best regards
      themaxxer
      Pixelschmiede GmbH
      www.pixelschmiede.ch

      Comment


      • #4
        anyone?

        best regards
        themaxxer
        Pixelschmiede GmbH
        www.pixelschmiede.ch

        Comment


        • #5
          Are you still looking for a solution to this?
          Dan Brew

          Comment


          • #6
            Originally posted by DanielBrew View Post
            Are you still looking for a solution to this?
            I have made it with "old-style" crop.
            ...but if you have some ideas, then YES. it could be very handy.

            best regards
            Pixelschmiede GmbH
            www.pixelschmiede.ch

            Comment


            • #7
              After doing a bit of reading it appears that some features in Max are buggy and others are badly implemented - difficult to believe I know
              Unfortunately for us two of these features are pre-render scripts and auto region. There are other ways to do this I think...
              Dan Brew

              Comment


              • #8
                Ok, I've got something working if anyone would like to test it.
                Run the script then select an object and press the 'set region' button. At the moment it only works for single objects and doesn't work if pixel aspect is set to something other than 1 in render settings. Both of these can limitations can be lifted with a bit more work if required.

                Code:
                (
                try (destroyDialog BBautoRegion) catch ()
                
                rollout BBautoRegion "AutoRegion 1.0"
                (
                	fn bb2rect =
                	(
                		renderSceneDialog.close()
                		vpSize = getViewSize()
                		BBmask = $
                		gw.setTransform(Matrix3 1)
                		gwMin = gw.wTransPoint BBmask.center
                		gwMax =  gw.wTransPoint BBmask.center
                		objBB = nodeGetBoundingBox BBmask (Matrix3 1) --get selection BB in worldspace co-ordsys
                		
                		for zi = 1 to 2 do
                		(
                			for yi = 1 to 2 do
                			(
                				for xi = 1 to 2 do
                				(
                					gw.setTransform(Matrix3 1)
                					wsPt = point3 obJBB[xi][1] objBB[yi][2] objBB[zi][3]
                					gwPnt = gw.wTransPoint wsPt
                					
                					if (gwPnt.x < gwMin.x) then
                					(
                						if (gwPnt.x > 0) then (gwMin.x = gwPnt.x) else (gwMin.x = 0) --set gwMin.x
                					)
                					if (gwPnt.y < gwMin.y) then
                					(
                						if (gwPnt.y > 0) then (gwMin.y = gwPnt.y) else (gwMin.y = 0) --set gwMin.y
                					)
                					if (gwPnt.x > gwMax.x) then
                					(
                						if (gwPnt.x < vpSize.x) then (gwMax.x = gwPnt.x) else (gwMax.x = vpSize.x) --set gwMax.x
                					)
                					if (gwPnt.y > gwMax.y) then
                					(
                						if (gwPnt.y < vpSize.y) then (gwMax.y = gwPnt.y) else (gwMax.y = vpSize.y) --set gwMax.x
                					)
                				) --end x loop
                			) --end y loop
                		) --end z loop
                		
                		if getRendImageAspect() < (vpSize.x/vpSize.y) then
                		(
                			roScale = (renderHeight/vpSize.y)
                			roPad = ((vpSize.x*roScale)-(renderWidth))/2
                			roRegion = box2 (point2 ((gwMin.x*roScale)-roPad) (gwMin.y*roScale)) (point2 ((gwMax.x*roScale)-roPad) (gwMax.y*roScale))
                		)
                		else
                		(
                			roScale = (renderWidth/vpSize.x)
                			roPad = ((vpSize.y*roScale)-(renderHeight))/2
                			roRegion = box2 (point2 (gwMin.x*roScale) ((gwMin.y*roScale)-roPad)) (point2 (gwMax.x*roScale) ((gwMax.y*roScale)-roPad))
                		)
                		
                		EditRenderRegion.IsEditable = true
                		if viewport.activeViewport != 0 then viewport.setRegionRect viewport.activeViewport roRegion
                		EditRenderRegion.UpdateRegion()
                		setRenderType #region
                		renderSceneDialog.open()
                	)--end fn bb2rect
                
                	button setRegion "Set Region"
                
                		on setRegion pressed do
                		(
                			if selection.count == 1 then
                			(
                				unregisterRedrawViewsCallback bb2rect
                				registerRedrawViewsCallback bb2rect
                				redrawViews()
                				unregisterRedrawViewsCallback bb2rect
                				redrawViews()
                			)
                		)
                	)--end rollout
                createDialog BBautoRegion
                )
                Dan Brew

                Comment


                • #9
                  wow, it's alway stunning for me that someone find ways to get a result only with some code.
                  great I will test it for sure.

                  thanks for your effort and I will reply if it's working for what I need it.

                  best regards
                  themaxxer
                  Pixelschmiede GmbH
                  www.pixelschmiede.ch

                  Comment


                  • #10
                    Your are the man Daniel!! you should collect all your scripts around the forum in a pack and share (or sell)

                    thank you very much for sharing

                    Comment


                    • #11
                      I'm glad it's useful to you.

                      Here's a later version that works with multiple object selections:
                      Code:
                      try (destroyDialog BBautoRegion) catch ()
                      
                      rollout BBautoRegion "AutoRegion"
                      (
                      	local sfState
                      	local selChanged
                      	
                      	on BBautoRegion open do
                      	(
                      		sfState = displaySafeFrames
                      		displaySafeFrames = true
                      		unregisterRedrawViewsCallback bb2rect
                      	)
                      	
                      	on BBautoRegion close do
                      	(
                      		displaySafeFrames = BBautoRegion.sfState
                      		unregisterRedrawViewsCallback bb2rect
                      		BBautoRegion.selChanged = undefined
                      		gc light:true
                      	)
                      	
                      	fn bb2rect =
                      	(
                      		if $ != undefined then
                      		(
                      			renderSceneDialog.close()
                      			vpSize = getViewSize()
                      			gw.setTransform(Matrix3 1)
                      			sel = getCurrentselection() as array
                      			BBmask = sel[1]
                      			gwMin = gw.wTransPoint BBmask.center
                      			gwMax =  gw.wTransPoint BBmask.center
                      			
                      			for BBmask in sel do
                      			(
                      				objBB = nodeGetBoundingBox BBmask (Matrix3 1) --get selection BB in worldspace co-ordsys
                      				for zi = 1 to 2 do
                      				(
                      					for yi = 1 to 2 do
                      					(
                      						for xi = 1 to 2 do
                      						(
                      							gw.setTransform(Matrix3 1)
                      							wsPt = point3 obJBB[xi][1] objBB[yi][2] objBB[zi][3]
                      							gwPnt = gw.wTransPoint wsPt
                      							
                      							if (gwPnt.x < gwMin.x) then
                      							(
                      								if (gwPnt.x > 0) then (gwMin.x = gwPnt.x) else (gwMin.x = 0) --set gwMin.x
                      							)
                      							if (gwPnt.y < gwMin.y) then
                      							(
                      								if (gwPnt.y > 0) then (gwMin.y = gwPnt.y) else (gwMin.y = 0) --set gwMin.y
                      							)
                      							if (gwPnt.x > gwMax.x) then
                      							(
                      								if (gwPnt.x < vpSize.x) then (gwMax.x = gwPnt.x) else (gwMax.x = vpSize.x) --set gwMax.x
                      							)
                      							if (gwPnt.y > gwMax.y) then
                      							(
                      								if (gwPnt.y < vpSize.y) then (gwMax.y = gwPnt.y) else (gwMax.y = vpSize.y) --set gwMax.x
                      							)
                      						) --end x loop
                      					) --end y loop
                      				)--end z loop
                      			)--end o loop
                      			
                      			if getRendImageAspect() < (vpSize.x/vpSize.y) then
                      			(
                      				roScale = (renderHeight/vpSize.y)
                      				roPad = ((vpSize.x*roScale)-(renderWidth))/2
                      				roRegion = box2 (point2 ((gwMin.x*roScale)-roPad) (gwMin.y*roScale)) (point2 ((gwMax.x*roScale)-roPad) (gwMax.y*roScale))
                      			)
                      			else
                      			(
                      				roScale = (renderWidth/vpSize.x)
                      				roPad = ((vpSize.y*roScale)-(renderHeight))/2
                      				roRegion = box2 (point2 (gwMin.x*roScale) ((gwMin.y*roScale)-roPad)) (point2 (gwMax.x*roScale) ((gwMax.y*roScale)-roPad))
                      			)
                      			
                      			EditRenderRegion.IsEditable = true
                      			if viewport.activeViewport != 0 then viewport.setRegionRect viewport.activeViewport roRegion
                      			EditRenderRegion.UpdateRegion()
                      			setRenderType #region
                      			renderSceneDialog.open() --need test for previous state
                      			displaySafeFrames  = true --need test for previous state
                      		)
                      	)--end fn bb2rect
                      	
                      	fn autobb2rect ev nd =
                      	(
                      		registerRedrawViewsCallback bb2rect
                      		redrawViews()
                      		unregisterRedrawViewsCallback bb2rect
                      		redrawViews()
                      	)
                      
                      	button setRegion "Set Region" pos:[5,10]
                      	checkButton autoRegion "Auto Region" pos:[80,10]
                      
                      		on setRegion pressed do
                      		(
                      			if selection.count == 1 then
                      			(
                      				autobb2rect 1 1
                      			)
                      		)
                      		
                      		on autoRegion changed state do
                      		(
                      			if state == true then
                      			(
                      				autobb2rect 1 1
                      				BBautoRegion.selChanged = NodeEventCallback mouseUp:true selectionChanged:autobb2rect --all:autobb2rect
                      			)
                      			else
                      			(
                      				selChanged = undefined
                      				gc light:true
                      			)
                      		)
                      	)--end rollout
                      createDialog BBautoRegion
                      I'm not any of my scripts are worth selling. I started a page on Scriptspot about 2 years ago but I have posted anything on there yet. Hopefully I'll have time to upload something soon.
                      Dan Brew

                      Comment


                      • #12
                        Thaaaank Daniel, could you please explain which is the difference between the "set region" (the only button in previous version) and "auto region"?

                        Will stay tunned to your scriptspot account

                        Best regards,

                        Comment


                        • #13
                          Originally posted by peprgb View Post
                          could you please explain which is the difference between the "set region" (the only button in previous version) and "auto region"?
                          They both do the same thing (set the renderer to region and set the region to the current selection) apart from while 'auto region' is pressed the region is automatically redrawn if the selection changes or is moved.
                          Dan Brew

                          Comment

                          Working...
                          X