home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Multimedia / k3d-setup-0.7.11.0.exe / share / k3d / scripts / MeshSourceScript / bicubic_patches.py < prev    next >
Encoding:
Text File  |  2008-11-16  |  1.2 KB  |  40 lines

  1. #python
  2.  
  3. import k3d
  4. k3d.check_node_environment(locals(), "MeshSourceScript")
  5.  
  6. # Perform required one-time setup to store geometric points in the mesh ...
  7. points = Output.create_points()
  8. point_selection = Output.create_point_selection()
  9.  
  10. # Perform required one-time setup to store bicubic patches in the mesh ...
  11. patches = k3d.bicubic_patch.create(Output)
  12.  
  13. # Create an (optional) array to hold color values at the parametric
  14. # corners of each patch ...
  15. Cs = patches.varying_data().create("Cs", "k3d::color")
  16.  
  17. # We will create two identical bicubic patches ...
  18. for i in range(2):
  19.     patches.patch_selections().append(0)
  20.     patches.patch_materials().append(None)
  21.  
  22.     for j in range(16):
  23.         patches.patch_points().append(len(points) + j)
  24.  
  25.     positions = [
  26.         (-5, -5, 0), (-2, -5, 2), (2, -5, -2), (5, -5, 0),
  27.         (-5, -2, 2), (-2, -2, 5), (2, -2, -5), (5, -2, -2),
  28.         (-5, 2, 2), (-2, 2, 5), (2, 2, -5), (5, 2, -2),
  29.         (-5, 5, 0), (-2, 5, 2), (2, 5, -2), (5, 5, 0)]
  30.  
  31.     for position in positions:
  32.         points.append(k3d.point3(position[0] + (12 * i), position[2], -position[1]))
  33.         point_selection.append(0.0)
  34.  
  35.     Cs.append(k3d.color(1, 0, 0))
  36.     Cs.append(k3d.color(0, 1, 0))
  37.     Cs.append(k3d.color(0, 0, 1))
  38.     Cs.append(k3d.color(1, 1, 1))
  39.  
  40.