I am trying to learn how to use the Maya API by making a type of sculpting brush. I have it working almost perfectly, except for a couple things...
When the user drags the cursor over the model, I want the model to visually deform in real time. Right now, as the user drags the cursor, the model doesn't change, but one the user releases the mouse button, everything gets changed all at once. I do not even have a doRelease function in my MPxContext class -- just doPress and doRelease.
Also, when the user drags, I'd like a box around the cursor that shows the selected area. Right now, I have it draw a square, and that part works, but the screen doesn't clear for each time step. So when the user drags, a long string of little squares follows along with it. The squares go away after the user releases, though (maybe it has something to do with the problem above?). Here is the relevant section of code:
// clear the overlay planes
// Set up the orthographic projection matix
glMatrixMode( GL_PROJECTION );
gluOrtho2D( 0.0f, m_View.portWidth(),
0.0f, m_View.portHeight() );
glMatrixMode( GL_MODELVIEW );
// Set line width
glLineWidth( 1.0 );
// Draw rectangle
glBegin( GL_LINE_LOOP );
glVertex2i( min.h, min.v );
glVertex2i( min.h, max.v );
glVertex2i( max.h, max.v );
glVertex2i( max.h, min.v );
// done drawing our overlay on the viewport
One last thing (for now)... Whenever I want to use my brushtool, I have to load the program, enter "smoothbrush" (my plugin name) into the command line, and then enter "setToolTo smoothbrushX" where X is some number. Is there a way to streamline this? Maybe make a button or something?
Thanks in advance!