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 >
Wrap
Text File
|
1996-01-24
|
3KB
|
118 lines
#VRML V1.0 ascii
Separator {
# Options: ON OFF AUTO
renderCulling AUTO
OUTPUT_TO Lattice.wrl
DEF BackgroundColor Info {
string ".1 .2 .5"
}
DEF local PARAMETERS {
fields [ SFLong xNumber, SFLong yNumber, SFLong zNumber]
xNumber 4
yNumber 3
zNumber 3
}
Material {
diffuseColor =Color("red")
}
# Define the nodes of a lattice
DEF xLoop LOOP {
fields [ SFLong start, SFLong end, SFLong step, SFLong position ]
start 1
end local:xNumber
step 1
DEF zLoop LOOP {
fields [ SFLong start, SFLong end, SFLong step, SFLong position ]
start 1
end local:zNumber
step 1
DEF yLoop LOOP {
fields [ SFLong start, SFLong end, SFLong step, SFLong position ]
start 1
end local:yNumber
step 1
VARNAME ball~`xLoop:position`~`yLoop:position`~`zLoop:position` Ball {
fields [ SFVec3f center, SFFloat radius ]
center xLoop:position yLoop:position zLoop:position
radius .1
}
}
}
}
Material {
diffuseColor =Color("green")
}
# Define connections parallel to the x, y and z axis
DEF xLoop2 LOOP {
fields [ SFLong start, SFLong end, SFLong step, SFLong position ]
start 1
end local:xNumber
step 1
DEF zLoop2 LOOP {
fields [ SFLong start, SFLong end, SFLong step, SFLong position ]
start 1
end local:zNumber
step 1
DEF yLoop2 LOOP {
fields [ SFLong start, SFLong end, SFLong step, SFLong position ]
start 1
end local:yNumber
step 1
# X direction
SELECT {
fields [ SFLong whichChild ]
whichChild if(xLoop2:position+1<local:xNumber)then(0)else(-1)
Connect {
fields [ SFNode first, SFNode second, SFFloat radius ]
first ball~`xLoop2:position`~`yLoop2:position`~`zLoop2:position`
second ball~`xLoop2:position+1`~`yLoop2:position`~`zLoop2:position`
radius 2'cm
}
}
# Z direction
SELECT {
fields [ SFLong whichChild ]
whichChild if(zLoop2:position+1<local:zNumber)then(0)else(-1)
Connect {
fields [ SFNode first, SFNode second, SFFloat radius ]
first ball~`xLoop2:position`~`yLoop2:position`~`zLoop2:position`
second ball~`xLoop2:position`~`yLoop2:position`~`zLoop2:position+1`
radius 2'cm
}
}
# Y direction
SELECT {
fields [ SFLong whichChild ]
whichChild if(yLoop2:position+1<local:yNumber)then(0)else(-1)
Connect {
fields [ SFNode first, SFNode second, SFFloat radius ]
first ball~`xLoop2:position`~`yLoop2:position`~`zLoop2:position`
second ball~`xLoop2:position`~`yLoop2:position+1`~`zLoop2:position`
radius 2'cm
}
}
}
}
}
}