home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1996 September / WIN95_09962.iso / vrml / MWE105.ZIP / EExamples / Helix.vxr < prev    next >
Text File  |  1996-04-14  |  1KB  |  46 lines

  1. #VRML V1.0 ascii
  2.  
  3. Separator {
  4.     # Options: ON OFF AUTO
  5.     renderCulling AUTO
  6.     
  7.     OUTPUT_TO Helix.wrl
  8.     
  9.     DEF BackgroundColor Info {
  10.         string  ".9 .9 .9"
  11.     }
  12.  
  13.     Material {
  14.         diffuseColor =Color("yellow")
  15.     }
  16.     
  17.     # This is where we will put the data for the helix
  18.     DEF dataSet Coordinate3 {
  19.         point [] # MFVec3f
  20.     }
  21.     
  22.     # This node connects the helix data points using polylines
  23.     DEF lineSet IndexedLineSet {
  24.         coordIndex [] # MFLong
  25.         materialIndex -1 # MFLong
  26.         normalIndex -1 # MFLong
  27.         textureCoordIndex -1 # MFLong
  28.     }
  29.     
  30.     # This node creates the data for the helix using the parametric equations
  31.     #     x = r cos t
  32.     #     y = r sin t
  33.     #     z = b t
  34.     LOOP {
  35.         fields [ SFLong start, SFLong end, SFLong step, SFLong position,
  36.             SFFloat t, SFFloat r ] # Define r and t
  37.         start 0
  38.         end 200
  39.         step 1
  40.         t position*.5    # Define t
  41.         r position*.1    # Define r
  42.         APPEND dataSet:point (r*cos(t),r*sin(t),t) # We need a vector value here so we use ()
  43.         APPEND lineSet:coordIndex position  # Be careful to specify an existing point index
  44.     }
  45.     APPEND lineSet:coordIndex -1  # this is needed to end the polyline
  46. }