/*
this function is called to start the object moving to the next position in mWalkList
*/
bool CrowdListener::nextLocation( int i )
{
// if we run out of point to go to then return false
if( mRobotNodesWalkList[i].empty() )
return false;
mDestinationList[i] = mRobotNodesWalkList[i].front(); // this gets the front of the deque
mRobotNodesWalkList[i].pop_front(); // this remove the front from the deque
if(mRobotNodes[i] != 0)
mDirectionList[i] = mDestinationList[i] - mRobotNodes[i]->getPosition();
mDistanceList[i] = mDirectionList[i].normalise();
Vector3 src = (mRobotNodes[i]->getPosition() - mDirectionList[i]) * Vector3::UNIT_X;
//Vector3 src = mRobotNodes[i]->getOrientation() * Vector3::UNIT_X;
if ((1.0f + src.dotProduct(mDirectionList[i])) < 0.0001f)
{
mRobotNodes[i]->yaw(Degree(180));
}
else
{
Ogre::Quaternion quat = src.getRotationTo(mDirectionList[i]);
//mRobotNodes[i]->rotate(quat);
// only apply the yaw rotation
mRobotNodes[i]->yaw( quat.getYaw() );
} // else
return tue;
}
بتاريخ 12 ابريل 2009 07:22 ص، قطب ahmed ezz حاجبيه بشدة وهو يقول:
Vector3 src = (mRobotNodes[i]->getPosition() - mDirectionList[i]) * Vector3::UNIT_X;
if ((1.0f + src.dotProduct(mDirectionList[i])) < 0.0001f)
{
mRobotNodes[i]->yaw(Degree(180));
}
else
{
Ogre::Quaternion quat = src.getRotationTo(mDirectionList[i]);
// only apply the yaw rotation
mRobotNodes[i]->yaw( quat.getYaw() );
}
في 12 نيسان 2009 08:02 م، عقد وسام البهنسي حاجبيه بتفكير وقال:
هل تستطيع أن تفسر ما الذي تقصده بهذه الحسبة؟mDistanceList[i] = mDirectionList[i].normalise();
Ogre::SceneNode::setDirection
mRobotNodes[i]->setDirection(mDirectionList[i], TS_LOCAL, Vector3::NEGATIVE_UNIT_Z);
bool CrowdListener::nextLocation( int i )
{
// if we run out of point to go to then return false
if( mRobotNodesWalkList[i].empty() )
return false;
mDestinationList[i] = mRobotNodesWalkList[i].front(); // this gets the front of the deque
mRobotNodesWalkList[i].pop_front(); // this remove the front from the deque
if(mRobotNodes[i] != 0)
mDirectionList[i] = mDestinationList[i] - mRobotNodes[i]->getPosition();
mDistanceList[i] = mDirectionList[i].normalise();
mRobotNodes[i]->setDirection(mDirectionList[i], TS_LOCAL, Vector3::NEGATIVE_UNIT_Z);
return true;
}
bool CrowdListener::nextLocation( int i )
{
// if we run out of point to go to then return false
if( mRobotNodesWalkList[i].empty() )
return false;
mDestinationList[i] = mRobotNodesWalkList[i].front(); // this gets the front of the deque
mRobotNodesWalkList[i].pop_front(); // this remove the front from the deque
if(mRobotNodes[i] != 0)
mDirectionList[i] = mDestinationList[i] - mRobotNodes[i]->getPosition();
mDistanceList[i] = mDirectionList[i].normalise();
// correct solution
Vector3 src = mRobotNodes[i]->getOrientation() * Vector3::UNIT_X;
if ((1.0f + src.dotProduct(mDirectionList[i])) < 0.0001f)
{
mRobotNodes[i]->yaw(Degree(180));
}
else
{
Ogre::Quaternion quat = src.getRotationTo(mDirectionList[i]);
//mRobotNodes[i]->rotate(quat);
// only apply the yaw rotation to prevent the unit from rotating in wrong way
Radian angle = quat.getYaw();
Degree da = Degree( angle );
mRobotNodes[i]->yaw( angle );
} // else
return true;
}