예제 #1
0
/* override */
bool apiSimpleShapeUI::select( MSelectInfo &selectInfo, MSelectionList &selectionList,
					MPointArray &worldSpaceSelectPts ) const
//
// Description:
//
//     Main selection routine
//
// Arguments:
//
//     selectInfo           - the selection state information
//     selectionList        - the list of selected items to add to
//     worldSpaceSelectPts  -
//
{
	bool selected = false;
	bool componentSelected = false;
	bool hilited = false;

	hilited = (selectInfo.displayStatus() == M3dView::kHilite);
	if ( hilited ) {
		componentSelected = selectVertices( selectInfo, selectionList, worldSpaceSelectPts );
		selected = selected || componentSelected;
	}

	if ( !selected ) 
	{
		// NOTE: If the geometry has an intersect routine it should
		// be called here with the selection ray to determine if the
		// the object was selected.

		selected = true;
		MSelectionMask priorityMask( MSelectionMask::kSelectNurbsSurfaces );
		MSelectionList item;
		item.add( selectInfo.selectPath() );
		MPoint xformedPt;
		if ( selectInfo.singleSelection() ) {
			MPoint center = surfaceShape()->boundingBox().center();
			xformedPt = center;
			xformedPt *= selectInfo.selectPath().inclusiveMatrix();
		}

		selectInfo.addSelection( item, xformedPt, selectionList,
								 worldSpaceSelectPts, priorityMask, false );
	}

	return selected;
}
예제 #2
0
		bool BaseShapeUI::select( MSelectInfo &selectInfo, MSelectionList &selectionList, MPointArray &worldSpaceSelectPts ) const {
			// Should never happen
			//
			if (!s_drawData.initialized) {
				std::cerr << "Can't do selection, OpenGL context not initialized!" << std::endl;
				return false;
			}

			//BaseShape *shape = (BaseShape *) surfaceShape();
			MStatus status;

			M3dView view = selectInfo.view();
			const MDagPath & path = selectInfo.multiPath();

			view.beginSelect();

			glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
			glEnableClientState(GL_VERTEX_ARRAY);
			glVertexPointer(3, GL_FLOAT, 0, Data::BackboneArrowVerts);

			glDrawArrays(GL_TRIANGLES, 0, Data::BackboneArrowNumVerts);

			glPopClientAttrib();

			if ( view.endSelect() > 0 )     // Hit count > 0
			{
				MSelectionMask priorityMask( MSelectionMask::kSelectObjectsMask );
				MSelectionList item;
				item.add( selectInfo.selectPath() );
				MPoint xformedPt;

				xformedPt *= path.inclusiveMatrix();
				selectInfo.addSelection( item, xformedPt, selectionList, worldSpaceSelectPts, priorityMask, false );

				return true;
			}

			return false;
		}