This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > June 2005 > accessing fields/events of Script A from Script B





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 accessing fields/events of Script A from Script B
John Andrews

2005-05-30, 11:24 pm

hope you're all having a memorial day...

I have a script node, A, with a number of eventIn's, 'Outs, & Fields.
I have a second script node, B. I would like to make some of the
eventOuts in B conditional on the values of a Field or Fields in Script
A. For example, mousing-over an object sends eventIn's to Script B,
which then activates eventOuts from B. But i would like some of the
eventOuts to occur only if a Switch in script A is turned on. My
current work-around is to use redundant fields (same field in A and B),
but this is becoming increasingly cantankerous...

thanks much,
john



ps- btw, i've currently

2148 ROUTE's
150 Scripts
62 EXTERNPROTO's

....and counting. The models/presentation are running beautifully in
both Contact5 and CosmoPlayer, though. Am i about to hit a wall?


Joerg Scheurich aka MUFTI

2005-05-31, 7:28 pm

> I have a script node, A, with a number of eventIn's, 'Outs, & Fields.
> I have a second script node, B. I would like to make some of the
> eventOuts in B conditional on the values of a Field or Fields in Script
> A.


In principle, you can join two scripts always together to one....

> ps- btw, i've currently


> 2148 ROUTE's
> 150 Scripts
> 62 EXTERNPROTO's


> Am i about to hit a wall?


In principle, you aready broke the wall at least by more than factor 10:

http://www.web3d.org/x3d/specificat...onformance.html

| Item
|
| VRML File Limit
| Minimum Browser Support
| Names for
| DEF/PROTO/field
| 50 utf8 octets.
| 50 utf8 octets.

150 Scripts
+ 150 EventIn fields (at least one per Script)
+ 150 EventOut fields (at least one per Script)
+ 62 PROTOs
-------------------
512 names (at least)

The limit of only 50 names sounds bizarr. Some exports from 3D modellers
name every object und is not uncommon to get more than 50 VRML objects
from 3D modellers 8-(

And till today i never saw a "50 names limit exceeded" error somewhere.

so long
MUFTI
--
Eine oder mehrere Erinnerungen werden moeglicherweise nicht angezeigt.
(Fehlermeldung von Micro$oft outlook)
John Andrews

2005-06-01, 7:29 pm

Joerg Scheurich aka MUFTI wrote:

>
> In principle, you can join two scripts always together to one....
>
>
>
>
> In principle, you aready broke the wall at least by more than factor 10:
>
> http://www.web3d.org/x3d/specificat...onformance.html
>
> | Item
> |
> | VRML File Limit
> | Minimum Browser Support
> | Names for
> | DEF/PROTO/field
> | 50 utf8 octets.
> | 50 utf8 octets.
>
> 150 Scripts
> + 150 EventIn fields (at least one per Script)
> + 150 EventOut fields (at least one per Script)
> + 62 PROTOs
> -------------------
> 512 names (at least)
>
> The limit of only 50 names sounds bizarr. Some exports from 3D modellers
> name every object und is not uncommon to get more than 50 VRML objects
> from 3D modellers 8-(
>
> And till today i never saw a "50 names limit exceeded" error somewhere.
>
> so long
> MUFTI
> --
> Eine oder mehrere Erinnerungen werden moeglicherweise nicht angezeigt.
> (Fehlermeldung von Micro$oft outlook)


well, you're absolutely right. and i did it (combined into single script), and in this case this is exactly
what needed to be done. Thanks, MUFTI, for the suggestion. (this is not the first time i've taken your
advice).

There are some situations, however, when combining Scripts isn't practical. For example, i've scripts to
adjust verticle exaggeration, run fly-throughs, and manage the HUD. From a programmer's perspective, i'd
want to keep these scripts separate, although there's probably no compelling practical reason to do so. If
i *do* decide to keep them separate, though: is there a way to access the member fields and events of
Script A from Script B. (as in C++, with it's 'Friend' function and public function/data capabilities).

Joerg Scheurich aka MUFTI

2005-06-01, 7:29 pm

> There are some situations, however, when combining Scripts isn't practical.

> From a programmer's perspective, i'd
> want to keep these scripts separate, although there's probably no
> compelling practical reason to do so.


Modularisation is a very strong reason to keep programming parts devided,
especially from a programmer's perspective 8-)

> If
> i *do* decide to keep them separate, though: is there a way to access
> the member fields and events of
> Script A from Script B.


If you use java, you can use a extra communication mechanism from java
itself - but this do not sound very practically 8-(

You can also think about bringing different scripts together inside
a PROTO and exchange data via the fields/exposedFields in the PROTO
interface. At least, this method do not need ROUTEs...

so long
MUFTI
--
Harald Koenig: If TeX wouldn't already exist, are you satisfied with the
quality of M$ Word or similar programs and would you use it to write your
books, or to you think TeX still would have to be invented these days ?
Donald E. Knuth: I hope to die before I *have* to use Microsoft Word.
Brian Hay

2005-06-14, 11:53 pm

On 2/06/2005 12:10 AM, John Andrews wrote:

> If
> i *do* decide to keep them separate, though: is there a way to access the member fields and events of
> Script A from Script B. (as in C++, with it's 'Friend' function and public function/data capabilities).


#VRML V2.0 utf8

DEF timer TimeSensor { loop TRUE }

DEF scriptA Script {
eventOut SFBool scriptAfield
url "java script:
function initialize() {
scriptAfield = true;
}
"
}

DEF scriptB Script {
field SFNode scriptA USE scriptA
eventIn SFTime readTime
url "java script:
function readTime(t) {
a = scriptA.scriptAfield;
print(a);
}
"
}

ROUTE timer.cycleTime TO scriptB.readTime


Regards,
Brian Hay.
dblaikie@gmail.com

2005-06-19, 7:15 am

Joerg Scheurich aka MUFTI wrote:
> The limit of only 50 names sounds bizarr. Some exports from 3D modellers
> name every object und is not uncommon to get more than 50 VRML objects
> from 3D modellers 8-(


I think you'll find that the limit on names refers to the number of
characters in a single identifier that the VRML browser must support
(that is a browser must provide support for names up to 50 utf8 octets
long, so if you want to write portable code don't use identifiers
longer than 50 utf8 octets), not the number of unique identifiers. (50
utf8 octets is 2 ^ (50*8) possible names.. more or less (nowhere near
all of those characters are displayable.. but anyway))

David

Sponsored Links


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