Using matrices

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
Zanman777
Posts: 17
Joined: Mon Apr 16, 2012 5:45 pm

Using matrices

Post by Zanman777 »

Hy,

To put things into context, I'm tryingto make the active camera rotate around the camera target, when the mouse is moved while holding the middle mouse button (just like in so many RTS games).

I never learnt about matrices in school. I did now, through the web, to understand their concept.

I'm still having trouble understanding exactly how matrices are used. Let me see if I got it right. Im my case, I would do something like this:

Code: Select all

 
CMatrix4 m;
m.setRotationCenter (camera->getTarget(), /*what is this translate vector?*/);
m.setRotationDegrees(vector3df(10 * MouseMove.X, 10 * MouseMove.Y, 0)); //where MouseMove is delta position of mouse 
m.transformVect (//and then I should get the position + direction vector of the camera);
 
Should the transformed vector be the camera's target?

Or am I doing this all completely wrong?

Please point me in the right direction if I need to learn more about matrices...
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Using matrices

Post by hendu »

You don't really need matrix math for this. The camera already has the constant target, so you can just move the camera position, it keeps looking at the target.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Using matrices

Post by Mel »

But you may want to orbit around the target point. And the Maya camera does that on its own already. WIth the Maya camera, you can:

orbit the target-with the left mouse button
move the camera-with the right mouse button
move along the view direction-with the middle mouse button (or both left and right)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Post Reply