Instances of ABNETZone proto
Goto page 1, 2  Next
 
Post new topic   Reply to topic    VRMLWorld.net Forum Index -> ABNet::Examples
View previous topic :: View next topic  
Author Message
Laz
Forum Junkie


Joined: 15 May 2003
Posts: 91
Location: upper midwest

PostPosted: Tue Mar 31, 2009 5:44 pm    Post subject: Instances of ABNETZone proto

I would like to add some shared features to the world i'm building but the number of like-types events concern me. Is it possible to "share" one event type through different objects or is that bad. The other thought is, is it possible to have more than one instance of the SharedEvent/abnetzone to accomodate more events of the same type. For instance having multiple SFRotaion events like in my back hoe or the other thought was using an sfrotation event on the door protos inside the house. I guess i'm fishing to see how flexible this might be or if i should try to keep shared events relatively simple as to not confuse a) visitors and b) the server. lol

Rick i heard you comment before that the backhoe might not be that bad to make a shared event. I would love to hear your thoughts on this and just how flexible I can be with with abnetzone/sharedevent, shared events.


If i use an SFRotation event of a door proto that is going to be used like 3-4 times will it work for all of them or will it require extra instances of the sharedevent proto to accomplish?
Back to top
Rick
Site Admin


Joined: 08 May 2003
Posts: 106
Location: NC, US

PostPosted: Wed Apr 01, 2009 7:58 am    Post subject:

Sure you can share one event. Make it an SFString and route to and from a Script node. Have the script node determine what is really being sent or received.

