emmanuel.mouillet@gmail.com wrote:Hi guys,
I would like to know if it's possible to build/assemble/dispatch maxwell scene without using the ui but just pyMaxwell.
http://www.maxwellrender.com/api/3.2/do ... archy.html
For exemple i have an animation with a time range of 1-125 with the following component :
- 1 camera :
/home/tmp/camera.abc
Our API is not able to read camera data straight from an alembic file. You can try the alembic python bindings (
http://docs.alembic.io/python/), I have no experience using it, sorry! At least you have to call 2 pymaxwell methods to create a camera properly:
Cmaxwell.addCamera( name, nSteps, shutter, filmWidth, filmHeight, iso, diaphragmType,
angle, nBlades, fps, xRes, yRes, pixelAspect, lensType = TYPE_THIN_LENS,
proyectionType = TYPE_PERSPECTIVE )
CmaxwellCamera.setStep( step, Cvector origin, Cvector focalPoint, Cvector, up,
focalLenght, fStop, stepTime, focalLengthNeedCorrection = 1 )
You will have to figure out all these values reading the .abc file by yourself.
emmanuel.mouillet@gmail.com wrote:- 3 animated mesh on my drive :
/home/tmp/moo.abc
/home/tmp/maa.abc
/home/tmp/muu.abc
You can do that following this example code:
Code: Select allimport pymaxwell as mw
def printExtensionParams(params):
for i in range(params.getNumItems()):
name,data,dataMin,dataMax,dataType,dataTypeSize,dataCount,ok = params.getByIndex(i)
print name
if dataType == mw.MXparamList.BYTEARRAY:
print 'BYTEARRAY'
elif dataType == mw.MXparamList.DOUBLE:
print 'DOUBLE'
elif dataType == mw.MXparamList.DOUBLEARRAY:
print 'DOUBLEARRAY'
elif dataType == mw.MXparamList.FLOAT:
print 'FLOAT'
elif dataType == mw.MXparamList.FLOATARRAY:
print 'FLOATARRAY'
elif dataType == mw.MXparamList.INT:
print 'INT'
elif dataType == mw.MXparamList.INTARRAY:
print 'INTARRAY'
elif dataType == mw.MXparamList.MXPARAMLIST:
print 'MXPARAMLIST'
elif dataType == mw.MXparamList.MXPARAMLISTARRAY:
print 'MXPARAMLISTARRAY'
elif dataType == mw.MXparamList.RGB:
print 'RGB'
elif dataType == mw.MXparamList.STRING:
print 'STRING'
elif dataType == mw.MXparamList.UCHAR:
print 'UCHAR'
elif dataType == mw.MXparamList.UINT:
print 'UINT'
def addAlembicObject(scene,mgr,abcPath,objName,frame):
extension = mgr.createDefaultGeometryLoaderExtension('MWObjectAlembic')
params = extension.getExtensionData()
#printExtensionParams(params)
params.setString('FileName',abcPath)
params.setInt('Frame#',frame)
obj = scene.createGeometryLoaderObject(objName,params)
if obj.isNull():
print('ERROR: object cannot be created')
return obj
if __name__ == "__main__":
mgr = mw.CextensionManager.instance()
mgr.loadAllExtensions()
flagAlembic = False
for i in range(mgr.getGeometryLoaderExtensionsCount()):
if mgr.getGeometryLoaderExtensionAtIndex(i).getName() == 'MWObjectAlembic':
print 'We can load alembic objects'
flagAlembic = True
if not flagAlembic:
print 'ERROR: cannot load MWObjectAlembic extension'
exit(1)
nFrames = 30
abcPath = 'C:/scenes/abc/walker_material.abc'
for i in range(nFrames):
scene = mw.Cmaxwell(mw.mwcallback)
addAlembicObject(scene,mgr,abcPath,'walker',i)
framePath = 'C:/scenes/abc/walker_{0:0>4d}'.format(i)+'.mxs'
print framePath+' saved'
if not scene.writeMXS(framePath):
print 'ERROR: cannot save '+framePath
emmanuel.mouillet@gmail.com wrote:- 3 surface shaders
/home/tmp/soo.mxm
/home/tmp/saa.mxm
/home/tmp/suu.mxm
You can do it like this:
scene = Cmaxwell(mwcallback)
...
material = scene.createMaterial('material name')
material.setReference(True,'/home/tmp/soo.mxm')
emmanuel.mouillet@gmail.com wrote:is it possible with pyMaxwell to :
- create an empty scene
- load my camera
- load by reference the 3 alembic mesh
- load by reference the 3 shaders
- assign each shaders to the good object
- setup and tweak my environment light
- setup my render settings
- save the generated scene_test.mxs on disk
- create an empty scene
OK
- load my camera
OK -> READING .abc FILE BY YOURSELF
- load by reference the 3 alembic mesh
OK
- load by reference the 3 shaders
OK
- assign each shaders to the good object
OK -> object.setMaterial(material)
- setup and tweak my environment light
OK Cmaxwell.getEnvironment()...
- setup my render settings
OK -> Cmaxwell.setRenderParameter(...)
- save the generated
scene_test.mxs on disk
OK -> Cmaxwell.writeMXS(...)
emmanuel.mouillet@gmail.com wrote:and then
- dispatch scene_test.mxs on the farm
- and modify the evaluated frame in the alembics loaders to render my animation
all this 100% generated from a python script render_scene_test.py
You can dispatch the mxs on the farm through python itself, pymaxwell has nothing to do with that
In the example code you can see how create N frames from each abc frame and save a .mxs for each one.
Hope it helps!