Page 1 of 1
mapchange ?
Posted: Thu Jun 29, 2006 9:16 am
by Angelus
Hello,
i´ve got a basic question on mapchanges ...
How can i load a new map, when my camera arrives at a specific position in the current map (for example a door or something like that ...) ?
Posted: Thu Jun 29, 2006 11:00 am
by Acki
Check the position or collision and if you there, unload the old meshes and create new ones...
Posted: Thu Jun 29, 2006 11:02 am
by cadue
It's simple:
Code: Select all
//load first map
IAnimatedMeshSceneNode* map1 = smgr->addAnimatedMeshSceneNode(smgr->getMesh(...));
//load second map
IAnimatedMeshSceneNode* map2 = smgr->addAnimatedMeshSceneNode(smgr->getMesh(...));
map2->setVisible(false);
//create camera
ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
while(device->run())
{
vector3df camPos = camera->getPosition();
if(camPos.X > ... && camPos.X < ... && camPos.Z > ... && camPos.Z < ...){
map1->setVisible(false);
map2->setVisible(true);
}
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
Posted: Thu Jun 29, 2006 1:18 pm
by Acki
Yes, you can do it this way if you're using only a few meshes...
But you'll have all meshes in memory, all the time !!!
Let's say you have a really big game with many maps (for example The Elder Scrolls series), then you have 100s of maps in memory...
Not talking about all the object meshes...
Posted: Thu Jun 29, 2006 3:32 pm
by Angelus
thank you ... i will try it
Posted: Thu Jun 29, 2006 5:57 pm
by luckymutt
@Acki -
would the only way to do it be to load and unload meshes like:
Code: Select all
while(device->run())
{
if(camera blah...) {
drop->first mesh
IAnimatedMeshSceneNode* map2 = smg->addAnimatedMeshSceneNode(smgr->getMesh(...));
...
...
...
}
I thought I read somewhere that it wasn't good to load/unload in the 'while'...but I dunno
Posted: Thu Jun 29, 2006 7:31 pm
by Acki
Well, it's always done inside the while, because it's the main loop...
Even if you call a function, it's always inside the main loop...
What you never should do is to do this between beginScene and endScene !!!
Now, I would call a function, create a loading screen and do the removings and creatings in there ...
Code: Select all
while(device->run()){
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
if(cam == endPos) loadNewMap();
}
void loadNewMap(){
guienv->addImage(loadingScreen);
driver->beginScene(true, true, SColor(255,100,101,140));
guienv->drawAll();
driver->endScene();
smgr->getRootSceneNode()->removeAll();
// create new map and objects
...
}
BTW: always think about there are many ways to do something, this is only one solution I think it's a good choice...