You could also add and remove nodes to the SharedZone events array. ( Haven't tried it, but it should work ).

When using shared events, it is best to use them as triggers. Take the door for example, instead of sending all the SFRotations events over the network, it is better to send a start time. Route the shared start time to start a timer that uses its associated interpolators.

You can only have one instance of the ABNetZone.

Each SharedEvent needs a unique name. I'll see if I can come up with an example to illustrate all these concepts.

-rick
Back to top
Laz
Forum Junkie


Joined: 15 May 2003
Posts: 91
Location: upper midwest

PostPosted: Wed Apr 01, 2009 5:43 pm    Post subject:

Back to top
vcard
Forum Junkie


Joined: 01 Aug 2008
Posts: 58

PostPosted: Fri Apr 03, 2009 7:19 pm    Post subject:

Hi Laz,

Try changing in your file

DEF SharedZone ABNetZone { ...

to

DEF ABNetZone ABNetZone { ...
Back to top
Laz
Forum Junkie


Joined: 15 May 2003
Posts: 91
Location: upper midwest

PostPosted: Fri Apr 03, 2009 9:55 pm    Post subject: switched

I switched the DEF name as you suggested although I'm not certain why that makes a difference. Normally a DEF name is just a name but i don't claim to know all about the server stuff so i am taking your word for it. Smile

It's hard to tell if it is working though since i can never seem to be in a world when others are around to help test it. I guess i'll just keep plugging away on other stuff until an opportunity presents itself. hehe

SharedZone.... too much blaxxun on the brain. LOL
Back to top
vcard
Forum Junkie


Joined: 01 Aug 2008
Posts: 58

PostPosted: Sat Apr 04, 2009 6:32 am    Post subject:

HI Lazz,

To test the shared events u can open two windows, side by side. In Abnet that is not a problem.

vcard
Back to top
Laz
Forum Junkie


Joined: 15 May 2003
Posts: 91
Location: upper midwest

PostPosted: Sat Apr 04, 2009 11:54 am    Post subject: WOW!

You mean it is as simple as that to test shared event in abnet? i thought it had to come from 2 seperate IP's lol

thank you very much for that info. that is a very useful thing to know Smile
Back to top
Laz
Forum Junkie


Joined: 15 May 2003
Posts: 91
Location: upper midwest

PostPosted: Sat Apr 04, 2009 12:18 pm    Post subject: strange-events

Ok that works as far as testing the shared event but now i have something really strange happening. Not sure if it of the proto that i am using or not but here is what is happening and i will post my code as well...

The shared events only work if both people have clicked the same target, then it starts to be shared BUT the cycles are not in sync.. when on one screen i click and the door opens, on the other it will close or jump to a fresh cycle from where it was at. For some reason it doesn't share unless both parties have clicked it and then it is out of whack. here is what i have...

Here is the proto code:


DEF comtime TimeSensor {
enabled TRUE
loop FALSE
cycleInterval 1.5
startTime IS startTime
}
DEF comturn OrientationInterpolator {
key [0,1]
keyValue [0 1 0 0, 0 1 0 0]
}

DEF com Script {
directOutput TRUE
eventIn SFTime comT
eventOut SFTime comout IS touchTime
field SFNode cturn USE comturn
field MFRotation open [0 1 0 0, 0 1 0 1.571]
field MFRotation close [0 1 0 1.571, 0 1 0 0]
field SFInt32 cntr 1
url "javascript:
function comT(v) {

if (cntr == 1) cturn.keyValue = open;
if (cntr == 2) cturn.keyValue = close;
if (cntr == 2) cntr = 1;
else cntr = cntr +1;
comout = v;
}
"
}
]
}
ROUTE comtouch.touchTime TO com.comT
ROUTE comtime.fraction_changed TO comturn.set_fraction
ROUTE comturn.value_changed TO door.rotation



And here is the ABNET reference and routing to server:


DEF ABNetZone ABNetZone {
events [
DEF SHARED_EV0 SharedEvent { name "se0" type "SFTime" },
DEF SHARED_EV1 SharedEvent { name "se1" type "SFTime" },
DEF SHARED_EV2 SharedEvent { name "se2" type "SFTime" },
]
}

DEF door1 com-door {
}
DEF door2 com-door {
translation -2 0 0.85
rotation 0 1 0 0.7855
}
DEF door3 com-door {
translation 2 0 0.85
rotation 0 1 0 -0.7855
}

ROUTE door1.touchTime TO SHARED_EV0.set_time
ROUTE SHARED_EV0.time_changed TO door1.startTime
ROUTE door2.touchTime TO SHARED_EV1.set_time
ROUTE SHARED_EV1.time_changed TO door2.startTime
ROUTE door3.touchTime TO SHARED_EV2.set_time
ROUTE SHARED_EV2.time_changed TO door3.startTime



Perhaps it is the proto itself since it holds the values for the OrientationInterpolator? After talking to rick one night and he straightened me out about using the TouchTime I thought that would have fixed it but apparently I am just not that smart about the server side stuff.

Crying or Very sad
Back to top
Laz
Forum Junkie


Joined: 15 May 2003
Posts: 91
Location: upper midwest

PostPosted: Sat Apr 04, 2009 12:36 pm    Post subject: I think....

Do you think it might be because the script in the proto isn't being shared?

I figured out how to get the animations to start for both people at same time but it is still out of sync
The Interpolator was the problem initially.

DEF comturn OrientationInterpolator {
key [0,1]
keyValue []
}
I made keyValue empty then the animation at least started at the same time on both screens.

if more than one person clicks. The counter value inside the script changes but probably not for both people at once?
Would it be unwise to send a seperate sever request for SFInt32 so the counter is in sync?

I feel kind of stupid sometimes. maybe i just cannot use this type of script with a shared event....
Back to top
Rick
Site Admin


Joined: 08 May 2003
Posts: 106
Location: NC, US

PostPosted: Wed Apr 08, 2009 7:48 am    Post subject:

I took a look http://home.comcast.net/~lazerousvr/temp/shared/shared.wrl:

Some things I noticed:

Code:
 eventIn  SFInt32 intFromServer
 eventIn  SFInt32 set_int
 eventOut SFInt32 int_changed


Those don't match the declarations in protos.wrl#ABNetZone

They need to be:

Code:
# SFInt32
 eventIn  SFInt32 int32FromServer
 eventIn  SFInt32 set_int32
 eventOut SFInt32 int32_changed


You might try changing your shared.wrl to match.

-rick
Back to top
Display posts from previous:   
Post new topic   Reply to topic    VRMLWorld.net Forum Index -> ABNet::Examples All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum