anon wrote:I also tried building up my own camera class from ICameraSceneNode but I got strange runtime errors from C++ about the EPS register when the ICameraSceneNode constructor is called. I think that's because of an inconstency between the way the irrlicht DLL is built and what my compiler thinks is the way things should work.
i derived my own camera class and i initally got the same "esp register" error message when the contstuctor was called... however, after changing one of the parameters in the contstructor the class now works perfectly! it's much easier to send events directly to the active camera now and makes the code much cleaner. this is what my class looks like:
Code: Select all
// in the .h file..
class HouseCam : public irr::scene::CCameraSceneNode {
public:
HouseCam();
virtual bool OnEvent(irr::SEvent event);
void UpdateCameraPos();
bool down,up,left,right;
};
// in .cpp file...
HouseCam::HouseCam() : CCameraSceneNode(g_irr.smgr->getRootSceneNode(),g_irr.smgr,-1){
down = up = left = right = false; //nice syntax :)
}
void HouseCam::UpdateCameraPos() {
if (down) {
this->setPosition( this->getPosition() + irr::core::vector3df(-3,0,0) );
this->setTarget( this->getTarget() + irr::core::vector3df(-3,0,0) );
}
if (up) {
this->setPosition( this->getPosition() + irr::core::vector3df(3,0,0) );
this->setTarget( this->getTarget() + irr::core::vector3df(3,0,0) );
}
if (left) {
this->setPosition( this->getPosition() + irr::core::vector3df(0,0,3) );
this->setTarget( this->getTarget() + irr::core::vector3df(0,0,3) );
}
if (right) {
this->setPosition( this->getPosition() + irr::core::vector3df(0,0,-3) );
this->setTarget( this->getTarget() + irr::core::vector3df(0,0,-3) );
}
this->updateAbsolutePosition();
}
bool HouseCam::OnEvent( irr::SEvent event ) {
if (event.EventType == irr::EET_KEY_INPUT_EVENT) {
if (event.KeyInput.PressedDown) { //key pressed
if (event.KeyInput.Key == irr::KEY_UP) up = true;
else if (event.KeyInput.Key == irr::KEY_DOWN) down = true;
else if (event.KeyInput.Key == irr::KEY_LEFT) left = true;
else if (event.KeyInput.Key == irr::KEY_RIGHT) right = true;
} else { //key released
if (event.KeyInput.Key == irr::KEY_UP) up = false;
else if (event.KeyInput.Key == irr::KEY_DOWN) down = false;
else if (event.KeyInput.Key == irr::KEY_LEFT) left = false;
else if (event.KeyInput.Key == irr::KEY_RIGHT) right = false;
}
}
return true;
}
the global pointer g_irr points to the irrlicht engine
i copied the files CCameraSceneNode.h and .cpp to my project folder and added them to the project, then derived a class from them.
let me know if this helps! also let me know if you found a better way to do this!