FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

resetting scenes, sio2 resource files, and multiple levels

+2
sio2interactive
geekschmoe
6 posters

Go down

resetting scenes, sio2 resource files, and multiple levels Empty resetting scenes, sio2 resource files, and multiple levels

Post  geekschmoe Fri Jun 26, 2009 12:06 pm

So this is an SIO2 game architecture question.

Let's say I have a game with 1 player (3rd person run around game like tutorial09), 2 levels and 3 types of non-player character objects. One non-player character object is only in level 1, one is only in level 2, and the last is in both levels. What's the proper high level algorithm for doing this with blender/sio2? Would you be copying some objects into multiple resource files (duplication) for simplicity's sake? I'm assuming blender layers could play into this some how, but that seems unlikely considering that everything must be in layer one for the sio2 export script to work correctly.

Can you use multiple *.sio2 files (one for each level maybe) in one application? If so, how do you switch between them?
Can you load up two sio2 resources bundles simultaneously and mix/match objects?
Given just 1 resource bundle, can you reset the state (re-load)? In terms of game architecture, I'm assuming you would also need to clear game state variables, so what's the preferred method of doing this.

Any help is thoroughly appreciated (especially links to wiki/forum/tutorials that I may have missed regarding this topic).

geekschmoe

Posts : 14
Join date : 2009-06-22

Back to top Go down

resetting scenes, sio2 resource files, and multiple levels Empty Re: resetting scenes, sio2 resource files, and multiple levels

Post  sio2interactive Fri Jun 26, 2009 3:30 pm

I personally use the following structure in all my personal SIO2 project:


game
- player
- hud
- level1
- level2
etc...

All the structure contain an independent SIO2resource and a Init, Free, Render function, like that you can load / unload and access every part of your game using a main handle (similar as the SIO2 structure).
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

resetting scenes, sio2 resource files, and multiple levels Empty Re: resetting scenes, sio2 resource files, and multiple levels

Post  Francescu Fri Jun 26, 2009 4:50 pm

In blender, you can create a scene for every level and duplicate (linked or not) objects from the various scenes. That works.

So every scene in blender would have its own .sio2 file corresponding to the level and that you can load / unload in your game using the sio2Resource**** load/unload/free/etc functions...

Francescu

Posts : 136
Join date : 2009-03-18

Back to top Go down

resetting scenes, sio2 resource files, and multiple levels Empty Re: resetting scenes, sio2 resource files, and multiple levels

Post  alexanderlonsky Thu Jul 09, 2009 12:50 am

trying to load resources from another .sio2
Code:

        myResource = sio2ResourceInit();
   sio2ResourceCreateDictionary( myResource );
   sio2ResourceOpen( myResource, "Gun.sio2", 1 );
   
   i = 0;
   while( i != myResource->gi.number_entry )
   {
      sio2ResourceExtract( myResource, NULL );
      ++i;
   }
Looked at sio2ResourceOpen function - sio2->_SIO2resource is rewrited - I lose my current scene, that was loaded before, then I removed
Code:
sio2->_SIO2resource = _SIO2resource;
from sio2ResourceOpen, but still have may be same problem in sio2ResourceExtract
What I make wrong? may be i chose wrong way? I can load other sources before main scene, but think that it is not good idea =)

alexanderlonsky

Posts : 24
Join date : 2009-06-11

Back to top Go down

resetting scenes, sio2 resource files, and multiple levels Empty Re: resetting scenes, sio2 resource files, and multiple levels

Post  sio2interactive Thu Jul 09, 2009 1:26 am

Just create separate SIO2resource handles... then bind them to the main context (sio2->_SIO2resource) when needed...

You can easily maintain something like:

SIO2resource *level;
SIO2resource *ui;
SIO2resource *player

That's what I personally use... after that is just a question of "load/unload" when needed Wink
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

resetting scenes, sio2 resource files, and multiple levels Empty Re: resetting scenes, sio2 resource files, and multiple levels

Post  alexanderlonsky Thu Jul 09, 2009 6:11 am

sio2interactive wrote:Just create separate SIO2resource handles... then bind them to the main context (sio2->_SIO2resource) when needed...

that is the problem.. I do not understand may be =)
how to create separate SIO2resource handles?
as i understood I should use -
Code:
myResource = sio2ResourceInit();
  sio2ResourceCreateDictionary( myResource );
  sio2ResourceOpen( myResource, "Gun.sio2", 1 );
 
  i = 0;
  while( i != myResource->gi.number_entry )
  {
      sio2ResourceExtract( myResource, NULL );
      ++i;
  }
