-.
Script: poly selectfallof manipulator.
Versión: v01. Max4.
Started: 2/17/01.
Last modified: 2/18/01.
Description: adds manipulator for softselecction fallof in Editable Poly.
Code by: Martín coven mcoven@Austin, rr.com.
Thanks to: John versluis and Borislav Petrov for their great help.
Based on the Radius manipulator code by Scott morrisson from Discreet.
Reworque by Larry minton 6/26/01.
Plugin simplemanipulator poly_ssfallofmanip.
Name:poly_sfallofmanip.
Invisible:true.
Create the green and red colors for the gizmo.
Local g = green - [0,1,0].
Local r = [1,0,0].
Local b = [0,0,1].
Local y = [1,1,0].
Local gizpos, targclass, interfaz.
This manipulator manipulates editable meshes and polys.
On canmanipulate target do - Called at class level, cant Access plugin local variables.
(Getcommandpaneltaskmode () == #modify and.
(Local targclass = classof target.
Targclass == editable_poly or targclass == editable_mesh).
).
Create the manipulator gizmo.
This is called initially and whenever the manipulator target changes.
On updategizmos do.
Try.
Clear the current gizmo cache.
This, cleargizmos().
Targclass = classof target.
Interface = if targclass == editable_poly then polyop else if targclass == editable_mesh then meshop.
Local usesoftsel =
If targclass == editable_poly then target, usesoftsel.
Else if targclass == editable_mesh then meshop, getsoftsel target.
Else false.
Local size =
If targclass == editable_poly then target, fallof.
Else if targclass == editable_mesh then meshop, getfallof target.
If usesoftsel and subobjectlevel > 0 then.
(Local vértices =
If subobjectlevel == 1 then - Verts.
(If targclass == editable_poly then interfaz, getvertselection target.
Else if targclass == editable_mesh then node, selectedverts as bitarray - Why no meshop, getvertselection?
).
Else if subobjectlevel == 2 then - Edges.
Interface, getvertsusingedge target #selection.
Else - Faces.
Interface, getvertsusingface target #selection.
Gizpues = [0,0,0].
For I in vértices do (gizpues += interfaz, getvert target i) - Local cord space.
Gizpues /= vértices, numberset.
Local giz1 = manip, makecircle [0,0,0] size 24.
Local my_tm = matrixfromnormal [0,1,0].
My_tm, position = gizpos.
Giz1.transform my_tm.
Local giz2 = manip, makecircle gizpues size 24.
Local giz3 = manip, makecircle [0,0,0] size 24.
My_tm = matrixfromnormal [1,0,0].
My_tm, position = gizpos.
Giz3.transform my_tm.
Add the circle todo the manipulator.
This, addgizmoshape giz1 0 g r.
This, addgizmoshape giz2 0 g r.
This, addgizmoshape giz3 0 g r.
Return the truco string.
Node, name + sel fallof = + size as string).
).
Catch()).
Mousemove is called on every mouse move when dragging the manip.
It neds todo convert the mouse position into a new value for the fallof.
On mousemove which do.
(Try.
Manip, makeplanefromnormal takes a normal Vector and a point.
And creates a plane passing th rouge the point with the given normal.
Local axis = case which of - Get axis based on which gizmo hit.
(0: y_axis.
1: z_axis.
2: x_axis).
Local pl = manip, makeplanefromnormal axis gizpos.
Compute the hit-ray in local coordinates.
Local viewray = this, getlocalviewray m.
Intersect the plane with the view ray.
Local projectedpoint = [0,0,0].
Local res = pl, intersect viewray &projectedpoint.
Format % : % : % : %\nViewray projectedpoint gizpues which.
If the intersection worked, set the fallof.
If (res) then.
(Projectedpoint = gizpues - Projectedpoint.
Local size = sqrt(projectedpoint.x2+ projectedpoint, y2+ projectedpoint, z2).
If targclass == editable_poly then target, fallof = size.
Else if targclass == editable_mesh then (meshop, setuiparam target #fallof size;update node geometry:false topology:false normals:false) -meshop UI parameter setters broken).
).
Catch()).
).