To Guillaume: Thanks for the heads-up! Do you know of any example scripts that demonstrate this? I can't seem to assign materials to objects this way. Also I found 1 more: the ApplyShader command.
To Jo: Well I wasn't even aware of this GetEvaluationID/ GetHierarchicalEvaluationID! I will definitely take a look at this. Thanks! On Fri, May 4, 2012 at 5:46 PM, jo benayoun <[email protected]> wrote: > Hey Nicolas, > > I know, this is not answering directly to your issue here, but rethinking > to your problems (tracking FCurves, materials, etc) for the project you're > working, I would ask why not building a custom scene graph (something > relatively simple) where all nodes are just CRef (the encapsulated pointer > to object should stay valid) pointing to SceneObjects. A custom scene graph > would let you implement a faster visitor pattern that you could think of > using the API, which would query the GetEvaluationID and > GetHierarchicalEvaluationID (awesome to avoid to visit an entire branch - > good for perfs) methods to track which scene objects is getting dirty. You > could also register to "siOnObjectAdded" and "siOnObjectRemoved" events to > keep your custom scene graph updated and aware to the scene. The scene > graph would be built when your renderer gets initialized. Im quite sure, it > doesnt fit your needs, but maybe it could help you to get new ideas :) > > A node of your scene graph, could be as simple as: > """ > struct scenegraphnode > { > /* next sibling and children as linkedlist */ > struct scenegraphnode *siblings[2]; > /* previous dirty number */ > ulong_t prev_dirty; > /* visitor to query the node */ > void (*visit)(struct scenegraphnode *self, struct visitor v); > /* the actual ref */ > XSI::CRef ref; > }; > > """ > > Your "struct visitor" could be a struct checking the dirty count, and if > it is not equal to the previous, in charge of getting the new material, > fcurve, position, etc > and sending those new informations to your renderer. > again, just an idea ... > -jo > > > > > > > > 2012/5/4 Nicolas Burtnyk <[email protected]> > >> 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 <[email protected]> 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 >>> <[email protected]>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 >>>> >>> >>> >> >

