[X3D-Public] games > state carryover on anchor between scenes

Christoph Valentin christoph.valentin at gmx.at
Tue Oct 15 19:18:22 PDT 2013


Hi Doug

>
> >>> Yes it could be fun for games! If you anchor between rooms or
> >>> indoor/outdoor scenes all those scenes can be be parsed separately as
> >>> needed. Which may render faster depending on viewer.
> >>
> >>>> The idea of bundling resources in a zip file is common in game engines
> >>>> (especially useful to distribute game mods), and as I'm implementing a
> >>>> game engine using X3D --- it would be cool if it would be just a
> >>>> standard X3D feature :)
> >>>>
> >>
> >> Q. for multi-scene games, how / where is game state -such as scoring, level, persona- carried over to subsequent scenes after an Anchor? Is there an SAI field on the Browser that can be set with (name,value) pairs from Script nodes/javascript, and if so which field(s)? Or is there another paradigm?
> >
> > [Christoph:] You could load one "master scene" by the Web3D browser, add modules/levels (whatever you call them) dynamically using the method Browser.createVrmlFromUrl() as children of a grouping node. Then you could store your state in the "master scene". You would need to define an interface between the "master scene" and your modules/levels
> >
> > Do not know whether to call this a "paradigm", it's just a possibility, and it needs more scripting than a simple anchor.
> >
> 
> Thanks Christoph. 
> Q. how does the interface work? Can createX3DFromUrl nodes refer to DEF 
> nodes not within its own subscene? Or would we somehow find a node to 
> talk to by crawling the scenegraph?
> 
As Dave wrote, you could wrap your levels within prototypes. Prototypes can define arbitrary interfaces.

You are right, DEF names outside the own subscene cannot be accessed directly (some Browsers have exceptions to this rule and allow to access DEF names of the "master scene" from some "sub scene" under some circumstances, but generally this is not possible).

The method Browser.createVrmlFromUrl() delivers an MFNode with all top level nodes of the loaded scene, so  you could define "the nth toplevel node has this and that interface function" and setup dynamic routes. However I would not recommend this because some browsers invert the order of the loaded nodes. Using prototypes (and inlines) is more straight forward. I myself have tried prototypes.

BR Christoph
> -Doug
> 
> Holding Game State Across modules/levels/rooms/scenes
> 
> Possibility 1:
> Master-Scene holds state for sub-scenes
> Method A: Browser.createVrmlFromUrl()/createX3DfromUrl() brings in sub-scenes to children of group node in master scene
> 
> Method B: 
> i) newscene = createX3DfromURL(url) is called first to generate a new X3DScene
> ii) then settings are transferred from the current scene to the newscene
> iii) then replaceWorld(newscene)
> 
> 
> Possibility 2:
> Browser object holds state between peer scenes
> Method: an SAI field or function on the Browser object that can be set from Script nodes, 
> http://www.web3d.org/files/specifications/19777-1/V3.0/Part1/functions.html#BrowserServices 
> - perhaps an array of strings or property list called 'crossSceneState':
> http://www.web3d.org/files/specifications/19777-1/V3.0/Part1/types.html#SAIPropertyList
> Anchor/LoadURL or createX3DfromURL + replaceWorld brings in peer scenes
> - each peer scene keeps the Browser.crossSceneState updated
> 
> Q. can I just add more properties to Browser from javascript ie Browser.mystate = new array()? If so would it stick around after an Anchor? 		 	   		  
> _______________________________________________
> X3D-Public mailing list
> X3D-Public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
> 



More information about the X3D-Public mailing list