Summary examples
doorway.wrl

	

#VRML V2.0 utf8
#
#  doorway.wrl
#  The Doorway
#      by David R. Nadeau
#
#  Four sliding stairs lead forward along a path to a glowing white
#  doorway.
#
#  A ProximitySensor routes to four TimeSensors, one per sliding
#  stair.  Each stair's timer routes to a PositionInterpolator that
#  outputs varying positions side-to-side along the X axis.
#  The PositionInterpolator's positions are routed into translation
#  fields for Transform nodes surrounding each stair.
#
#  By using different starting positions, the four stairs are made to
#  slide back and forth in a pattern.
#
#  Things to experiment with:
#        Add sound!  Perhaps the crackling of fire below and the grinding
#        sliding sounds of the stone stairs.
#
#        Use a ScalarInterpolator to flicker the red light as if there is
#        fire below.
#
#        Surround the doorway with an Anchor node that leads somewhere!
#
#        Place a ProximitySensor around the doorway.  As you approach it,
#        the ProximitySensor triggers an OrientationInterpolator which
#        slowly rotates the door open.  The open door reveals ... !
#

WorldInfo {
    title "The Doorway"
    info [ "Copyright (c) 1997, David R. Nadeau" ]
}

DEF Entry Viewpoint {
    position 0.0 3.1 10.0
    description "Entry View"
}
NavigationInfo {
    type [ "WALK", "ANY" ]
    avatarSize [ 0.5, 3.0, 1.5 ]
    headlight FALSE
}

DEF Proximity ProximitySensor {
    size 10.0 10.0 50.0
}

Background {
    skyColor [
	0.0 0.0 0.0,
	0.0 0.0 0.0,
	1.0 0.0 0.0
    ]
    skyAngle [ 1.47, 1.67 ]
}


#
#  Generic light sources used to give the world ambience
#
#PointLight {
#    ambientIntensity 0.0
#    intensity 1.0
#    color 0.6 0.6 0.6
#    location 0.0 6.0 -8.0
#}
DirectionalLight {
    ambientIntensity 0.5
    intensity 1.0
    #color 0.0 0.15 0.5
    color 0.0 0.3 1.0
    direction 1.0 -1.0 -3.0
}
DirectionalLight {
    ambientIntensity 0.3
    intensity 1.0
    color 1.0 0.0 0.0
    direction -1.0 2.5 -1.0
}
DirectionalLight {
    ambientIntensity 0.0
    intensity 1.0
    color 1.0 0.0 0.0
    direction -1.0 2.5 -1.0
}


#
#  Path to stairs
#
Transform {
    translation 0.0 -0.5 8.0
    children [
	Shape {
	    appearance Appearance {
		material Material {
		    diffuseColor 0.8 0.8 0.8
		}
		texture DEF Granit ImageTexture {
		    url "granit_g.jpg"
		}
		textureTransform TextureTransform {
		    scale 0.5 0.5
		}
	    }
	    geometry Box {
		size 4.0 0.4 16.0
	    }
	}
    ]
}


#
#  Moving stairs
#
DEF Stair1 Transform {
    translation 0.0 0.0 0.0
    children [
	DEF Stair Inline {
	    url "tread.wrl"
	}
    ]
}

Transform {
    translation -1.0 0.5 -2.0
    children [
	DEF Stair2 Transform {
	    translation 0.0 0.0 0.0
	    children [ USE Stair ]
	}
    ]
}

Transform {
    translation 1.5 1.0 -4.0
    children [
	DEF Stair3 Transform {
	    translation 0.0 0.0 0.0
	    children [ USE Stair ]
	}
    ]
}

Transform {
    translation 0.0 1.5 -6.0
    children [
	DEF Stair4 Transform {
	    translation 0.0 0.0 0.0
	    children [ USE Stair ]
	}
    ]
}


#
#  The last stair and a door
#
Transform {
    translation 0.0 2.0 -8.0
    children [ USE Stair ]
}

Transform {
    translation 0.0 2.0 -10.0
    scale 0.7 0.7 0.7
    children [
	Inline {
	    url "glowdoor.wrl"
	}
    ]
}


