Normals

Example from: The Annotated VRML 2.0 Reference Manual


Group {
  children [
    Transform {
      translation -3 0 0
      children Shape {
	appearance DEF A1 Appearance { material Material { diffuseColor 1 1 1 } }
	geometry IndexedFaceSet {
	  coord DEF C1 Coordinate {
	    point [ 1 0 1, 1 0 -1, -1 0 -1, -1 0 1, 0 3 0 ]
	  }
	  coordIndex [ 0 1 4 -1  1 2 4 -1  2 3 4 -1  3 0 4 ]
	  normal Normal {
	    vector [  .707 0  .707,  .707 0 -.707,
		     -.707 0 -.707, -.707 0  .707,
		      .707 .707 0, 0 .707 -.707, -.707 .707 0, 0 .707 .707 ]
	  }
	  normalIndex [ 0 1 4 -1  1 2 5 -1  2 3 6 -1  3 0 7 ]
	}
      }
    }
    Transform {
      children Shape {
	appearance USE A1
	geometry IndexedFaceSet {
	  coord USE C1
	  coordIndex [ 0 1 4 -1  1 2 4 -1  2 3 4 -1  3 0 4 ]
	  normal Normal {
	    vector [  .707 0  .707,  .707 0 -.707,
		     -.707 0 -.707, -.707 0  .707, 0 1 0 ]
	  }
	  # use coordIndex for normal indices
	}
      }
    }
    Transform {
      translation 3 0 0
      children Shape {
	appearance USE A1
	geometry IndexedFaceSet {
	  coord USE C1
	  coordIndex [ 0 1 4 -1  1 2 4 -1  2 3 4 -1  3 0 4 ]
	  normal Normal {
	    vector [ .707 .707 0, 0 .707 -.707, -.707 .707 0, 0 .707 .707 ]
	  }
	  normalIndex [ 0, 1, 2, 3 ] # alternate every other face
	  normalPerVertex FALSE
	}
      }
    }
    DirectionalLight { direction 1 0 0 }
    Background { skyColor 1 1 1 }
  ]
}



mrl