PDA

View Full Version : scripting materials/textures....


chans
08-19-2008, 12:13 PM
hi,
i've run into a few curious problems while trying to write a script to do some processing on textures. first, what i'm trying to accomplish:

I'm trying to write a script that will generate some data based on a map plugged into the currently selected material(s) in the material manager. the material in question is using a cg realtime shader node and the texture i want to operate on is plugged into that realtime node.

I'm hoping the work flow will be as follows:
1. user goes to mat manager and selects the material.
2. user right clicks or goes to a menu and selects command
3. user is presented with dialog that asks for a few input params
4. user hits "generate" button and work is done.

so now for where i'm stuck:
1. How can you find out what material is selected in mat manager? The Selected property and IsSelected() method of a Material object only returns true if the material is selected in xsi explorer. It does NOT reflect whether or not it is selected in mat manager at all.
2. How do you access the RTShader node of a material? Our is a custom node, but its still a RTShader node and I can’t seem to find a way to access it. in particular, I’m trying to access the textures that are plugged into the node. Our custom node is called RMEShader, but when I try something like this:

SelectObj( "Reference.hair.branchcurrent.hair.RMEShader", null, null );

XSI gives me this error in the script window:
// ERROR : 2000 - Argument 0 (SelectionList) is invalid
// ERROR : 2001-SELE-SelectObj - Argument 0 is invalid
SelectObj("Reference.hair.branchcurrent.hair.RMEShader", null, null);
// ERROR : Invalid procedure call or argument - [line 1]

But if I select the RMEShader node from xsi explorer, I see this in the script window:
SelectObj("Reference.hair.branchcurrent.hair.RMEShader", null, null);

Which is exactly what I have above. So why doesn’t that work? In fact, if I select the RMEShader node in explorer, then copy the script window output and past it back in and run it, I get the same error as above!

thanks in advance for any and all help!
Cheers,
Chan.

StephenBlair
08-19-2008, 01:27 PM
If you get the Material, then you could get the shader like this:

oMaterial.Shaders("RMEShader");