Code: Select all
void update_mRot(ISceneNode * nodee) {
vector2df rotation(0,0);
vector2df center(cenW,cenH); // cenW,cenH = center of the screen
f32 xrot=0;
f32 yrot=0;
if (my > cenH)
xrot=(((my-cenH)/ROTSPEED)); // ROTSPEED = 80.0
else if (my < cenH)
xrot=-(((cenH-my)/ROTSPEED));
// else if (my == cenH) xrot=0;
if (mx > cenW)
yrot=(((mx-cenW)/ROTSPEED));
else if (mx < cenW)
yrot=-(((cenW-mx)/ROTSPEED));
// else if (mx == cenW) xrot=0;
rotation.X=xrot;
rotation.Y=yrot;
turn(nodee, rotation.Y*ROTSPEED); // <---- turn,pitch functions from Freeflight thread
pitch(nodee, rotation.X*ROTSPEED);
center = center.getInterpolated(vector2df(mx,my), 2*frameDeltaTime);
mx = center.X;
my = center.Y;
std::cout << mx << " " << my << std::endl;
device->getCursorControl()->setPosition(mx,my);
}
what it is supposed to do is: rotate the node relatively to mouse movement - the further mouse is from center of the screen the faster spin is. at the same time mouse cursor is pushed to the center, what causes loss of rotating speed if u know what i mean (coz its kind of hard to keep the 'node' in 1 position if cursor is not exactly at center)
i've tried to find some similiar threads but i couldn't find anything suitable
how this is supposed to be done anyway? is this a correct approach? i dunno how to control the node using mouse other way