sio2ResourceClose( myResource );
   
   sio2ResourceResetState();
   
   sio2ResourceBindAllImages(myResource );
   
   sio2ResourceBindAllMaterials( myResource );
   
   sio2ResourceBindAllMatrix( myResource );
   
   sio2ResourceGenId( myResource );
and after that
sio2ResourceAdd(myResource, ...)?
but for example sio2ResourceExtract( myResource, NULL ); breaks or rewrites sio2->_SIO2resource.
sorry, I am confused, may be need to sleep more =)

alexanderlonsky

Posts : 24
Join date : 2009-06-11

Back to top Go down

resetting scenes, sio2 resource files, and multiple levels Empty Re: resetting scenes, sio2 resource files, and multiple levels

Post  sio2interactive Thu Jul 09, 2009 8:07 am

SIO2 expect that all type of resource are added inside the global sio2->_SIO2resource... so when you init multiple resource make sure that:

Code:


// Within your "game" structure
SIO2resource *myResource = NULL;
SIO2resource *player = NULL;

...
...
sio2->_SIO2resource = myResource = sio2ResourceInit();

sio2ResourceCreateDictionary( myResource );
sio2ResourceOpen( myResource, "Gun.sio2", 1 );
...
...


sio2->_SIO2resource = player = sio2ResourceInit();

sio2ResourceCreateDictionary( player );
sio2ResourceOpen( player, "player.sio2", 1 );
...
...


sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

resetting scenes, sio2 resource files, and multiple levels Empty Re: resetting scenes, sio2 resource files, and multiple levels

Post  alexanderlonsky Thu Jul 09, 2009 8:16 am

a-a, understood, thanks. huge my problem - I used sio2->_SIO2resource for rendering that was rewrited.
"do not work more than 8h per day - it is not worth of it "
Smile

alexanderlonsky

Posts : 24
Join date : 2009-06-11

Back to top Go down

resetting scenes, sio2 resource files, and multiple levels Empty render function.

Post  evrenbingol Tue Jul 21, 2009 12:39 am

Is there a way to bind all these resource under a singe resource object during init of the game.

or do I need to call, say sio2ResourceRender function twice, Once for main character and once for the level

sio2ResourceRender( m_pMainCharacter,
sio2->_SIO2window,
sio2->_SIO2camera ,
SIO2_RENDER_SOLID_OBJECT | SIO2_RENDER_CLIPPED_OBJECT);

sio2ResourceRender( m_pLevel,
sio2->_SIO2window,
sio2->_SIO2camera ,
SIO2_RENDER_SOLID_OBJECT | SIO2_RENDER_CLIPPED_OBJECT);

evrenbingol

Posts : 7
Join date : 2009-07-12

Back to top Go down

resetting scenes, sio2 resource files, and multiple levels Empty Re: resetting scenes, sio2 resource files, and multiple levels

Post  sio2interactive Tue Jul 21, 2009 1:04 am

Well for the main character I believe that it is always visible... and you have one of them... so basically you do not need to effectuate some clipping and you can simply use the sio2ObjectRender function...
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

resetting scenes, sio2 resource files, and multiple levels Empty Re: resetting scenes, sio2 resource files, and multiple levels

Post  cdicelico Fri Aug 14, 2009 3:25 pm

sio2interactive wrote:I personally use the following structure in all my personal SIO2 project:


game
- player
- hud
- level1
- level2
etc...

All the structure contain an independent SIO2resource and a Init, Free, Render function, like that you can load / unload and access every part of your game using a main handle (similar as the SIO2 structure).

So, you're saying that a good "best practice" to follow would be to add a "games" folder to the project, with player, hud, & level subfolders, then essentially create each one as an SIO2resource with its own Init, Free, and Render functions, then call those based on events in game from the template.mm file? Is that right?

Thanks.

cdicelico

Posts : 8
Join date : 2009-08-06

Back to top Go down

resetting scenes, sio2 resource files, and multiple levels Empty Re: resetting scenes, sio2 resource files, and multiple levels

Post  sio2interactive Fri Aug 14, 2009 3:29 pm

no no no... not at all check the source of MeditationGarden to see what I mean... the structure used there is good for ANY type of game.
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

resetting scenes, sio2 resource files, and multiple levels Empty Re: resetting scenes, sio2 resource files, and multiple levels

Post  cdicelico Fri Aug 14, 2009 3:38 pm

Ah, okay, thanks.

cdicelico

Posts : 8
Join date : 2009-08-06

Back to top Go down

resetting scenes, sio2 resource files, and multiple levels Empty Re: resetting scenes, sio2 resource files, and multiple levels

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum