本文整理汇总了C++中ogre::Quaternion::FromAxes方法的典型用法代码示例。如果您正苦于以下问题:C++ Quaternion::FromAxes方法的具体用法?C++ Quaternion::FromAxes怎么用?C++ Quaternion::FromAxes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Quaternion
的用法示例。
在下文中一共展示了Quaternion::FromAxes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setDirection
//-----------------------------------------------------------------------------------------
void CCameraEditor::setDirection(const Ogre::Vector3 &vec)
{
if (vec == Ogre::Vector3::ZERO) return;
Ogre::Vector3 zAdjustVec = -vec;
zAdjustVec.normalise();
Ogre::Quaternion orientation;
Ogre::Vector3 YawFixedAxis = Ogre::Vector3::UNIT_Y;
Ogre::Vector3 xVec = YawFixedAxis.crossProduct( zAdjustVec );
xVec.normalise();
Ogre::Vector3 yVec = zAdjustVec.crossProduct( xVec );
yVec.normalise();
orientation.FromAxes( xVec, yVec, zAdjustVec );
// transform to parent space
if (mParentEditor->get())
{
orientation = mParentEditor->get()->getNode()->_getDerivedOrientation().Inverse() * orientation;
}
mOrientation->set(orientation);
}
示例2: _setCameraAttribute
void MiniMapMaker::_setCameraAttribute(void)
{
switch (mCameraDirectionType)
{
case CDT_MiniMap :
{
// 设置摄像机的视角垂直向下
Ogre::Quaternion orientation;
orientation.FromAxes(Ogre::Vector3::UNIT_X, Ogre::Vector3::NEGATIVE_UNIT_Z, Ogre::Vector3::UNIT_Y);
mCamera->setOrientation(orientation);
break;
}
case CDT_CameraDirection :
{
// 获取当前摄像机的方向
mCameraDir = mManipulator->getCamera()->getDirection();
// 求出这个方向与地面所成的角度
float tanValue =
Ogre::Math::Abs(mCameraDir.y) / Ogre::Math::Sqrt(mCameraDir.x*mCameraDir.x + mCameraDir.z*mCameraDir.z);
mCamDirAngle = Ogre::Math::ATan(tanValue);
// 设置要进行小地图拍照的摄像机的方向
mCamera->setDirection(mCameraDir);
// 求出摄像机拍照时的横向移动的方向(该方向与摄像机的方向是垂直的)
mMoveZDir = mCameraDir.crossProduct(Ogre::Vector3::UNIT_Y).normalisedCopy();
// 求出摄像机拍照时的纵向移动的方向(该方向与摄像机的方向是相反的)
mInvertCameraDir = -mCameraDir;
// 因为我们只关心在xz平面的移动,所以y分量置0
mInvertCameraDir.y = 0.0f;
mInvertCameraDir.normalise();
// 判断当前摄像机方向是指向哪个方向的
_computeCameraDirQuadrant();
mUseRealCameraAngle = true;
break;
}
case CDT_North :
{
break;
}
case CDT_South :
{
break;
}
case CDT_West :
{
break;
}
case CDT_East :
{
break;
}
default :
{
break;
}
}
}
示例3: _createModifyList
//--------------------------------------------------------------------------------
void CMultiSelEditor::_createModifyList()
{
mWorldAABB = Ogre::AxisAlignedBox::BOX_NULL;
mModifyList.clear();
NameObjectPairList::const_iterator it = mSelectedObjects.begin();
while(it != mSelectedObjects.end())
{
CBaseEditor *add = it->second;
Ogre::AxisAlignedBox box = add->getWorldAABB();
mWorldAABB.merge(box);
Ogre::String name = add->getName();
if(mModifyList.find(name) == mModifyList.end())
mModifyList.insert(NameObjectPairList::value_type(add->getName(), add));
it++;
}
Ogre::String remname;
Ogre::StringVector removeList;
removeList.clear();
it = mModifyList.begin();
while(it != mModifyList.end())
{
remname = it->second->getParent()->getName();
if(mModifyList.find(remname) != mModifyList.end())
removeList.push_back(it->first);
it++;
}
for(unsigned int x = 0;x < removeList.size(); x++)
{
mModifyList.erase(mModifyList.find(removeList[x]));
}
Ogre::Vector3 xTot = Ogre::Vector3::ZERO;
Ogre::Vector3 yTot = Ogre::Vector3::ZERO;
Ogre::Vector3 zTot = Ogre::Vector3::ZERO;
int count = 0;
it = mModifyList.begin();
while(it != mModifyList.end())
{
xTot += it->second->getDerivedOrientation() * Ogre::Vector3::UNIT_X;
yTot += it->second->getDerivedOrientation() * Ogre::Vector3::UNIT_Y;
zTot += it->second->getDerivedOrientation() * Ogre::Vector3::UNIT_Z;
count++;
it++;
}
if(count)
{
xTot /= ((float)count);
yTot /= ((float)count);
zTot /= ((float)count);
Ogre::Vector3 normal = Ogre::Vector3::UNIT_Z;
Ogre::Quaternion q;
q.FromAxes(xTot,yTot,zTot);
mNode->setPosition(mWorldAABB.getCenter());
mNode->setOrientation(q);
}
else
{
mNode->setPosition(Ogre::Vector3::ZERO);
mNode->setOrientation(Ogre::Quaternion::IDENTITY);
}
mNode->setScale(1,1,1);
if(mSelectedObjects.size() == 0)
{
mSystem->SelectTreeItem(mOgitorsRoot->GetRootEditor());
mSystem->PresentPropertiesView(0);
}
else if(mSelectedObjects.size() == 1)
{
mSystem->SelectTreeItem(mSelectedObjects.begin()->second);
mSystem->PresentPropertiesView(mSelectedObjects.begin()->second);
}
else
{
mSystem->SelectTreeItem(this);
mSystem->PresentPropertiesView(this);
}
SelectionChangeEvent evt(this);
EventManager::getSingletonPtr()->sendEvent(this, 0, &evt);
}