VRML : Chemistry in VRML
Source code for example 7 : A sp2 hybridised
atom.
#VRML V1.0 ascii
Separator {
#Setup lights, camera, and material as usuall
DirectionalLight { direction 0 0 -1 }
DirectionalLight { direction 0 -1 0 }
PerspectiveCamera {
position 0 8 0
orientation -1 0 0 1.57
}
Material {
diffuseColor 1 0 0
ambientColor 0.2 0 0
}
#Create a small sphere representing the nucleus
Sphere { radius 0.2 }
#Create a new material for the orbitals, and rotate so
#that y axis lies where x axis used to
Material {
diffuseColor 0 0 1
ambientColor 0 0 .2
}
Rotation { rotation 0 0 1 1.57096 }
#Move 1.2 units along the y axis (old x axis), and draw
#a cone, DEFing it for re-use later in the world
Separator {
DEF mytrans Translation { translation 0 -1.2 0 }
DEF mycone Cone {
parts SIDES
height 2
bottomRadius 1
}
#Move the same distance in the same direction. We are
#now at the base of the cone, and we add a sphere to
#round of the orbital
USE mytrans
DEF atom Sphere { radius 1 }
}
#Now we rotate around the x axis (old y axis) an angle
#of 120 degrees, and repeat, USEing the objects DEFed
#above. Note how much space and time this saves.
Separator {
Rotation { rotation 1 0 0 2.094396 }
USE mytrans
USE mycone
USE mytrans
USE atom
}
#This time, we rotate in the opposite direction, and
#and create the last orbital
Separator {
Rotation { rotation 1 0 0 -2.094396 }
USE mytrans
USE mycone
USE mytrans
USE atom
}
}
#End of File
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!