I used this code with the old projects using a terrain scene node:
Code: Select all
class MyEventReceiver : public IEventReceiver
{
public:
MyEventReceiver(scene::ISceneNode* terrain)
{
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
KeyIsDown[i] = false;
}
bool OnEvent(const SEvent& event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT)
KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
return false;
}
// This is used to check whether a key is being held down
virtual bool IsKeyDown(EKEY_CODE keyCode) const
{
return KeyIsDown[keyCode];
}
private:
// We use this array to store the current state of each key
bool KeyIsDown[KEY_KEY_CODES_COUNT];
};
Code: Select all
// add terrain scene node
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
"media/terrain-heightmap.bmp",
0, // parent node
-1, // node id
core::vector3df(0.f, -1200.f, 0.f), // position
core::vector3df(0.f, 0.f, 0.f), // rotation
core::vector3df(40.f, 4.4f, 40.f), // scale
video::SColor ( 255, 255, 255, 255 ), // vertexColor,
5, // maxLOD
scene::ETPS_17, // patchSize
4 // smoothFactor
);
Code: Select all
// create event receiver
MyEventReceiver receiver(terrain);
device->setEventReceiver(&receiver);
Code: Select all
// in draw loop
// add an ESCAPE key to exit
if (receiver.IsKeyDown(irr::KEY_ESCAPE))
{
device->closeDevice();
device->drop();
exit(0);
}
Code: Select all
scene::ISceneNode* Irr = smgr->loadScene("media/game.irr");
Code: Select all
error C2440: 'initializing' : cannot convert from 'bool' to 'irr::scene::ISceneNode *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast