(solved)how to make irrlicht maya cam translate like rts cam
Posted: Wed May 11, 2005 8:35 am
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
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