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-Rings.vr

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


  
  
  NavigationInfo{ type "EXAMINE" }
  
  Transform { scale 1 1 1 children
   Shape { appearance Appearance { material Material{ diffuseColor 1 1 1}}
    geometry  Sphere {}
   }
  }
  
  DEF XForm Transform{ scale 2 2 2 rotation 1 0 0 0
    children[
      Shape{
        appearance Appearance{ material Material{ diffuseColor 1 1 1 }
           texture ImageTexture { url "rings.gif"}}
        geometry DEF scrIFS IndexedFaceSet{
           coord DEF scrCoord Coordinate{}
           texCoord DEF scrTC TextureCoordinate{}
           solid FALSE creaseAngle 1.5 } } ]
  }
  
  DEF INIT Script{
    field SFNode scrTC  USE scrTC
    field SFNode scrIFS USE scrIFS
    field SFNode scrCoord  USE scrCoord
    directOutput TRUE
  url ["javascript:
  function initialize() { 
    var n=50, d=1.7, r=1;
    stepFi=2.0*3.1416 / n;
    var k=0;
    var p = new MFVec3f();    p.length = 2*n;
    for (var i= 0; i< n; i++) {
      fi=i*stepFi; si = Math.sin(fi);  co = Math.cos(fi);
      p[k].x=r*si; p[k].y=r*co; p[k++].z=0;
      p[k].x=d*si; p[k].y=d*co; p[k++].z=0; }
    var c = new MFInt32( );  c.length = 5*n-1;
    k=0;
    for (var i= 0; i< n-1; i++) {
      c[k++]=2*i;  c[k++]=2*i+1;  c[k++]=2*i+3;  c[k++]=2*i+2; c[k++]=-1;}
    c[k++]=2*(n-1);  c[k++]=2*(n-1)+1;  c[k++]=1;  c[k++]=0;
    scrCoord.set_point = p;
    scrIFS.set_coordIndex = c;
  //print(c);
  
    var pt = new MFVec2f();  pt.length = 4;
    pt[0].x=0; pt[0].y=0;  pt[1].x=1; pt[0].y=0;
    pt[2].x=1; pt[0].y=1;  pt[3].x=0; pt[0].y=1;
    scrTC.set_point = pt;
    var ti = new MFInt32( );  ti.length = 5*n-1;
    k=0;
    for (i= 0; i< n-1; i++){
      ti[k++]=0;  ti[k++]=1; ti[k++]=2; ti[k++]=3; ti[k++]=-1;}
    ti[k++]=0;  ti[k++]=1; ti[k++]=2; ti[k++]=3;
    scrIFS.set_texCoordIndex = ti;
  
  }"]
  }
  


(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.