[Closed] Scripted modifier plugin
Hello,
i'm very much into plugins lately. I've written a modifier-plugin which loads images into the environment-background. These are images of skies and they're used for our lighting. This works nicely. But i'd like to restrict the use of this modifier to only lights, in particular lights with targets.
So if i select a box and add a modifier, i don't want to see my sky-modifier in the list. Is it somehow possible to do this?
This is the header of my plugin
plugin modifier skyTool
name:"skytool"
classID:#(0x5b729c64, 0x77b6f166)
extends:EmptyModifier
replaceUI:true
version:1
(
some code...
)
Klaas
As far as I know, scripted plugin modifiers do not provide a filtering mechanism for the modifier list to detect whether the modifier is applicable or not. C++ plugins do.
One possible solution would be to implement a dummy base modifier plugin with the desired filtering in C++ and then extend that, but obviously it requires knowledge of the SDK.
Thanks bobo for the kind reply.
I think i won’t stretch myself over to the sdk for now.
Klaas
what you could do – at least partially – is detect what object it’s being applied to and change the user interface based on that / put up a warning dialog, etc. that way at least it’s clear to your artists that it should only be used on the appropriate object types
e.g.
plugin simpleMod test name:"test" classID:#(0xc8a0855, 0x44472ea6) version:1 invisible:true (
rollout roll_test "test" (
label lbl_stat ""
)
parameters main rollout:roll_test (
val type:#float
)
on attachedToNode obj do ( if (classOf obj.baseObject != GeoSphere) then ( messageBox "Boink!" ) )
)
The ‘partially’ comes from the fact that if you copy this modifier and then paste it to some other object, the attachedToNode is not triggered.
Another option – which doesn’t fix the ‘partially’ above – is to set invisible:true for your scripted plugin, and only allow it to be added via e.g. toolbar, menu item or – most likely candidate – right-click quad menu macro item. You can control whether or not the quad menu item is visible/enabled quite easily based on the current selection, and only have the item available if the selection is the desired light type. Then just let the macro handle adding the modifier (addModifier $ yourMod).
Hey Richard,
that last suggestion looks very good. I can do toolbars and menus! It’s a modifier which isn’t going to be used very often, so i’ll just pop it in our regular scriptmenu.
Is this by the way how the cameracorrection modifier works? It doesn’t show up in the list of modifiers, but it is visible in the modifier-menu.
Klaas
yep, that’s exacty how that modifier works
Check out…
macro: UI\MacroScripts\Lights and Cameras-CameraCorrection_Quad.mcr
modifier: stdplugs\stdscripts\modifier_camera_perspective_correction.ms