media @ VU
[] readme course(s) preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthought(s) appendix reference(s) example(s) resource(s) _

talk show tell print

vrml-math-GlobeP.vr

vrml-math-GlobeP.vr (wrl ) [ flux / bitmanagement / cortona / octaga ]


  
  
  NavigationInfo{ type "EXAMINE" }
  Background{ skyColor .5 .5 1}
  
  PROTO Globe[
   field MFString urlImg ""
   field SFInt32  n      30
  ]{
  DEF Root Transform{ scale 2 2 2 children[
   Shape{ appearance
    Appearance{ material Material{ diffuseColor 1 1 1}
     texture ImageTexture { url IS urlImg}}
    geometry DEF scrIFS IndexedFaceSet{ coord DEF scrCoord Coordinate{}
     texCoord DEF scrTC TextureCoordinate{}
     creaseAngle 2}}
   DEF Touch TouchSensor{}
  ]}
  DEF Clock TimeSensor{ cycleInterval 60}
  DEF Animation OrientationInterpolator{
   key[0,.5,1] keyValue[0 1 0 0,0 1 0 3.14,0 1 0 6.28]}
  
  ROUTE Touch.touchTime TO Clock.startTime
  ROUTE Clock.fraction_changed TO Animation.set_fraction
  ROUTE Animation.value_changed TO Root.rotation
  
  DEF INIT Script{
    field SFNode scrTC  USE scrTC
    field SFNode scrIFS USE scrIFS
    field SFNode scrCoord  USE scrCoord
    field SFInt32 n IS n
    directOutput TRUE
  url ["javascript:
  function initialize() { 
    n1=n+1;
    stepTh=3.142/(n-1); stepFi=6.2832/n;
    var k=0, i,j;
    var p = new MFVec3f();  p.length = n*n;
    for (j= 0; j< n; j++)
      for (i= 0; i< n; i++) {
        fi=i*stepFi;   theta=j*stepTh;
        t=Math.sin(theta);
        p[k].x=t*Math.sin(fi);
        p[k].y=-Math.cos(theta);
        p[k++].z=t*Math.cos(fi); }
    scrCoord.set_point = p;
    var c = new MFInt32( );  c.length = 5*(n-1)*n;
    k=0;
    for (j= 0; j< n-1; j++){
     for (i= 0; i< n-1; i++){
      c[k++]=i+n*j; c[k++]=i+n*j+1; c[k++]=i+n*j+n+1; c[k++]=i+n*j+n; c[k++]=-1;}
     c[k++]=n*j+n-1; c[k++]=n*j; c[k++]=n*j+n; c[k++]=n*j+n+n-1; c[k++]=-1;
    }
    scrIFS.set_coordIndex = c;
  
    var pt = new MFVec2f();  pt.length = n*n1;
    k=0;  var sti=1.0/n, stj=1/(n-1);
    for (j= 0; j< n; j++)
      for (i= 0; i< n1; i++) {
        pt[k].x=i*sti;
        pt[k++].y=j*stj;}
    scrTC.set_point = pt;
    var ti = new MFInt32( );  ti.length = 5*(n-1)*n;
    k=0;
    for (j= 0; j< n-1; j++)
     for (i= 0; i< n; i++){
      ti[k++]=i+n1*j;  ti[k++]=i+n1*j+1;
      ti[k++]=i+n1*j+n1+1; ti[k++]=i+n1*j+n1; ti[k++]=-1;}
  //print( ti );
    scrIFS.set_texCoordIndex = ti;
  }"]
  }}
  
  Globe{}
  


(C) A. Eliëns 2/9/2007

You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.