[Closed] Make it clearer about modifier Limits
I want to clear a little bit situation with Limits because people ask.
by SDK meaning it’s nothing else then a mechanics to show extra Gizmo elements – “Limits” – extra lines on gizmo in specified axis corresponding to value defined by developer.
in the mxs it’s made with:
on modLimitZMin do <expr>
on modLimitZMax do <expr>
on modLimitAxis do <expr>
handlers
we ca see it for example with this snippet:
plugin simpleMod EZLimits
name:"EZLimits"
classID:#(0x00001967, 0x3c1122a1)
(
parameters main rollout:main
(
axis type:#integer ui:ui_axis default:3
limit type:#boolean default:off ui:ui_limit
zmin type:#float default:0 ui:ui_zmin
zmax type:#float default:0 ui:ui_zmax
)
rollout main "Parameters"
(
group "Axis: "
(
radiobuttons ui_axis labels:#("X ", "Y", "Z") columns:3 align:#left offset:[20,-2]
)
group "Limits: "
(
checkbox ui_limit "Enabled"
spinner ui_zmin "Lower: " range:[-1e9,1e9,0] type:#float scale:0.01 fieldwidth:54 align:#rigth offset:[4,0]
spinner ui_zmax "Upper: " range:[-1e9,1e9,0] type:#float scale:0.01 fieldwidth:54 align:#rigth offset:[4,-2]
)
)
on map i p do p
on modLimitZMin do if limit then zmin*(max-min)[axis] else 0.0
on modLimitZMax do if limit then zmax*(max-min)[axis] else 0.0
on modLimitAxis do #(#x, #y, #z)[axis]
)
(
max create mode
delete objects
b = box widthsegs:2 lengthsegs:2 heightsegs:2 isselected:on
addmodifier b (EZLimits())
max modify mode
)
another story is about what to do with limits…
as i said it’s all about what developer wants. limits only show area (range) of different than main deformation.
it might be any difference depending on developer’s implementation.
many of modifiers use limits to suppress effect of the modifier. but i’s not the rule.
here is another snippet that shows a using of limits:
plugin simpleMod Zwister
name:"Zwister"
classID:#(0x00001967, 0xcc1122a1)
(
parameters main rollout:main
(
angle type:#float default:0 ui:ui_angle
limit type:#boolean default:off ui:ui_limit
zmin type:#float default:0 ui:ui_zmin
zmax type:#float default:0 ui:ui_zmax
)
rollout main "Parameters"
(
group "Zwist: "
(
spinner ui_angle "Angle: " range:[-1e9,1e9,0] type:#float fieldwidth:54 align:#rigth offset:[4,-2]
)
group "Limits: "
(
checkbox ui_limit "Enabled"
spinner ui_zmin "Lower: " range:[0,1,0] type:#float scale:0.01 fieldwidth:54 align:#rigth offset:[4,0]
spinner ui_zmax "Upper: " range:[0,1,0] type:#float scale:0.01 fieldwidth:54 align:#rigth offset:[4,-2]
)
)
on map i p do if angle == 0 then p else
(
zp = (p.z - min.z)/extent.z
if limit do
(
zp = if (zp < zmin or zmin > zmax) then zp else if zp <= zmax then zmin else zmin + (zp - zmax)
)
v = zp * angle
p *= rotateZMatrix v
)
on modLimitZMin do if limit then zmin*(max.z-min.z) else 0.0
on modLimitZMax do if limit then zmax*(max.z-min.z) else 0.0
on modLimitAxis do #z
)
(
max create mode
delete objects
b = box width:10 length:10 height:50 widthsegs:10 lengthsegs:10 heightsegs:30 isselected:on
addmodifier b (Zwister angle:360 limit:on zmin:0.3 zmax:0.7)
max modify mode
)
here is another example which is absolutely nothing about a “limitation”:
plugin simpleMod DoublePush
name:"DoublePush - ;)"
classID:#(0x00001967, 0xcc1322a1)
(
parameters main rollout:main
(
lower_val type:#float default:1 ui:ui_lower_val
lower_pos type:#float default:0 ui:ui_lower_pos
upper_val type:#float default:1 ui:ui_upper_val
upper_pos type:#float default:1 ui:ui_upper_pos
)
rollout main "Parameters"
(
group "Lower: "
(
spinner ui_lower_val "Value: " range:[-1e9,1e9,0] type:#float fieldwidth:54 align:#rigth offset:[4,-2]
spinner ui_lower_pos "Position: " range:[0,1,0] type:#float scale:0.01 fieldwidth:54 align:#rigth offset:[4,0]
)
group "Upper: "
(
spinner ui_upper_val "Value: " range:[-1e9,1e9,0] type:#float fieldwidth:54 align:#rigth offset:[4,-2]
spinner ui_upper_pos "Position: " range:[0,1,0] type:#float scale:0.01 fieldwidth:54 align:#rigth offset:[4,0]
)
)
fn hermite t = (-2*t^3+3*t^2)
fn spline t p =
(
if t <= p then hermite (t/p) else hermite (1 - (t-p)/(1-p))
)
on map i p do if angle == 0 then p else
(
zp = (p.z - min.z)/extent.z
v = (spline zp lower_pos)*lower_val + (spline zp upper_pos)*upper_val
p *= scalematrix [1+v,1+v,1]
)
on modLimitZMin do lower_pos*(max.z-min.z)
on modLimitZMax do upper_pos*(max.z-min.z)
on modLimitAxis do #z
)
(
max create mode
delete objects
b = cylinder radius:5 height:50 sides:32 heightsegs:100 isselected:on
addmodifier b (DoublePush lower_val:2.0 lower_pos:0.3 upper_val:-0.5 upper_pos:0.8 )
max modify mode
)
thanks denis for the useful examples and information.
I’ll have to check them out and see how they work in detail.
There is a lock of examples in the help files.
Just as a note worth mentioning, you may want to make your Limits unit based on the WorldUnits. That will match all the max modifiers which use limits with a unit type of World Units rather than Float (like your example)
Proper method would be as follows…
on modLimitZMin do if LimitEnabled then LimitMin else 0.0
on modLimitZMax do if LimitEnabled then LimitMax else 0.0
on modLimitAxis do #(#x, #y, #z)[Axis]