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 / bezier_triangle_patches.py next >
Encoding:
Text File  |  2009-01-23  |  1.3 KB  |  41 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 bezier triangle patches in the mesh ...
  11. patches = k3d.bezier_triangle_patch.create(Output)
  12.  
  13. # We will create two identical bezier triangle patches ...
  14. for i in range(2):
  15.     patches.patch_first_points().append(len(points))
  16.     patches.patch_orders().append(4)
  17.     patches.patch_selections().append(0)
  18.     patches.patch_materials().append(None)
  19.  
  20.     # from The Platonic Spheroids at http://www.cise.ufl.edu/research/SurfLab/pre99-papers/97.spheroids.ps.gz
  21.     # The tetroid:
  22.     # (3,-3,-3) (1,-1,-7) (-1,1,-7) (-3,3,-3)
  23.     #    (1,-7,-1) (-11,-11,-11) (-7,1,-1)
  24.     #           (-1,-7,1) (-7,-1,1)
  25.     #                (-3,-3,3)
  26.     positions = [
  27.         (3,-3,-3),
  28.         (1,-7,-1), (1,-1,-7),
  29.         (-1,-7,1), (-11,-11,-11), (-1,1,-7),
  30.         (-3,-3,3), (-7,-1,1), (-7,1,-1), (-3,3,-3) ]
  31.  
  32.     # Assign patch_points and patch_weights here ...
  33.     for j in range(0,len(positions)):
  34.         patches.patch_points().append(len(points) + j)
  35.         patches.patch_point_weights().append(1)
  36.  
  37.     for position in positions:
  38.         points.append(k3d.point3(position[0] + (12 * i), position[2], -position[1]))
  39.         point_selection.append(0.0)
  40.  
  41.