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 / linear_curves.py < prev    next >
Encoding:
Text File  |  2009-01-06  |  1.2 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 linear curves in the mesh ...
  11. curves = k3d.linear_curve.create(Output)
  12.  
  13. # Create an (optional) array to store 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 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(3)
  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.  
  33.     positions = [(0, 0, 5), (5, 0, 0), (0, 0, -5)]
  34.  
  35.     for position in positions:
  36.         points.append(k3d.point3(position[0] + (j * 5), position[1], position[2]))
  37.         point_selection.append(0.0)
  38.  
  39.     Cs.append(k3d.color(1, 1, j * 0.2))
  40.  
  41.