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 / cubic_curves.py < prev    next >
Encoding:
Text File  |  2009-01-06  |  1.5 KB  |  44 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 cubic curves in the mesh ...
  11. curves = k3d.cubic_curve.create(Output)
  12.  
  13. # Create an (optional) array to store per-group curve widths ...
  14. constantwidth = curves.constant_data().create("constantwidth", "k3d::double_t")
  15.  
  16. # Create an (optional) array to store per-curve curve colors ...
  17. Cs = curves.uniform_data().create("Cs", "k3d::color")
  18.  
  19. # Add some curves ...
  20. curves.periodic().append(False)
  21. curves.material().append(None)
  22. constantwidth.append(0.5)
  23.  
  24. for j in range(5):
  25.     curves.curve_first_points().append(len(curves.curve_points()))
  26.     curves.curve_point_counts().append(7)
  27.     curves.curve_selections().append(0.0)
  28.  
  29.     curves.curve_points().append(len(points) + 0)
  30.     curves.curve_points().append(len(points) + 1)
  31.     curves.curve_points().append(len(points) + 2)
  32.     curves.curve_points().append(len(points) + 3)
  33.     curves.curve_points().append(len(points) + 4)
  34.     curves.curve_points().append(len(points) + 5)
  35.     curves.curve_points().append(len(points) + 6)
  36.  
  37.     positions = [(0, 0, 5), (-5, 0, 5), (-5, 0, 0), (0, 0, 0), (5, 0, 0), (5, 0, -5), (0, 0, -5)]
  38.     for position in positions:
  39.         points.append(k3d.point3(position[0] + (j * 5), position[1], position[2]))
  40.         point_selection.append(0.0)
  41.  
  42.     Cs.append(k3d.color(1, 1, j * 0.2))
  43.  
  44.