#VRML V2.0 utf8 3D Cardinal curve, Evgeny Demidov, 4 Feb 2001 # Thanks to R.J.M.Smeenk for suggestion to make CPoint PROTO NavigationInfo{ type "EXAMINE" } Viewpoint{ position 0 2.1 6 orientation 1 0 0 -.4} PROTO CPoint[ field SFInt32 Id 0 field SFColor col 1 1 0 field SFFloat R .1 eventOut SFInt32 setId exposedField SFVec3f translation 0 0 0 ]{ Transform{ translation IS translation children[ Shape{ appearance Appearance{ material Material{ diffuseColor IS col } } geometry Sphere{ radius IS R}} DEF ts TouchSensor{}] } DEF CPscr Script{ eventIn SFBool getTS eventOut SFInt32 setId IS setId field SFInt32 Id IS Id directOutput TRUE url ["javascript: function getTS(val){ if(val) setId = Id; }"] } ROUTE ts.isActive TO CPscr.getTS } DEF alf CPoint{ translation .5 -2 -2 col 1 0 0 R .2} DEF A CPoint{ translation -.5 -1 -.5 Id 1} DEF B CPoint{ translation .5 1 .5 Id 2} DEF C CPoint{ translation 1 1 1 Id 3 } Transform{ children[ Shape{ appearance Appearance{ material Material{ emissiveColor 1 1 1 } } geometry DEF spline IndexedLineSet{ coord DEF spCoord Coordinate{} } } ]} DEF Marker Transform{ children[ Shape{ appearance Appearance{ material Material{ diffuseColor 1 1 1 transparency .3} } geometry Sphere{ radius .15} }]} PROTO Pointer[ field SFColor col 0 0 1 exposedField SFVec3f translation 0 0 0]{ Transform{ translation IS translation children[ Shape{ appearance Appearance{ material Material{ diffuseColor IS col } } geometry Sphere{ radius .1} } ]}} DEF ptXY Pointer{} DEF ptXZ Pointer{ col 0 1 0} DEF ptYZ Pointer{ col 1 0 0} Transform{ children[ Shape{ appearance Appearance{ material Material{ diffuseColor 0 0 .9} } geometry DEF plane IndexedFaceSet{ coord Coordinate{ point[-2 -2 -2,2 -2 -2,2 2 -2,-2 2 -2]} coordIndex[0 1 2 3] solid FALSE} } Shape{ appearance Appearance{ material Material{ emissiveColor 0 0 1} } geometry DEF grid IndexedLineSet{ coord Coordinate{ point[-2 -2 -1.99,2 -2 -1.99,-2 -1 -1.99,2 -1 -1.99,-2 0 -1.99,2 0 -1.99, -2 1 -1.99,2 1 -1.99,-2 2 -1.99,2 2 -1.99, -2 -2 -1.99,-2 2 -1.99, -1 -2 -1.99,-1 2 -1.99,0 -2 -1.99,0 2 -1.99, 1 -2 -1.99,1 2 -1.99, 2 -2 -1.99,2 2 -1.99]} coordIndex[0 1 -1 2 3 -1 4 5 -1 6 7 -1 8 9 -1 10 11 -1 12 13 -1 14 15 -1 16 17 -1 18 19]} } DEF tsXY PlaneSensor{} ]} Transform{ rotation 1 0 0 -1.57 children[ Shape{ appearance Appearance{ material Material{ diffuseColor .8 .8 .8 } } geometry USE plane } Shape{ appearance Appearance{ material Material{ emissiveColor .5 .5 .5} } geometry USE grid} DEF tsXZ PlaneSensor{} ]} Transform{ rotation 0 1 0 1.57 children[ Shape{ appearance Appearance{ material Material{ diffuseColor 1 0 0 } } geometry USE plane } Shape{ appearance Appearance{ material Material{ emissiveColor .9 0 0} } geometry USE grid} DEF tsYZ PlaneSensor{} ]} DEF SCR Script{ eventIn SFVec3f setXY eventIn SFVec3f setYZ eventIn SFVec3f setXZ eventIn SFInt32 getId field SFNode Marker USE Marker field SFNode ptXY USE ptXY field SFNode ptYZ USE ptYZ field SFNode ptXZ USE ptXZ field SFNode alf USE alf field SFNode A USE A field SFNode B USE B field SFNode C USE C field SFNode spline USE spline field SFNode spCoord USE spCoord ## globals field MFNode Ni [] field SFVec3f mark 0 0 0 field MFVec3f posN [] field SFVec3f posXY 0 0 0 field SFVec3f posXZ 0 0 0 field SFVec3f posYZ 0 0 0 field SFInt32 num 0 field SFInt32 iN 0 directOutput TRUE url ["javascript: function initialize() { Ni = new MFNode(alf,A,B,C); posN = new MFVec3f( new SFVec3f(.5,-2,-2), new SFVec3f(-.5, -1, -.5), new SFVec3f(.5, 1, .5), new SFVec3f(1, 1, 1) ); posXY = new SFVec3f(0, 0, -2); posXZ = new SFVec3f(0, -2, 0); posYZ = new SFVec3f(-2, 0, 0); num = 20; var c = new MFInt32( ); c.length = 2*num+1; for (i= 0; i<= 2*num; i++) c[i] = i; spline.set_coordIndex = c; iN = 2; alpha = .5; setXYZ(posN[iN]); } function getId( Id ){ iN = Id; setXYZ(posN[iN]);} function setXYZ(val){ if (iN == 0){ val.y = -2; val.z = -2; alpha = val.x; Browser.setDescription('alpha=' + alpha); } mark.x = posXZ.x = posXY.x = val.x; mark.y = posXY.y = posYZ.y = val.y; mark.z = posXZ.z = posYZ.z = val.z; Marker.set_translation = mark; ptXY.set_translation = posXY; ptXZ.set_translation = posXZ; ptYZ.set_translation = posYZ; posN[iN].x = val.x; posN[iN].y = val.y; posN[iN].z = val.z; Ni[iN].set_translation = posN[iN]; var p = new MFVec3f(); p.length = 2*num+1; st = .05; A1 = posN[1].add(posN[2].subtract(posN[1]).multiply(alpha)); B1 = posN[2].subtract(posN[3].subtract(posN[1]).multiply(alpha)); B2 = posN[2].add(posN[3].subtract(posN[1]).multiply(alpha)); C1 = posN[3].add(posN[2].subtract(posN[3]).multiply(alpha)); for (i= 0; i<= num; i++){ u = i*st; u1 = 1-u; u12 = u1*u1; u2 = u*u; b0 = u1*u12; b1 = 3*u*u12; b2 = 3*u2*u1; b3 = u*u2; p[i]=posN[1].multiply(b0).add(A1.multiply(b1)).add(B1.multiply(b2)) .add(posN[2].multiply(b3)); p[i+num]=posN[2].multiply(b0).add(B2.multiply(b1)).add(C1.multiply(b2)) .add(posN[3].multiply(b3));} spCoord.set_point = p; } function setXY(val){ setXYZ(new SFVec3f(val.x,val.y,mark.z));} function setYZ(val){ setXYZ(new SFVec3f(mark.x,val.y,-val.x));} function setXZ(val){ setXYZ(new SFVec3f(val.x,mark.y,-val.y));} "] } ROUTE alf.setId TO SCR.getId ROUTE A.setId TO SCR.getId ROUTE B.setId TO SCR.getId ROUTE C.setId TO SCR.getId ROUTE tsXY.trackPoint_changed TO SCR.setXY ROUTE tsXZ.trackPoint_changed TO SCR.setXZ ROUTE tsYZ.trackPoint_changed TO SCR.setYZ