Loading multiple scenes - fastest way?

View previous topic View next topic Go down

Loading multiple scenes - fastest way?

Post  michele.balistreri on Thu Oct 30, 2008 8:36 am

In my application I have several, very different scenes which happen as a sequence (i mean that they never interleave, once I am done with one, I can destroy it and load the other). I would like each to have its own sio2 file and would like to know what is the best way to cleanly unload a scene and be ready to load another

michele.balistreri

Posts : 5
Join date : 2008-10-21

View user profile

Back to top Go down

Re: Loading multiple scenes - fastest way?

Post  sio2interactive on Thu Oct 30, 2008 4:41 pm

sio2ResourceUnloadAll( sio2->_SIO2resource );

This will literally destroy everything and restore back the resource manager to its initial stage... you can also use the sio2ResourceUnload function with one of the follow parameters:

Code:


typedef enum
{
   SIO2_OBJECT = 0,
   SIO2_MATERIAL,
   SIO2_LAMP,   
   SIO2_CAMERA,   
   SIO2_IMAGE,
   SIO2_SOUNDBUFFER,
   SIO2_SCRIPT,
   SIO2_VIDEO,   
   SIO2_SOUND,
   SIO2_WIDGET,
   SIO2_PHYSIC,
   SIO2_SENSOR,
   SIO2_EMITTER,
   SIO2_MIST,
   SIO2_FONT,
   
   SIO2_RESOURCE_ALL
   
} SIO2_RESOURCE_TYPE;


Each of them will delete from the resource manager everything that have been allocated for a proper type. If you have resources that you want to keep because they are shared or? I suggest you implement your own unloading routine and add (ex:) a custom tag to the object or resource to avoid to be deleted etc... SIO2 provide you everything that you need to implement this type of mechanism, checkout the sio2ResourceUnload function for more information.

Hope this help,
avatar
sio2interactive

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

View user profile http://sio2interactive.com

Back to top Go down

Re: Loading multiple scenes - fastest way?

Post  charlierby on Wed Nov 05, 2008 9:08 am

Is it possible that there is a problem when loading a scene with physics (the scene itself is ok and works as expected) and then unloading everything with sio2ResourceUnloadAll() and then loading another scene (which is also ok)? I get an error in sio2_physic.cc - bad access at:

Code:
_SIO2physic->_btSoftRigidDynamicsWorld->addRigidBody( _SIO2object->_btRigidBody );

btSoftRigidDynamicsWorld seems to be null - any ideas?

Greetings,

charlierby

Posts : 27
Join date : 2008-10-17

View user profile

Back to top Go down

Re: Loading multiple scenes - fastest way?

Post  sio2interactive on Wed Nov 05, 2008 4:36 pm

Heuuuuuuu.... yeah man... the physic world is also destroyed... just recreate one with sio2PhysicInit() or avoid unloading it when you are flushing the resources...
avatar
sio2interactive

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

View user profile http://sio2interactive.com

Back to top Go down

Re: Loading multiple scenes - fastest way?

Post  charlierby on Thu Nov 06, 2008 6:37 am

thx for your help Wink

charlierby

Posts : 27
Join date : 2008-10-17

View user profile

Back to top Go down

Re: Loading multiple scenes - fastest way?

Post  sio2interactive on Thu Nov 06, 2008 4:31 pm

Another thing that you can do but this is considered as "advanced" is:

Maintain multiple handle to _SIO2resource, and load your scene in another thread making sure that the resource handle that you load is assigned to the main sio2 context. Then in the main thread when everything is ready GenMatrix & GenIds (since they are the only commands that uses GL).

Like that you can load another scene while still rendering and only when ready you can switch the SIO2resource handles to render/unload.

The only thing that you need to pay attention is: When a new resource is created it will automatically be added to the resource handle assigned to the sio2 handle. ( I know Im kinda repeating myself but that's important )
avatar
sio2interactive

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

View user profile http://sio2interactive.com

Back to top Go down

Re: Loading multiple scenes - fastest way?

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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