2 Demonstrate scene rendering with pymxs.
7 from pymxs
import runtime
as rt
9 INST = rt.Name(
"instance")
12 '''Create a scene made of spiralling spheres.'''
13 sphere = rt.sphere(radius=6.0)
18 for i
in range(0, revolutions, 20):
26 result, nodes = rt.MaxOps.CloneNodes(sphere, cloneType=INST, newNodes=pymxs.byref(
None))
27 radians = math.radians(i)
28 x_sphere = radius * math.cos(radians)
29 y_sphere = radius * math.sin(radians)
32 nodes[0].Position = rt.Point3(x_sphere, y_sphere, z_sphere)
36 def maximize_perspective():
37 '''Setup perspective for the render'''
38 rt.viewport.setLayout(rt.Name(
'layout_1'))
39 rt.viewport.setType(rt.Name(
'view_persp_user'))
42 rt.point3(0.707107, 0.353553, -0.612372),
43 rt.point3(-0.707107, 0.353553, -0.612372),
44 rt.point3(0, 0.866025, 0.5),
45 rt.point3(-0.00967026,-70.3466,-552.481)
50 '''Render in the renderoutput directory.'''
51 output_path = os.path.join(rt.getDir(rt.Name(
"renderoutput")),
'foo.jpg')
52 if os.path.exists(output_path):
53 os.remove(output_path)
54 rt.render(outputFile=output_path)
57 '''Create a demo scene, adjust the perspective and render the scene'''
58 rt.resetMaxFile(rt.Name(
'noPrompt'))
60 maximize_perspective()