I used this code to load new levels:
bool cimGame::LoadMap (const char* mapname)
{
//Delete the engine's content.
engine->DeleteAll();
// Set VFS current directory to the level we want to load.
csRef<iVFS> VFS (CS_QUERY_REGISTRY (GetObjectRegistry (), iVFS));
VFS->ChDir (mapname);
// Load the level file which is called 'world'.
if (!loader->LoadMapFile ("world"))
ReportError("Error couldn't load level!");
// Initialize collision objects for all loaded objects.
csColliderHelper::InitializeCollisionWrappers (cdsys, engine);
// Let the engine prepare all lightmaps for use and also free all images
// that were loaded for the texture manager.
engine->Prepare ();
// Find the starting position in this level.
csVector3 pos (0);
if (engine->GetCameraPositions ()->GetCount () > 0)
{
// There is a valid starting position defined in the level file.
iCameraPosition* campos = engine->GetCameraPositions ()->Get (0);
room = engine->GetSectors ()->FindByName (campos->GetSector ());
pos = campos->GetPosition ();
}
else
{
// We didn't find a valid starting position. So we default
// to going to room called 'room' at position (0,0,0).
room = engine->GetSectors ()->FindByName ("room");
pos = csVector3 (0, 0, 0);
}
if (!room)
ReportError("Can't find a valid starting position!");
// Now we need to position the camera in our world.
view->GetCamera ()->SetSector (room);
view->GetCamera ()->GetTransform ().SetOrigin (pos);
// Initialize our collider actor.
collider_actor.SetCollideSystem (cdsys);
collider_actor.SetEngine (engine);
csVector3 legs (.2f, .3f, .2f);
csVector3 body (.2f, 1.2f, .2f);
csVector3 shift (0, -1, 0);
collider_actor.InitializeColliders (view->GetCamera (),
legs, body, shift);
return true;
}
2007/5/28, Jim Sager <[EMAIL PROTECTED]>:
Using the application simpmap, I would like to be able to hit the
downarrow key and unload "flarge", and load up "castle"
I tried the code:
if (kbd->GetKeyState (CSKEY_DOWN))
{
csRef<iVFS> VFS (CS_QUERY_REGISTRY (GetObjectRegistry (), iVFS));
VFS->ChDir ("/lev/castle");
loader->LoadMapFile ("world");
}
Also is there a way to unload "EVERYTHING" in the engine and start from
scratch?
Yes, use the IEngine->DeleteAll() function.
If not, I'll have to take careful measure to deallocate all the memory
before loading the new world.
,CrazyJim
------------------------------
Luggage? GPS? Comic books?
Check out fitting gifts for
grads<http://us.rd.yahoo.com/evt=48249/*http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz>at
Yahoo! Search.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Crystal-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]
?subject=unsubscribe
--
Jocó
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Crystal-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]