CHaMUE_2 and CHaMUEBary
I rewrote a previous version of our on-mesh drawing tools from scratch in order to integrate them in our new project (CHaMUE_2) and to make them freeform-compatible. In particular, I used barycentric coordinates in order to attach drawn line samples to distinct polygons, instead of storing them as an isolated data structure in world coordinates. I implemented two tools: the , which checks PHANToM contact states to store cursor positions in the CHaMUEBary structure, and th e, which instead requires mesh collision detection with arbitrary line segments (a function provided by H-Collide, an "upgrade" to the Ghost API).
The CHaMUEBary hierarchy
Creation of a hierarchy for freeform-compatible line drawing (CHaMUEBary, subproject to the CHaMUE_2 project):
As can be seen from the above hierarchy, it is easy to turn off all users' lines on a given mesh, but difficult to turn off a given user's lines on all meshes. All of these classes are really wrappers for STL-VECTORs of objects of the lower level class (plus nice functions)
How CHaMUE_2 uses CHaMUEBary for the Brush and Laser
All of the above is a CHaMUE_2-independent "project", and only has Ghost3.1 as a dependency. The CHaMUE_2 project itself depends on BOTH CHaMUEBary and Ghost3.1 (and math and network and...) Now, this CHaMUEBary hierarchy is used and updated by the Linehandler class (itself in the main CHaMUE_2 project), which uses CHaMUEBary for both spray and brush drawing modes of course. Most of the LineHandler code is about updating the CHaMUEBary structure correctly upon new line creation, line termination, or switching from one mesh to another while drawing a given line. A LineHandler instance is stored with every CComMesh instance, ie there is one LineHandler per mesh.
Needed intersection and triangle information is provided by:
The spraypaint class, which calculates laser intersection and triangle information, makes it easily accessible to LineHandler. It also contains drawing code for an extension to the cursor: the actual laser line (gray when inactive, red when drawing, halting exactly at the first mesh intersection)
(Originally laser mode was implemented by creating a hack in the CHaMUEBary hierarchy, avoiding the need for barycentric information. Then integration of HCollide made the above laser features fully functional, but required an IF-DEF coding structure, mostly present in the CHaMUEBary and classic mesh classes. In brief, when you write code, you have to make sure it works with and without H-Collide enabled, which sometimes requires to duplicate code and use IF-DEF.)
In brief, a given mesh's LineHandler is called from the CHaMUE graphics loop (CHaMUE_2View, which here runs the ModePolyline update) either because: