Camera moving

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
NightBird
Posts: 12
Joined: Tue May 25, 2004 6:47 pm

Camera moving

Post by NightBird »

I'm needing to have the camera of the scene respond only when the middle mouse button is clicked. I've tried a couple of methods, but none seem to work.

This is the code I'm using in the event handler:
case EMIE_MOUSE_MOVED:
if (held) {
double difx = oldx - event.MouseInput.X,dify = oldy - event.MouseInput.Y;
oldx = event.MouseInput.X;
oldy = event.MouseInput.Y;
camera = smgr->getActiveCamera();
vector3df rot = camera->getRotation();
double adjust = asin(difx/MOUSE_MOVE);
rot.rotateXZBy(adjust,camera->getPosition());
adjust = asin(dify/MOUSE_MOVE);
rot.rotateXYBy(adjust,camera->getPosition());
camera->setRotation(rot);

return true;
}
break;

anyone have any idea as to what is wrong with the code? or if someone already has something like this, and is willing to share, I'm fine with that.
thesmileman
Posts: 360
Joined: Tue Feb 10, 2004 2:20 am
Location: Lubbock, TX

Post by thesmileman »

If you use an arrary to handle input like described by keyless in the forum(A very good way to do it I might add) you can do something like this:

Code: Select all

if(EMIE_MOUSE_MOVED && !keys[LEFT_MOUSE] && !keys[RIGHT_MOUSE] && keys[MIDDLE_MOUSE])
{
   //do something
}
search the fourm to find the input method by Keyless it really is very good.
NightBird
Posts: 12
Joined: Tue May 25, 2004 6:47 pm

Post by NightBird »

No, I believe I have confused you. I can't get the camera to work right, and I have a feeling it's something to do with how I'm doing things mathmatically, or something. I can understand what you mean, with the method you describe, that would remove some unnessisary variables, and I may use that for the main system, however that isn't the problem.

Basically, it's the Maya cammera, just with middle button activates it's moving around instead of the left button.
bal
Posts: 829
Joined: Fri Jun 18, 2004 5:19 pm
Location: Geluwe, Belgium

Post by bal »

Think it was Keless :P
And here's the link because the search engine of this forum is kinda horrible :)
http://irrlicht.sourceforge.net/phpBB2/ ... light=keys
General Tools List
General FAQ
System: AMD Barton 2600+, 512MB, 9600XT 256MB, WinXP + FC3
Post Reply