This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > March 2004 > Stopwatch





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 Stopwatch
Junaid

2004-03-15, 7:30 pm

Hi,
Im modelling chemical reactions in VRML. I am basically looking for a
simple start/stop stopwatch to use for working out the reaction time. If you
have a PROTO or just some code for a simple stopwatch I would really
appreciate it. I only need a seconds counter.

Thanks in advance,
Junaid
University of Birmingham.


Joerg Scheurich aka MUFTI

2004-03-16, 7:30 am

> have a PROTO or just some code for a simple stopwatch I would really
> appreciate it. I only need a seconds counter.


You may need to tailor the rounding function....

#VRML V2.0 utf8

DEF TimeSensor1 TimeSensor
{
loop TRUE
}

DEF TouchSensor1 TouchSensor
{
}

Transform
{
children
[
Shape
{
appearance Appearance
{
material Material
{
}
}
geometry DEF Text1 Text
{
string
[
"not started"
]
}
}
]
translation -0.904124 -2.298555 0
}

Transform
{
children
[
Shape
{
appearance Appearance
{
material Material
{
}
}
geometry Sphere
{
}
}
]
}

DEF Script1 Script
{
eventIn SFTime time1_in
eventIn SFTime time2_in
eventOut MFString mstring1_out
field SFTime starttimeStore 0
field SFBool startedStore FALSE
url
[
"java script:

// field SFTime starttimeStore //
// field SFBool startedStore //
// eventOut MFString mstring1_out //

function time1_in(value)
{
if (startedStore)
mstring1_out = new MFString((Math.round((value - starttimeStore) * 100)/100).toString());
}

function time2_in(value)
{
if (!startedStore)
starttimeStore = value;
startedStore = !startedStore;
}

"
]
}

ROUTE TimeSensor1.time TO Script1.time1_in
ROUTE TouchSensor1.touchTime TO Script1.time2_in
ROUTE Script1.mstring1_out TO Text1.set_string

Sponsored Links


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