Rotate object using cursor inputs

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
henkten
Posts: 6
Joined: Fri Sep 26, 2008 9:20 pm

Rotate object using cursor inputs

Post by henkten »

Hi everyone :) , I'm new to irrlicht, so please bear with me. :(

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;
}
Last edited by henkten on Sat Oct 04, 2008 3:47 am, edited 3 times in total.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

I imagine that your whole program is going to be pretty short. I'd suggest that you post it (inside

Code: Select all

 tags) rather that have us guess exactly what it is that you're doing.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
henkten
Posts: 6
Joined: Fri Sep 26, 2008 9:20 pm

Post by henkten »

I've found another post in the forums that explains what I'm trying to do(searched forum before I posted this topic, but apparently didn't search thoroughly enough), but I don't know how to delete this topic though. I apprecite the advice still Rogerborg. :D
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You don't need to delete it, just link to the forum entry you found and it will help people searching for the same topic :)
henkten
Posts: 6
Joined: Fri Sep 26, 2008 9:20 pm

Solution

Post by henkten »

Thanks for the advice Hybrid, I concur. :) Here's the page with almost identical request and solution-
http://irrlicht.sourceforge.net/phpBB2/ ... manipulate
Post Reply