#VRML V2.0 utf8

WorldInfo {
  title "Spiral-Textured Sphere on Checker-Textured Floor"
  info [ "PhBRML demo",
	 "Philippe Bekaert, Computer Graphics Research Group, K.U.Leuven",
	 "e-mail: Philippe.Bekaert@cs.kuleuven.ac.be" ]
}

Viewpoint {
  position 12.3459 2.31265 -0.692065
  orientation -0.108013 0.984233 0.140068 1.84314
  fieldOfView 0.785398
  description "ViewPoint 1"
}

DEF neutral PhBXYZSpectrum {xyz 1 1 1}

DEF DiffuseWhite PhBHomogeneousSurface {
   bsdf PhBSDF {
      intensity 0.8
      spectrum USE neutral 
      scatterer PhBDiffuseReflector {}
   }
}

DEF SpecularWhite PhBHomogeneousSurface {
   bsdf PhBSDF {
      intensity 0.8 ,
      spectrum USE neutral ,
      scatterer PhBPhongReflector { sharpness 1000 } 
   }
}

DEF SpiralWhite PhB3DTexturedSurface {
   texture PhBProcedural3DTexture {
      url "spiral"
   }
   textureTransform3D PhB3DTextureTransform { scale 2 2 2 }
   surfaces [ USE DiffuseWhite , USE SpecularWhite ]
}

DEF Black PhBHomogeneousSurface {}

DEF CheckerWhite PhB3DTexturedSurface {
   texture PhBProcedural3DTexture {
      url "checker"
   }
   surfaces [ USE DiffuseWhite , USE Black ]
   textureTransform3D PhB3DTextureTransform { scale 0.2 0.2 0.2 }
}

# physically based light source appearance
DEF Light PhBHomogeneousSurface {
   edf PhBEDF {
      intensity 10000.   		# [lux]
      spectrum USE neutral
      emitter PhBDiffuseEmitter {}
   }
}

PROTO QuadFace [
 exposedField MFVec3f points [ ]
] {
   IndexedFaceSet {
      coord Coordinate {
	 point IS points
      }
      coordIndex [ 0 1 2 3 ]
      colorPerVertex FALSE
      normalPerVertex FALSE
      solid FALSE
   }
}

Transform {
   children [ Shape {             # interesting looking sphere
      geometry Sphere { radius 3. }
      appearance PhBAppearance {
	 surface USE SpiralWhite
      }
   }, Shape {                     # ground (b&w chckered)
      geometry QuadFace { points 
	  [  100 -10.1 -100
	    -100 -10.1 -100
	    -100 -10.1  100
	     100 -10.1  100 ]
      }
      appearance PhBAppearance {
	 surface USE CheckerWhite
      }
   }, Transform {                  # first light
      translation 7 10 7             
      children Shape {
	 geometry Sphere { radius 0.1 }
	 appearance PhBAppearance {
	    surface USE Light
	 }
      }
   }, Transform {                 # second light
      translation 7 10 -7
      children Shape {
	 geometry Sphere { radius 0.1 }
	 appearance PhBAppearance {
	    surface USE Light
	 }
      }
   }
     ]
}