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 / bilinear_patches.py < prev    next >
Encoding:
Text File  |  2008-11-16  |  1.0 KB  |  36 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 bilinear patches in the mesh ...
  11. patches = k3d.bilinear_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 bilinear 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(4):
  23.         patches.patch_points().append(len(points) + j)
  24.  
  25.     positions = [ (-5, 0, 5), (5, 0, 5), (0, -5, -5), (0, 5, -5) ]
  26.  
  27.     for position in positions:
  28.         points.append(k3d.point3(position[0] + (12 * i), position[1], position[2]))
  29.         point_selection.append(0.0)
  30.  
  31.     Cs.append(k3d.color(1, 0, 0))
  32.     Cs.append(k3d.color(0, 1, 0))
  33.     Cs.append(k3d.color(0, 0, 1))
  34.     Cs.append(k3d.color(1, 1, 1))
  35.  
  36.