Python Particles - RenderMan & Maya |
Introduction
This challenge will enable you to explore several basic concepts of python programming: RenderMan ParticlesTo successfully complete this part of the challenge you will write two python scripts. The first script will contain at least 5 procedures. Each procedure will produce a list of 3D points that describe of the positions of an arbitary number of "particles" that form a specific shape. For example, the following python script implements a procedure called cubic(). #------------------------- gen_points.py -------------------- import random import math def cubic(num_points, side): data = [] count = 0 half_side = side/2 while count < num_points: x = random.uniform(-half_side, half_side) y = random.uniform(-half_side, half_side) z = random.uniform(-half_side, half_side) data.append( (x,y,z) ) count += 1 return data #------------------------------------------------------------ You are expected to implement the following procedures, spherical(num_points, radius) cylindrical(num_points, radius, height) box(num_points, width, length, height) cone(num_points, radius, height) The second python script will use the first script to generate particle positions that will be written to a rib file. An example implementation is shown next. |
#---------------------- rib_particles.py -------------------- import gen_points def writeCubic(rib_path, num_particles, side, particle_width): data = gen_points.cubic(num_particles, side) half_side = side/2 rib_out = open(rib_path, 'w') # Maya will use the bounding box dimensions to # represent the particles as a simple box. # minX, minY, minZ, maxX, maxY, maxZ rib_out.write('##bbox: %s %s %s %s %s %s \n' % (-half_side,-half_side,-half_side, half_side,half_side,half_side)) rib_out.write('Points "P" [\n') for x,y,z in data: rib_out.write('%1.3f %1.3f %1.3f\n' % (x,y,z)) rib_out.write('] "constantwidth" [%1.3f]\n' % particle_width) rib_out.close() #------------------------------------------------------------ |
A pre-baked rib file that describes a very simple collection of particles would look as follows. The rib files that you will produce may define many thousands of particles. ##bbox: -3 -3 -3 3 3 3 Points "P" [ -0.752 2.126 0.999 -0.027 2.452 -0.492 0.333 -2.494 -0.612 ] "constantwidth" [0.050] How pre-baked rib files are used in Maya will be demonstrated during our zoom sessions. You are expected to add following 4 procedures to the rib_particles.py script, writeSpherical(rib_path, num_points, radius, particle_width) writeCylindrical(rib_path, num_points, radius, height, particle_width) writeBox(rib_path, num_points, width, length, height, particle_width) writeCone(rib_path, num_points, radius, height, particle_width) |
Maya ParticlesTo successfully complete this part of the challenge you will write only one python script. For example, the next code snippet implements a procedure called cubicCloud(). #-------------------- maya_particles.py ----------------------- import maya.cmds as cmds import gen_points def cubicCloud(num_particles, side): # Use the gen_points module to create a list of points data = gen_points.cubic(num_particles, side) # Use Maya's python command to add the cubic particle # cloud to the viewport. Capture and return the name of # the particle system. return cmds.particle(p=data)[0] #------------------------------------------------------------ You are expected to implement and add following procedures to the maya_particles script, sphericalCloud(num_points, radius) cylindricalCloud(num_points, radius, height) boxCloud(num_points, width, length, height) conicalCloud(num_points, radius, height) How the procedures implemented by your maya_particles script are used in Maya will be demonstrated during our zoom sessions. |
What is Expected?
The technical breakdown on your web page should show the following.
|
GradingThe following categories will be used for grading your work. |
|