* fixed formula for right-click character turning, thx sbp!

* implemented MSG_SET_FACING sending if character is turned with right-click.
This commit is contained in:
false_genesis 2008-08-17 16:05:20 +00:00
parent 8e8242b34c
commit 2808ca7efe
3 changed files with 11 additions and 3 deletions

View File

@ -128,6 +128,7 @@ private:
core::vector2df xyCharMovement; // stores sin() and cos() values for current MyCharacter orientation, so that they need to be calculated only if the character turns around core::vector2df xyCharMovement; // stores sin() and cos() values for current MyCharacter orientation, so that they need to be calculated only if the character turns around
bool mouse_pressed_left; bool mouse_pressed_left;
bool mouse_pressed_right; bool mouse_pressed_right;
float old_char_o;
}; };

View File

@ -33,6 +33,7 @@ SceneWorld::SceneWorld(PseuGUI *g) : Scene(g)
mychar = wsession->GetMyChar(); mychar = wsession->GetMyChar();
ASSERT(mychar); ASSERT(mychar);
_CalcXYMoveVect(mychar->GetO()); _CalcXYMoveVect(mychar->GetO());
old_char_o = mychar->GetO();
ILightSceneNode* light = smgr->addLightSceneNode(0, core::vector3df(0,0,0), SColorf(255, 255, 255, 255), 1000.0f); ILightSceneNode* light = smgr->addLightSceneNode(0, core::vector3df(0,0,0), SColorf(255, 255, 255, 255), 1000.0f);
SLight ldata = light->getLightData(); SLight ldata = light->getLightData();
@ -367,11 +368,16 @@ void SceneWorld::OnUpdate(s32 timediff)
} }
device->getCursorControl()->setPosition(mouse_pos); device->getCursorControl()->setPosition(mouse_pos);
// TODO: implement charater turning on right-click-mouse-move. // rotate character if right mpouse button pressed.
// the code below doesnt work at all actually, no idea why. seems like camera interferes with mychar pos or so..
if(mouse_pressed_right) if(mouse_pressed_right)
{ {
mychar->GetPositionPtr()->o = IRR_TO_O(DEG_TO_RAD(camera->getHeading())); mychar->GetPositionPtr()->o = PI*3/2 - DEG_TO_RAD(camera->getHeading());
// send update to server only if we turned by some amount and not always when we turn
if(!equals(old_char_o, mychar->GetO(), MOVE_TURN_UPDATE_DIFF))
{
old_char_o = mychar->GetO();
movemgr->MoveSetFacing();
}
} }
} }
} }

View File

@ -5,6 +5,7 @@
#include "UpdateData.h" #include "UpdateData.h"
#define MOVE_HEARTBEAT_DELAY 500 #define MOVE_HEARTBEAT_DELAY 500
#define MOVE_TURN_UPDATE_DIFF 0.15f // not sure about original/real value, but this seems good
// -- // --
// -- MovementFlags and MovementInfo can be found in UpdateData.h // -- MovementFlags and MovementInfo can be found in UpdateData.h