Re: Version 0.322 - selection highlighting, grid, ship movement
Posted: Fri Mar 19, 2010 2:39 pm
here is the right calculation of the direction vector. the ship does no more flip onto the back:
Code: Select all
void CombatWnd::MoveCombatShip(CombatShipPtr &combat_ship, Ogre::Vector3& destination)
{
const Ship& ship = combat_ship->GetShip();
ShipData& ship_data = m_ship_assets[combat_ship->GetShip().ID()];
Ogre::Quaternion start_quat_direction = ship_data.m_node->getOrientation();
Ogre::Vector3 dest_vec_direction = destination - ship_data.m_node->getPosition();
//calc the direction
dest_vec_direction.normalise();
Ogre::Matrix3 matrix;
matrix.SetColumn(0,Ogre::Vector3(dest_vec_direction.y, -dest_vec_direction.x, 0));
matrix.SetColumn(1,Ogre::Vector3(dest_vec_direction.x, dest_vec_direction.y, 0));
matrix.SetColumn(2,Ogre::Vector3(0, 0, 1));
Ogre::Quaternion dest_quat_direction(matrix);
dest_quat_direction.normalise();
...