Everything related to SDK.
User avatar
By sebkaine
#388890
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

- 3 animated mesh on my drive :
/home/tmp/moo.abc
/home/tmp/maa.abc
/home/tmp/muu.abc

- 3 surface shaders
/home/tmp/soo.mxm
/home/tmp/saa.mxm
/home/tmp/suu.mxm

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

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

Thanks for your time !

Cheers

E
User avatar
By Brany
#388895
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 all
import 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!
#388898
Thanks a lot for your extremely detail and helpful answer Brany ! :)

For the camera i am not tied to .abc would it be possible to read a camera directly with a .fbx file ?

The motivation of this question is that i am using
- Houdini Indie
- Maya LT
None of them allow external renderer.

So i was evaluating any options to be able to use maxwell in an other way, 3 possibility come to my mind :
- use Maxwell Studio
- use blender
- use pyMaxwell

-> Maxwell Studio doesn't support animation render so it's a dead end for animation / vfx work
-> Blender is not supported by NL officially / has a none reliable .fbx importer / has no .abc impoter so again dead end

The only options that remains is pyMaxwell/python and it looks indeed to be possible to build and dispatch this way.
- My idea would be to work and import assets in studio in a reference_scene.mxs
- Lookdev in studio
- Then build the .mxs sequence for animation with pyMaxwell / Python from reference_scene.mxs and thus have ;
reference_scene.0001.mxs
reference_scene.0002.mxs
...
reference_scene.0125.mxs

in other word just modify/force the evaluated frame in script.

Does it look doable in practice or does it look stupid/overkill/not usable in production ?

Thanks again for your time !

Cheers

E
User avatar
By Brany
#388899
I have no experience setting production pipelines, but it seems feasible for me.

Regarding the camera, pymaxwell is not able to read cameras from other sources than a .mxs file, sorry!
#388900
Thanks again for your answer Brany !

The more i think about it , the more i thinks it's not a viable option !

Because loading 3 mesh is one thing, but load
- many geo .abc
- many volumetric .vdb
- particles
- shaders
- use an external lib to read camera ...
=> load this in script to build the scene ...

This sound more like i'm building the Titanic. :)

I'm gonna stick with Mantra and use Maxwell for lookdev and lighting reference for the moment ...

Cheers

E
New podcast - CG Talks

Hi guys! We've just finished the first season of […]

Thanks, Luis, appreciated. It looks like industria[…]

That looks like a low bpc (bits per channel) norma[…]

Fully working plugin for C4D

When you will be working on it please try to keep […]