This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > May 2005 > HOW to convert SFFloat to SFString ??





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 HOW to convert SFFloat to SFString ??
sunnewton

2005-05-30, 7:25 pm

Hi,

Thanks for the help for my previous problems.

Now I need some help about how to change a SFFloat format to SFString
format ?

I want to display the speed of a car in TEXT, but the output of
eventOut is in SFFloat format stype,, how can I change it to SFString
in order to input set_string eventIn.

Thanks in advance for replies !

Joerg Scheurich aka MUFTI

2005-05-30, 7:25 pm


> Now I need some help about how to change a SFFloat format to SFString
> format ?


There is a .toString() function in ECMAscript.

#VRML V2.0 utf8

DEF Script1 Script
{
eventIn SFFloat float1_in
eventOut MFString mstring1_out
url
[
"java script:

// eventOut MFString mstring1_out //

function float1_in(value)
{
// value SFFloat
var r = Math.round(value * 10) / 10;
mstring1_out = new MFString(r.toString());
}
"
]
}

DEF TimeSensor1 TimeSensor
{
loop TRUE
}

ROUTE TimeSensor1.fraction_changed TO Script1.float1_in

Transform
{
children
[
Shape
{
appearance Appearance
{
material Material
{
}
}
geometry DEF Text1 Text
{
string
[
"?"
]
}
}
]
}

ROUTE Script1.mstring1_out TO Text1.set_string
Sponsored Links


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