MBoundingBox footPrint::boundingBox() const { // Get the size // MObject thisNode = thisMObject(); MPlug plug( thisNode, size ); MDistance sizeVal; plug.getValue( sizeVal ); double multiplier = sizeVal.asCentimeters(); MPoint corner1( -0.17, 0.0, -0.7 ); MPoint corner2( 0.17, 0.0, 0.3 ); corner1 = corner1 * multiplier; corner2 = corner2 * multiplier; return MBoundingBox( corner1, corner2 ); }
MBoundingBox swissArmyLocator::boundingBox() const { // Get the size // MObject thisNode = thisMObject(); MPlug plug(thisNode, aSize); MDistance sizeVal; plug.getValue(sizeVal); double multiplier = sizeVal.asCentimeters(); MPoint corner1(-1.1, 0.0, -1.1); MPoint corner2(1.1, 0.0, 1.1); corner1 = corner1 * multiplier; corner2 = corner2 * multiplier; return MBoundingBox(corner1, corner2); }
float FootPrintDrawOverride::getMultiplier(const MDagPath& objPath) const { // Retrieve value of the size attribute from the node MStatus status; MObject footprintNode = objPath.node(&status); if (status) { MPlug plug(footprintNode, footPrint::size); if (!plug.isNull()) { MDistance sizeVal; if (plug.getValue(sizeVal)) { return (float)sizeVal.asCentimeters(); } } } return 1.0f; }
float convert( const MDistance &from ) { return from.asCentimeters(); }
// called by legacy default viewport void footPrint::draw( M3dView & view, const MDagPath & /*path*/, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { // Get the size // MObject thisNode = thisMObject(); MPlug plug( thisNode, size ); MDistance sizeVal; plug.getValue( sizeVal ); float multiplier = (float) sizeVal.asCentimeters(); view.beginGL(); if ( ( style == M3dView::kFlatShaded ) || ( style == M3dView::kGouraudShaded ) ) { // Push the color settings // glPushAttrib( GL_CURRENT_BIT ); if ( status == M3dView::kActive ) { view.setDrawColor( 13, M3dView::kActiveColors ); } else { view.setDrawColor( 13, M3dView::kDormantColors ); } glBegin( GL_TRIANGLE_FAN ); int i; int last = soleCount - 1; for ( i = 0; i < last; ++i ) { glVertex3f( sole[i][0] * multiplier, sole[i][1] * multiplier, sole[i][2] * multiplier ); } glEnd(); glBegin( GL_TRIANGLE_FAN ); last = heelCount - 1; for ( i = 0; i < last; ++i ) { glVertex3f( heel[i][0] * multiplier, heel[i][1] * multiplier, heel[i][2] * multiplier ); } glEnd(); glPopAttrib(); } // Draw the outline of the foot // glBegin( GL_LINES ); int i; int last = soleCount - 1; for ( i = 0; i < last; ++i ) { glVertex3f( sole[i][0] * multiplier, sole[i][1] * multiplier, sole[i][2] * multiplier ); glVertex3f( sole[i+1][0] * multiplier, sole[i+1][1] * multiplier, sole[i+1][2] * multiplier ); } last = heelCount - 1; for ( i = 0; i < last; ++i ) { glVertex3f( heel[i][0] * multiplier, heel[i][1] * multiplier, heel[i][2] * multiplier ); glVertex3f( heel[i+1][0] * multiplier, heel[i+1][1] * multiplier, heel[i+1][2] * multiplier ); } glEnd(); view.endGL(); // Draw the name of the footPrint view.setDrawColor( MColor( 0.1f, 0.8f, 0.8f, 1.0f ) ); view.drawText( MString("Footprint"), MPoint( 0.0, 0.0, 0.0 ), M3dView::kCenter ); }
MStatus Molecule3Cmd::redoIt() { MStatus stat; MDagPath dagPath; MFnMesh meshFn; // Create a ball int nBallPolys; MPointArray ballVerts; MIntArray ballPolyCounts; MIntArray ballPolyConnects; MFloatArray ballUCoords; MFloatArray ballVCoords; MIntArray ballFvUVIDs; genBall( MPoint::origin, ballRodRatio * radius.value(), segs, nBallPolys, ballVerts, ballPolyCounts, ballPolyConnects, true, ballUCoords, ballVCoords, ballFvUVIDs ); unsigned int i, j, vertOffset; MPointArray meshVerts; MPoint p0, p1; MObject objTransform; // Setup for rods int nRodPolys; MPointArray rodVerts; MIntArray rodPolyCounts; MIntArray rodPolyConnects; MFloatArray rodUCoords; MFloatArray rodVCoords; MIntArray rodFvUVIDs; // Setup for newMesh int nNewPolys; MPointArray newVerts; MIntArray newPolyCounts; MIntArray newPolyConnects; MFloatArray newUCoords; MFloatArray newVCoords; MIntArray newFvUVIDs; int uvOffset; MDagModifier dagMod; MFnDagNode dagFn; objTransforms.clear(); // Iterate over the meshes unsigned int mi; for( mi=0; mi < selMeshes.length(); mi++ ) { dagPath = selMeshes[mi]; meshFn.setObject( dagPath ); uvOffset = 0; nNewPolys = 0; newVerts.clear(); newPolyCounts.clear(); newPolyConnects.clear(); newUCoords.clear(); newVCoords.clear(); newFvUVIDs.clear(); // Generate balls meshFn.getPoints( meshVerts, MSpace::kWorld ); for( i=0; i < meshVerts.length(); i++ ) { vertOffset = newVerts.length(); // Add the ball to the new mesh nNewPolys += nBallPolys; // Move the ball vertices to the mesh vertex. Add it to the newMesh for( j=0; j < ballVerts.length(); j++ ) newVerts.append( meshVerts[i] + ballVerts[j] ); for( j=0; j < ballPolyCounts.length(); j++ ) newPolyCounts.append( ballPolyCounts[j] ); for( j=0; j < ballPolyConnects.length(); j++ ) newPolyConnects.append( vertOffset + ballPolyConnects[j] ); // Only add the uv coordinates once, since they are shared // by all balls if( i == 0 ) { for( j=0; j < ballUCoords.length(); j++ ) { newUCoords.append( ballUCoords[j] ); newVCoords.append( ballVCoords[j] ); } } for( j=0; j < ballFvUVIDs.length(); j++ ) { newFvUVIDs.append( uvOffset + ballFvUVIDs[j] ); } } uvOffset = newUCoords.length(); // Generate rods int nRods = 0; MItMeshEdge edgeIter( dagPath ); for( ; !edgeIter.isDone(); edgeIter.next(), nRods++ ) { p0 = edgeIter.point( 0, MSpace::kWorld ); p1 = edgeIter.point( 1, MSpace::kWorld ); // N.B. Generate the uv coordinates only once since they // are referenced by all rods genRod( p0, p1, radius.value(), segs, nRodPolys, rodVerts, rodPolyCounts, rodPolyConnects, nRods == 0, rodUCoords, rodVCoords, rodFvUVIDs ); vertOffset = newVerts.length(); // Add the rod to the mesh nNewPolys += nRodPolys; for( i=0; i < rodVerts.length(); i++ ) newVerts.append( rodVerts[i] ); for( i=0; i < rodPolyCounts.length(); i++ ) newPolyCounts.append( rodPolyCounts[i] ); for( i=0; i < rodPolyConnects.length(); i++ ) newPolyConnects.append( vertOffset + rodPolyConnects[i] ); // First rod if( nRods == 0 ) { // Add rod's uv coordinates to the list for( i=0; i < rodUCoords.length(); i++ ) { newUCoords.append( rodUCoords[i] ); newVCoords.append( rodVCoords[i] ); } } // Set the face-vertex-uvIDs for( i=0; i < rodFvUVIDs.length(); i++ ) { newFvUVIDs.append( uvOffset + rodFvUVIDs[i] ); } } objTransform = meshFn.create( newVerts.length(), nNewPolys, newVerts, newPolyCounts, newPolyConnects, newUCoords, newVCoords, MObject::kNullObj, &stat ); if( !stat ) { MGlobal::displayError( MString( "Unable to create mesh: " ) + stat.errorString() ); return stat; } objTransforms.append( objTransform ); meshFn.assignUVs( newPolyCounts, newFvUVIDs ); meshFn.updateSurface(); // Rename transform node dagFn.setObject( objTransform ); dagFn.setName( "molecule" ); // Put mesh into the initial shading group dagMod.commandToExecute( MString( "sets -e -fe initialShadingGroup " ) + meshFn.name() ); } // Select all the newly created molecule meshes MString cmd( "select -r" ); for( i=0; i < objTransforms.length(); i++ ) { dagFn.setObject( objTransforms[i] ); cmd += " " + dagFn.name(); } dagMod.commandToExecute( cmd ); return dagMod.doIt(); }
//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- MStatus CVstSelectCoincidentFacesCmd::DoSelect() { MSelectionList meshList; GetSpecifiedMeshes( meshList ); MSelectionList coincidentList; MDagPath mDagPath; MObject cObj; MPointArray points; MIntArray iIndexes; MIntArray jIndexes; uint iCount; bool addI; bool same; bool foundVertex; double tolerance( MPoint_kTol ); if ( m_undo.ArgDatabase().isFlagSet( kOptTolerance ) ) { MDistance optTolerance; m_undo.ArgDatabase().getFlagArgument( kOptTolerance, 0U, optTolerance ); tolerance = optTolerance.as( MDistance::internalUnit() ); } for ( MItSelectionList sIt( meshList ); !sIt.isDone(); sIt.next() ) { if ( !sIt.getDagPath( mDagPath, cObj ) ) continue; MFnSingleIndexedComponent sFn; MObject sObj( sFn.create( MFn::kMeshPolygonComponent ) ); MFnMesh meshFn( mDagPath ); meshFn.getPoints( points ); if ( !sIt.hasComponents() ) { const uint nFaces( meshFn.numPolygons() ); for ( uint i( 0U ); i != nFaces; ++i ) { meshFn.getPolygonVertices( i, iIndexes ); iCount = iIndexes.length(); addI = false; for ( uint j( i + 1 ); j < nFaces; ++j ) { meshFn.getPolygonVertices( j, jIndexes ); if ( jIndexes.length() == iCount ) { same = true; for ( uint k( 0U ); k != iCount; ++k ) { foundVertex = false; const MPoint &kPoint( points[ iIndexes[ k ] ] ); for ( uint l( 0U ); l < iCount; ++l ) { if ( kPoint.isEquivalent( points[ jIndexes[ l ] ], tolerance ) ) { foundVertex = true; break; } } if ( !foundVertex ) { same = false; break; } } if ( same ) { addI = true; sFn.addElement( j ); } } } if ( addI ) { sFn.addElement( i ); } } } else { MFnSingleIndexedComponent cFn( cObj ); MIntArray cA; MFnSingleIndexedComponent( cObj ).getElements( cA ); const uint nFaces( cA.length() ); for ( uint i( 0U ); i != nFaces; ++i ) { meshFn.getPolygonVertices( cA[ i ], iIndexes ); iCount = iIndexes.length(); addI = false; for ( uint j( i + 1U ); j < nFaces; ++j ) { meshFn.getPolygonVertices( cA[ j ], jIndexes ); if ( jIndexes.length() == iCount ) { same = true; for ( uint k( 0U ); k != iCount; ++k ) { foundVertex = false; const MPoint &kPoint( points[ iIndexes[ k ] ] ); for ( uint l( 0U ); l < iCount; ++l ) { if ( kPoint.isEquivalent( points[ jIndexes[ l ] ], tolerance ) ) { foundVertex = true; break; } } if ( !foundVertex ) { same = false; break; } } if ( same ) { addI = true; sFn.addElement( cA[ j ] ); } } } if ( addI ) { sFn.addElement( cA[ i ] ); } } } if ( sFn.elementCount() > 0 ) { coincidentList.add( mDagPath, sObj ); } else { MSelectionList tmpList; tmpList.add( mDagPath, cObj ); MStringArray tmpA; tmpList.getSelectionStrings( tmpA ); minfo << "No coincident faces on:"; for ( uint i( 0U ); i != tmpA.length(); ++i ) { minfo << " " << tmpA[ i ]; } minfo << std::endl; } } if ( coincidentList.length() ) { MGlobal::setActiveSelectionList( coincidentList ); MStringArray tmpA; coincidentList.getSelectionStrings( tmpA ); setResult( tmpA ); } else { if ( meshList.length() > 0U ) { minfo << "No coincident faces found" << std::endl; } } return MS::kSuccess; }
MStatus CXRayCameraExport::ExportCamera(const MFileObject& file) { MDagPath node; MObject component; MSelectionList list; MFnDagNode nodeFn; MFnCamera C; MStatus st ; MGlobal::getActiveSelectionList( list ); for ( u32 index = 0; index < list.length(); ++index ) { list.getDagPath ( index, node, component ); nodeFn.setObject ( node ); st = C.setObject (node); if(st!=MStatus::kSuccess) { Msg ("Selected object is not a camera"); return MStatus::kInvalidParameter; } } Msg("exporting camera named [%s]", C.name().asChar()); MTime tmTemp,tmTemp2; MTime tmQuant; // Remember the frame the scene was at so we can restore it later. MTime storedFrame = MAnimControl::currentTime(); MTime startFrame = MAnimControl::minTime(); MTime endFrame = MAnimControl::maxTime(); tmTemp.setUnit (MTime::uiUnit()); tmTemp2.setUnit (MTime::uiUnit()); tmQuant.setUnit (MTime::uiUnit()); tmQuant = 10.0; //3 time in sec. temporary COMotion M; M.SetParam (0, (int)(endFrame-startFrame).as(MTime::uiUnit()), 30); Fvector P,R; tmTemp = startFrame; MObject cam_parent = C.parent(0); MFnTransform parentTransform(cam_parent); MDistance dist; while(tmTemp <= endFrame) { MAnimControl::setCurrentTime( tmTemp ); MMatrix parentMatrix = parentTransform.transformation().asMatrix(); MMatrix cv; cv.setToIdentity (); cv[2][2] = -1.0; MMatrix TM; TM = (cv*parentMatrix)*cv; TM = cv*TM; parentMatrix = TM; Msg ("frame[%d]",(int)tmTemp.as(MTime::uiUnit())); dist.setValue (parentMatrix[3][0]); P.x = (float)dist.asMeters(); dist.setValue (parentMatrix[3][1]); P.y = (float)dist.asMeters(); dist.setValue (parentMatrix[3][2]); P.z = (float)dist.asMeters(); Msg ("P %3.3f,%3.3f,%3.3f",P.x,P.y,P.z); double rot[3]; MTransformationMatrix::RotationOrder rot_order = MTransformationMatrix::kXYZ; st = parentTransform.getRotation( rot, rot_order ); R.x = -(float)rot[0]; R.y = -(float)rot[1]; R.z = -(float)rot[2]; //. Msg ("rt %3.3f,%3.3f,%3.3f kWorld",R.x,R.y,R.z); tmTemp2 = tmTemp-startFrame; M.CreateKey (float(tmTemp2.as(MTime::uiUnit()))/30.0f,P,R); if(tmTemp==endFrame) break; tmTemp += tmQuant; if(tmTemp>endFrame) tmTemp=endFrame; }; MString fn_save_to = file.fullName(); fn_save_to += ".anm"; Msg("file full name [%s]", fn_save_to); M.SaveMotion (fn_save_to.asChar()); MAnimControl::setCurrentTime( storedFrame ); return MS::kSuccess; }
//--------------------------------------------------------------- void DocumentExporter::exportAsset() { COLLADASW::Asset asset(&mStreamWriter); // Add contributor information // Set the author char* userName = getenv ( USERNAME ); if ( !userName || *userName == 0 ) { userName = getenv ( USER ); } if ( userName && *userName != 0 ) { asset.getContributor().mAuthor = NativeString( userName ).toUtf8String(); } // Source is the scene we have exported from String currentScene = MFileIO::currentFile().asChar(); if ( currentScene.size() > 0 ) { COLLADASW::URI sourceFileUri ( COLLADASW::URI::nativePathToUri ( currentScene ) ); if ( sourceFileUri.getScheme ().empty () ) sourceFileUri.setScheme ( COLLADASW::URI::SCHEME_FILE ); asset.getContributor().mSourceData = sourceFileUri.getURIString(); } std::size_t foundLast = COLLADABU::CURRENT_REVISION.find_last_of("."); std::size_t foundFirst = COLLADABU::CURRENT_REVISION.find_first_of("."); String versionMajor = COLLADABU::CURRENT_REVISION.substr(0, foundFirst); String versionMinor = COLLADABU::CURRENT_REVISION.substr(foundFirst + 1, foundLast - foundFirst -1 ); asset.getContributor().mAuthoringTool = AUTHORING_TOOL_NAME + MGlobal::mayaVersion().asChar() + (COLLADABU::CURRENT_REVISION.empty() ? "" : String("; ") + String("Version: ") + versionMajor + "." + versionMinor) + (COLLADABU::CURRENT_REVISION.empty() ? "" : String("; ") + String("Revision: ") + COLLADABU::CURRENT_REVISION.substr(foundLast + 1)); // comments MString optstr = MString("\n\t\t\tColladaMaya export options: ") + "\n\t\t\tbakeTransforms=" + ExportOptions::bakeTransforms() + ";relativePaths=" + ExportOptions::relativePaths() + ";preserveSourceTree=" + ExportOptions::preserveSourceTree() + ";copyTextures=" + ExportOptions::copyTextures() + ";exportTriangles=" + ExportOptions::exportTriangles() + ";exportCgfxFileReferences=" + ExportOptions::exportCgfxFileReferences() + ";\n\t\t\tisSampling=" + ExportOptions::isSampling() + ";curveConstrainSampling=" + ExportOptions::curveConstrainSampling() + ";removeStaticCurves=" + ExportOptions::removeStaticCurves() + ";exportPhysics=" + ExportOptions::exportPhysics() + ";exportConvexMeshGeometries=" + ExportOptions::exportConvexMeshGeometries() + ";exportPolygonMeshes=" + ExportOptions::exportPolygonMeshes() + ";exportLights=" + ExportOptions::exportLights() + ";\n\t\t\texportCameras=" + ExportOptions::exportCameras() + ";exportAnimationsOnly=" + ExportOptions::exportAnimationsOnly() + ";exportSeparateFile=" + ExportOptions::exportSeparateFile() + ";modelNameDAE=" + ExportOptions::getDAEmodelName() + ";exportJoints=" + ExportOptions::exportJoints() + ";exportSkin=" + ExportOptions::exportSkin() + ";exportAnimations=" + ExportOptions::exportAnimations() + ";exportOptimizedBezierAnimation=" + ExportOptions::exportOptimizedBezierAnimations() + ";exportInvisibleNodes=" + ExportOptions::exportInvisibleNodes() + ";exportDefaultCameras=" + ExportOptions::exportDefaultCameras() + ";\n\t\t\texportTexCoords=" + ExportOptions::exportTexCoords() + ";exportNormals=" + ExportOptions::exportNormals() + ";exportNormalsPerVertex=" + ExportOptions::exportNormalsPerVertex() + ";exportVertexColors=" + ExportOptions::exportVertexColors() + ";exportVertexColorsPerVertex=" + ExportOptions::exportVertexColorsPerVertex() + ";\n\t\t\texportTexTangents=" + ExportOptions::exportTexTangents() + ";exportTangents=" + ExportOptions::exportTangents() + ";exportReferencedMaterials=" + ExportOptions::exportReferencedMaterials() + ";exportMaterialsOnly=" + ExportOptions::exportMaterialsOnly() + ";\n\t\t\texportXRefs=" + ExportOptions::exportXRefs() + ";dereferenceXRefs=" + ExportOptions::dereferenceXRefs() + ";exportCameraAsLookat=" + ExportOptions::exportCameraAsLookat() + ";cameraXFov=" + ExportOptions::cameraXFov() + ";cameraYFov=" + ExportOptions::cameraYFov() + ";doublePrecision=" + ExportOptions::doublePrecision () + "\n\t\t"; asset.getContributor().mComments = optstr.asChar(); // Up axis if ( MGlobal::isYAxisUp() ) asset.setUpAxisType ( COLLADASW::Asset::Y_UP ); else if ( MGlobal::isZAxisUp() ) asset.setUpAxisType ( COLLADASW::Asset::Z_UP ); // Retrieve the linear unit name MString mayaLinearUnitName; MGlobal::executeCommand ( "currentUnit -q -linear -fullName;", mayaLinearUnitName ); String linearUnitName = mayaLinearUnitName.asChar(); // Get the UI unit type (internal units are centimeter, collada want // a number relative to meters). // All transform components with units will be in maya's internal units // (radians for rotations and centimeters for translations). MDistance testDistance ( 1.0f, MDistance::uiUnit() ); // Get the conversion factor relative to meters for the collada document. // For example, 1.0 for the name "meter"; 1000 for the name "kilometer"; // 0.3048 for the name "foot". double colladaConversionFactor = ( float ) testDistance.as ( MDistance::kMeters ); float colladaUnitFactor = float ( 1.0 / colladaConversionFactor ); asset.setUnit ( linearUnitName, colladaConversionFactor ); // Asset heraus schreiben asset.add(); }
void swissArmyLocator::draw(M3dView &view, const MDagPath &/*path*/, M3dView::DisplayStyle style, M3dView::DisplayStatus status) { // Get the size // MObject thisNode = thisMObject(); MPlug plug(thisNode, aSize); MDistance sizeVal; plug.getValue(sizeVal); MPlug arrow1AnglePlug(thisNode, aArrow1Angle); MAngle arrow1Angle; arrow1AnglePlug.getValue(arrow1Angle); double angle1 = -arrow1Angle.asRadians() - 3.1415927/2.0; MPlug arrow3AnglePlug(thisNode, aArrow3Angle); MAngle arrow3Angle; arrow3AnglePlug.getValue(arrow3Angle); double angle3 = arrow3Angle.asRadians(); MPlug statePlug(thisNode, aState); int state; statePlug.getValue(state); MPlug togglePlug(thisNode, aToggle); bool toggle; togglePlug.getValue(toggle); MPlug directionXPlug(thisNode, aArrow2DirectionX); MPlug directionYPlug(thisNode, aArrow2DirectionY); MPlug directionZPlug(thisNode, aArrow2DirectionZ); double dirX; double dirY; double dirZ; directionXPlug.getValue(dirX); directionYPlug.getValue(dirY); directionZPlug.getValue(dirZ); double angle2 = atan2(dirZ,dirX); angle2 += 3.1415927; float multiplier = (float) sizeVal.asCentimeters(); view.beginGL(); if ((style == M3dView::kFlatShaded) || (style == M3dView::kGouraudShaded)) { // Push the color settings // glPushAttrib(GL_CURRENT_BIT); if (status == M3dView::kActive) { view.setDrawColor(13, M3dView::kActiveColors); } else { view.setDrawColor(13, M3dView::kDormantColors); } int i; int last; if (toggle) { if (status == M3dView::kActive) view.setDrawColor(15, M3dView::kActiveColors); else view.setDrawColor(15, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = centreCount - 1; for (i = 0; i < last; ++i) { glVertex3f(centre[i][0] * multiplier, centre[i][1] * multiplier, centre[i][2] * multiplier); } glEnd(); } if (state == 0) { if (status == M3dView::kActive) view.setDrawColor(19, M3dView::kActiveColors); else view.setDrawColor(19, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = state1Count - 1; for (i = 0; i < last; ++i) { glVertex3f(state1[i][0] * multiplier, state1[i][1] * multiplier, state1[i][2] * multiplier); } glEnd(); } if (state == 1) { if (status == M3dView::kActive) view.setDrawColor(21, M3dView::kActiveColors); else view.setDrawColor(21, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = state2Count - 1; for (i = 0; i < last; ++i) { glVertex3f(state2[i][0] * multiplier, state2[i][1] * multiplier, state2[i][2] * multiplier); } glEnd(); } if (state == 2) { if (status == M3dView::kActive) view.setDrawColor(18, M3dView::kActiveColors); else view.setDrawColor(18, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = state3Count - 1; for (i = 0; i < last; ++i) { glVertex3f(state3[i][0] * multiplier, state3[i][1] * multiplier, state3[i][2] * multiplier); } glEnd(); } if (state == 3) { if (status == M3dView::kActive) view.setDrawColor(17, M3dView::kActiveColors); else view.setDrawColor(17, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = state4Count - 1; for (i = 0; i < last; ++i) { glVertex3f(state4[i][0] * multiplier, state4[i][1] * multiplier, state4[i][2] * multiplier); } glEnd(); } if (status == M3dView::kActive) view.setDrawColor(12, M3dView::kActiveColors); else view.setDrawColor(12, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = arrow1Count - 1; for (i = 0; i < last; ++i) { glVertex3f( (float) (- arrow1[i][0] * multiplier * cos(angle1) - arrow1[i][2] * multiplier * sin(angle1)), (float) (arrow1[i][1] * multiplier + delta1), (float) (arrow1[i][2] * multiplier * cos(angle1) - arrow1[i][0] * multiplier * sin(angle1))); } glEnd(); if (status == M3dView::kActive) view.setDrawColor(16, M3dView::kActiveColors); else view.setDrawColor(16, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = arrow2Count - 1; for (i = 0; i < last; ++i) { glVertex3f( (float) (- arrow2[i][0] * multiplier * cos(angle2) - arrow2[i][2] * multiplier * sin(angle2)), (float) (arrow2[i][1] * multiplier + delta2), (float) (arrow2[i][2] * multiplier * cos(angle2) - arrow2[i][0] * multiplier * sin(angle2))); } glEnd(); if (status == M3dView::kActive) view.setDrawColor(13, M3dView::kActiveColors); else view.setDrawColor(13, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = arrow3Count - 1; for (i = 0; i < last; ++i) { glVertex3f( (float) (- arrow3[i][0] * multiplier * cos(angle3) - arrow3[i][2] * multiplier * sin(angle3)), (float) (arrow3[i][1] * multiplier + delta3), (float) (arrow3[i][2] * multiplier * cos(angle3) - arrow3[i][0] * multiplier * sin(angle3))); } glEnd(); if (status == M3dView::kActive) view.setDrawColor(5, M3dView::kActiveColors); else view.setDrawColor(5, M3dView::kDormantColors); glBegin(GL_TRIANGLE_FAN); last = arrow4Count - 1; for (i = 0; i < last; ++i) { glVertex3f((float) (arrow4[i][0] * multiplier), (float) (arrow4[i][1] * multiplier + delta4), (float) (arrow4[i][2] * multiplier)); } glEnd(); glPopAttrib(); } // Draw the outline of the locator // glBegin(GL_LINES); int i; int last; if (toggle) { last = centreCount - 1; for (i = 0; i < last; ++i) { glVertex3f(centre[i][0] * multiplier, centre[i][1] * multiplier, centre[i][2] * multiplier); glVertex3f(centre[i+1][0] * multiplier, centre[i+1][1] * multiplier, centre[i+1][2] * multiplier); } } if (state == 0) { last = state1Count - 1; for (i = 0; i < last; ++i) { glVertex3f(state1[i][0] * multiplier, state1[i][1] * multiplier, state1[i][2] * multiplier); glVertex3f(state1[i+1][0] * multiplier, state1[i+1][1] * multiplier, state1[i+1][2] * multiplier); } } if (state == 1) { last = state2Count - 1; for (i = 0; i < last; ++i) { glVertex3f(state2[i][0] * multiplier, state2[i][1] * multiplier, state2[i][2] * multiplier); glVertex3f(state2[i+1][0] * multiplier, state2[i+1][1] * multiplier, state2[i+1][2] * multiplier); } } if (state == 2) { last = state3Count - 1; for (i = 0; i < last; ++i) { glVertex3f(state3[i][0] * multiplier, state3[i][1] * multiplier, state3[i][2] * multiplier); glVertex3f(state3[i+1][0] * multiplier, state3[i+1][1] * multiplier, state3[i+1][2] * multiplier); } } if (state == 3) { last = state4Count - 1; for (i = 0; i < last; ++i) { glVertex3f(state4[i][0] * multiplier, state4[i][1] * multiplier, state4[i][2] * multiplier); glVertex3f(state4[i+1][0] * multiplier, state4[i+1][1] * multiplier, state4[i+1][2] * multiplier); } } last = arrow1Count - 1; for (i = 0; i < last; ++i) { glVertex3f((float) (- arrow1[i][0] * multiplier * cos(angle1) - arrow1[i][2] * multiplier * sin(angle1)), (float) (arrow1[i][1] * multiplier + delta1), (float) (arrow1[i][2] * multiplier * cos(angle1) - arrow1[i][0] * multiplier * sin(angle1))); glVertex3f((float) (- arrow1[i+1][0] * multiplier * cos(angle1) - arrow1[i+1][2] * multiplier * sin(angle1)), (float) (arrow1[i+1][1] * multiplier + delta1), (float) (arrow1[i+1][2] * multiplier * cos(angle1) - arrow1[i+1][0] * multiplier * sin(angle1))); } last = arrow2Count - 1; for (i = 0; i < last; ++i) { glVertex3f((float) (- arrow2[i][0] * multiplier * cos(angle2) - arrow2[i][2] * multiplier * sin(angle2)), (float) (arrow2[i][1] * multiplier + delta2), (float) (arrow2[i][2] * multiplier * cos(angle2) - arrow2[i][0] * multiplier * sin(angle2))); glVertex3f((float) (- arrow2[i+1][0] * multiplier * cos(angle2) - arrow2[i+1][2] * multiplier * sin(angle2)), (float) (arrow2[i+1][1] * multiplier + delta2), (float) (arrow2[i+1][2] * multiplier * cos(angle2) - arrow2[i+1][0] * multiplier * sin(angle2))); } last = arrow3Count - 1; for (i = 0; i < last; ++i) { glVertex3f((float) (- arrow3[i][0] * multiplier * cos(angle3) - arrow3[i][2] * multiplier * sin(angle3)), (float) (arrow3[i][1] * multiplier + delta3), (float) (arrow3[i][2] * multiplier * cos(angle3) - arrow3[i][0] * multiplier * sin(angle3))); glVertex3f((float) (- arrow3[i+1][0] * multiplier * cos(angle3) - arrow3[i+1][2] * multiplier * sin(angle3)), (float) (arrow3[i+1][1] * multiplier + delta3), (float) (arrow3[i+1][2] * multiplier * cos(angle3) - arrow3[i+1][0] * multiplier * sin(angle3))); } last = arrow4Count - 1; for (i = 0; i < last; ++i) { glVertex3f((float) (arrow4[i][0] * multiplier), (float) (arrow4[i][1] * multiplier + delta4), (float) (arrow4[i][2] * multiplier)); glVertex3f((float) (arrow4[i+1][0] * multiplier), (float) (arrow4[i+1][1] * multiplier + delta4), (float) (arrow4[i+1][2] * multiplier)); } last = perimeterCount - 1; for (i = 0; i < last; ++i) { glVertex3f(perimeter[i][0] * multiplier, perimeter[i][1] * multiplier, perimeter[i][2] * multiplier); glVertex3f(perimeter[i+1][0] * multiplier, perimeter[i+1][1] * multiplier, perimeter[i+1][2] * multiplier); } glEnd(); view.endGL(); }