#VRML V2.0 utf8 Spline transformation, Evgeny Demidov, 3 Mar 2001 NavigationInfo{ type "EXAMINE" } Viewpoint{ fieldOfView .2 position .5 5 0 orientation 1 0 0 -1.57 description "top"} Viewpoint{ fieldOfView .2 position .5 0 5 description "side"} Background {skyColor 0 0 1} EXTERNPROTO IFSModel[ exposedField MFVec3f Mpoints ] "SharkIFS.wrl#Model" PROTO CPoint[ field SFInt32 Id 0 field SFColor col 1 1 0 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 .02}} 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 } PROTO Line[ field SFNode lc NULL]{ Transform{ children[ Shape{ appearance Appearance{ material Material{ emissiveColor 0 1 1 } } geometry IndexedLineSet{ coord IS lc coordIndex[0 1]} } ]}} 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 .02} } ]}} DEF IFSmod IFSModel{} DEF N0 CPoint{ translation 0 0 .25} DEF N1 CPoint{ translation .333 0 .25 Id 1 col 0 1 1 } DEF N2 CPoint{ translation .666 0 .25 Id 2 col 0 1 1 } DEF N3 CPoint{ translation 1 0 .25 Id 3 } Line{ lc DEF line1 Coordinate{} } Line{ lc DEF line2 Coordinate{} } 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 .025} }]} DEF ptXY Pointer{} DEF ptXZ Pointer{ col 0 1 0} Transform{ children[ Shape{ appearance Appearance{ material Material{ diffuseColor 0 0 .9} } geometry DEF plane IndexedFaceSet{ coord Coordinate{ point[-.5 -.5 -.5,1.5 -.5 -.5,1.5 .5 -.5,-.5 .5 -.5]} coordIndex[0 1 2 3] solid FALSE} } Shape{ appearance Appearance{ material Material{ emissiveColor 0 0 1} } geometry DEF grid IndexedLineSet{ coord Coordinate{ point[ -.5 -.5 -.49,1.5 -.5 -.49,-.5 -.25 -.49,1.5 -.25 -.49,-.5 0 -.49,1.5 0 -.49, -.5 .25 -.49,1.5 .25 -.49,-.5 .5 -.49,1.5 .5 -.49, -.5 -.5 -.49,-.5 .5 -.49, 0 -.5 -.49,0 .5 -.49,.333 -.5 -.49,.333 .5 -.49, .666 -.5 -.49,.666 .5 -.49, 1 -.5 -.49,1 .5 -.49 1.5 -.5 -.49,1.5 .5 -.49]} 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 -1 20 21]} } 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{ translation 1.4 0 -.25 children[ Shape{ appearance Appearance{ material Material{ diffuseColor 1 0 0}} geometry Sphere{ radius .05}} DEF tsIFS TouchSensor{} ]} Transform{ translation 1.4 0 .25 children[ Shape{ appearance Appearance{ material Material{ diffuseColor 0 1 0}} geometry Sphere{ radius .05}} DEF tsPrint TouchSensor{} ]} DEF SCR Script{ eventIn SFVec3f setXY eventIn SFVec3f setXZ eventIn SFInt32 getId eventIn SFBool setIFS eventIn SFBool Print field SFNode Marker USE Marker field SFNode ptXY USE ptXY field SFNode ptXZ USE ptXZ field SFNode N0 USE N0 field SFNode N1 USE N1 field SFNode N2 USE N2 field SFNode N3 USE N3 field SFNode spline USE spline field SFNode spCoord USE spCoord field SFNode IFSmod USE IFSmod field SFNode line1 USE line1 field SFNode line2 USE line2 ## globals field MFNode Ni [] field SFVec3f mark 0 0 0 field MFVec3f posN [] field MFVec3f Model [] field SFVec3f posXY 0 0 0 field SFVec3f posXZ 0 0 0 field SFInt32 num 0 field SFInt32 iN 0 directOutput TRUE url ["javascript: function initialize() { Ni = new MFNode(N0,N1,N2,N3); posN = new MFVec3f( new SFVec3f(0,0,.25), new SFVec3f(.333,0,.25), new SFVec3f(.666,0,.25), new SFVec3f(1,0,.25) ); posXY = new SFVec3f(0, 0, -.5); posXZ = new SFVec3f(0, -.5, 0); num = 20; var c = new MFInt32( ); c.length = 2*(num+1)+12; for (i= 0; i<= num; i++) c[i] = i; for (i= 0; i<= num; i++) c[i+num+1] = 2*num+1-i; i = 2*(num+1); c[i++] = -1; c[i++] = 15; c[i++] = 36; c[i++] = -1; c[i++] = 10; c[i++] = 31; c[i++] = -1; c[i++] = 5; c[i++] = 26; c[i++] = -1; c[i++] = 0; c[i++] = 21; spline.set_coordIndex = c; Model = new MFVec3f(); for (i= 0; i< IFSmod.Mpoints.length; i++) Model[i] = IFSmod.Mpoints[i]; iN = 0; setXYZ(posN[iN]); } function getId( Id ){ iN = Id; setXYZ(posN[iN]);} function setXYZ(val){ mark.x = posXZ.x = posXY.x = val.x; mark.y = posXY.y = val.y; mark.z = posXZ.z = val.z; Marker.set_translation = mark; ptXY.set_translation = posXY; ptXZ.set_translation = posXZ; 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; 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+num+1] = p[i] = posN[0].multiply(b0).add(posN[1].multiply(b1)) .add(posN[2].multiply(b2)).add(posN[3].multiply(b3)); p[i+num+1].z -= .5; } spCoord.set_point = p; line1.set_point = new MFVec3f(posN[0],posN[1]); line2.set_point = new MFVec3f(posN[2],posN[3]); } function setIFS(val){ if(val){ var Mod = new MFVec3f(); Mod.length = Model.length; for (i= 0; i< Model.length; i++){ u = Model[i].x; u1 = 1-u; u12 = u1*u1; u2 = u*u; b0 = u1*u12; b1 = 3*u*u12; b2 = 3*u2*u1; b3 = u*u2; t = posN[0].multiply(b0).add(posN[1].multiply(b1)) .add(posN[2].multiply(b2)).add(posN[3].multiply(b3)); t.x -= u; t.z -= .25; Mod[i] = Model[i].add(t); } IFSmod.set_Mpoints = Mod; }} function Print(val){ if(val){ for (i= 0; i< 4; i++) print(' '+ posN[i].x +' '+ posN[i].y +' '+ (posN[i].z-.25) ); }} function setXY(val){ setXYZ(new SFVec3f(val.x,val.y,mark.z));} function setXZ(val){ setXYZ(new SFVec3f(val.x,mark.y,-val.y));} "] } ROUTE N0.setId TO SCR.getId ROUTE N1.setId TO SCR.getId ROUTE N2.setId TO SCR.getId ROUTE N3.setId TO SCR.getId ROUTE tsXY.trackPoint_changed TO SCR.setXY ROUTE tsXZ.trackPoint_changed TO SCR.setXZ ROUTE tsIFS.isActive TO SCR.setIFS ROUTE tsPrint.isActive TO SCR.Print