#
#  An archway above the door
#
Transform {
    translation -2.0 6.0 -10.0
    rotation 0.0 0.0 1.0 0.785
    children [
	DEF ArchBox Shape {
	    appearance Appearance {
		material Material {
		    ambientIntensity 0.0
		    diffuseColor 1.0 1.0 1.0
		    emissiveColor 0.4 0.4 0.4
		}
		texture ImageTexture {
		    url "marble_g.jpg"
		}
	    }
	    geometry Box {
		size 4.0 0.2 2.0
	    }
	}
	Transform {
	    translation 1.0 0.2 1.0
	    children [ USE ArchBox ]
	}
	Transform {
	    translation 2.0 0.4 2.0
	    children [ USE ArchBox ]
	}
    ]
}

Transform {
    translation 2.0 6.0 -10.0
    rotation 0.0 0.0 1.0 -0.785
    children [
	USE ArchBox,
	Transform {
	    translation -1.0 0.2 1.0
	    children [ USE ArchBox ]
	}
	Transform {
	    translation -2.0 0.4 2.0
	    children [ USE ArchBox ]
	}
    ]
}





#
#  Animation control
#
#  For each stair, a TimeSensor is triggered by a world ProximitySensor.
#  Once triggered, the time sensor outputs fractions forever.  The fractions
#  are routed in to PositionInterpolators that smoothly interpolate a
#  sliding position back and forth along the X axis.  These positions are
#  routed in to translations for the individual stairs.
#
DEF Stair1Timer TimeSensor {
    cycleInterval 4.0
    loop TRUE
}
DEF Stair1Path PositionInterpolator {
    key      [ 0.0,         0.25,        0.5,         0.75,         1.0         ]
    keyValue [ 0.0 0.0 0.0, 3.0 0.0 0.0, 0.0 0.0 0.0, -3.0 0.0 0.0, 0.0 0.0 0.0 ]
}
ROUTE Proximity.enterTime          TO Stair1Timer.set_startTime
ROUTE Stair1Timer.fraction_changed TO Stair1Path.set_fraction
ROUTE Stair1Path.value_changed     TO Stair1.set_translation



DEF Stair2Timer TimeSensor {
    cycleInterval 4.0
    loop TRUE
}
DEF Stair2Path PositionInterpolator {
    key      [ 0.0,         0.25,        0.5,          0.75,        1.0         ]
    keyValue [ 3.0 0.0 0.0, 0.0 0.0 0.0, -3.0 0.0 0.0, 0.0 0.0 0.0, 3.0 0.0 0.0 ]
}
ROUTE Proximity.enterTime          TO Stair2Timer.set_startTime
ROUTE Stair2Timer.fraction_changed TO Stair2Path.set_fraction
ROUTE Stair2Path.value_changed     TO Stair2.set_translation


DEF Stair3Timer TimeSensor {
    cycleInterval 4.0
    loop TRUE
}
DEF Stair3Path PositionInterpolator {
    key      [ 0.0,          0.25,        0.5,         0.75,         1.0         ]
    keyValue [ -3.0 0.0 0.0, 0.0 0.0 0.0, 3.0 0.0 0.0, 0.0 0.0 0.0, -3.0 0.0 0.0 ]
}
ROUTE Proximity.enterTime          TO Stair3Timer.set_startTime
ROUTE Stair3Timer.fraction_changed TO Stair3Path.set_fraction
ROUTE Stair3Path.value_changed     TO Stair3.set_translation


DEF Stair4Timer TimeSensor {
    cycleInterval 4.0
    loop TRUE
}
DEF Stair4Path PositionInterpolator {
    key      [ 0.0,         0.25,         0.5,         0.75,        1.0         ]
    keyValue [ 0.0 0.0 0.0, -3.0 0.0 0.0, 0.0 0.0 0.0, 3.0 0.0 0.0, 0.0 0.0 0.0 ]
}
ROUTE Proximity.enterTime          TO Stair4Timer.set_startTime
ROUTE Stair4Timer.fraction_changed TO Stair4Path.set_fraction
ROUTE Stair4Path.value_changed     TO Stair4.set_translation