I played a bit around with Irrlicht
and C++, and got the following MWE:
#include <iostream>
#include <Irrlicht/irrlicht.h>
#include <Irrlicht/driverChoice.h>
#include <cstdio>
#include <Irrlicht/EDriverTypes.h>
#include <Irrlicht/irrTypes.h>
#include <Irrlicht/IrrlichtDevice.h>
class MyEventReceiver : public irr::IEventReceiver
{
private:
bool KeyIsDown[irr::KEY_KEY_CODES_COUNT];
public:
virtual bool OnEvent(const irr::SEvent &event)
{
if(event.EventType == irr::EET_KEY_INPUT_EVENT)
this->KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
return false;
}
virtual bool IsKeyDown(irr::EKEY_CODE keyCode) const
{
return this->KeyIsDown[keyCode];
}
MyEventReceiver()
{
for(irr::u32 i = 0; i < irr::KEY_KEY_CODES_COUNT; ++i)
{
this->KeyIsDown[i] = false;
}
}
};
int main(void)
{
MyEventReceiver receiver;
irr::IrrlichtDevice *device = irr::createDevice(irr::video::EDT_OPENGL, irr::core::dimension2d<irr::u32>(1024, 800), 16, false, false, false, &receiver);
irr::video::IVideoDriver* driver = device->getVideoDriver();
irr::scene::ISceneManager* scmg = device->getSceneManager();
irr::scene::ICameraSceneNode *camera = scmg->addCameraSceneNodeFPS();
getchar();
const double pref_pos = 2.5;
irr::core::vector3df sphere_cur_pos = irr::core::vector3df(0, 0, 0);
irr::core::vector3df sphere_position = irr::core::vector3df(0, 0, 0);
std::cout << "Set initial vectors\n!";
irr::scene::ISceneNode *cur_node = nullptr;
cur_node = scmg->addSphereSceneNode(1.0f, 16, 0, -1, irr::core::vector3df(10, 0, 0));
std::cout << "Set node\n";
sphere_cur_pos = (*cur_node).getPosition();
std::cout << "New sphere is at (" << sphere_cur_pos.X << ", " << sphere_cur_pos.Y << ", " << sphere_cur_pos.Z << ')' << '\n';
std::cout << "Hello World\n";
getchar();
return 0;
}
Compilation line is
g++-5 -std=c++14 irrlicht_vector_test.cpp -o irrlicht -lIrrlicht `pkg-config --libs x11` `pkg-config --libs xxf86vm` `pkg-config --libs gl` && ./irrlicht
The output of the program is
Set initial vectors
!Set node
New sphere is at (2.70951e-35, 37135.9, 2.83893e-29)
Hello World
If I exchange
sphere_cur_pos = (*cur_node).getPosition();
with
sphere_cur_pos = (*cur_node).getAbsolutePosition();
I get as output
Set initial vectors
!Set node
New sphere is at (1, 1, 1)
Hello World
Both outputs are regardless of the vector settings in addSphereSceneNode()
. What am I doing wrong?