I'm still learning the engine, so pls don't laugh at me
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 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
(solved)how to make irrlicht maya cam translate like rts cam
-
- Posts: 61
- Joined: Sun May 08, 2005 11:30 am
(solved)how to make irrlicht maya cam translate like rts cam
Last edited by Rabid Mantis on Thu May 12, 2005 5:06 am, edited 3 times in total.
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
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
-
- Posts: 61
- Joined: Sun May 08, 2005 11:30 am
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.
-
- Posts: 61
- Joined: Sun May 08, 2005 11:30 am
SOLUTION
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
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