media @ VU
vrml-math-curve.vr
vrml-math-curve.vr
(wrl
)
[ flux /
bitmanagement /
cortona /
octaga
]
# 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
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 .1}}
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 N0 CPoint{ translation -1 -1 -1 }
DEF N3 CPoint{ translation 1 1 1 Id 3 }
DEF N1 CPoint{ translation -.5 -1 -.5 Id 1 col 0 1 1 }
DEF N2 CPoint{ translation .5 1 .5 Id 2 col 0 1 1 }
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]} }
]}}
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 .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 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 line1 USE line1
field SFNode line2 USE line2
## 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(N0,N1,N2,N3);
posN = new MFVec3f( new SFVec3f(-1,-1,-1),
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 = num+1;
for (i= 0; i<= num; i++) c[i] = i;
spline.set_coordIndex = c;
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 = 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 = 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]=posN[0].multiply(b0).add(posN[1].multiply(b1)).add(posN[2].multiply(b2))
.add(posN[3].multiply(b3));}
spCoord.set_point = p;
line1.set_point = new MFVec3f(posN[0],posN[1]);
line2.set_point = new MFVec3f(posN[2],posN[3]);
}
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 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 tsYZ.trackPoint_changed TO SCR.setYZ
(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.