3D Graphics in VRML

Cube

cube.wrl axis.wrl

Z is "in your face"

units are meters (metres) right handed.


#VRML V1.0 ascii

Separator { 

    Cube {    } 

}

More Geometry and Positioning

csc1.wrl csct.wrl

Object Space -> World Space -> Camera Space -> Window


#VRML V1.0 ascii

Separator { 

    Cube {    }

    Translation { translation 3 0 0 }

    Sphere { }

    Translation { translation 3 0 0 }

    Cone { } 

}

Rotation

cscr.wrlrot2.wrl

#VRML V1.0 ascii

Separator {

  Separator { 

    Rotation { rotation 0.5 0.866 0.0 0.8 }

    Cube {    }

  }

    Translation { translation 3 0 0 }

    Sphere { }

    Translation { translation 3 0 0 }

  Separator { 

    Rotation { rotation 0.5 -0.866 0.0 1.3 }

    Cone { } 

  }

}

Colors

cscm.wrl

#VRML V1.0 ascii

Separator {

  Separator { 

    Material { diffuseColor 1 0 0 }

    Rotation { rotation 0.5 0.866 0.0 0.8 }

    Cube {    }

  }

    Translation { translation 3 0 0 }

    Material { diffuseColor 0 1 0 }

    Sphere { radius 1.3 }

    Translation { translation 3 0 0 }

  Separator { 

    Material { diffuseColor 0 0 1 }

    Rotation { rotation 0.5 -0.866 0.0 1.3 }

    Cone { bottomRadius 1.3 } 

  }

}

More Materials

material.wrl

Materials determine how light reflects

ambient, diffuse, emmisive, specular, shininess, transparency


#VRML V1.0 ascii

Separator { 



  Separator {

    Material { 

      diffuseColor 1 0.5 0.9

      ambientColor 0.2 0.1 0.2

      shininess 0.05

    }

    Sphere { radius 0.7 }

  }

  Separator {

    Translation { translation 1 1.732 0 }

    Material { 

      diffuseColor 0 1 0

      transparency 0.5

    }

    Sphere { radius 0.7 }

  }

  Separator {

    Translation { translation 2 0 0 }

    Material { 

      diffuseColor 1 1 0

      shininess 1.0

    }

    Sphere { radius 0.7 }

  }

  Separator {

    Translation { translation 1 1 1.732 }

    Material { emissiveColor 0 1 1

               shininess 0.5 }

    Sphere { radius 0.7 }

  }

}

Lights

cscml.wrl cscml2.wrl

#VRML V1.0 ascii

Separator {

  DirectionalLight { direction -0.6 -0.6 -0.5 }

  Separator { 

    Material { diffuseColor 1 0 0 }

    Rotation { rotation 0.5 0.866 0.0 0.8 }

    Cube {    }

  }

    Translation { translation 3 0 0 }

    Material { diffuseColor 0 1 0 }

    Sphere { radius 1.3 }

    Translation { translation 3 0 0 }

  Separator { 

    Material { diffuseColor 0 0 1 }

    Rotation { rotation 0.5 -0.866 0.0 1.3 }

    Cone { bottomRadius 1.3 } 

  }

}

IndexedFaceSet

tetra.wrl

#VRML V1.0 ascii

Separator { 

    Coordinate3 {

    point   [ 0 0 0,

              1 1.732 0,

              2 0 0,

              1 0.577 1.633 ]

    }



    IndexedFaceSet {

    coordIndex  [ 0, 1, 2, -1, 

                  0, 2, 3, -1, 

                  0, 3, 1, -1, 

                  1, 3, 2, -1 ]

  

    } 

}

Textures

tetras2.wrl

    Texture2 { filename "boxes.jpg"  }

Texture Coordinates

tetratc.wrl t2.wrl

#VRML V1.0 ascii

Separator { 

  Separator {

    Material {   diffuseColor 1 0 0

                 transparency 0.5    }

    Sphere { radius 0.7 }  }

  Separator {

    Translation { translation 1 1.732 0 }

    Material {   diffuseColor 0 1 0

                 transparency 0.5    }

    Sphere { radius 0.7 }  }

  Separator {

    Translation { translation 2 0 0 }

    Material {   diffuseColor 0 0 1

                 transparency 0.5    }

    Sphere { radius 0.7 }  }

  Separator {

    Translation { translation 1 0.577 1.732 }

    Material { diffuseColor 1 1 1

               transparency 0.5 }

    Sphere { radius 0.7 }  }

  

  Texture2 { filename "boxes.jpg"  }



  TextureCoordinate2{ point [0 .5, 1 1, 1 .5, 0 0, 0 1, 1 0] }



  Coordinate3 {

    point   [ 0 0 0,

              1 1.732 0,

              2 0 0,

              1 0.577 1.732 ]

    }



  IndexedFaceSet {

    coordIndex  [ 0, 1, 2, -1, 

                  0, 2, 3, -1, 

                  0, 3, 1, -1, 

                  1, 3, 2, -1 ]

    textureCoordIndex [ 0, 1, 2, -1, 

                        0, 2, 3, -1, 

                        0, 4, 1, -1, 

                        5, 3, 2, -1 ]

    } 

}

Cameras

cameras.wrl CamCalc

#VRML V1.0 ascii

Separator { 

  DEF Camera Switch {

    whichChild 0

    DEF Front PerspectiveCamera { position 1 0.577 4 }

    DEF Red PerspectiveCamera {

                                   position -1 -0.577 -0.577

                                   orientation -0.5 0.866 0 -1.57

                                 }

    DEF Green PerspectiveCamera { 

                                   position 1 7 -1

                                   orientation 1 0 0 -1.8

                               }

    DEF Blue PerspectiveCamera {

                                   position 3 -0.577 -0.577

                                   orientation 0.5 0.866 0 1.57

                              }

  }

  Separator {

    Material { 

      diffuseColor 1 0 0

      transparency 0.5

    }

    Sphere { radius 0.7 }

  }

  Separator {

    Translation { translation 1 1.732 0 }

    Material { 

      diffuseColor 0 1 0

      transparency 0.5

    }

    Sphere { radius 0.7 }

  }

  Separator {

    Translation { translation 2 0 0 }

    Material { 

      diffuseColor 0 0 1

      transparency 0.5

    }

    Sphere { radius 0.7 }

  }

  Separator {

    Translation { translation 1 0.577 1.633 }

    Material { diffuseColor 1 1 1

               transparency 0.5

               shininess 0.5 }

    Sphere { radius 0.7 }

  }

        Texture2 { filename "boxes.jpg"  }



  TextureCoordinate2{ point [0 .5, 1 1, 1 .5, 0 0, 0 1, 1 0]}



    Coordinate3 {

    point   [ 0 0 0,

              1 1.732 0,

              2 0 0,

              1 0.577 1.633 ]

    }



    IndexedFaceSet {

    coordIndex  [ 0, 1, 2, -1, 

                  0, 2, 3, -1, 

                  0, 3, 1, -1, 

                  1, 3, 2, -1 ]

    textureCoordIndex [ 0, 1, 2, -1, 

                        0, 2, 3, -1, 

                        0, 4, 1, -1, 

                        5, 3, 2, -1 ]



                        

  

    } 

}