[Closed] Limit effect in simpleMod plugin
Did someone ever used this simpleMod built-in events?
on modLimitZMin do <expr> – s’d return Float
on modLimitZMax do <expr> – s’d return Float
on modLimitAxis do <expr> – s’d return #x, #y or #z
I wish to update one of my modifiers with “limit effect” feature but
I cannot find anywhere a piece of example on how to use this buddies.
I added them in syntax correct manner but they do nothing atm.
I’ll make this plugin public anyway, so here is the full code so far.
plugin simpleMod Zigzag
name:"Zig Zag"
classID:#(0xa8eba5be, 0x89ff7eab)
version:2
(
parameters main rollout:params
(
amount type:#worldunits ui:spAmount default:20
cycles type:#float ui:spCycles default:1
axis type:#radiobtnindex ui:rbAxis default:1
limit type:#boolean ui:cbxLimit default:false
upperlimit type:#float ui:spUpLimit default:0
lowerlimit type:#float ui:spLwLimit default:0
)
rollout params "Parameters"
(
group "ZigZag"
(
spinner spAmount "Amount: " type:#float range:[-1000,1000,20]
spinner spCycles "Cycles: " type:#float range:[0,100,1]
)
group "Axis"
(
radiobuttons rbAxis labels:#("X","Y","Z") coluns:3
)
group "Limits"
(
checkbox cbxLimit "Limit Effect" align:#right
spinner spUpLimit "Upper: " type:#float range:[0,1000,0]
spinner spLwLimit "Lower: " type:#float range:[-1000,0,0]
)
)
rollout roAbout "About" rolledUp:true
(
label lblAuthor "Author: P. Karabakalov"
label lblVers "Version 1 ( 16-08-2009 )"
label lblDate "Version 2 ( 04-01-2012 )"
)
on map i p do
(
case axis of
(
1: p.x += amount*sin((p.z-(center.z))*pi*cycles)
2: p.y += amount*sin((p.z-(center.z))*pi*cycles)
3: p.z += amount*sin(sqrt(p.x^2+p.y^2) - \
sqrt(center.x^2+center.y^2)*pi*cycles)
)
p
)
on modLimitZMin do
(
if limit then lowerlimit else 0
)
on modLimitZMax do
(
if limit then upperlimit else 0
)
on modLimitAxis do
(
case axis of
(
1: #x
2: #y
3: #z
)
)
)
Thanks in advance for any hint
The handlers you mentioned only implement the gizmo drawing of the limits, not the actual limiting. How exactly you are limiting your effect is up to you and should go in the on map i p do() handler.
Here is one possible way (it does stop the zig-zag effect and retains the original shape while preserving the last X/Y offset outside the limit).
Since your effect is working only on the Z coordinate, the Limit should always returns #z regardless of the main axis you apply the effect to. (your code increments X and Y as function of Z, so only Z makes sense as a limit).
plugin simpleMod Zigzag
name:"Zig Zag"
classID:#(0xa8eba5be, 0x89ff7eab)
version:2
(
parameters main rollout:params
(
amount type:#worldunits ui:spAmount default:20
cycles type:#float ui:spCycles default:1
axis type:#radiobtnindex ui:rbAxis default:1
limit type:#boolean ui:cbxLimit default:false
upperlimit type:#float ui:spUpLimit default:0
lowerlimit type:#float ui:spLwLimit default:0
)
rollout params "Parameters"
(
group "ZigZag"
(
spinner spAmount "Amount: " type:#float range:[-1000,1000,20]
spinner spCycles "Cycles: " type:#float range:[0,100,1]
)
group "Axis"
(
radiobuttons rbAxis labels:#("X","Y","Z") coluns:3
)
group "Limits"
(
checkbox cbxLimit "Limit Effect" align:#right
spinner spUpLimit "Upper: " type:#float range:[0,1000,0]
spinner spLwLimit "Lower: " type:#float range:[-1000,0,0]
)
)
rollout roAbout "About" rolledUp:true
(
label lblAuthor "Author: P. Karabakalov"
label lblVers "Version 1 ( 16-08-2009 )"
label lblDate "Version 2 ( 04-01-2012 )"
)
on map i p do
(
case axis of
(
1:
(
if limit and p.z > upperlimit then
p.x += amount*sin((upperlimit-(center.z))*pi*cycles)
else if limit and p.z < lowerlimit then
p.x += amount*sin((lowerlimit-(center.z))*pi*cycles)
else p.x += amount*sin((p.z-(center.z))*pi*cycles)
)
2: (
if limit and p.z > upperlimit then
p.y += amount*sin((upperlimit-(center.z))*pi*cycles)
else if limit and p.z < lowerlimit then
p.y += amount*sin((lowerlimit-(center.z))*pi*cycles)
else p.y += amount*sin((p.z-(center.z))*pi*cycles)
)
3: p.z += amount*sin(sqrt(p.x^2+p.y^2) - sqrt(center.x^2+center.y^2)*pi*cycles)
)
p
)
on modLimitZMin do
(
if limit then lowerlimit else 0
)
on modLimitZMax do
(
if limit then upperlimit else 0
)
on modLimitAxis do
(
#z
)
)
There might be better approaches (see how the Bend modifier keeps the last direction of the bent mesh beyond the limit).
I did not add a limit to the Z axis case since I am not sure what it is supposed to do anyway.
I will update the documentation to explain these handlers better because they are really not documented well (looks like copy&paste from the developer’s notes around Max 3 or 4, before my time).
Many thanks for the reply!
I was not aware of that this handlers only control the gizmo drawing.
Now with this note in mind I can continue