View Full Version : Need to access items not listed in RenderClass
JeffPatton 04-04-2006, 04:54 PM I'm trying to write my first script. After a lot of reading & thread searching, I think I have a question now...
After reading through the "Mental_Ray_Renderer:Renderer Class" section of the MAXscript reference, I didn't see a critical item listed that I need to access for my script. I need to access the "scene diameter" information that MR calculates if at all possible.
Another item that I'd like to access is the scene extents, but that's not a requirement.
Any thoughts? Have I just simply overlooked something?
Thanks in advance for any help.
|
|
JHaywood
04-04-2006, 05:26 PM
Can you give me some more information on the "scene diameter"? When does MR calculate it, where it the number found normally, what exactly is it calculating, etc.? I'm not familiar with what you're talking about. If it's not directly available through MXS, you might be able to create a function that manually does the same calculations that MR would.
JeffPatton
04-04-2006, 05:51 PM
Thanks for the reply James. The scene diameter calculation happens at the beginning of the rendering process with MR. I believe it's used to calculate the "automatic" radius size settings of the GI photons.
I've attached a screen shot of the MR dialog box that lists the items in question.
The reasons I need those are as follows: Scene radius: I use my own photon size calculatons based on this setting provided by MR, so I'd like to make a script that will run my calculations automatically. Second, I want to use the scene extent settings to allow people to create a skydome object around their scenes then ultimately have a few pre-defined sky gradients for users to choose from for quick lighting setups.
Thanks for the reply James. The scene diameter calculation happens at the beginning of the rendering process with MR. I believe it's used to calculate the "automatic" radius size settings of the GI photons.
I've attached a screen shot of the MR dialog box that lists the items in question.
The reasons I need those are as follows: Scene radius: I use my own photon size calculatons based on this setting provided by MR, so I'd like to make a script that will run my calculations automatically. Second, I want to use the scene extent settings to allow people to create a skydome object around their scenes then ultimately have a few pre-defined sky gradients for users to choose from for quick lighting setups.
Find out the world bounding box of all scene objects.
Then get the diagonal of that bounding box.
In your example,
distance [-368.94,-222.6,-0.01] [220.45,325.46,16.25]
804.994 --pretty close to the scene diameter shown in the dialog!
To get the world bounding box, you can use:
fn getSceneSize =
(
local theMin = [1,1,1] * 10.0^8
local theMax = [-1,-1,-1] * 10.0^8
for o in objects where o.renderable and not o.isHiddenInVpt do
(
if o.min.x < theMin.x do theMin.x = o.min.x
if o.min.y < theMin.y do theMin.y = o.min.y
if o.min.z < theMin.z do theMin.z = o.min.z
if o.max.x > theMax.x do theMax.x = o.max.x
if o.max.y > theMax.y do theMax.y = o.max.y
if o.max.z > theMax.z do theMax.z = o.max.z
)
#(theMin, theMax, distance theMin theMax) --return min, max and diameter
)
getSceneSize()
JeffPatton
04-04-2006, 09:33 PM
Thanks Bobo, that seems to work fairly well as long as I run the code prior to lights being added to the scene. Which is not a problem since adding a sunlight would be part of the script and I can simply add it after the radius calculation.
Unless there's a way for the world bounding box to ignore lights? I'll do some reading on that and see what I can find.
Light
04-04-2006, 09:38 PM
Hi Jeff,
You can do that by replacing this: for o in objects where o.renderable and not o.isHiddenInVpt do
with this: for o in objects where o.renderable and not o.isHiddenInVpt and superClassOf o != light do
in Bobo's code.
Light
JeffPatton
04-04-2006, 09:50 PM
Cool..Thanks! I'll give that a go.
JeffPatton
04-04-2006, 10:13 PM
Just tried your tip and it worked like a charm. Thanks man! And thanks again to Bobo too.
JHaywood
04-05-2006, 05:36 PM
Just thought I'd chime in here with a alternate way of getting the scene extents. Assuming that you only need the extents of the mesh objects in the scene, you could simply use:
distance geometry.min geometry.max
Look up "ObjectSet" in the reference doc for a description of these pre-defined system variables, like "objects" and "geometry". They come in very handy at times.
JeffPatton
04-05-2006, 06:07 PM
Thanks for the alternative idea, I'll be sure to research that option as well as I attempt to create this script.
Aearon
04-05-2006, 07:01 PM
distance geometry.min geometry.max
that's pretty neat man
Just thought I'd chime in here with a alternate way of getting the scene extents. Assuming that you only need the extents of the mesh objects in the scene, you could simply use:
distance geometry.min geometry.max
Look up "ObjectSet" in the reference doc for a description of these pre-defined system variables, like "objects" and "geometry". They come in very handy at times.
The problem is that this takes into account ALL geometry objects, included those hidden for various reasons, non-renderable etc.
A good script would have to check among other things:
*Is the node set to renderable
*Is the object visible in the scene during rendering
-is it hidden and if it is, is the Render Hidden Objects checked or not.
-is it frozen with Hide Frozen Objects on
-is the layer of the object hidden
etc.
My script did not check half of the things required normally, for example it did not exclude lights, cameras and helpers, did not take into account renderable splines, did not take into account helpers that are potentially renderable (for example volumetric gizmos might be considered part of the rendered scene) and many more.
JHaywood
04-06-2006, 05:26 PM
The problem is that this takes into account ALL geometry objects, included those hidden for various reasons, non-renderable etc.
Yeah, I totally agree. I mainly just think that the system variables, like "objects", "lights", and "geometry" are cool. Plus, for the specific purpose of making the skydome, I think the geometry.min/max line is valid. Or substitue with "objects" if it absolutely needs to encompass everything.
But you make a good point about not cutting corners and taking the time to create scripts that try to predict, and deal with, all eventualities.
CGTalk Moderation
04-06-2006, 05:26 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.