3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1]

Author Topic: Quick Level Loading Technique  (Read 403 times)

« on: October 08, 2013, 06:03:36 PM »
nothing really breathtaking... just an alternate way to do what typically was done using exitfade() to load a new level...

this way uses iObjectRefresh() to replace the old level with some new stuff...

the video shows in real time how quickly a 2200 x 2200 meter level loads (about 3 seconds start counting from the time the boulder stops moving)...

the next one takes a lil longer because both the terrain and the skybox are being replaced...

http://www.youtube.com/watch?v=YADG1UrNOQc

your initial levels can load faster as well seeing as they're just place holders...

the code looks like this...

Code: [Select]
int            level=0, newLevel=0;


void Main()
{
   if(iKeyDown(iKeyCode("DIK_1")))  newLevel=1;
   if(iKeyDown(iKeyCode("DIK_2")))  newLevel=2;
   if(iKeyDown(iKeyCode("DIK_3")))  newLevel=3;


   if(newLevel==1 and level!=1){
     iObjectRefresh(OBJ_44,".\\3drad_res\\objects\\skinmesh\\data\\testmap\\");
     iObjectRefresh(OBJ_66,".\\3drad_res\\objects\\rigidbody\\data\\testmap\\");

     iObjectLocationReset(OBJ_88,Vector3(0,35,0));
     level=1;
   }

   if(newLevel==2 and level!=2){
     iObjectRefresh(OBJ_0,".\\3drad_res\\objects\\sky 5x 02\\data\\skybox.sky");
     iObjectRefresh(OBJ_44,".\\3drad_res\\objects\\skinmesh\\data\\terrain0100\\");
     iObjectRefresh(OBJ_66,".\\3drad_res\\objects\\rigidbody\\data\\terrain0100\\");

     iObjectLocationReset(OBJ_88,Vector3(0,35,0));
     level=2;

   }

  if(newLevel==3 and level!=3){
     iObjectRefresh(OBJ_44,".\\3drad_res\\objects\\skinmesh\\data\\mkx_grassstrip\\");
     iObjectRefresh(OBJ_66,".\\3drad_res\\objects\\rigidbody\\data\\mkx_grassstrip\\");

     iObjectLocationReset(OBJ_88,Vector3(0,35,0));
     level=3;
   }

}



--Mike

« Reply #1 on: October 09, 2013, 05:35:57 AM »
Hi Mike I have used iObjectRefresh() and I find it great for changing car bodies and I have used it to change a whole scene.

I use the script below for changing the car body. All you need to do is change the value of the 'opts' variable. All the car body skinmesh addresses are stored in the carfile[] array, carOpts[] array contained the car window skinmesh addresses. If 'opts' is zero the car body isn't changed from the default car body.

When I complete the project I hope to have the whole scene, track, scenery and rigidbodies changed this way. Change time isn't instant but much faster than reloading the next level.

Doing it this way you must get the mesh centers all the same or things will get a bit messy.

n_iron


Quote
         if(opts>0){        // set selected body
            iObjectRefresh(carbodySM,"."+carfile[opts]);
            iObjectRefresh(carwindowSM,"."+carOpts[opts]);
            switch (opts){
               case 1:  iObjectRefresh(OBJ_176,"."+carfile[0]);
                        iObjectRefresh(OBJ_198,"."+carOpts[0]);break;
               case 2:  iObjectRefresh(OBJ_132,"."+carfile[0]);
                        iObjectRefresh(OBJ_154,"."+carOpts[0]);break;
               case 3:  iObjectRefresh(OBJ_220,"."+carfile[0]);
                        iObjectRefresh(OBJ_242,"."+carOpts[0]);break;
               case 4:  iObjectRefresh(OBJ_264,"."+carfile[0]);
                        iObjectRefresh(OBJ_286,"."+carOpts[0]);
            }
         }
Pages: [1]