(solved)how to make irrlicht maya cam translate like rts cam

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
Rabid Mantis
Posts: 61
Joined: Sun May 08, 2005 11:30 am

(solved)how to make irrlicht maya cam translate like rts cam

Post by Rabid Mantis »

I'm still learning the engine, so pls don't laugh at me :P

I'm changing the source for the maya control setup(CCameraMayaSceneNode.cpp), and I'm trying to set the camera up so instead of moving straight up and down ("translating" - when holding rmb and moving the mouse up and down), it'll stay on the horizontal plane, moving forward(up), and backward(down), but unlike zoom, it stays on the horizontal plane (scrolling left and right already work properly) I found some less desirable ways to do it, but I was wondering if anyone could fill me in on how to make that work properly within the engine. My goal is to mimic the homeworld camera controls, if you've played that before. My guess is that it mostly involves this code:

core::vector3df tvectX = Pos - Target;
tvectX = tvectX.crossProduct(UpVector);
tvectX.normalize();

core::vector3df tvectY = (va->getFarLeftDown() - va->getFarRightDown());
tvectY = tvectY.crossProduct(UpVector.Y > 0 ? Pos - Target : Target - Pos);
tvectY.normalize();

translate += tvectX * (translateStartX - MousePos.X)*translateSpeed + tvectY * (translateStartY - MousePos.Y)*translateSpeed;

If anyone's got some example code I can look at, or if someone has posted this somewhere, I'd greatly appreciate it :D I've got it to do everything else I want it to, but this one is giving me trouble.

I'm guessing there might be someplace where people share example code for getting the engine to do different things. If so, can anyone direct me to it? thanks
Last edited by Rabid Mantis on Thu May 12, 2005 5:06 am, edited 3 times in total.
ayman
Posts: 51
Joined: Sat Feb 05, 2005 7:33 pm
Location: Piefke State

Post by ayman »

Hi Rabid Mantis,

I don't understand exactly what you want - "homeworld camera controls" says nothing to me.

But if you want to move a camera the way YOU want instead of moving it like the FPS-cam or the maya-cam, why don't you use the ISceneManager::addCameraSceneNode () instead and write you own IEventReceiver?

Or is it the actual moving code, that you are unable to write? In this case I can't help, cause I didn't understand _how_ your cam _should_ move.

Regards
Ayman
Rabid Mantis
Posts: 61
Joined: Sun May 08, 2005 11:30 am

Post by Rabid Mantis »

hmm the post I made earlier got deleted. oh well it's not important anymore
Last edited by Rabid Mantis on Thu May 12, 2005 5:02 am, edited 1 time in total.
Rabid Mantis
Posts: 61
Joined: Sun May 08, 2005 11:30 am

SOLUTION

Post by Rabid Mantis »

allright I am an idiot. I figured it out... forget everything I posted above. Here's how to do it (for those of you who don't know already :p )

open CCameraMayaSceneNode.cpp

you can remove this code unless you still need it for some reason:

core::vector3df tvectY = (va->getFarLeftDown() - va->getFarRightDown());
tvectY = tvectY.crossProduct(UpVector.Y > 0 ? Pos - Target : Target - Pos);
tvectY.normalize();


further down, remove these (there's two of these):

translate += tvectX * (translateStartX - MousePos.X)*translateSpeed + tvectY * (translateStartY - MousePos.Y)*translateSpeed;

and replace them with two of these:

translate += tvectX * (translateStartX - MousePos.X *translateSpeed;
translate.X += tvectX.Z * (translateStartY - MousePos.Y)*translateSpeed;
translate.Z -= tvectX.X * (translateStartY - MousePos.Y)*translateSpeed;


... and that's all there is to it. I was making a big deal out of nothing :roll:
Post Reply