I modified arras Shifted Tiled Terrain Scene Node for a project of mine and because the terrain is soo big I tried to implement a little radar that shows where the camera is on the map.
I did it like this:
Code: Select all
video::ITexture* dot=driver->getTexture("Media/dot.bmp");
video::ITexture* map=driver->getTexture("Media/Map.jpg");
while(device->run())
{
driver->beginScene(true, true, video::SColor(255,100,101,140));
// calculate time between frames
oldtime = time;
time = (f32)timer->getTime() / 1000.0f;
deltaT = time - oldtime;
// camera movement control
if(key.pressed(KEY_KEY_W)) camera.moveForward(speed * deltaT);
if(key.pressed(KEY_KEY_S)) camera.moveBack(speed * deltaT);
if(key.pressed(KEY_KEY_D)) camera.moveRight(speed * deltaT);
if(key.pressed(KEY_KEY_A)) camera.moveLeft(speed * deltaT);
// mouse directional control
camera.turnRight(50 * (device->getCursorControl()->getRelativePosition().X - 0.5f));
camera.turnUp(50 * (device->getCursorControl()->getRelativePosition().Y - 0.5f));
device->getCursorControl()->setPosition(0.5f, 0.5f);
device->getCursorControl()->setVisible(false);
.
.
.
swprintf(tmp, 1024, L"camera position: %i, %i, %i,", (s32)camera.getPosition().X, (s32)camera.getPosition().Y, (s32)camera.getPosition().Z);
font->draw(tmp, core::rect<s32>( 10, 50, 400, 60 ), video::SColor(255,255,255,255));
swprintf(tmp, 1024, L"camera heading: %i", (s32)camera.getHeading());
font->draw(tmp, core::rect<s32>( 10, 70, 400, 80 ), video::SColor(255,255,255,255));
u32 prm = driver->getPrimitiveCountDrawn();
swprintf(tmp, 1024, L"primitives: %i", prm );
font->draw(tmp, core::rect<s32>( 10, 90, 300, 100 ), video::SColor(255,255,255,255));
// Add Terrainradar
guienv->addImage(map,core::position2d<s32>(590,10));//Map for radar
guienv->addImage(dot,core::position2d<s32>(((s32)camera.getPosition().X/10)+590-3,210-((s32)camera.getPosition().Z/10)-3));
.
.
.
I think it's because I have to load the texture with every step and so my memory gets fuller and fuller.
I tried to do my code at some other points of the program but it doesn't work.
Has anybody an idea how to do this without killing my memory
Thank you very much,
regards,
Jan

