I'm trying to get an cube to rotate when I move the mouse, on the x & y planes, corresponding to the x and y values from Cursor input.
I used the cursor's getPosition function, put it in 3d vector, used it in setRotation, but I didn't get it to work.
Thank you all for helping me out & for your time.
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
int main()
{
IrrlichtDevice* device = createDevice( video::EDT_OPENGL, core::dimension2d<s32>(640, 480),
16, false, false, false);// &receiver
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
scene::ISceneNode * node = smgr->addCubeSceneNode();
if (node)
{
node->setPosition(core::vector3df(0,0,30));
node->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp"));
node->setMaterialFlag(video::EMF_LIGHTING, false);
}
scene::ICameraSceneNode * cam = smgr->addCameraSceneNode();
device->getCursorControl()->setVisible(false);
int lastFPS = -1;
while(device->run())
{
core::position2di cursormain = device->getCursorControl()->getPosition();
core::vector3df cursormain3dv(cursormain.X,cursormain.Y,0);
core::vector3df v = node->getRotation();
node->setRotation(v+cursormain3dv);
driver->beginScene(true, true, video::SColor(255,113,113,133));
smgr->drawAll(); // draw the 3d scene
driver->endScene();
}
device->drop();
return 0;
}