Sure

// Set up the application
bool Phage::Application()
{
...
if (!LoadLevel ("Phage1"))
return ReportError ("Error loading level!");
...
}
Load the game level
// Load an initial game level
bool Phage::LoadLevel(csString level)
{
// Some flags to allow for 'in-game' movement and actions
LevelFlag = true;
StartCamFlag = false;
string levelName = "";
string libName = "";
string entitiesFile = "";
levelName = "/lev/" + level;
libName = "/lib/" + level;
entitiesFile = level + "_entities";
const char* load_level = levelName.c_str ();
const char* load_lib = libName.c_str ();
const char* load_entities = entitiesFile.c_str ();
#ifdef CS_DEBUG
Report (CS_REPORTER_SEVERITY_NOTIFY, "Attempting to load Map 1 level ...");
#endif
// Create the level entity
level_entity = pl->CreateEntity ("level", bl, "level_behave",
"pcworld.zonemanager",
CEL_PROPCLASS_END);
if (!level_entity)
return ReportError ("Error creating level entity!");
// Now get the iPcZoneManager interface so we can setup the level.
csRef<iPcZoneManager> zonemgr = CEL_QUERY_PROPCLASS_ENT (level_entity,
iPcZoneManager);
iCelZone* zone = zonemgr->CreateZone ("main");
iCelRegion* region = zonemgr->CreateRegion ("main");
zone->LinkRegion (region);
// Load the mapfile
iCelMapFile* mapfile = region->CreateMapFile ();
mapfile->SetPath (load_level);
mapfile->SetFile ("world");
// Load the entities file for the initial map
iCelMapFile* entitiesfile = region->CreateMapFile ();
entitiesfile->SetPath (load_lib);
entitiesfile->SetFile (load_entities);
return true;
}
Now in-line, while the game is running:
// Process the current frame
void Phage::ProcessFrame ()
{
...
if (phageKeyboard->randSteps == 50)
{
if (loadBattle)
{
loadBattle = false;
//battleFlag = true;
//MouseMove = false;
worldPos = playerMesh->GetMovable()->GetFullPosition();
LoadBattleLevel ("Battle1");
//MoveHero (csVector3(-42,.5,-82), "Scene2");
MoveHero (csVector3(2,2,15), "Scene2");
LoadBattle1Enemies ();
TransformBattle1Entities ();
}
...
}
Load the battle map:
// Load the battle map
bool Phage::LoadBattleLevel (csString level)
{
string levelName = "";
string libName = "";
string entitiesFile = "";
levelName = "/lev/" + level;
libName = "/lib/" + level;
entitiesFile = level + "_entities";
// Some flags to allow for 'in-game' movement and actions
LevelFlag = true;
StartCamFlag = false;
loadBattle = false;
const char* load_level = levelName.c_str ();
const char* load_lib = libName.c_str ();
const char* load_entities = entitiesFile.c_str ();
#ifdef CS_DEBUG
Report (CS_REPORTER_SEVERITY_NOTIFY, "Attempting to load Map 1 Battle 1 level ...");
#endif
// Create an entity for the battle map
battle_entity = pl->CreateEntity ("level", bl, "level_behave",
"pcworld.zonemanager",
CEL_PROPCLASS_END);
if (!battle_entity)
return ReportError ("Error creating level entity!");
// Create a 2nd iPcZoneManager interface so we can setup the battle map
csRef<iPcZoneManager> battle_zonemgr = CEL_QUERY_PROPCLASS_ENT (battle_entity,
iPcZoneManager);
iCelZone* battle_zone = battle_zonemgr->CreateZone ("Battle");
iCelRegion* battle_region = battle_zonemgr->CreateRegion ("Battle");
battle_zone->LinkRegion (battle_region);
// Create and load the battle map
iCelMapFile* battle_mapfile = battle_region->CreateMapFile ();
battle_mapfile->SetPath (load_level);
battle_mapfile->SetFile ("world");
// Load the entities file for the initial map
// iCelMapFile* battle_entitiesfile = battle_region->CreateMapFile ();
// battle_entitiesfile->SetPath ("/lib/Phage1");
// battle_entitiesfile->SetFile ("Phage1_entities");
// Get the starting position within the new map and initialize the sector
CamStartPos();
return true;
}
And finally:
// Move the hero to the new sector/map
bool Phage::MoveHero(csVector3 destPos, csString destSector)
{
// Variables for being able to move sectors
float yrot;
iSector* sector;
loadMap = false;
string destinationSector = destSector;
const char* destination = destinationSector.c_str ();
// Get the zone manager from the battle level entity
csRef<iPcZoneManager> pczonemgr = CEL_QUERY_PROPCLASS_ENT (battle_entity,
iPcZoneManager);
// Set the camera to the new region in the battle map
pccamera->SetZoneManager(pczonemgr, true, "Battle", "Camera");
// Position our mesh in the new sector
csVector3 oldPos = pccamera->GetCamera()->GetTransform().GetOrigin();
pclinmove->GetLastPosition (oldPos, yrot, sector);
sector = engine->FindSector (destination);
pclinmove->SetFullPosition (destPos, yrot, sector);
return true;
}
It all works as it should, it just doesn't place the hero/camera at the "Full" position passed, i think its doing the interpolated position or whatever.
Any ideas?
Thanks!