#VRML V2.0 utf8 ####################################################### # SnailTrail.wrl V1.0 (24-Sep-1998) # ===================== # Idea spark : Patrick Jermann, TECFA, University of Geneva # Conception : David Ott, TECFA # TecSupport : Sylvere Martin-Michiellot, TECFA # Copyright : David.Ott@tecfa.unige.ch # # Free for all non-commercial uses if you keep this notice # intact and share with other. # # Description : # SnailTrail.wrl was designed to leave a trace of the # users exploration of the Virtual World. It # belongs to the awareness tools family, and is # supposed to give information enabling the user # see which places he visited. The code is quite # simple and has the following properties : # -leaves a red trace behind the user, # -outputs the number of points of the # IndexedLineSet in the VRMLconsole # # Next steps : # Find a way to reduce point number for faster # rendering, either by taking the position each X sec. # with a TimeSensor {interval X}, or by limiting the # point array size (but this would clamp off earlier # trail information), or by comparing segment (t;t-1) # with segment (t-1;t-2) and deciding if the orientation # of the 2 segments are almost similar (let's say less # than X degrees difference) and if so replacing t-1 # with t. ######################################################## # ProximiySensor tracks user movements DEF PS ProximitySensor {size 1e25 1e25 1e25} # IndexedLineSet updated whenever user changes location Shape { geometry DEF ILS IndexedLineSet { colorPerVertex FALSE color Color { color 1 0 0} # color of the trace coord DEF Coord Coordinate{} } } # This Shape{} is just for demo purpose. The code works without it :) Shape { appearance Appearance { material Material { diffuseColor .5 .5 .5 } } geometry Box {} } # This script adds the actualPosition to the point array # and adds the actual point array length to the coordIndex # array. DEF SCR Script { eventIn SFVec3f newPos field MFVec3f theArray [] field SFNode pointArray USE Coord eventOut MFInt32 coordIndex eventOut MFVec3f point url [ "vrmlscript: function newPos(actualPosition) { var theArray = pointArray.point; var theArrayLength = theArray.length; var i = theArrayLength; theArray[i] = new SFVec3f(actualPosition.x,actualPosition.y,actualPosition.z); point = theArray; coordIndex[i] = theArrayLength; print(i); }" ] } # Route ProximitySensor to Script ROUTE PS.position_changed TO SCR.newPos # Route Script to IndexedLineSet ROUTE SCR.point TO Coord.point ROUTE SCR.coordIndex TO ILS.coordIndex