home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1996 September / WIN95_09962.iso / vrml / MWE105.ZIP / EExamples / Lattice.vxr < prev    next >
Text File  |  1996-01-24  |  3KB  |  118 lines

  1. #VRML V1.0 ascii
  2.  
  3. Separator {
  4.     # Options: ON OFF AUTO
  5.     renderCulling AUTO
  6.     
  7.     OUTPUT_TO Lattice.wrl
  8.     
  9.     DEF BackgroundColor Info {
  10.         string  ".1 .2 .5"
  11.     }
  12.  
  13.     DEF local PARAMETERS {
  14.         fields [ SFLong xNumber, SFLong yNumber, SFLong zNumber]
  15.         xNumber 4
  16.         yNumber 3
  17.         zNumber 3
  18.     }
  19.     
  20.     Material {
  21.         diffuseColor =Color("red")
  22.     }
  23.     
  24.     # Define the nodes of a lattice
  25.     
  26.     DEF xLoop LOOP {
  27.         fields [ SFLong start, SFLong end, SFLong step, SFLong position ]
  28.         start 1
  29.         end local:xNumber
  30.         step 1
  31.         
  32.         DEF zLoop LOOP {
  33.             fields [ SFLong start, SFLong end, SFLong step, SFLong position ]
  34.             start 1 
  35.             end local:zNumber
  36.             step 1
  37.                     
  38.             DEF yLoop LOOP {
  39.                 fields [ SFLong start, SFLong end, SFLong step, SFLong position ]
  40.                 start 1
  41.                 end local:yNumber
  42.                 step 1
  43.                                 
  44.                 VARNAME ball~`xLoop:position`~`yLoop:position`~`zLoop:position` Ball {
  45.                     fields [ SFVec3f center, SFFloat radius ]
  46.                     center xLoop:position yLoop:position zLoop:position
  47.                     radius .1
  48.                 }
  49.             }
  50.         }        
  51.     }
  52.  
  53.     Material {
  54.         diffuseColor =Color("green")
  55.     }
  56.     
  57.     # Define connections parallel to the x, y and z axis
  58.     DEF xLoop2 LOOP {
  59.         fields [ SFLong start, SFLong end, SFLong step, SFLong position ]
  60.         start 1
  61.         end local:xNumber
  62.         step 1
  63.         
  64.         DEF zLoop2 LOOP {
  65.             fields [ SFLong start, SFLong end, SFLong step, SFLong position ]
  66.             start 1
  67.             end local:zNumber
  68.             step 1
  69.             
  70.             DEF yLoop2 LOOP {
  71.                 fields [ SFLong start, SFLong end, SFLong step, SFLong position ]
  72.                 start 1
  73.                 end local:yNumber
  74.                 step 1
  75.                 
  76.                 # X direction
  77.  
  78.                 SELECT {
  79.                     fields [ SFLong whichChild ]
  80.                     whichChild if(xLoop2:position+1<local:xNumber)then(0)else(-1)
  81.                     
  82.                     Connect {
  83.                         fields [ SFNode first, SFNode second, SFFloat radius ]
  84.                         first ball~`xLoop2:position`~`yLoop2:position`~`zLoop2:position`
  85.                         second ball~`xLoop2:position+1`~`yLoop2:position`~`zLoop2:position`
  86.                         radius 2'cm
  87.                     }
  88.                 }
  89.  
  90.                 # Z direction
  91.                 SELECT {
  92.                     fields [ SFLong whichChild ]
  93.                     whichChild if(zLoop2:position+1<local:zNumber)then(0)else(-1)
  94.                     
  95.                     Connect {
  96.                         fields [ SFNode first, SFNode second, SFFloat radius ]
  97.                         first ball~`xLoop2:position`~`yLoop2:position`~`zLoop2:position`
  98.                         second ball~`xLoop2:position`~`yLoop2:position`~`zLoop2:position+1`
  99.                         radius 2'cm
  100.                     }
  101.                 }
  102.  
  103.                 # Y direction
  104.                 SELECT {
  105.                     fields [ SFLong whichChild ]
  106.                     whichChild if(yLoop2:position+1<local:yNumber)then(0)else(-1)
  107.                     
  108.                     Connect {
  109.                         fields [ SFNode first, SFNode second, SFFloat radius ]
  110.                         first ball~`xLoop2:position`~`yLoop2:position`~`zLoop2:position`
  111.                         second ball~`xLoop2:position`~`yLoop2:position+1`~`zLoop2:position`
  112.                         radius 2'cm
  113.                     }
  114.                 }
  115.             }
  116.         }
  117.     }
  118. }