public static MFnIkJoint[] AddReverseFootBone() { MSelectionList selected = new MSelectionList(); MGlobal.getActiveSelectionList(selected); if (selected.length == 3) { MDagPath rootObject = new MDagPath(), endObject = new MDagPath(), ctlObject = new MDagPath(); selected.getDagPath(0, rootObject); selected.getDagPath(1, endObject); selected.getDagPath(2, ctlObject); return(AddReverseFootBone(rootObject, endObject, ctlObject)); } return(null); }
//====================================================================== // // Check the parsed arguments and do/undo/redo the command as appropriate // void checkArgs(ref MArgDatabase argsDb) { MSelectionList objects = new MSelectionList(); argsDb.getObjects(objects); for (uint i = 0; i < objects.length; ++i) { MDagPath dagPath = new MDagPath(); objects.getDagPath((uint)i, dagPath); MFnDagNode dagNode = new MFnDagNode(dagPath.node); MObject obj = dagNode.child(0); if (obj.apiTypeStr == "kMesh") { fMesh = new MFnMesh(obj); fObj = obj; fObjTransform = dagPath.node; } } if( fMesh == null || fObj == null || fObjTransform == null ) { string errMsg = MStringResource.getString(MetaDataRegisterMStringResources.kObjectNotFoundError); throw new ArgumentException(errMsg, "argsDb"); } }
public static bool BindReverseFootRPIK() { MSelectionList selected = new MSelectionList(); MGlobal.getActiveSelectionList(selected); if (selected.length == 4) { MDagPath legRootDagPath = new MDagPath(), ankleDagPath = new MDagPath(), middleDagPath = new MDagPath(), endDagPath = new MDagPath(); selected.getDagPath(0, legRootDagPath); selected.getDagPath(1, ankleDagPath); selected.getDagPath(2, middleDagPath); selected.getDagPath(3, endDagPath); return(BindReverseFootRPIK(legRootDagPath, ankleDagPath, middleDagPath, endDagPath)); } return(false); }
//====================================================================== // // Look through the arg database and verify that the arguments are // valid. Only checks the common flags so derived classes should call // this parent method first before checking their own flags. // public virtual void checkArgs(MArgDatabase argsDb) { String formatType = "raw"; fSerialize = AssociationsSerializer.formatByName(formatType); if (fSerialize == null) { String fmt = MStringResource.getString(MetaDataRegisterMStringResources.kMetadataFormatNotFound); String msg = String.Format(fmt, formatType); displayError(msg); throw new System.ArgumentException(msg); } //---------------------------------------- // (selection list) // // Commands need at least one mesh object on which to operate so gather up // the list of meshes specified and/or selected. // // Empty out the list of meshes on which to operate so that it can be // populated from the selection or specified lists. fMeshes.clear(); MSelectionList objects = new MSelectionList(); argsDb.getObjects(objects); for (int i = 0; i < objects.length; ++i) { MDagPath dagPath = new MDagPath(); objects.getDagPath((uint)i, dagPath); MFnDagNode dagNode = new MFnDagNode(dagPath.node); MObject obj = dagNode.child(0); if (obj.apiTypeStr == "kMesh") { MFnMesh mesh = new MFnMesh(obj); if (mesh != null) { fMeshes.append(obj); } } else { String fmt = MStringResource.getString(MetaDataRegisterMStringResources.kObjectTypeError); String msg = String.Format(fmt, dagPath.fullPathName + "[" + obj.apiTypeStr + "]"); displayError(msg); throw new System.InvalidOperationException(msg); } } if (fMeshes.length == 0) { String msg = MStringResource.getString(MetaDataRegisterMStringResources.kObjectNotFoundError); displayError(msg); throw new System.InvalidOperationException(msg); } }
//====================================================================== // // Look through the arg database and verify that the arguments are // valid. Only checks the common flags so derived classes should call // this parent method first before checking their own flags. // public virtual void checkArgs(MArgDatabase argsDb) { String formatType = "raw"; fSerialize = AssociationsSerializer.formatByName( formatType ); if( fSerialize == null) { String fmt = MStringResource.getString(MetaDataRegisterMStringResources.kMetadataFormatNotFound); String msg = String.Format(fmt, formatType); displayError(msg); throw new System.ArgumentException(msg); } //---------------------------------------- // (selection list) // // Commands need at least one mesh object on which to operate so gather up // the list of meshes specified and/or selected. // // Empty out the list of meshes on which to operate so that it can be // populated from the selection or specified lists. fMeshes.clear(); MSelectionList objects = new MSelectionList(); argsDb.getObjects(objects); for (int i = 0; i<objects.length; ++i) { MDagPath dagPath = new MDagPath(); objects.getDagPath((uint)i, dagPath); MFnDagNode dagNode = new MFnDagNode( dagPath.node ); MObject obj = dagNode.child(0); if (obj.apiTypeStr == "kMesh") { MFnMesh mesh = new MFnMesh(obj); if(mesh != null) fMeshes.append(obj); } else { String fmt = MStringResource.getString(MetaDataRegisterMStringResources.kObjectTypeError); String msg = String.Format(fmt, dagPath.fullPathName + "[" + obj.apiTypeStr + "]"); displayError(msg); throw new System.InvalidOperationException(msg); } } if( fMeshes.length == 0 ) { String msg = MStringResource.getString(MetaDataRegisterMStringResources.kObjectNotFoundError); displayError(msg); throw new System.InvalidOperationException(msg); } }
//====================================================================== // // Check the parsed arguments and do/undo/redo the command as appropriate // void checkArgs(ref MArgDatabase argsDb) { //---------------------------------------- // (selection list) // // Commands need at least one node on which to operate so gather up // the list of nodes specified and/or selected. // // Empty out the list of nodes on which to operate so that it can be // populated from the selection or specified lists. fNodes.clear(); MSelectionList objects = new MSelectionList(); argsDb.getObjects(objects); for (uint i = 0; i < objects.length; ++i) { MDagPath dagPath = new MDagPath(); objects.getDagPath((uint)i, dagPath); MFnDagNode dagNode = new MFnDagNode(dagPath.node); MObject obj = dagNode.child(0); if (obj.apiTypeStr == "kMesh") { if (obj == MObject.kNullObj) { throw new ApplicationException("Error: objects.getDependNode() "); } fNodes.append(dagPath.node); } else { String fmt = MStringResource.getString(MetaDataRegisterMStringResources.kObjectTypeError); String msg = String.Format(fmt, dagPath.fullPathName + "[" + obj.apiTypeStr + "]"); displayError(msg); throw new System.InvalidOperationException(msg); } } if (fNodes.length == 0) { string errMsg = MStringResource.getString(MetaDataRegisterMStringResources.kObjectNotFoundError); throw new ArgumentException(errMsg, "argsDb"); } }
// // Description: // // Component/attribute matching method. // This method validates component names and indices which are // specified as a string and adds the corresponding component // to the passed in selection list. // // For instance, select commands such as "select shape1.vtx[0:7]" // are validated with this method and the corresponding component // is added to the selection list. // // Arguments // // item - DAG selection item for the object being matched // spec - attribute specification object // list - list to add components to // // Returns // // the result of the match // public override MatchResult matchComponent(MSelectionList item, MAttributeSpecArray spec, MSelectionList list) { MatchResult result = MatchResult.kMatchOk; MAttributeSpec attrSpec = spec[0]; int dim = attrSpec.dimensions; // Look for attributes specifications of the form : // vtx[ index ] // vtx[ lower:upper ] // if ( (1 == spec.length) && (dim > 0) && (attrSpec.name == "vtx") ) { int numVertices = (int)meshGeom().vertices.length; MAttributeIndex attrIndex = attrSpec[0]; int upper = 0; int lower = 0; if ( attrIndex.hasLowerBound ) { attrIndex.getLower( out lower ); } if ( attrIndex.hasUpperBound ) { attrIndex.getUpper( out upper ); } // Check the attribute index range is valid // if ( (lower > upper) || (upper >= numVertices) ) { result = MatchResult.kMatchInvalidAttributeRange; } else { MDagPath path = new MDagPath(); item.getDagPath( 0, path ); MFnSingleIndexedComponent fnVtxComp = new MFnSingleIndexedComponent(); MObject vtxComp = fnVtxComp.create( MFn.Type.kMeshVertComponent ); for ( int i=lower; i<=upper; i++ ) { fnVtxComp.addElement( i ); } list.add( path, vtxComp ); } } else { // Pass this to the parent class return base.matchComponent( item, spec, list ); } return result; }
//====================================================================== // // Check the parsed arguments and do/undo/redo the command as appropriate // void checkArgs(ref MArgDatabase argsDb) { //---------------------------------------- // -structure flag // fStructureFlag.parse(ref argsDb, flagStructure); if (fStructureFlag.isSet()) { if (!fStructureFlag.isArgValid()) { string errMsg = MStringResource.getString(MetaDataRegisterMStringResources.kInvalidString); throw new ArgumentException(errMsg, "argsDb"); } string structureName = fStructureFlag.arg(); try { fStructure = Structure.structureByName(structureName); } catch (System.Exception) { string msgFmt = MStringResource.getString(MetaDataRegisterMStringResources.kCreateMetadataStructureNotFound); throw new ArgumentException(String.Format(msgFmt, structureName), "argsDb"); } } else { string errMsg = MStringResource.getString(MetaDataRegisterMStringResources.kCreateMetadataNoStructureName); throw new ArgumentException(errMsg, "argsDb"); } //---------------------------------------- // -streamName flag // fStreamNameFlag.parse(ref argsDb, flagStreamName); if (fStreamNameFlag.isSet()) { if (!fStreamNameFlag.isArgValid()) { string errMsg = MStringResource.getString(MetaDataRegisterMStringResources.kInvalidString); throw new ArgumentException(errMsg, "argsDb"); } fStreamName = fStreamNameFlag.arg(); } else { string errMsg = MStringResource.getString(MetaDataRegisterMStringResources.kCreateMetadataNoStructureName); throw new ArgumentException(errMsg, "argsDb"); } //---------------------------------------- // -channelType flag // fChannelTypeFlag.parse(ref argsDb, flagChannelType); if (fChannelTypeFlag.isSet()) { if (!fChannelTypeFlag.isArgValid()) { string errMsg = MStringResource.getString(MetaDataRegisterMStringResources.kInvalidString); throw new ArgumentException(errMsg, "argsDb"); } fChannelType = fChannelTypeFlag.arg(); } else { string errMsg = MStringResource.getString(MetaDataRegisterMStringResources.kCreateMetadataNoStructureName); throw new ArgumentException(errMsg, "argsDb"); } //---------------------------------------- // (selection list) // // Commands need at least one node on which to operate so gather up // the list of nodes specified and/or selected. // // Empty out the list of nodes on which to operate so that it can be // populated from the selection or specified lists. fNodes.clear(); MSelectionList objects = new MSelectionList(); argsDb.getObjects(objects); for (uint i = 0; i < objects.length; ++i) { MDagPath dagPath = new MDagPath(); objects.getDagPath((uint)i, dagPath); MFnDagNode dagNode = new MFnDagNode(dagPath.node); MObject obj = dagNode.child(0); if (obj.apiTypeStr == "kMesh") { if (obj == MObject.kNullObj) { throw new ApplicationException("Error: objects.getDependNode() "); } fNodes.append(dagPath.node); } else { String fmt = MStringResource.getString(MetaDataRegisterMStringResources.kObjectTypeError); String msg = String.Format(fmt, dagPath.fullPathName + "[" + obj.apiTypeStr + "]"); displayError(msg); throw new System.InvalidOperationException(msg); } } if (fNodes.length == 0) { string errMsg = MStringResource.getString(MetaDataRegisterMStringResources.kObjectNotFoundError); throw new ArgumentException(errMsg, "argsDb"); } }
// get the DAG node MDagPath getDagNode(string node_name) { MSelectionList sl = new MSelectionList(); sl.add(node_name, true); MDagPath dp = new MDagPath(); sl.getDagPath(0, dp); return dp; }
// Parses the given command line arguments and executes them. // public override void doIt(MArgList args) { parseArgs(args); bool nothingSet = (!createdUsed && !appendCameraUsed && !appendCameraAndSetUsed && !deleteLayerUsed && !cameraUsed && !layerUsed && !helpUsed && !setUsed && !layerTypeUsed && !numLayersUsed); if (nothingSet) { throw new ArgumentException("A flag must be used. testCameraSet -help for available flags", "args"); } if (helpUsed) { MGlobal.displayInfo("testExCameraSet -help"); MGlobal.displayInfo("\ttestExCameraSet tests the functionality of the exCameraSet node."); MGlobal.displayInfo(""); MGlobal.displayInfo("\t-h -help : This message is printed"); MGlobal.displayInfo("\t-a -active [true/false]: Set/get whether a particular layer is active"); MGlobal.displayInfo("\t-ac -appendCamera <cameraName>: Append a new camera layer to the cameraSet using the specified camera"); MGlobal.displayInfo("\t-acs -appendCameraAndSet <cameraName> <setName>: Append a new camera layer to the cameraSet using the specified camera and set"); MGlobal.displayInfo("\t-cam -camera [<cameraName>]: Set/get the camera for a particular layer"); MGlobal.displayInfo("\t-c -create : Create a new cameraSet node"); MGlobal.displayInfo("\t-d -deleteLayer <layerIndex>: Delete the layer at the given index"); MGlobal.displayInfo("\t-nl -numLayers: Returns the number of layers defined in the specified cameraSet"); MGlobal.displayInfo("\t-l -layer <layerIndex>: Specifies the layer index to be used when accessing layer information"); MGlobal.displayInfo("\t-lt -layerType [<layerTypeName>]: Set/get the layer type for a particular layer. Possible values are Mono, Left, and Right."); MGlobal.displayInfo("\t-s -set [<setName>]: Set/get the set for a particular layer"); MGlobal.displayInfo("\t-e -edit : Perform an edit operation"); MGlobal.displayInfo("\t-q -query : Perform a query operation"); MGlobal.displayInfo(""); } uint nObjs = list.length; if (nObjs == 0) { if (createdUsed) { // Create a new cameraSet node. // MFnDependencyNode dirFn = new MFnDependencyNode(); string noName = ""; try { MObject dirObj = dirFn.create(exCameraSet.type_id, noName); MGlobal.select(dirObj, MGlobal.ListAdjustment.kReplaceList); } catch (System.Exception ex) { throw new ApplicationException("Could not create a cameraSet node", ex); } return; } if (appendCameraUsed || appendCameraAndSetUsed || deleteLayerUsed || editUsed || cameraUsed || setUsed || layerTypeUsed || activeUsed || numLayersUsed) { throw new ArgumentException("Must specify a cameraSet node", "args"); } } else { if (createdUsed) { throw new ArgumentException("-create cannot have any object specified", "args"); } if (appendCameraUsed) { if (nObjs != 1) { throw new ArgumentException("-appendCamera must have a single cameraSet node specified", "args"); } // Get the specified cameraSet node. // MObject dirNode = MObject.kNullObj; if (!getExCameraSetNode(dirNode)) { throw new ArgumentException("-appendCamera must have a valid exCameraSet node specified", "args"); } // Get a dag path to the specified camera. // MSelectionList camList = new MSelectionList(); camList.add(camName); MDagPath camPath = new MDagPath(); camList.getDagPath(0, camPath); if (!camPath.isValid) { throw new ArgumentException("-appendCamera must have a valid camera node specified", "args"); } // Call the MFnCameraSet method to append the layer. // MFnCameraSet dirFn = new MFnCameraSet(dirNode); dirFn.appendLayer(camPath, MObject.kNullObj); return; } if (appendCameraAndSetUsed) { if (nObjs != 1) { throw new ArgumentException("-appendCameraAndSet must have a single cameraSet node specified", "args"); } // Get the specified cameraSet node. // MObject dirNode = MObject.kNullObj; if (!getExCameraSetNode(dirNode)) { throw new ArgumentException("-appendCameraAndSet must have a valid exCameraSet node specified", "args"); } // Get a dag path to the specified camera. // MSelectionList camList = new MSelectionList(); camList.add(camName); MDagPath camPath = new MDagPath(); camList.getDagPath(0, camPath); if (!camPath.isValid) { throw new ArgumentException("-appendCameraAndSet must have a valid camera node specified", "args"); } // Get the specified set node. // MSelectionList setList = new MSelectionList(); setList.add(setName); MObject setObj = MObject.kNullObj; setList.getDependNode(0, setObj); if (setObj == MObject.kNullObj) { throw new ArgumentException("-appendCameraAndSet must have a valid set node specified", "args"); } // Call the MFnCameraSet method to append the layer. // MFnCameraSet dirFn = new MFnCameraSet(dirNode); dirFn.appendLayer(camPath, setObj); return; } if (deleteLayerUsed) { if (nObjs != 1) { throw new ArgumentException("-deleteLayer must have a single cameraSet node specified", "args"); } // Get the specified cameraSet node. // MObject dirNode = MObject.kNullObj; if (!getExCameraSetNode(dirNode)) { throw new ArgumentException("-deleteLayer must have a valid exCameraSet node specified", "args"); } // Call the MFnCameraSet method to delete the layer. // MFnCameraSet dirFn = new MFnCameraSet(dirNode); dirFn.deleteLayer((uint)cameraLayer); return; } if (numLayersUsed) { if (queryUsed) { // Get the specified cameraSet node. // MObject dirNode = MObject.kNullObj; if (!getExCameraSetNode(dirNode)) { throw new ArgumentException("-numLayers must have a valid exCameraSet node specified", "args"); } // Call the MFnCameraSet method to get the number of layers. // MFnCameraSet dirFn = new MFnCameraSet(dirNode); uint numLayers = dirFn.numLayers; setResult((int)numLayers); } else { throw new ArgumentException("-numLayers requires the query flag to be used", "args"); } return; } if (cameraUsed) { if ((nObjs != 1) || (!layerUsed)) { throw new ArgumentException("-camera must have a cameraSet node and layer specified", "args"); } // Get the specified cameraSet node. // MObject dirNode = MObject.kNullObj; if (!getExCameraSetNode(dirNode)) { throw new ArgumentException("-camera must have a valid exCameraSet node specified", "args"); } if (editUsed) { // Get a dag path to the specified camera. // MSelectionList camList = new MSelectionList(); camList.add(camName); MDagPath camPath = new MDagPath(); camList.getDagPath(0, camPath); if (!camPath.isValid) { throw new ArgumentException("-camera must have a valid camera node specified", "args"); } // Call the MFnCameraSet method to set the camera. // MFnCameraSet dirFn = new MFnCameraSet(dirNode); dirFn.setLayerCamera((uint)cameraLayer, camPath); } else if (queryUsed) { // Call the MFnCameraSet method to get the camera. // MDagPath camPath = new MDagPath(); MFnCameraSet dirFn = new MFnCameraSet(dirNode); dirFn.getLayerCamera((uint)cameraLayer, camPath); MObject camNode = camPath.node; MFnDependencyNode nodeFn = new MFnDependencyNode(camNode); setResult(nodeFn.name); } } if (setUsed) { if ((nObjs != 1) || (!layerUsed)) { throw new ArgumentException("-set must have a cameraSet node and layer specified", "args"); } // Get the specified cameraSet node. // MObject dirNode = MObject.kNullObj; if (!getExCameraSetNode(dirNode)) { throw new ArgumentException("-set must have a valid exCameraSet node specified", "args"); } if (editUsed) { // Get the specified set node. // MObject setObj = MObject.kNullObj; if (setName != "") { MSelectionList setList = new MSelectionList(); setList.add(setName); setList.getDependNode(0, setObj); if (setObj == MObject.kNullObj) { throw new ArgumentException("-set must have a valid set node specified", "args"); } } // Call the MFnCameraSet method to set the set node. // MFnCameraSet dirFn = new MFnCameraSet(dirNode); dirFn.setLayerSceneData((uint)cameraLayer, setObj); } else if (queryUsed) { // Call the MFnCameraSet method to get the set node. // MObject setObj = new MObject(); MFnCameraSet dirFn = new MFnCameraSet(dirNode); dirFn.getLayerSceneData((uint)cameraLayer, setObj); MFnDependencyNode nodeFn = new MFnDependencyNode(setObj); setResult(nodeFn.name); } } if (layerTypeUsed) { if ((nObjs != 1) || (!layerUsed)) { throw new ArgumentException("-layerType must have a cameraSet node and layer specified", "args"); } // Get the specified cameraSet node. // MObject dirNode = MObject.kNullObj; if (!getExCameraSetNode(dirNode)) { throw new ArgumentException("-layerType must have a valid exCameraSet node specified", "args"); } MFnDependencyNode nodeFn = new MFnDependencyNode(dirNode); exCameraSet exDir = nodeFn.userNode as exCameraSet; if (editUsed) { // Get the specified layer type. // int pt = -1; if (layerTypeVal == "Mono") pt = 0; else if (layerTypeVal == "Left") pt = 1; else if (layerTypeVal == "Right") pt = 2; else { throw new ArgumentException("-layerType must have a valid type specified", "args"); } // Call the exCameraSet method to set the layer type. // exDir.setLayerType((uint)cameraLayer, pt); } else if (queryUsed) { // Call the exCameraSet method to get the layer type. // try { int lt = exDir.getLayerType((uint)cameraLayer); if (lt == 0) setResult("Mono"); else if (lt == 1) setResult("Left"); else if (lt == 2) setResult("Right"); } catch (System.Exception ex) { throw new ApplicationException("exCameraSet node does not have a valid layer type", ex); } } } if (activeUsed) { if ((nObjs != 1) || (!layerUsed)) { throw new ArgumentException("-active must have a cameraSet node and layer specified", "args"); } // Get the specified cameraSet node. // MObject dirNode = MObject.kNullObj; if (!getExCameraSetNode(dirNode)) { throw new ArgumentException("-active must have a valid exCameraSet node specified", "args"); } if (editUsed) { // Call the MFnCameraSet method to set the set node. // MFnCameraSet dirFn = new MFnCameraSet(dirNode); dirFn.setLayerActive((uint)cameraLayer, activeVal); } else if (queryUsed) { // Call the MFnCameraSet method to get the active value. // MFnCameraSet dirFn = new MFnCameraSet(dirNode); activeVal = dirFn.isLayerActive((uint)cameraLayer); setResult(activeVal); } } } return; }
public override MatchResult matchComponent(MSelectionList item, MAttributeSpecArray spec, MSelectionList list) // // Description: // // Component/attribute matching method. // This method validates component names and indices which are // specified as a string and adds the corresponding component // to the passed in selection list. // // For instance, select commands such as "select shape1.vtx[0:7]" // are validated with this method and the corresponding component // is added to the selection list. // // Arguments // // item - DAG selection item for the object being matched // spec - attribute specification object // list - list to add components to // // Returns // // the result of the match // { MatchResult result = MatchResult.kMatchOk; MAttributeSpec attrSpec = spec[0]; int dim = attrSpec.dimensions; // Look for attributes specifications of the form : // vtx[ index ] // vtx[ lower:upper ] // if ( (1 == spec.length) && (dim > 0) && (attrSpec.name == "vtx") ) { int numVertices = (int)meshGeom().vertices.length; MAttributeIndex attrIndex = attrSpec[0]; int upper = 0; int lower = 0; if ( attrIndex.hasLowerBound ) { attrIndex.getLower( out lower ); } if ( attrIndex.hasUpperBound ) { attrIndex.getUpper( out upper ); } // Check the attribute index range is valid // if ( (lower > upper) || (upper >= numVertices) ) { result = MatchResult.kMatchInvalidAttributeRange; } else { MDagPath path = new MDagPath(); item.getDagPath( 0, path ); MFnSingleIndexedComponent fnVtxComp = new MFnSingleIndexedComponent(); MObject vtxComp = fnVtxComp.create( MFn.Type.kMeshVertComponent ); for ( int i=lower; i<=upper; i++ ) { fnVtxComp.addElement( i ); } list.add( path, vtxComp ); } } else { // Pass this to the parent class return base.matchComponent( item, spec, list ); } return result; }
public void ResetCamera() { //<PerspectiveCamera UpDirection="0,1,0" Position="1,1,1" LookDirection="-1,-1,-1" FieldOfView="45" /> MDagPath cameraPath ; try { // Try with a Maya host first cameraPath =M3dView.active3dView.Camera ; } catch { // We are in standalone mode (WPF application) MSelectionList list =new MSelectionList () ; list.add ("persp") ; cameraPath =new MDagPath () ; list.getDagPath (0, cameraPath) ; } MFnCamera fnCamera =new MFnCamera (cameraPath) ; MPoint eyePoint =fnCamera.eyePoint (MSpace.Space.kWorld) ; MPoint centerOfInterestPoint =fnCamera.centerOfInterestPoint (MSpace.Space.kWorld) ; MVector direction =centerOfInterestPoint.minus (eyePoint) ; MVector upDirection =fnCamera.upDirection (MSpace.Space.kWorld) ; camera.Position =new Point3D (eyePoint.x, eyePoint.y, eyePoint.z) ; camera.LookDirection =new Vector3D (direction.x, direction.y, direction.z) ; MAngle fieldOfView =new MAngle (fnCamera.verticalFieldOfView) ; //verticalFieldOfView / horizontalFieldOfView camera.FieldOfView =fieldOfView.asDegrees ; camera.UpDirection =new Vector3D (upDirection.x, upDirection.y, upDirection.z) ; camera.NearPlaneDistance =fnCamera.nearClippingPlane ; camera.FarPlaneDistance =fnCamera.farClippingPlane ; camera.Transform =new Transform3DGroup () ; (camera.Transform as Transform3DGroup).Children.Add (new TranslateTransform3D (new Vector3D ())) ; }
public override void doIt(MArgList args) { MSelectionList list = new MSelectionList(); MArgDatabase argData; argData = new MArgDatabase(syntax, args); argData.getObjects(list); // Get the flags // bool allDagUsed = argData.isFlagSet(kAllDagFlag); bool parentAddedUsed = argData.isFlagSet(kParentAddedFlag); bool parentRemovedUsed = argData.isFlagSet(kParentRemovedFlag); bool childAddedUsed = argData.isFlagSet(kChildAddedFlag); bool childRemovedUsed = argData.isFlagSet(kChildRemovedFlag); bool childReorderedUsed = argData.isFlagSet(kChildReorderedFlag); bool helpUsed = argData.isFlagSet(kHelpFlag); bool nothingSet = (!allDagUsed && !parentAddedUsed && !parentRemovedUsed && !childAddedUsed && !childRemovedUsed && !childReorderedUsed && !helpUsed); if (nothingSet) { throw new ArgumentException("-A flag must be used. dagMessage -help for available flags.", "args"); } if (argData.isFlagSet(kHelpFlag)) { MGlobal.displayInfo("dagMessage -help"); MGlobal.displayInfo("\tdagMessage adds a callback to the selected nodes,"); MGlobal.displayInfo("\tor if no nodes are selected, to all nodes. The callback"); MGlobal.displayInfo("\tprints a message when called. When the plug-in is unloaded"); MGlobal.displayInfo("\tthe callbacks are removed."); MGlobal.displayInfo(""); MGlobal.displayInfo("\t-h -help : This message is printed"); MGlobal.displayInfo("\t-ad -allDag : parent changes and child reorders"); MGlobal.displayInfo("\t-pa -parentAdded : A parent is added"); MGlobal.displayInfo("\t-pr -parentRemoved : A parent is removed"); MGlobal.displayInfo("\t-ca -childAdded : A child is added (only for individual nodes)"); MGlobal.displayInfo("\t-cr -childRemoved : A child is removed (only for individual nodes)"); MGlobal.displayInfo("\t-cro -childReordered : A child is reordered"); MGlobal.displayInfo(""); } uint nObjs = list.length; if (nObjs == 0) { // Add the callback for all changes of the specified type. // if (allDagUsed) { try { MDagMessage.AllDagChangesEvent += userDAGGenericCB; } catch (Exception) { throw new ApplicationException("Could not add a -allDag callback"); } } if (parentAddedUsed) { addGenericCallback(null, MDagMessage.DagMessage.kParentAdded, " parent added "); } if (parentRemovedUsed) { addGenericCallback(null, MDagMessage.DagMessage.kParentRemoved, " parent removed "); } if (childAddedUsed) { throw new ArgumentException("-childAdded can only be used when a node is selected", "args"); } if (childRemovedUsed) { throw new ArgumentException("-childRemoved can only be used when a node is selected", "args"); } if (childReorderedUsed) { addGenericCallback(null, MDagMessage.DagMessage.kChildReordered, " child reordered "); } } else { for (uint i = 0; i < nObjs; i++) { MDagPath dagPath = new MDagPath(); list.getDagPath(i, dagPath); if (!dagPath.isValid) { continue; } // Add the callback for all changes of the specified type. // if (allDagUsed) { // we don't use obsolete function // addAllDagChangesCallback // use addAllDagChangesDagPathCallback instead try { dagPath.AllDagChangesDagPath += userDAGGenericCB; string infoStr = string.Format("Added a callback for all Dag changes on {0}", dagPath.fullPathName); MGlobal.displayInfo(infoStr); } catch (Exception) { throw new ApplicationException("Could not add a -allDag callback"); } } if (parentAddedUsed) { addGenericCallback(dagPath, MDagMessage.DagMessage.kParentAdded, " parent added "); } if (parentRemovedUsed) { addGenericCallback(dagPath, MDagMessage.DagMessage.kParentRemoved, " parent removed "); } if (childAddedUsed) { addGenericCallback(dagPath, MDagMessage.DagMessage.kChildAdded, " child added "); } if (childRemovedUsed) { addGenericCallback(dagPath, MDagMessage.DagMessage.kChildRemoved, " child removed "); } if (childReorderedUsed) { addGenericCallback(dagPath, MDagMessage.DagMessage.kChildReordered, " child reordered "); } } } return; }