PDA

View Full Version : Xref Scene override material/properties


DaveWortley
05-01-2008, 03:08 PM
Is there a way through maxscript to have an override on a Xref scene entry.

For instance, to have a material set to override any in the xref scene entry, or be able to set things like Visible to camera off....

Kramsurfer
05-01-2008, 06:31 PM
I xref Scene'd a max file with 9 boxes in it... then in the listener..


tnXref = xrefs.getXRefFile 1
XRefScene:"Nine_Boxes.max"
tnXref.tree.children
#children($Box01, $Box02, $Box03, $Box04, $Box05, $Box06, $Box07, $Box08, $Box09)
tnXref.tree.children[2]
$Box:Box02 @ [17359.349609,-445.685547,0.000000]
tnXref.tree.children[2].primaryVisibility = off
false
for tnObj in tnXref.tree.children do tnObj.material = StandardMaterial diffusecolor:( color 128 128 128 )
OK

The .tree construct allows you to access/change all the node properties...
The loop is a "material override" for the x-ref scene... We've been doing mattes like this for years... The best part is all you have to do is reload the Xref to get all the old properties back..

DaveWortley
05-02-2008, 01:45 PM
Thanks Kramsurfer, that looks really useful!

Once this script has run does it store the settings propperly, or do you need to set it as a pre-render script if you submit it over backburner?

DaveWortley
05-02-2008, 05:14 PM
Hmm ok so resets when you re-open the file... Currently designing an interface to work in our pipeline with this as it will be uber useful, I guess I've now got to write a script that writes a script, lol. Once it's generated the script I can have this as a pre-render script so I can render over backburner.

Kramsurfer
05-05-2008, 05:04 PM
I have it as a #filePostOpen callback for network rendering, but I'm sure the #prerender would work too...
And you'll want to define one material to a var and apply it.. the example I gave makes a unique material for each object, not such a good idea, but was a quick one line demo...

DaveWortley
05-06-2008, 10:59 AM
Do you setup your script manually every time or do you have an automated way of doing it?

My next challenge is to adapt a script I wrote that sets up colour correction masks quickly by filtering through all the scene materials and applys a self illuminating material to all of them, but If the material has an opacity map it makes a new material with the opacity map.

thatoneguy
05-06-2008, 06:33 PM
Hmmmmmm... it would seem I need to add another feature to Professor Xref....

DaveWortley
05-07-2008, 02:13 PM
Professor Xref?

I did some test yesterday with using this as an override on lots of xrefs and I had problems, only appear to apply to some objects... need to test it propperly.

Kramsurfer
05-07-2008, 04:56 PM
I have an non-renderable object in the scene and when our scene manager sees that object, it puts the callback in "persistently" before submittal, then removes it. That way it says with the file when it goes to render, but the user never sees it, they just add a max object with a cute name...
On the self illuminating material thing... make sure you random at least 8 values apart so you can get a clean selection. Are you selecting in PhotoShop, AE or Combustion? My color random is for this is
( color (( random 2 25 )*10) (( random 2 25 )*10) (( random 2 25 )*10))
when the aliasing happens it can be hard to have a clean selection.
Of course randomizing it, you'll occassionally get a green real close to another green on something you need a clean selection on, so it's a rerender.... but these should render super fast anyway..
good luck

DaveWortley
05-07-2008, 06:21 PM
I only use pure Red, Green and Blue for masks as with anything else you don't get true antialiasing, sure this means sometimes u have to set up a few masks but as you say it doesn't take very long to render.

Kramsurfer
05-07-2008, 07:00 PM
If you're using Vray, check out the multiMatteElement, it does just that for MaterialID's or Gbuffer Id's... no Material changes required... it's F'n Sweet.... downside, only three matte's per image...

DaveWortley
05-07-2008, 07:47 PM
If you're using Vray, check out the multiMatteElement, it does just that for MaterialID's or Gbuffer Id's... no Material changes required... it's F'n Sweet.... downside, only three matte's per image...

Again it's not true antialiasing, there is noise...

DaveWortley
05-08-2008, 10:55 AM
tnXref = xrefs.getxreffile 2
for i = 1 to tnXref.tree.children.count do
(
tnXref.tree.children[i].primaryVisibility = off
tnXref.tree.children[i].inheritVisibility = on
)

Why doesn't this work? Some of my objects are still visible whereas some are invisible.

tnXref.tree.children.count = 122

But the number of objects in the Xreffed scene is 192, it appears to be ignoring objects in groups or objects that have references in.


I'm using 3dsmax 9 32bit (no SP)

Kramsurfer
05-08-2008, 04:29 PM
What do you mean by "have references in?" Do you have X-ref objects or a nested xref-Scene that you are then X-ref'n?

Setup:
"Nine Boxes.max" xref'd into max file Nine Spheres.
"Nine Spheres.max" then Xref'd into fresh session of max.

Listener:

NineSpheres=xrefs.getXRefFile 1

XRefScene:"Nine_Spheres.max"

NineBoxes= xrefs.getXRefFile 1 root:NineSpheres

XRefScene:"Nine_Boxes.max"

NineBoxes.tree.children

#children($Box01, $Box02, $Box03, $Box04, $Box05, $Box06, $Box07, $Box08, $Box09)



Just tried the group thing too... yes applying a material to the group head does NOT apply the material to the entire group.. So you'll have to check each object to see if they have children... if so then recurse to apply to those, while checking to see if those objects have children... Ya gotta round up all the kids, manually...


ns = xrefs.getXRefFile 1

XRefScene:"Nine_Spheres.max"

ns.tree.children

#children($Sphere01, $Sphere02, $Sphere05, $Sphere08, $Group01)

ns.tree.children[5].material = standardMAterial()

Standardmaterial:Standard

ns.tree.children[5].children[3].material

undefined

CGTalk Moderation
05-08-2008, 04:29 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.