VRML : Chemistry in VRML
Source code for example 4 : A p orbital.
#VRML V1.0 ascii
Separator {
#Create Lights, Camera, and Material as before
DirectionalLight { direction 0 0 -1 }
DirectionalLight { direction 0 -1 0 }
PerspectiveCamera {
position 8 2 8
orientation 0 1 0 0.7853
}
Material {
diffuseColor 0 1 0
ambientColor 0 0.2 0
}
#Create axes using same method as before
DEF gaxis Cylinder {
height 10
radius 0.1
}
Separator {
Rotation { rotation 0 0 1 1.570796 }
USE gaxis
Rotation { rotation 1 0 0 1.570796 }
USE gaxis
}
#Create a new material
Material {
diffuseColor 0 0 1
ambientColor 0 0 0.2
}
#Move "down" by 1.2 units, and create a cone.
#Note that the cone and the translation are DEFined
#so they can be used again later on
DEF mytrans Translation { translation 0 -1.2 0 }
DEF mycone Cone {
parts SIDES
height 2
bottomRadius 1
}
#USE mytrans shift down another 1.2 units ( bottom of
#the cone, and here we create a ball to round of the
#pi orbital
USE mytrans
DEF atom Sphere { radius 1 }
#This rotation turns the y axis upside-down, so down is
#now up. Therefore "mytrans" now goes "up" 1.2 units
Rotation { rotation 1 0 0 3.151692 }
USE mytrans
USE mytrans
#At this point, we are back at the "real" (0,0,0) and the
#whole process is repeated upside down, finishing off the
#pi orbital
USE mytrans
USE mycone
USE mytrans
USE atom
}
#End of File
#Note how the use of DEF and USE saved us from typing out
#the same things many times. It is a good idea to use DEF
#and USE as often as is posible
Previous Topic (Chemistry in VRML)
Back to the VRML Reference
Back to the Main Page
©Tom Thurston, 1997
Please feel free to use and redistribute this NONcommercially!