MaxScript Release 0.11 Source for max 4 (02/18/2001)
Copyright (c) 2001 by Borislav Petrov, Bobo's
Symmetry is a set of max
4 functions and macroscripts (ActionItems) meant for usage in the QuadMenus,
Toolbars or as Shortcuts.
It was rewritten from scratch and is many
hundred times faster, but is very similar in its functionality to the old
Symmetry script for MAX R3.
It will let you select (automatically
or manually) the symmetrical sub-object elements (vertcies, edges and faces)
while modeling with polygons
(esp. characters for SubDiv modeling)
Symmetry II consists of a set of functions
located in the file SYMMETRY_FUNCTIONS.MS and some Macroscripts in
the form SYMMETRY_ABC.MCR.
Download the distribution
Unzip the .MS file to your \STDPLUGS\STDSCRIPTS
Unzip the .MCR files to your \UI\MACROSCRIPTS
Unzip the .BMP icon files to your \UI\ICONS
Start max 4,
Go to Customize>Customize User Interface,
find Category "Symmetry Modeling" and build a QuadMenu, a Menu, or assign
Shortcuts to the single commands.
(Alternatively you can drag&drop the
items to a toolbar)
BASICS OF SYMMETRY
The following video
shows the VERY basics of the tool (Divx AVI, 5MB)
The current version works on PolyObjects (Vertex,
Edge and Face level), and EditableMeshes (Vertex level only, more to come)
The StackView must be at Base level, with
Show End Result turned off. Select Modifiers not supported yet.
There are two ways to use Symmetry:
Mirror and AUTO Mirror.
When using the Manual modes, select
some sub-object elements on the one side of the object, then execute Mirror
Along X, Mirror Along Y, etc. ActionItems. The corresponding elements will
become selected on the other side.
The current mode will be respected, this means
that using the same command, selecting vertices will select corresponding
vertices, selecting edges will select corresponding edges etc. NOTE that
when working with EMeshes, only vertices will be selected (edges and faces
support coming later).
When selecting one of the Auto modes, a checkmark
will appear in the QuadMenu and the mode will remain active until unchecked
Any combination of Auto Modes can be active
at any time. You can toggle both X and Y Mirror modes for example, or even
all 3 at the same time.
When in Auto Mirror mode, selecting sub-object
elements will select the corresponding elements immediately. The mouse
cursor will display a Wait symbox (sandclock) while working in large meshes.
Mirror Along X mirrors the current
sub-object selection relatively to the YZ plane (left-right), looking for
a symmetrical sub-object along the X axis. It is a MANUAL action performed
just once when picked.
Mirror Along Y mirrors the current
sub-object selection relatively to the XZ plane (front-back), looking for
a symmetrical sub-object along the Y axis. A MANUAL one.
Mirror Along Z mirrors the current
sub-object selection relatively to the XY plane (top-bottom). A MANUAL
Mirror In XY Plane mirrors the current
sub-object selection along the X axis first, then along the Y axis. It
is equivalent to picking Mirror Along X and then Mirror Along Y.
Mirror In XZ Plane and
YZ Plane do the same with the other two axes.
Mirror In 3D Space performs all 3 Mirrors
(X, Y, then Z).
AUTO Mirror Along X is the AUTOMATIC
version of Mirror Along X. When enabled, it will stay active until turned
off again. A checkmark will appear in the QuadMenu.
AUTO Mirror Along Y and
Along Z are the respective AUTOMATIC switches for the other two axes.
You can activate them in combinations to get AUTO Mirror In Plane.
Force Database Rebuild performs a rebuild
of the database. Use whenever the topology has changed and a Manual Action
is desired. The AUTO Actions will do this by themselves.
Customize Symmetry Settings is a dialog
controlling some of the preferences. It is for advanced users ONLY and
should not be changed most of the time.
Symmetry uses the local object
axes to define the planes of symmetry. "Symmetry along X" means "Mirror
relatively to YZ Plane".
To change the symmetry plane, adjust the Pivot
Point using Hierarchy>Affect Pivot Only, then apply Reset X-Form Utility
Symmetry maintains a voxel-based
3D database of all vertices in the current object. The image bellow shows
how it works:
The green point to
the right is the original selected vertex to be mirror-selected along the
The red pointis
the symmetrical vertex to be selected.
The red plane
shows the local XZ plane used as a plane of symmetry.
Symmetry divides the object space into Voxels
(Spatial SubDivisions). On the image, there are 10x10x10 Voxels, 1000 altogether.
Each vertex of the teapot is inside of exactly one Voxel, so are the green
and red vertices.
Symmetry writes down the indices of all vertices
found in each Voxel. This is the process called "Database Rebuilding".
This way by looking at only 1/1000 of the volume it can quickly find the
desired vertex without accessing all vertices in the mesh.
Symmetry finds the Voxel the green vertex
resides in (Voxel is shown in green, too).
Then it searches for the Voxel with spatial
coordinates that are symmetrical to the green Voxel - this Voxel (shown
in red) has the exactly same X and Z coordinates, but the Y
is mirrored relatively to the plane of symmetry.
Now that it knows which Voxel to check, it
can look at the Database and compare the positions of the few vertices
found in the current Voxel to the expected position of the symmetrical
vertex. If there is a vertex inside the threshold, it gets selected.
Face and Edge selections are handled at vertex
level. For each Edge, two vertex queries have to be performed. For a Quad,
there are four checks. If all of them return valid symmetry results, the
Edge/Face containing these symmetry vertices gets selected.
This database is created when an object is
being selected for the first time. The database should be updated after
a change in topology. When in AUTO Mirror mode, this will occur automatically
- two callbacks will be monitoring the topology (new / deleted elements)
and geometry (existing elements changing position) and will flag
the mesh as changed, but will not update the database immediately. Whenever
a new selection is requested, the database will be updated first and the
flag will be set to valid again. This means that the database will be updated
only when necessary.
When in MANUAL mode, the datatbase will never
be updated unless the user changes between objects, or calls the Force
Database Rebuild action explicitly.
The database update times depend on the number
of vertices in the mesh and the number of voxel subdivisions. The default
value of voxel subdivisions is 10. Reducting this value down to 2 will
speed up rebuild times, but will slow down selection operations significantly!
Increasing the value (up to 20) will increase rebuild times, but will speed
up search times. With typical meshes bellow 5000 vertices, the default
of 10 should be ok.
The table bellow shows the results of a test
performed with a Plane object with 32x32 segments converted to PolyObject.
Note that with low Voxel settings, rebuilding takes short time, but each
voxel contains too many vertices which slows down the search times. Increasing
Subdivisions speeds up the Search with best results around 9-10 subdivisions.
Values over 10 do not speed up the Search significantly, but increase Rebuild
times. With increasing number of vertices these results may vary...
Symmetry In PolyObject Mode
1089 Vertices, 2048 Faces.
561 Symmetry Points Found.
Voxel Subdivisions / Total
Database Rebuilt in:
|2 / 8
|3 / 27
|4 / 64
|5 / 125
|6 / 216
|7 / 343
|8 / 512
|9 / 729
|10 / 1000
|11 / 1331
|12 / 1728
|15 / 3375
|18 / 5832
|20 / 8000
The symmetrical vertex will be selected based
on a user-defined Search Threshold. This means that the symmetical vertex
can be inside a certain tolerance. The default threshold value is 0.1 units.
The default search method is "First
In Threshold" which means "find the first symmetrical
vertex inside the threshold and voxel". It is the fastest method, but somewhat
unprecise when the threshold value is higher than the shortest edge length.
The original selected vertex will be taken and its Voxel will be acquired.
Then the symmetrical voxel on the other side of the mirror plane will will
be searched for a possible mirror vertex with a coordinate around the expected
mirror position +/- the threshold. The first vertex that
falls inside the threshold will be picked. If there are other vertices
with higher indices in the mesh that are closer, they will be ignored.
The second method "Nearest In Threshold"
tests ALL vertices in the voxel for the threshold AND their
distance to the expected location, and picks the one that is closest. This
method is the slowest but yields the best results.
The third search method "Nearest In
Voxel" will tests ALL vertices inside the voxel and pick the closest
one without an additional threshold. In this case, the voxel size is used
as the threshold. Results depend highly on the Voxel Divisions value.
Symmetry filters out any redundancy
in the selection. If you select all 100 vertices in a mesh and each vertex
has a corresponding symmetrical vertex, only 50 queries will be performed.
Some internal values have been exposed to
the user through a Dialog - use the Customize Symmetry Settings macroscript
if you feel fit. If you get unexpected results, press the "RESET to Defaults"
Symmetry can be set up to print
detailed information about the searching process in the MAXScript listener
EMesh currently supported in Vertex Mode only
You cannot DESELECT sub-objects while in AUTO
Mirror Mode. You have to toggle it off, deselect, then toggle on again.
Version 0.11 Source