This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > January 2004 > Display Value of hitpoint_changed?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Display Value of hitpoint_changed?
Dale

2004-01-03, 5:28 am

There's got to be a way to display the value of a touch sensor's
hitpoint_changed. I'm making an IndexedFaceSet from USGS elevation data. By
putting a TouchSensor into the same group with the IndexedFaceSet, I've been
able to make a little cursor ball that follows the mouse cursor around on
the ground surface. Now all I want to do is to display the position of that
cursor ball, preferably onto a Billboard. I tried adding a ProximitySensor
to the ball, but that didn't work, just made the ball disappear. I can't
even get anything to display to the console. Anybody done this before?


Cecile Muller

2004-01-03, 8:29 pm

> There's got to be a way to display the value of a touch sensor's
quote:

> hitpoint_changed.



You have to use a Script{} node because you can't directly route a
vector to a string. The easiest is to display the value is to use a
Text{} node that is either in a Billboard{} or in a HUD (search the
newsgroup's archives at
http://groups.google.com/groups?hl=...=comp.lang.vrml
if you don't know how to make one).

Here is an example:
------------
#VRML V2.0 utf8

Viewpoint{}
Group{
children [
DEF TS TouchSensor{}
Shape{
appearance Appearance{material Material{emissiveColor 1 0 0}}
geometry Sphere{}
}
]
}
Transform{
translation 0 2 0
children Billboard {
axisOfRotation 0 0 0
children Shape{
appearance Appearance{material Material{emissiveColor 0 1 0}}
geometry DEF txt Text{
string "Roll the mouse over the sphere"
fontStyle FontStyle{justify "MIDDLE"}
}
}
}
}
DEF brain Script{
eventIn SFVec3f hitPoint_in
eventOut MFString text_out
url "java script:
function hitPoint_in(v){text_out[0] = v;}
"
}
ROUTE TS.hitPoint_changed TO brain.hitPoint_in
ROUTE brain.text_out TO txt.string
------------
PrisNo6

2004-01-03, 9:29 pm

"Dale" <dmgreer@nspm.airmail.net> wrote in message news:<bt61e9$9hf@library2.airnews.net>...
quote:

> There's got to be a way to display the value of a touch sensor's
> hitpoint_changed. I'm making an IndexedFaceSet from USGS elevation data. By
> putting a TouchSensor into the same group with the IndexedFaceSet, I've been
> able to make a little cursor ball that follows the mouse cursor around on
> the ground surface. Now all I want to do is to display the position of that
> cursor ball, preferably onto a Billboard. I tried adding a ProximitySensor
> to the ball, but that didn't work, just made the ball disappear. I can't
> even get anything to display to the console. Anybody done this before?



The way I resolved this issue, based on advice from this forum, was to
use the browser status bar to display such dynamically changing data,
as opposed to trying to update a billboarding text label. The
following code fragment may be of use, is based on a sphere geometry
object, and is not particularized for the IndexedFaceSet object. But
it may give you some ideas:

# Popup label in browser status bar
DEF display_Message Script {
# Initialize array lblpopupName with empty strings to
prevent
# undefined string value runtime error
field SFNode LabelNode USE tmp_lblName
eventIn SFBool set_boolean
url [
"java script:
function set_boolean (bolValue) {

// Syntax - for Cosmo compability - convert MFstring array to
SFstring
browser_desc_changed = new String();
array_desc_changed = new Array();

array_desc_changed = LabelNode.string;
browser_desc_changed = array_desc_changed.toString();

// Set popup label
if( bolValue == true )
Browser.setDescription(browser_desc_changed);
else
Browser.setDescription('');
}"
] # end url
# Output events for browser router are implied
} # end Script
# Router for popup label in browser
ROUTE sense_Sphere_Object.isOver TO display_Message.set_boolean
# End routers
Dale

2004-01-05, 5:28 am

"Cecile Muller" <spam@wildpeaks.com> wrote in message
news:aff31ac6.0401031539.730ce629@posting.google.com...
quote:

>
> You have to use a Script{} node because you can't directly route a
> vector to a string. The easiest is to display the value is to use a
> Text{} node that is either in a Billboard{} or in a HUD (search the
> newsgroup's archives at
> http://groups.google.com/groups?hl=...=comp.lang.vrml
> if you don't know how to make one).
>
> Here is an example:
> ------------
> #VRML V2.0 utf8
>
> Viewpoint{}
> Group{
> children [
> DEF TS TouchSensor{}
> Shape{
> appearance Appearance{material Material{emissiveColor 1 0 0}}
> geometry Sphere{}
> }
> ]
> }
> Transform{
> translation 0 2 0
> children Billboard {
> axisOfRotation 0 0 0
> children Shape{
> appearance Appearance{material Material{emissiveColor 0 1 0}}
> geometry DEF txt Text{
> string "Roll the mouse over the sphere"
> fontStyle FontStyle{justify "MIDDLE"}
> }
> }
> }
> }
> DEF brain Script{
> eventIn SFVec3f hitPoint_in
> eventOut MFString text_out
> url "java script:
> function hitPoint_in(v){text_out[0] = v;}
> "
> }
> ROUTE TS.hitPoint_changed TO brain.hitPoint_in
> ROUTE brain.text_out TO txt.string
> ------------



Very cool, thanks! This is just what I needed to get me over the hump of
understanding how this stuff works.


Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews