This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > VRML > September 2004 > trigger script's eventIn (function) at a certain time
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 |
trigger script's eventIn (function) at a certain time
|
|
| Robert Ludig 2004-09-02, 12:18 pm |
| Hello, I have a function (set_altitude) within a scriptnode that can
set the altitude of a certain point in the ElevationGrid. As Paramter
(val) it gets the index of the point (val[0]) and the height it shall
be set so (val[1]). It works fine.
My only problem is:
I want this function get called at certain time. The goal is to change
altitudes at a specific time ...
How could I call the function after lets say (10 seconds) ???
Here is the code :
-------------- vrmlcode ----------------
#VRML V2.0 utf8
Shape
{
geometry DEF MyIFS ElevationGrid
{
xDimension 5
zDimension 5
zSpacing 0.05
xSpacing 0.05
colorPerVertex TRUE
creaseAngle 0
color Color
{
color
[
1 0 0, 1 0 0, 1 0 0, 1 0 0, 1 0 0,
1 0 0, 1 0 0, 1 0 0, 1 0 0, 1 0 0,
1 0 0, 1 0 0, 1 0 0, 1 0 0, 1 0 0,
1 0 0, 1 0 0, 1 0 0, 1 0 0, 1 0 0,
1 0 0, 1 0 0, 1 0 0, 1 0 0, 1 0 0
]
}
height
[
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0
]
}
appearance Appearance
{
material Material
{
specularColor 1 1 1
}
}
}
DEF DeformerScript Script
{
field SFNode MyIFS USE MyIFS
eventIn SFVec3f set_altitude
url "vrmlscript:
function set_altitude (val,time)
{
MyIFS.height[val[0]] = val[1];
MyIFS.color.color[val[0]] = new SFColor(0, 1, 0);
}
"
}
# the following changes the point with the index 12 to the height of
0.04
# but I want that to happen at a secific time (for example 10 seconds
after
# the timer started)
DEF PosIntpl PositionInterpolator
{
key [0, 1]
keyValue [12 0.04 0,12 0.04 0]
}
DEF Timer TimeSensor
{
cycleInterval 10
loop TRUE
}
ROUTE Timer.fraction_changed TO PosIntpl.set_fraction
ROUTE PosIntpl.value_changed TO DeformerScript.set_altitude
| |
| Holger Grahn 2004-09-02, 12:18 pm |
|
Hi
TimeSensor has an eventOut cycleTime which triggers every cycle.
-- Holger
"Robert Ludig" <schwertfischtrombose@gmx.de> schrieb im Newsbeitrag
news:cgkum9$oer@odah37.prod.google.com...
> Hello, I have a function (set_altitude) within a scriptnode that can
> set the altitude of a certain point in the ElevationGrid. As Paramter
> (val) it gets the index of the point (val[0]) and the height it shall
> be set so (val[1]). It works fine.
> My only problem is:
> I want this function get called at certain time. The goal is to change
> altitudes at a specific time ...
> How could I call the function after lets say (10 seconds) ???
>
> Here is the code :
>
> -------------- vrmlcode ----------------
>
> #VRML V2.0 utf8
>
> Shape
> {
> geometry DEF MyIFS ElevationGrid
> {
> xDimension 5
> zDimension 5
> zSpacing 0.05
> xSpacing 0.05
> colorPerVertex TRUE
> creaseAngle 0
> color Color
> {
> color
> [
> 1 0 0, 1 0 0, 1 0 0, 1 0 0, 1 0 0,
> 1 0 0, 1 0 0, 1 0 0, 1 0 0, 1 0 0,
> 1 0 0, 1 0 0, 1 0 0, 1 0 0, 1 0 0,
> 1 0 0, 1 0 0, 1 0 0, 1 0 0, 1 0 0,
> 1 0 0, 1 0 0, 1 0 0, 1 0 0, 1 0 0
> ]
> }
> height
> [
> 0,0,0,0,0,
> 0,0,0,0,0,
> 0,0,0,0,0,
> 0,0,0,0,0,
> 0,0,0,0,0
> ]
> }
> appearance Appearance
> {
> material Material
> {
> specularColor 1 1 1
> }
> }
> }
> DEF DeformerScript Script
> {
> field SFNode MyIFS USE MyIFS
> eventIn SFVec3f set_altitude
> url "vrmlscript:
> function set_altitude (val,time)
> {
> MyIFS.height[val[0]] = val[1];
> MyIFS.color.color[val[0]] = new SFColor(0, 1, 0);
> }
> "
> }
>
> # the following changes the point with the index 12 to the height of
> 0.04
> # but I want that to happen at a secific time (for example 10 seconds
> after
> # the timer started)
> DEF PosIntpl PositionInterpolator
> {
> key [0, 1]
> keyValue [12 0.04 0,12 0.04 0]
> }
>
> DEF Timer TimeSensor
> {
> cycleInterval 10
> loop TRUE
> }
>
> ROUTE Timer.fraction_changed TO PosIntpl.set_fraction
> ROUTE PosIntpl.value_changed TO DeformerScript.set_altitude
>
| |
|
|
Count the number of cycleIntervals and/or turn the timer off and on as
necessary.
"Robert Ludewig" <schwertfischtrombose@gmx.de> wrote in message
news:2p8737Fiaq5iU1@uni-berlin.de...
> But then I could only call thet function at multiples of cycleinterval.
> Also ther would be no way to only call that function ofter 10 secounds and
> after 30 secounds.
> (if I would chose a cycleinterval of 10 secs, the function would also get
> called at 20 secs)
>
>
| |
|
|
"Robert Ludewig" <schwertfischtrombose@gmx.de> wrote in message
news:2p9pr2Fiig9aU1@uni-berlin.de...
> I need to be able to specify any time I want for triggering the function.
> Not just multiples of cuclyinterval:
>
> 12,3 sec 24,456 sec 200,1 sec
Set cycleInterval to 0.1 or use the fraction_changed or time event outs.
> Also I need to be able to call the function several times at the same
time:
> Because I need to be bale to move more than one coord at the same time.
Use a for loop and change as many coords as you like.
| |
| Cecile Muller 2004-09-04, 4:19 am |
| > Thank you for you time, solving the problem that I should have solved by
> what simon gave me as hints. .
> I am rather new to vrml, and have to admit it is not that easy for me to
> familiarize with the vrml programming principles since I come form the plain
> OO-corner wich requires a completely different way of thinking ....
> As we germans say:
> "Shooting from behind through the chest into the eye ...."
With strong wind too :-p
Ah don't worry, when you understand the structure, it will come easy.
The thing to remember is that the scene is mainly composed of
separated elements that communicate thru events instead of being one
script executed one line after the other (which is a bit like OO
actually imho).
| |
| Joerg Scheurich aka MUFTI 2004-09-05, 11:17 pm |
| > I am rather new to vrml, and have to admit it is not that easy for me to
> familiarize with the vrml programming principles since I come form the plain
> OO-corner wich requires a completely different way of thinking ....
The basic idea behind the field/eventIn restrictions of fields in shapes like
ElevationGrid is optimization.
Using a type of shape without buildin optimization can make things more
easy for complicated tasks.
so long
MUFTI
--
Eine Unter-Speisekarte wird erscheinen, in der Sie waehlen koennen,
entweder zu spielen, oder das Video zu schlingen.
(aus einem Software-Handbuch, Stichworte: menu und loop)
| |
| simon 2004-09-05, 11:17 pm |
| spam@wildpeaks.com (Cecile Muller) wrote in message news:<aff31ac6.0408292317.9f7c74b@posting.google.com>...
> With strong wind too :-p
> Ah don't worry, when you understand the structure, it will come easy.
> The thing to remember is that the scene is mainly composed of
> separated elements that communicate thru events instead of being one
> script executed one line after the other (which is a bit like OO
> actually imho).
sure, protos are just classes, and then protos make nodes ( instances
) and a lot of the time the objects can be real? virtual objects!
rather than conceptual ones.
but i find the event passing more interesting, because a browser could
avoid executing whole blocks of code, if no events from that code are
routed to an object in the field of view! ( or within sound range.)
BTW this also means that dynamics have to be absolute, so that things
appear to continue when you don't look at them, which is why you need
interpolators and an unintuitive timeSensor!
this also means that multiprocessor execution could be efficient,
which i'm guessing was the original idea, when a world gets really big
and highly multiuser then its the only way to go, ( a user could be
processing things that they alone see.)
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|