neonber.blogg.se

Autodesk maya 2014 api
Autodesk maya 2014 api









Compiled in VS 2013 and tested in Maya 2014. MBoundingBox bbox = mesh_dagNode.boundingBox Ĭmds.loadPlugin('')Ĭreate any polymesh object and connect its worldMesh to the input of created VoxelGenerator node e.g.Ĭmds.connectAttr('pPrismShape1.worldMesh', 'VoxelGenerator1.inputMesh')ĭownload Visual Studio project with the files above. MFnDagNode mesh_dagNode = new MFnDagNode(mesh_dpath) / Delete (MObject) voxels stored in this.voxelObjectsįor (int i = 0 i < voxelObjects.length i++) MMatrix mInclusive = mesh_dpath.inclusiveMatrix Private void LocalToWorldSpace(ref MPoint point) / Transform MPoint using mesh transformation matrix NewVoxel_tRotation(rotation) ĭagModifier.doIt() // Create all generated voxels NewVoxel_tTranslation(new MVector(fPoint.x, MDagPath newVoxel_mdp = MDagPath.getAPathTo(newVoxel) MObject newVoxel = dagModifier.createNode("locator", MDagModifier dagModifier = new MDagModifier() įor (double x = + xlen * borderOffset MFnTransform newVoxel_mfnTransform = new MFnTransform() create function set to work with voxels transforms MFloatArray hitRayParams = new MFloatArray() MFloatPointArray hitPoints = new MFloatPointArray() MMeshIsectAccelParams accelParams = null MFloatVector rayDirection = new MFloatVector(outerPoint) block of parameters for MFnMesh.allIntersections() Var rotation = transformationMatrix.rotation Var transformationMatrix = new MTransformationMatrix(mExclusive) MFloatPoint outerPoint = new MFloatPoint((float)( * 2), the second (outer) point for tracing ray / and method returning true if voxel is inside mesh. / Generate voxels grid based on bounding box of the mesh Step = (float)((minEdge - 2 * minEdge * borderOffset) / (nsity - 1)) Public VoxelGrid(MObject oMesh, short typeIndex, / the shortest dimension of a bounding box / type of an algorithm used for a grid generation Private MMatrix mExclusive // MDagPath.exclusiveMatrix of input mesh

autodesk maya 2014 api

Public int VoxelCount // Number of created voxel nodes Private const float borderOffset = 0.01f // Grid offset (inside a volume)ĭouble xlen // Bounding box length along xĭouble ylen // Bounding box length along yĭouble zlen // Bounding box length along z Private MObjectArray voxelObjects // Array of voxels Private MBoundingBox bbox // Bounding box of the input mesh Private MFnMesh mfnMesh // Poly Function Set for input mesh Private MDagPath mesh_dpath // Input mesh as MDagPath Private Type voxelType // Type of the VoxelGrid (world or object oriented)

#AUTODESK MAYA 2014 API UPDATE#

We call in these two methods on each update in order to regenerate voxels. VoxelGenerator.oOutput = numAttr.create("output",įile VoxelGrid.cs contains methods DeleteVoxels() and GenerateVoxels(). VoxelGenerator.oInputMesh = typedAttr.create("inputMesh", VoxelGenerator.oVoxelType = enumAttr.create("voxelType", "type") MFnNumericAttribute numAttr = new MFnNumericAttribute() MFnTypedAttribute typedAttr = new MFnTypedAttribute() MFnEnumAttribute enumAttr = new MFnEnumAttribute() MGlobal.displayInfo("calculation time (ms): " + MDataHandle outputHandle = dataBlock.outputValue(oOutput) set grid.VoxelCount as value of the output attribute generate voxels based on input mesh, type and density attributes Short density = densityDataHandle.asShort MDataHandle densityDataHandle = dataBlock.inputValue(oDensity) Short voxelType = voxelTypeDataHandle.asShort MDataHandle voxelTypeDataHandle = dataBlock.inputValue(oVoxelType) MPlug mesh_mplug = new MPlug(thisMObject(), oInputMesh) MGlobal.displayInfo("No mesh connected.") MObject oConnectedMesh = meshDataHandle.asMesh MDataHandle meshDataHandle = dataBlock.inputValue(oInputMesh) Override public bool compute(MPlug plug, MDataBlock dataBlock) set default value for the input attributeĪDensity = new MFnNumericAttribute(oDensity) Public class VoxelGenerator : MPxNode //, IMPxNode This class is instantiated by Maya for each node created in a Maya [assembly: MPxNodeClass(typeof(MayaNetPlugin.VoxelGenerator), "VoxelGenerator", I added my comments to make it more comprehensible. It defines node name, input and output attributes and compute() method. Public string GetMayaDotNetSdkBuildVersion()įile myNode.cs contains a primary node class. This line is not mandatory, but improves loading performances

autodesk maya 2014 api

We don't need to change anything in the file myPlugin.cs, so I cut out all comments to make it much shorter. Maya Plugin Wizard creates files myNode.cs and myPlugin.cs.









Autodesk maya 2014 api