There is unfortunately one last way to assign material to polygons using the Materials and MaterialID attributes. And this way is not using a specific command (the user could just set those values from an ICETree or by script). It is a relatively new feature, so not too many users know this way though.
Cheers, Guillaume On Fri, May 4, 2012 at 8:20 PM, Nicolas Burtnyk <nico...@redshift3d.com>wrote: > Thanks Steven! > > I already use siOnConnectShader (and siOnDisconnectShader) to track > changes to the shader tree. These don't get fired as a result of assigning > a material to an object. siOnCreateShader only gets called when you create > a shader node and in fact partially fails at even that since it doesn't get > called when you create a material (which creates a shader as well). > > Thanks for the tip on material assignment via drag & drop. Kind of a > shame that it ends up calling CopyPaste command but it should be simple > enough to monitor for that command as well. > > -Nicolas > > > > On Fri, May 4, 2012 at 4:54 PM, Steven Caron <car...@gmail.com> wrote: > >> have you tried... siOnCreateShader? i generated this event from the >> wizard and it seems to log a lot of relevant info. also there is >> siOnConnectShader >> >> " *Question*: Can material assignment happen without this command being >> run? In other words, is catching this command sufficient for monitoring >> all the ways that a material can be assigned to an object? I'm not very >> experienced with using Softimage, but I know that in Maya there are a >> million and one ways to assign materials. " >> >> -one could change the shader graph but not the material assignment. >> -one could 'drag and drop' a material from the material view in the >> explorer on to an object. that calls 'CopyPaste()' command. i have always >> been on the fence whether that command is good or bad) >> >> >> On Fri, May 4, 2012 at 4:39 PM, Nicolas Burtnyk >> <nico...@redshift3d.com>wrote: >> >>> Hi list people! >>> >>> For my custom renderer, I'm trying to keep track of when materials get >>> assigned to objects. >>> This is part of an overall system which tracks changes to the scene so >>> that I can incrementally process only the parts of the scene that change >>> between renders. >>> >>> Since there is no specific event that gets fired when a material is >>> assigned to an object (that I know of - please correct me if I'm wrong!), >>> I'm trying to use *siOnEndCommand *to catch the *AssignMaterial *command. >>> *By the way Softimage devs: please add a OnMaterialAssigned event :)* >>> >>> I have 1 question and 1 issue: >>> >>> *Question*: Can material assignment happen without this command being >>> run? In other words, is catching this command sufficient for monitoring >>> all the ways that a material can be assigned to an object? I'm not very >>> experienced with using Softimage, but I know that in Maya there are a >>> million and one ways to assign materials. >>> >>> *Issue*: While I'm correctly receiving the ApplyMaterial command in the >>> siOnEndCommand callback, I'm having trouble deciphering the command >>> arguments. >>> Basically I want to know the Material that was assigned and the >>> Object(s) it was assigned to. Simple, right? >>> In the siOnEndCommand callback, I get the "Command" attribute from the >>> context and create a Command object from it. I then retreive the arguments >>> using Command::GetArguments(). The ArgumentArray always has a count of 2 >>> (whether I assign the material to 1 or more objects). >>> The second argument (ActionWhenLocalMaterialsOverlap) is irrelevant to >>> me. The first argument is a CValueArray that has a CRef for the Material >>> being assigned as its first element and some mysterious CRef as its second >>> item. *My issue is that I don't know what to do with this strange CRef* >>> . >>> >>> Here is a concrete example: >>> >>> I have 2 objects and 1 material in my scene and assign the material to >>> both objects in a single action: >>> Application.AssignMaterial("Sources.Materials.DefaultLib.Material,sphere,cylinder", >>> "siLetLocalMaterialsOverlap") >>> >>> In the siOnEndCommand callback I get: >>> >>> Command(Context(in_ctxt).GetAttribute(L"Command")).GetArguments()[0].GetValue()returns >>> a CValueArray with 2 items. >>> >>> Item 0 : CValue, m_t=siRef - this is a CRef to the Material being >>> assigned, as expected. GetAsText() return >>> "Sources.Materials.DefaultLib.Material" and GetClassIDName() returns >>> "Material". Good to go. >>> >>> Item 1 : CValue, m_t=siRef - this is some kind of weird CRef that I >>> don't know how to handle. GetAsText() returns "sphere,cylinder" and >>> GetClassIDName() returns "Object". What do I do now? How can I get those >>> objects as CRefs? Do I have to tokenize the string and parse out the >>> object names? It's not hard, but I'd like to do something cleaner if >>> possible. >>> >>> Thanks!! >>> >>> -Nicolas >>> >> >> >