Amazing!! I know you used SKeyMap to define controls, but when I copy and paste it (lol) into my game, it shows up with an error. I dunno where to put it...
Also, in my Q3 map the camera moves straight through the map. What did you do to create that collision thing? Is it the anim part?
I think it will be much easier for you to use Event Receiver and after that simply call if the key has been pressed
1) Create event receiver and key array
Code: Select all
bool keys[KEY_KEY_CODES_COUNT];
class Receiver : public IEventReceiver {
public:
virtual bool OnEvent(const SEvent& event) {
//* * * * * * * * * * * * * * * * * * * * * * * * * * * *
if(event.EventType == irr::EET_KEY_INPUT_EVENT)
{
keys[event.KeyInput.Key] = event.KeyInput.PressedDown;
return false;
}
//* * * * * * * * * * * * * * * * * * * * * * * * * * * *
return false;
}
};
Receiver e_receiver;
2) When you create your Irrlicht device add the receiver name at the end with & before it:
Code: Select all
createDevice(video::EDT_OPENGL, core::dimension2d<s32>(800,600),32, false, true, false,&e_receiver);
3) After creating the device fill the key array:
Code: Select all
for(int x=0; x<irr::KEY_KEY_CODES_COUNT; x++) keys[x] = false;
4) Use:
Code: Select all
if (keys[KEY_KEY_W]) { DoSomething(); }
A: He`s loading the level here:
Code: Select all
device->getFileSystem()->addZipFileArchive("./baseq3/baseq3.pk3");
scene::IAnimatedMesh* bspmesh = 0;
bspmesh = smgr->getMesh("nemesis.bsp");
scene::ISceneNode* bspnode = 0;
bspnode = smgr->addOctTreeSceneNode(bspmesh->getMesh(0));
bspnode->setPosition(core::vector3df(0,0,0));
bspnode->setScale( irr::core::vector3df(2,2,2) );
B: Add collision to the level here:
Code: Select all
//triangle selector
scene::ITriangleSelector* selector = 0;
selector = smgr->createOctTreeTriangleSelector(bspmesh->getMesh(0), bspnode, 128);
bspnode->setTriangleSelector(selector);
selector->drop();
C: Create your camera
D: Add collision to th ecamera here:
Code: Select all
//collision detector animator
scene::ISceneNodeAnimator* anim = 0;
anim = smgr->createCollisionResponseAnimator(selector, camera, core::vector3df(30,50,30),
core::vector3df(0,-100,0),
core::vector3df(0,50,0));
camera->addAnimator(anim);
anim->drop();
For better explanation I advice you to check this tutorial:
http://irrlicht.sourceforge.net/tut007.html
It was very useful for me 5 days ago. And the Irrlicht documentation too.
Good luck!
