garf
New Member
Posts: 3
|
Post by garf on Apr 19, 2006 23:36:45 GMT
Hi..
I have just started experimenting with touch sensors... I know you can make the world play a sound when you click on it, but is there anyway I can get it to do anything else?
For example, here is what I want to do..
I have a VRML world inside a visual basic program. When a certain sensor is clicked, I want it to export which sensor was hit so I can save it to a variable in VB... can this be done?
I am also wondering if it can be used to open a url if it's in a browser... ??
Thanks for anyones help
|
|
|
Post by thyme on Apr 20, 2006 4:58:59 GMT
hi garf I have just started experimenting with touch sensors... I know you can make the world play a sound when you click on it, but is there anyway I can get it to do anything else?
You can directly ROUTE the ToucheSensor's touchTime field to any other SFTime type field from another node. Often though you will find that you want the touchTime field to cause some other type of field to be set, for example a SFBool. Because this can not be done using ROUTEs (both types must match) you will need to use a little script. You can ROUTE the ToucheSensor's touchTime field to an eventIn field contained in a Script node. When the eventIn field receives a signal from the ROUTE a JavaScript function will be called. In this function you can write to a field of a different type as shown in the folowing example: #VRML V2.0 utf8 #generated by Seamless3d 2.095 DEF myTouchSensor TouchSensor { } DEF myTransform Transform { children Shape { appearance Appearance { material Material {}} geometry Box {} } }
DEF myTimeSensor TimeSensor { cycleInterval 4 enabled FALSE loop TRUE }
DEF myOrientationInterpolator OrientationInterpolator { key [0 .333333 .666667 1 ] keyValue [0 1 0 0 0 1 0 2.094395 0 1 0 4.18879 0 1 0 6.283185 ] }
DEF myScript Script { directOutput TRUE #make it leagal to write directly to fields field SFNode myTimeSensor USE myTimeSensor #reference the node above named myTimeSensor so that the script can write to it eventIn SFTime myEventInTimeField url "javascript: function myEventInTimeField(){ //use the same name as the SFTime field above to specify which field calls this function myTimeSensor.enabled = true; //write to the TimeSensor's enabled field } " } ROUTE myTouchSensor.touchTime TO myScript.myEventInTimeField ROUTE myTimeSensor.fraction_changed TO myOrientationInterpolator.set_fraction ROUTE myOrientationInterpolator.value_changed TO myTransform.rotation
I want it to export which sensor was hit so I can save it to a variable in VB... can this be done? I know this can be done but I have never used VB with VRML myself. I know of others who have though. I have done this using Java and the EAI interface but this was such a long time ago I don't remeber the details. I am also wondering if it can be used to open a URL if it's in a browser... ??
VRML has an Anchor node for the task of opening URLs. Clicking any 3d objects that are contained inside the Anchor node's children field will cause the Anchor node to open the URL specified in the url field as shown in the folowing example: #VRML V2.0 utf8 #generated by Seamless3d 2.095 Anchor { children Shape { appearance Appearance { material Material {
} } geometry Sphere { } } description "click to open the Seamless3d home page" url "http://www.seamless3d.com" }
regards thyme
|
|