Introducing VRML
cutplane.wrl

	

#VRML V2.0 utf8
#
#  cutplane.wrl
#  A sliding cutting plane
#    by David R. Nadeau
#
#  This world illustrates the use of the 'SlidingPlane' node type defined in
#  the external file 'cut.wrl'.  That node creates a plane that slides back
#  and forth, changing the texture on it based upon the plane's X position.
#

#
#  Externally defined node types
#
EXTERNPROTO TexturePlane [
    field MFNode textures
    eventIn SFFloat set_fraction
] "cut.wrl#TexturePlane"

EXTERNPROTO SlidingPlane [
    field MFNode textures
    field SFVec2f minMaxX
    field SFFloat initialX
] "cut.wrl#SlidingPlane"


#
#  Header
#
WorldInfo {
    title "Cutting Plane"
    info [ "Copyright (c) 1997, David R. Nadeau" ]
}

Viewpoint {
    position 4.0 0.4 2.5
    orientation 0.0 1.0 0.0 0.785
    description "Entry view"
}

NavigationInfo {
    type [ "EXAMINE", "ANY" ]
    headlight TRUE
}

Background {
    skyColor [
        0.0 0.0 0.0
        0.0 0.0 0.0
        0.0 0.1 0.3
    ]
    skyAngle [
        1.57,
        1.87,
    ]
}



#
#  Build a box with a grid texture on the sides.  Only include the
#  side, bottom, and end.  The cutting planes will slide back and
#  forth within the box.
#
Shape {
    appearance Appearance {
        # no material - emissive
        texture ImageTexture {
            url "grill.png"
        }
        textureTransform TextureTransform {
            translation 0.5 0.5
        }
    }
    geometry IndexedFaceSet {
        coord Coordinate {
            point [
            # Left side
                -1.0 -1.0 0.0,
                -1.0 -1.0 -4.0,
                -1.0 1.0 -4.0,
                -1.0 1.0 0.0,
            # Bottom
                -1.0 -1.0 0.0,
                 1.0 -1.0 0.0,
                 1.0 -1.0 -4.0,
                -1.0 -1.0 -4.0,
            # Back
                -1.0 -1.0 -4.0,
                 1.0 -1.0 -4.0,
                 1.0  1.0 -4.0,
                -1.0  1.0 -4.0,
            ]
        }
        coordIndex [
            0, 1, 2, 3, -1,
            4, 5, 6, 7, -1,
            8, 9, 10, 11, -1,
        ]
        texCoord TextureCoordinate {
            point [
                0.0 0.0,
                0.0 8.0,
                4.0 8.0,
                4.0 0.0,

                0.0 0.0,
                4.0 0.0,
                4.0 4.0,
                0.0 4.0,
            ]
        }
        texCoordIndex [
            0, 1, 2, 3, -1,
            1, 2, 3, 0, -1,
            4, 5, 6, 7, -1,
        ]
        solid FALSE
    }
}


#
#  Add a label above one side of the box
#
Transform {
    translation -1.0 1.3 -2.0
    rotation 0.0 1.0 0.0 1.571
    children Shape {
        appearance Appearance {
            # no material - emissive
        }
        geometry Text {
            string "Time (sec)"
            fontStyle FontStyle {
                size 0.4
                style "BOLD"
                justify "MIDDLE"
            }
        }
    }
}


#
#  Create two moving cutting planes, one initially at the front and
#  the other initially at the back.
#
SlidingPlane {
    initialX 0.0
    minMaxX 0.0 4.0
    textures [
        ImageTexture {
            url "cp1.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp2.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp3.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp4.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp5.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp6.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp7.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp8.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp9.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp10.png"
            repeatS FALSE
            repeatT FALSE
        }
    ]
}

SlidingPlane {
    initialX 4.0
    minMaxX 0.0 4.0
    textures [
        ImageTexture {
            url "cp1.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp2.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp3.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp4.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp5.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp6.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp7.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp8.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp9.png"
            repeatS FALSE
            repeatT FALSE
        }
        ImageTexture {
            url "cp10.png"
            repeatS FALSE
            repeatT FALSE
        }
    ]
}