Videep Mishraa
Videep Mishraa

Reputation: 169

Maxscript Scripted Modifier

I have been trying to create a scripted modifier. All works fine. The only thing is I want to display the current Z position of the object in the modifier. This will require me to update the modifier everytime the object updates. Can someone please guide me on how to update a modifier on the movement of its base object?

sample code:

plugin modifier accessBaseObject
name:"Access Details" classID:#(0x260e697e, 0x64b63822) replaceUI:true version:1
(
    parameters main rollout:params
    (
        enterValue type:#float animatable:true ui:spnEnterValue default:0.0
        on spnEnterValue set val do (print $.name)
    )
    rollout params "Modifier Parameters"
    (
        spinner spnEnterValue "Enter Value : "
    )

    on update do
    (
        print ($CAMERA.pos.Z)
    )
)

Thanks in advance, Videep

Upvotes: 0

Views: 2091

Answers (3)

Bela Bessenyei
Bela Bessenyei

Reputation: 1

"Scripted Modifier plug-ins can only extend existing Modifier plug-ins. " Please see the doc, this might be the reason for it and $.pos usually ok.

However if you camera is moved by an other script animation you can still force update by changing some values and on some value change call your function inside your plugin.

Upvotes: 0

Klaudikus
Klaudikus

Reputation: 392

Frozen Wiki pretty much summed it up. Custom Attributes typically do the trick for this sort of thing. You can store weak references, and handle them however you please. For more info check Paul Neale's website: http://www.paulneale.com/

For scripted controller: http://www.paulneale.com/tutorials/Scripting/weakReferences/weakReferences.htm

Upvotes: 0

FrozenKiwi
FrozenKiwi

Reputation: 1513

A modifier is not really aware of the base objects position in the world.

Think of it in terms of information flow:

Object->Modifier->World

You don't receive information about the world (your Z position, same as the object doesn't recieve information about the modifier.

Generally, if you find yourself requiring information that goes against the flow, you have a design issue that could be resolved in a better way. Generally that would be by implementing a world space modifier, but unfortunately I don't think thats possible in MaxScript.

To hack around this, you could find your node and access it directly.

theNode = refs.dependentNodes yourModifier firstOnly:on

But this won't update when the node moves, and won't handle instancing. I'd consider refactoring your plugin to use a different class - try script controller, or make a script object that depends on the input object.

Upvotes: 1

Related Questions