Fri, Dec 23rd, 2016
posted by jjburton 09:12 PM

First of all, what is ray casting? Ray casting in maya is when one of several api functions is called which when given a vector, start point and shapes to hit – returns points of intersection.

Turns out you can use that information for all kinds of things. For several years now, we’ve been using it to place follicles, cast curves and shapes on other meshes and other functions. A few months ago, I took a quick pass at adding a snap to function to our implementation where a user selects objects to snap, activates the tool and then casts a ray in scene to get a point in space to snap to. It worked but penetrations were rampant and I planned on revisiting it when I had some time.

Recently I found I had small chunks of time and this was one of the things that seemed useful to use one of those chunks for.

The solution we ended up with is as follows:

  1. Objects are selected
  2. The tool is activated
  3. The user left clicks the screen to cast a ray given the options they’ve provided via the marking menu
  4. A locator is generated and continuously updated while the key is held down
  5. When the left click is released, the snap targets:
    1. Cast another ray either along their ‘down’ axis or casting back to the hit point depending or orient mode
    2. The first mesh hit is assumed to be the driven shape of the control or object and provides the offset distance to use
    3. The targets are snapped to a new point in space from the hit point out along the normal of the mesh or nurbs surface of that hit the offset distance detected or provided via the marking menu for fixed amount
    4. The objects are oriented (if required

The core of our functionality for this work on this pass is found:

  • cgm.core.lib.rayCaster — I simplified our call to a more generic rayCaster.cast rather than breaking down multi hit and other modes via separate calls. Also added normal returns from hit points as it was necessary for the offseting
  • cgm.core.classes.DraggerContextFactory.clickMesh — oh so much…
    • Added offsetting
    • Cast plane mode. Can create objects on a function generated cast plane of x,y,z
    • vectorLine — new create type for visualizing vectors and normals
    • data — new create type to just get data
    • object axis args — for orient stuff
    • Duplication — Selected objects are duplicated and snapped with each left click until the tool is dropped.
  • cgm.core.lib.math_utils.get_vector_of_two_points — Self evident.
  • cgm.core.lib.distance_utils.get_pos_by_vec_dist —  Get a point along a ray given a point, ray and distance along that ray

Lessons learned:

  • Not 100% satisfied on current orient mode and I think Bokser may take a stab at that
  • Maybe I was the only one still using it but zoo’s baseMel UI has some serious slowdown in 2016. Normal mc. calls are much much faster. I’m culling out our usage as I can for speedier ui’s.
  • Initially I was using a vector from the hit point to the snap object as the offset vector but it proved to be inconsistent – For example, if you cast to a far side of a mesh with a ‘far’ cast, the offset put it inside the shape that was hit. Ended up finding the normal of the mesh/nurbs shape hit point to be a much better offset vector to use.
  • There are some issues with Maya api 2.0 folks should be aware of if you should want to mess with this stuff yourselves. These were all found to be True in Maya 2016.
    • meshFn.allIntersections — When casting at poly edges, 2.0 fails. 1.0 does not
    • surfaceFn.intersect — Nurbs surface UV returns a different rawUV than 1.0’s. 1.0’s normalizes as expected, 2.0’s does not
    • surfaceFn.normal — Nurbs surface normal return is junk and broken with 2.0. 1.0’s is just fine.

More on all of this, a vid or two and a new tool to play with in a few weeks.

Wed, Sep 21st, 2016
posted by jjburton 11:09 AM

More vids on specific tool pages. See links inline

Sometimes you just gotta ship something.

For a LONG time now, I’ve been struggling to get Morpheus 2 where I wanted it. Having a small window to get something done because of personal stuff, I wanted to get something done. It’s also been way too long since we’ve released a ‘solid’ tool build so wanted to do that here.

I’ll keep this post updated with new builds as they become more stable until the next major release.

  • Build – 09.22.2016
    • Path fixes that may have been causing some folks issues
    • Soft selection evaluation base functions in
    •  math
      • Most math functions now work with soft select evaluation
      • Added Reset to Targets to Base section
      • Added CopyTo to Target Math section
  • Build – 09.21.2016

So, I made a new tool encompassing a chunk of the tech from Morpheus 2’s development into a manner that is more user friendly. An overview of some of the tech added:

  • Versions — Things should be working from Maya 2011 – 2017
    • 2017
      • Worked on resolving a host of issues. From gui hard crashing to zoo.path stuff mentioned in a blog post last month.
  • Help — cgmTools>Help
    • Added Report issue — link to bit bucket report issue form. Please use this to re port issues.
    • Get Builds — link to page to download wip builds
  • cgmMeshTools — cgmTools>rigging>cgm.meshTools.
    •  MeshMath
      • Symmetry evaluation implemented
      • Base to targed functions/selections
      • Lots of math functions for working with mesh targets – normally blendshape work.
    • Ray Casting
      • ClickMesh
        • Added Nurbs Support
        • Added Snap support – Select targets, activate and snap stuff to any geo you have loaded as targets or in the scene. This is something I wanted to do way back when I first started playing with rayCasting and I’m happy to check that box
        • Follicles on nurbs now work
      • Curve Slice — Lathe curves from objects within mesh objects
      • Curve Wrapping — More advanced curve lathing
      • Implemented multi surface casting to most functions
    • Utils
      • Proximity Mesh/Query — Create proximity mesh or selections from one mesh to another
  • Snap Making Menu — cgmTools>Hotkeys>Snap Tools
    • Added the rayCasting snap
  • cgmMeta
    • A lot of the optimization from last month is in the build.
  • Web documentation
    • Check the side bar here to find the new tool sections (meshTools, cgmMMSnap)
  • cgmHotkeyer
    • Back with Maya 2016, zoo’s hotkey setup no longer worked because of Maya changes. We wrote our own and all hotkey setup uses that now.
  • Other stuff – as the last post released build was years ago, there is a HUGE amount of tools and functions implemented.



Fri, Sep 2nd, 2016
posted by jjburton 09:09 PM

So I got a message from a user on Thursday saying that cgmToolbox didn’t work in Maya 2017. Got around to installing 2017 and yup – borked. Spent the evening on Thursday identifying this issue and Friday was fix day.

If you don’t care about what was wrong and just want the bottom line — cgmToolbox should be working in 2017 Maya with the new build I’ll be pushing to the repository shortly.

If you do care…

NOTE – If you use use zooToolbox and specifically zooPy.path.Path (or zoo.Path as I’ll call it), this post would behoove you to look at unless you like stumbling down the same rambling trail others have tread.

Been using zoo stuff for well over 5 years now and Hamish(creator of zooTools) is out of the game last I knew so I decided I had best fix the problem as googling the topic got jack squat and my usual sounding boards hadn’t come across it yet.

Initially I thought Autodesk had gone and changed something and blew up my stuff but at the end of the day it turned out to be the fact that the python that 2017 is running updated the python str class. It just so happens that zoo.Path runs that as a subclass and was overloading some built in calls (find and replace specifically). Anyway, there is a walk generator for path stuff that pushing an instance of the zoo.Path into it rather than a ‘native’ string. Part of that (new to 2017) walker calls on ‘replace’ and so breaks because it needs to replace the path separator which zoo.Path specifically avoids in it’s overload.  zoo.Path’s replace is ONLY for replacing tokens between the separators.

Long story short, that raises an error of ‘/’ cannot be indexed because the find call (in zoo.Path) is specifically removing in it’s searching.

Interesting tidbits:

  • With 2017, os.path.sep is now ‘\\’ up till 2017, it’s been ‘\’ at least all the way back to Maya 2011. On windows at least
  • Something changed with the os.walk generator to make it not work as it did before 2017. Maybe it used to str(arg) stuff in the process and now just passes through the string. Whatever the reason, it broke.
  • import sys || sys.version — gives you your python version. If you’re curious 2017’s is 2.7.11

Some code changes

  • zooPy.path.Path — If you have old versions of zoo installed and trying to run stuff in 2017. It’s gonna break on you if it hasn’t already. You can use this or do your own patch:)
    • osPath — call to return a os.path.sep joined version of the path. Path natively works with ‘/’ and the new double ‘//’ messes with stuff
    • _list_filesystem_items — changed the walk creator to use a osPath string to stop the failing
  • Cleaned out a bunch of stuff from __init__ files. — I’d had some built in calls for listing files and getting other info back before I knew the right way to do it or at least a better one.
  • cgmToolbox
    • clean_scriptPaths/clean_pluginPaths — The call that was breaking stuff were my path setup stuff. As such, the env for these guys got a little borked during the troubleshooting. This was a quick attempt at fixing stuff. As an experiment, this may or may not be reworked.
      • Check all paths for valid paths (will add to the env without failing)
      • Removed a bunch of .git stuff that some other scripts I’d used from someone else apparently added.
      • Acts as a report for what’s there if you didn’t know as it reports all good ones
  • core.cgmPy.os_Utils
    • get_lsFromPath — reworked from the __init__ cleanup. Accepts file paths now and just gets the director they’re in for searching

Now I can get back to cgmBlendshape for Morphy 2. Wrote some fun mesh math stuff toward that end earlier in the week as well but that’s a post for another day…:)


Tue, Oct 16th, 2012
posted by jjburton 02:10 PM

Finally got this little bit of R&D in a functioning tool.

After looking into that bug at the end, it was messing up because this version of the Morphy proxy geo had messed up UV’s. Follicles need decent UV’s to work. Will look at adding a check for decent UV’s.


  • Add target mesh objects with the ‘>>’ button
  • Modes:
    • Surface – places on the surface
    • Bisect – places at every contact of the cast ray on the object(s)
    • MidPoint – finds the midpoint of hit points
  • Drag – whether you want creation as you drag or not. Default is only on mouse release
  • Clamp – how many intersection are allowed, 0 means infinite
  • Create Modes – all but locator and joint will create when you drop the tool or press ‘q’ on most maya default setups
    • locator
    • joint
    • jointChain
    • curve
    • follicle
    • group — only a transform at that spot
  • Start – initializes tool
  • Drop – finalizes it (or ‘q’)

To do in the future:

  • mirror mode
  • skinDeep mode – for placing joints just within the surface for facial work
  • Add a check to make sure a mesh has suitable UV’s