If you know the exact positions where you want to create the instances, you have several options:
1. Create a Maya particle system with particles at those positions and use an instancer on it. The plug-in will export Maxwell instances.
2. Create Maya instances at those positions. This will slow down the viewport, though.
3. Create maxwellInstance objects at those positions. You can set a low LOD on the instance objects so that the Maya viewport doesn't slow down.
4. Use the API of the Maya plug-in to create Maxwell instances at those positions at export time.
5. Use the API of the Maya plug-in to create a MaxwellCloner object at export time, and pass it the object positions in the PARTICLE_POSITIONS attribute (the extension doesn't require a BIN file, it's also possible to give it the positions directly, as vectors). I wouldn't go this way though, because you won't be able to control the orientation of the instances.
The documentation for the plug-in API is here:
http://support.nextlimit.com/display/ma ... lug-in+API. In your case, you can add a post-scene hook which creates the instances, e.g.:
Code: Select allimport maxwell
import maya.OpenMaya as OpenMaya
def MakeInst():
tm = OpenMaya.MTransformationMatrix()
pivot = OpenMaya.MMatrix()
pivot.setToIdentity()
# Assume there's an object called pSphere1 in the scene, which we will instance.
sphere = maxwell.FindShape('pSphere1')
# Create an instance at (5, 0, 0).
inst1 = maxwell.Instance('inst1', sphere)
pos = OpenMaya.MVector(5, 0, 0)
tm.setTranslation(pos, OpenMaya.MSpace.kObject)
m = tm.asMatrix()
# The parameters for this method are: world matrix, pivot matrix, time, scaleTranslation.
# The time parameter is used for motion blur and must be in the range [0..1], where 0 means
# shutter open time and 1 means shutter close time. You can call the method several times
# with different time values to specify the transformation of the object at each step.
# The scaleTranslation parameter is a boolean which asks the Maxwell plug-in to convert the
# translation part of the matrices from the Maya system unit to meters, and also apply the
# global scale factor which is set in the render settings panel. Please note that the Maya
# system unit is always centimeters, regardless of the unit configured in the Maya preferences.
inst1.SetTransformation(m, pivot, 0, True)
# Create a second instance at (0, 0, 5).
inst2 = maxwell.Instance('inst2', sphere)
pos = OpenMaya.MVector(0, 0, 5)
tm.setTranslation(pos, OpenMaya.MSpace.kObject)
m = tm.asMatrix()
inst2.SetTransformation(m, pivot, 0, True)
# This makes the plug-in print some debug messages in the Maya script editors, including error messages
# caused by improper API usage.
maxwell.EnableDebugMessages(True)
# Tell the Maya plug-in to call our MakeInst() function after the entire scene has been exported,
# but before the MXS is written.
maxwell.SetExportCallback('MakeInstExample', maxwell.ExportCallbackType_AfterScene, 'MakeInst()')
If you really want to create a cloner extension, you will have to create a
maxwell.ExtensionParams object (see the documentation of the
CreateExtensionParamBlock() C++ function for details), fill in parameters with its Set*() methods and then create a
maxwell.ExtensionShape object with it (see the equivalent
CreateExtensionShape() C++ function for details). To get the list of parameters that an extension supports you can use the MEL command "maxwell -listExtensions true".
PS: don't confuse the API of the Maya plug-in with the pyMaxwell API, or with the Maxwell SDK. They are completely unrelated.