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

  1. #VRML V1.0 ascii
  2.  
  3. Separator {
  4.     # Options: ON OFF AUTO
  5.     renderCulling AUTO
  6.     
  7.     OUTPUT_TO HalfCylinder.wrl
  8.     
  9.     # Approximate a half cylinder using two half circle planes, a face, and 6 sides
  10.     
  11.     # Data for a half cyclinder
  12.     DEF shapeData Coordinate3 {
  13.         point [ ]
  14.     }
  15.     
  16.     # Define the data for the top half a circle
  17.     LOOP {
  18.         fields [ SFFloat start, SFFloat end, SFFloat step, SFFloat position]
  19.         start 0
  20.         end 181'deg
  21.         step 180'deg/6
  22.         
  23.         APPEND shapeData:point (cos(position),1,sin(position))
  24.     }
  25.     
  26.     # Define the data for the bottom half a circle
  27.     LOOP {
  28.         fields [ SFFloat start, SFFloat end, SFFloat step, SFFloat position]
  29.         start 0
  30.         end 181'deg
  31.         step 180'deg/6
  32.         
  33.         APPEND shapeData:point (cos(position),-1,sin(position))
  34.     }
  35.  
  36.     DEF shapeIndex IndexedFaceSet {
  37.         coordIndex [ ]
  38.     }
  39.  
  40.     # Connect the points to make a half cylinder
  41.  
  42.     APPEND shapeIndex:coordIndex (0,1,2,3,4,5,6,-1) # Top half
  43.     APPEND shapeIndex:coordIndex (7,8,9,10,11,12,13,-1) # Bottom half
  44.     APPEND shapeIndex:coordIndex (0,7,13,6,-1) # The slice
  45.  
  46.     APPEND shapeIndex:coordIndex (0,7,8,1,-1) # The sides
  47.     APPEND shapeIndex:coordIndex (1,8,9,2,-1) # The sides
  48.     APPEND shapeIndex:coordIndex (2,9,10,3,-1) # The sides
  49.     APPEND shapeIndex:coordIndex (3,10,11,4,-1) # The sides
  50.     APPEND shapeIndex:coordIndex (4,11,12,5,-1) # The sides
  51.     APPEND shapeIndex:coordIndex (5,12,13,6,-1) # The sides
  52. }
  53.