Snap¶
Status: Alpha release
Last Updated: 27 October 2017
Overview¶
cgmSnap is a new tool that refactors some functions we had around the toolbox as well as a fresh push of new features in November 2017. You can access features by our marking menu, a standalone ui and the top cgm menu.
Until we get embeded video sorted. Please use this link: https://vimeo.com/205492894 to see the marking menu implementation.
What can I do with it?
- Do basic snapping with a myriad of pivot targets
- Raycast snapping and aiming
- Match snapping tools for updating items on the fly
- Use various pivot options for snapping without affecting object's pivot
Pivots¶
In general, positional snapping works by rotatePivot(rp) as that is the main pivot an animator uses in maya. A pivot is a point in space. There are tools for changing pivots on the fly when animating (see DynParenTool for our implemenation of that). These tools allow you to access a lot more options while not changing the underlying pivots. Let's first talk about the kinds of pivots we'll be working with.
rotatePivot(rp)¶
The main pivot maya uses. When you translate or rotate in general in maya you're working with this point. This is the default pivot for any snapping and querying functions.
scalePivot(sp)¶
In maya you have the ability to change the scale pivot of an object separate from its rotation pivot. An example of this we use is for scaling the foot for example where the rp is at the ankle and the sp is at on the ground to scaling the foot doesn't push it into the floor.
closestPoint(cp)¶
This is one the first of our special positions we use. Given a object to snap and a group of targets, it will find the closest point on all shapes of the target objects. These calls support shapes of the following types: nurbsCurve, nurbsSurface and poly
boundingBox(bb)¶
Maya's bounding box call is a world centric box encompassing the shapes of the target objects or components. Commonly this is a part of resetting pivot points to the center of the object's shapes for example.
In addition we have some additional mode calls for this:
center
- Default mode with bounding box queries. The center of the boxfront/z+
- Directionally speaking we consider z+ forward and y+ as upback/z-
top/y+
bottom/y-
left/x+
right/x-
axisBox(ab)¶
A new concept we're experimenting with. This is a local space bounding box where the box follows the local rotational data of the target. The initial reason for this was for getting certain positions with nurbs controls which don't work with rayCasting. Supports the same mode calls as boundingBox.
groundPos¶
The z/x clamped value of the target's rp.
casts¶
Casts utilize our rayCasting calls. For pivots we're using those casts to get new point information.
castCenter
- Given a point to cast from. Cast two opposing vectors to figure out the mid point of that cast.castNear
- Closest hit from targeted surfacescastFar
- Furthest hit from targeted surfacescastAllNear
- Closest hit from all surfaces (except self)castAllFar
- Furthest ...
Accessing¶
UI - Standalone
- Top cgm menu -
CGM > Snap > Snap UI
- Marking menu (several of them) -
SnapThat
- Top cgm menu -
UI - Nested
- You can find most of the tools nested in the cgmToolbox
Python
import cgm
cgm.core.tools.lib.tool_calls.cgmSnapTools()
UI¶
If you open the stand alone ui, you should see something like this image below. When seen from the cgmToolbox it'll just look like the fly out sections in that ui.
Snap¶
Functions for snapping items around. In general, they function on a selection basis with all targeting the last.
Point
- To the last selected objectPoint - Closest
- To the closest point on the last surface,curve,shapeParent
- Position and orientationOrient
- rotation onlyRayCast
- Uses the rayCast options to detect a point in space
Match Mode¶
Options for how matching matches.
point
- Position onlyorient
- Orientation onlypoint/orient
- Both
MatchSnap¶
If an object is tagged to a cgmMatchTarget, will match the object to the match target. For example, if it is an updatable object, it will update.
Self
- Update the selected object to their respective match targetsTarget
- Updates the selected's match targets to the selectedBuffer
- Update utilizing the match buffer
Arrange¶
Along Line (Even)
- Arrange selected along line from frist to last evenlyAlong Line (Spaced)
- Arrange selected along a line snapping middle objects to their nearest point on the line
Aim¶
Functions for aiming items around. In general, they function on a selection basis with all targeting the last.
Aim
- Currently uses object defaults from Menu. Will take into account object tagging in future.Sel Order
- Aim all selected objects in selection order with the last aiming back at the previous oneFirst to Mid
- First object aims at the midpoint of the rest of the selectionAimCast
- Uses rayCasting to aim selected objects in real time at a point of intersection
Mode¶
local
- Use local vector based on object defaults OR stored aiming optionsworld
- Use world vectormatrix
- IN DEVELOPMENT Bokser is playing around
Object Defaults¶
Because assumptions are often wrong.
Obj Aim
- Aim axisObj Up
- Up axisObj Out
- The local out axis for vector work. Out is rarely used and may be deprecated.
Tag Selected for Aim
- Adds attributes to selected objects to make them aimable on their own axis regardless of defaults
Advanced¶
Until we get embeded video sorted. Please use this link: https://vimeo.com/244879615
Advanced snapping functions to access more pivotal data options.
In general with advanced snapping we have our object which is what we want to snap and any targets there after in our selection which are where we will get or target position from.
Note
These functions don't modify the rp of the object to snap unless specified. Instead we use a vector from our rp to the requested obj pivot point and that distance to offset the rp from the target position
Obj Pivot
- What pivot of our object to snap we want to work with.Obj Mode
- Which mode. See breakdown in bb for more details. Applies toaxisBox
andcast
as wellTarget Pivot
- What target position we wantTarget Mode
- What mode for the target queries
We also have flags to specify what we want to do with the data.
pos
- Snap to the position of the queried datarot
- Snap to the rotation of the first targetra
- RotateAxis ...ro
- RotateOrder ...sp
- Move the scalePivotrp
- Move the rotatePivot
Finally, do something with the data.
Snap
- Actually do the snappingSeq
- Perform snapping in a sequence of one to the next in reverse order to account for dependencies. For exampleobj1,obj2,obj3
will be done asobj2>obj3
thenobj1>obj2
.Query
- Query mode. Just report to the scirpt editor
Tip
For example if you want to snap the bottom of the object you could use the axisBox
objPivot and y-
mode