[Closed] ObjectID modifier – need help
Dear people of cgtalk,
please enlighten me on how to proceed.
I have been studying the help files, but am a little baffled.
The goal:
I want to mimic the material id modifier, it should change the object id, though.
Please do not just paste some done code here, I want to do this on my own, but i need some helpers.
1.) I know i am making a scripted plugin. There are different levels of these, I think I need a level 3 one? How do i explicitly declare it as such?
2.) Obviously the type needs to be “modifier”. However the help file states that such plugins can only extend already exisitng ones. I can either extend their rollout or replace it. But I would like to have to seperate ones.
3.) How do I get the object the modifier is placed on?
As far as i saw there are only these four accesible variables: version, this, delegate, loading. Delegate however is not what i am looking for.
My result until now:
plugin modifier ObjectID
name:"ObjectID"
classID:#(418365571, 1986905657)
(
parameters main rollout:params
(
objid type:#Integer animateable:false default:1
on objid set val do delegate.gbufferchannel = val
)
rollout params "Object ID"
(
spinner objid "Object ID" type:#Integer range:[1, 100, 1]
)
)
which returns:
–unkown properrty: “gbufferchannel” in undefined
Also, this now renders me unable to open the modifier dropdown list -.-
Any help would be appreciated, thanks!
‘this’ is your plugin instance (max object) after the plugin was created.
refs.dependentnodes returns node(s) that are dependent on the specified MAXObject.
usually all nodes which depend on some modifier are nodes that this modifier is applied to
I tested your code and it works with one minor change.
-
I guess you don’t need to declare a level.
-
I didn’t need to extend anything.
-
I would access the object simply by “$” because it will always be the selected object. This also works when multiple objects are selected, but doesn’t work with instances of the modifier.
The only thing missing in your code: You didn’t link the “objid” parameter to the “objid” spinner.
objid type:#Integer animateable:false default:1 ui:objid
Let’s say your modifier works. I use it to change the object ID, then I manually go into object properties and change the ID to something else. What happens?
Yes, lo, good question, I did not think about that.
I did a test and as expected the object id is still changeable, but will not update the modifier.
Also, as you stated, MrFryday, having the modifier instanced over several objects does only affect the original copy.
This is what I have for now:
plugin modifier ObjectID
name:"ObjectID"
classID:#(418365571, 1986905657)
(
parameters main rollout:params
(
int_objid type:#Integer animateable:false default:1 ui:spn_objid
on int_objid set val do $.gbufferchannel = val
--on $.gbufferchannel changed val2 do spn_objid.value = val2
)
rollout params "Parameters"
(
spinner spn_objid "Object ID:" type:#Integer range:[1, 1000, 1]
)
)
But the commented line throws an:
-- error in anonymous codevloack; filename:
C:\[...]\objectidmodifier.ms; Position: 244; Line:: 10
-- Syntaxerror: at path name, expected name
-- In Line: on $.g
So I think the crux here lies in how to access the base mesh properly?
there is no way as i know to protect gbufferchannel property from a changing by user. so … if user changes this value with no using of your plugin how does the plugin have to reflect it?
(auto-update, throw warning, do nothing, … ?)
“on … changed” only works with existing ui elements. You have to check out callbacks for that. Either there already is something that registers change in an object or if the modifier is highlighted or something, or you have to add a callback function – but that could impact performance dramatically. Sorry, never did something like that before.
I would say it’s a faulty concept from the get go – modifiers are meant to control properties of “Objects”, not “Nodes”.
i agree. but the idea seems like as to manage a group of nodes (their ids) with one modifier applyed to them. it’s the only reason i can see … and probably there is another reason to not use layers for it
also i’m not sure that the idea is not to use gbufferchannel property for anything different then it was meant for
denis, thank you very much for replying, I am not at home right now so just skimmed your texts, but seems pretty informative!
the idea behind the modifier is to supplement vray. since a few versions you can distribute different maps in one material node (e.g. plugged into the diffuse channel), via object id.
i thought it’d be quite helpful, as this way you could wire it in a custom attribtue modifier, for instance.
Then why not mimic Vray Property workflow and make it dialog, or see if you can extend the Vray Property dialog to add Object ID? The Vray Property Dialog is just an UI to write object property strings.
-Eric
interesting… playing with this task i found that changing of #gbufferchannel property via mxs doesn’t fire any event of any callback system (general, node event, when construct). it means i don’t see easy way to monitor it.
So maybe I should go deeper into the story:
I made a parallax office, gave all the layers the same multi id material.
this branches into one lit and one unlit branch.
These two materials have multi id textures in their diffuse slots.
Now all of these get different object ids, so that the door is a door (ID: 1) and the paintings on the wall have the right bitmap applied, too (random ID: 2-5).
I then tried to wire parameter everything together into a custom attribute holder, as this is for the company I work at.
I would like to have a slider, e.g. that is titled “Paintings:” and which is bound between 2 and 5 on this modifier.
But I couldnt find a neat way to do that without running a script or something.
Unfortunately there is now way to access the gbuffer via parameter wiring, as far as I found out.
@denisT thats rather unlucky… but thanks anyways for checking, means a lot to me