本文整理汇总了C++中ogre::Quaternion::FromAngleAxis方法的典型用法代码示例。如果您正苦于以下问题:C++ Quaternion::FromAngleAxis方法的具体用法?C++ Quaternion::FromAngleAxis怎么用?C++ Quaternion::FromAngleAxis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Quaternion
的用法示例。
在下文中一共展示了Quaternion::FromAngleAxis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createMapObj
int Terrain::createMapObj(int x, int y, std::string meshname, int dir)
{
stTileEntityData* entitydata = new stTileEntityData;
entitydata->mTileEntity = Core::getSingleton().mSceneMgr->createEntity(meshname);
entitydata->mTileNode = mTerrainNode->createChildSceneNode();
entitydata->mTileNode->attachObject(entitydata->mTileEntity);
float xx,yy;
getWorldCoords(x,y,xx,yy);
entitydata->mTileNode->setPosition(xx ,getHeight(xx,yy),yy);
Ogre::Quaternion q;
switch(dir)
{
case North:
q.FromAngleAxis(Ogre::Degree(180),Ogre::Vector3(0,1,0));
break;
case South:
q.FromAngleAxis(Ogre::Degree(360),Ogre::Vector3(0,1,0));
break;
case West:
q.FromAngleAxis(Ogre::Degree(270),Ogre::Vector3(0,1,0));
break;
case East:
q.FromAngleAxis(Ogre::Degree(90),Ogre::Vector3(0,1,0));
break;
}
entitydata->mTileNode->setOrientation(q);
mObjId ++;
mMapObjMap.insert(std::map<int, stTileEntityData*>::value_type(mObjId,entitydata ));
return mObjId;
}
示例2: ProcessKeyInput
void AACamera::ProcessKeyInput(OIS::Keyboard *mKeyboard)
{
static unsigned RollSpeed = 5;
if (mKeyboard->isKeyDown(OIS::KC_RIGHT))
{
if (abs(RelativeOrientation.getRoll().valueDegrees())<10)
{
Ogre::Quaternion q;
q.FromAngleAxis(-Ogre::Degree(RollSpeed),Ogre::Vector3::UNIT_Z);
CameraAdditionalRotation.StartRotation(RelativeOrientation, RelativeOrientation*q, CommonDeclarations::GetFPS());
}
}
else
if(mKeyboard->isKeyDown(OIS::KC_LEFT))
{
if (abs(RelativeOrientation.getRoll().valueDegrees())<10)
{
Ogre::Quaternion q;
q.FromAngleAxis(Ogre::Degree(RollSpeed),Ogre::Vector3::UNIT_Z);
CameraAdditionalRotation.StartRotation(RelativeOrientation, RelativeOrientation*q, CommonDeclarations::GetFPS());
}
}
else
{
if (RelativeOrientation!=Ogre::Quaternion::IDENTITY)
{
Ogre::Quaternion q = Ogre::Quaternion::IDENTITY;
CameraAdditionalRotation.StartRotation(RelativeOrientation, q, CommonDeclarations::GetFPS());
}
}
}
示例3: GetRotQuat
/**
*@brief 角度からクオータニオンを取得する関数
* @param path 角度(ロール)
* @param path 角度(ピッチ)
* @param path 角度(ヨー)
* @return クォータニオン
*/
Ogre::Quaternion GetRotQuat(float roll, float pitch, float yaw)
{
Ogre::Quaternion tRoll;
tRoll.FromAngleAxis(Ogre::Degree(roll),Ogre::Vector3(1,0,0));
Ogre::Quaternion tPitch;
tPitch.FromAngleAxis(Ogre::Degree(pitch),Ogre::Vector3(0,1,0));
Ogre::Quaternion tYaw;
tYaw.FromAngleAxis(Ogre::Degree(yaw),Ogre::Vector3(0,0,1));
tRoll = tRoll * tPitch;
tRoll = tRoll * tYaw;
return tRoll;
}
示例4: generateEnvironment
void GameState::generateEnvironment()
{
Ogre::StaticGeometry *sg = mSceneMgr->createStaticGeometry("Asteroids");
const int size = 7000;
const int amount = 5;
sg->setRegionDimensions(Ogre::Vector3(size, size, size));
//sg->setOrigin(Ogre::Vector3(-size/2, 0, -size/2));
sg->setOrigin(Vector3(-size/2, -size/2, -size/2) + Vector3(0, 0, 0)); // this will center the staticgeometry around the point in 3D space
for (int x = -size/2; x < size/2; x += (size/amount))
{
for (int y = -size/2; y < size/2; y += (size/amount))
{
for (int z = -size/2; z < size/2; z += (size/amount))
{
Ogre::Real r = size / (float)amount / 2;
Ogre::Vector3 pos(x + Ogre::Math::RangeRandom(-r, r), y + Ogre::Math::RangeRandom(-r, r), z + Ogre::Math::RangeRandom(-r, r));
Ogre::Vector3 scale(Ogre::Math::RangeRandom(0.7, 20), Ogre::Math::RangeRandom(0.7, 20), Ogre::Math::RangeRandom(0.7, 20));
Ogre::Quaternion orientation;
orientation.FromAngleAxis(Ogre::Degree(Ogre::Math::RangeRandom(0, 359)), Ogre::Vector3::UNIT_Y);
MyEntity * ent = new MyEntity("asteroid1.mesh", mSceneMgr, mWorld, pos);
ent->transform(orientation, Ogre::Vector3::ZERO);
//ent->setScale(scale);
sg->addEntity(ent->getEntity(), pos, orientation/*, scale*/);
}
}
}
sg->build();
}
示例5: parseQuaternion
Ogre::Quaternion Util::parseQuaternion(TiXmlElement *XMLNode)
{
Ogre::Quaternion orientation;
if(XMLNode->Attribute("qx"))
{
orientation.x = Ogre::StringConverter::parseReal(XMLNode->Attribute("qx"));
orientation.y = Ogre::StringConverter::parseReal(XMLNode->Attribute("qy"));
orientation.z = Ogre::StringConverter::parseReal(XMLNode->Attribute("qz"));
orientation.w = Ogre::StringConverter::parseReal(XMLNode->Attribute("qw"));
}
else if(XMLNode->Attribute("axisX"))
{
Ogre::Vector3 axis;
axis.x = Ogre::StringConverter::parseReal(XMLNode->Attribute("axisX"));
axis.y = Ogre::StringConverter::parseReal(XMLNode->Attribute("axisY"));
axis.z = Ogre::StringConverter::parseReal(XMLNode->Attribute("axisZ"));
Ogre::Real angle = Ogre::StringConverter::parseReal(XMLNode->Attribute("angle"));;
orientation.FromAngleAxis(Ogre::Angle(angle), axis);
}
else if(XMLNode->Attribute("angleX"))
{
Ogre::Vector3 axis;
axis.x = Ogre::StringConverter::parseReal(XMLNode->Attribute("angleX"));
axis.y = Ogre::StringConverter::parseReal(XMLNode->Attribute("angleY"));
axis.z = Ogre::StringConverter::parseReal(XMLNode->Attribute("angleZ"));
//orientation.FromAxes(&axis);
//orientation.F
}
return orientation;
}
示例6: updateWheel
void OgreWheel::updateWheel(const float angle)
{
// Render change angle
Ogre::Quaternion qq;
qq.FromAngleAxis(Ogre::Radian(-angle)*5, Ogre::Vector3(0, 1, 0));
mNode->setOrientation(qq);
}
示例7: SetupAnimation
void OgreApplication::SetupAnimation(Ogre::String object_name){
/* Retrieve scene manager and root scene node */
Ogre::SceneManager* scene_manager = ogre_root_->getSceneManager("MySceneManager");
Ogre::SceneNode* root_scene_node = scene_manager->getRootSceneNode();
/* Set up animation */
Ogre::Real duration = Ogre::Math::TWO_PI;
Ogre::Real num_steps = 36;
Ogre::Real step = duration/num_steps;
Ogre::Animation* animation = scene_manager->createAnimation("Animation", duration);
animation->setInterpolationMode(Ogre::Animation::IM_LINEAR);
Ogre::Node *object_scene_node = root_scene_node->getChild(object_name);
Ogre::NodeAnimationTrack* track = animation->createNodeTrack(0, object_scene_node);
/* Set up frames for animation */
Ogre::TransformKeyFrame* key;
Ogre::Quaternion quat;
for (int i = 0; i < num_steps; i++){
Ogre::Real current = ((float) i) * step;
key = track->createNodeKeyFrame(current);
quat.FromAngleAxis(Ogre::Radian(-current), Ogre::Vector3(0, 1, 0));
key->setRotation(quat);
key->setScale(Ogre::Vector3(0.5, 0.5, 0.5));
}
/* Create animation state */
animation_state_ = scene_manager->createAnimationState("Animation");
animation_state_->setEnabled(true);
animation_state_->setLoop(true);
/* Turn on animating flag */
animating_ = true;
}
示例8: setRotation
void SceneEntity::setRotation(float angel)
{
mRotateAngel = angel;
Ogre::Quaternion ori;
ori.FromAngleAxis(Ogre::Radian(Ogre::Math::PI/180*mRotateAngel),Ogre::Vector3(0,1,0));
mSceneNode->setOrientation(ori);
}
示例9: setLocalRotation
void OgrePointSpecification::setLocalRotation(const VEHA::RotationVector& orientation)
{
Ogre::Quaternion q;
Ogre::Vector3 v(orientation.x,orientation.y,orientation.z);
q.FromAngleAxis(Ogre::Radian(orientation.angle),v);
_node->setOrientation(q);
_node->_update(true,true);
}
示例10: onRightButtonPressed
void PlayerCameraOgre::onRightButtonPressed()
{
if (!mRightButtonPressedLastFrame)
mMousePosLastFrame = mMouse->getPosition();
mp::Vector2i diff = mMouse->getPosition() - mMousePosLastFrame;
const mp::Vector3f &playerPos = mPlayer->model()->getPosition();
Ogre::Vector3 pivotPoint(playerPos.getX(), playerPos.getY() + mPivotHeight, playerPos.getZ());
float yaw = (float)diff.getX() * CAMERA_SPEED;
float pitch = (float)-diff.getY() * CAMERA_SPEED;
Ogre::Quaternion yawQuat;
yawQuat.FromAngleAxis(Ogre::Radian(yaw), Ogre::Vector3::UNIT_Y);
Ogre::Matrix3 yawMat;
yawQuat.ToRotationMatrix(yawMat);
Ogre::Vector3 pivotToPos = Ogre::Vector3(mRealPosition.getX(), mRealPosition.getY(), mRealPosition.getZ()) - pivotPoint;
Ogre::Matrix4 pos(1, 0, 0, pivotToPos.x,
0, 1, 0, pivotToPos.y,
0, 0, 1, pivotToPos.z,
0, 0, 0, 1);
Ogre::Vector3 xz(pivotToPos.x, 0, pivotToPos.z);
Ogre::Vector3 norm(-xz.z, 0, xz.x);
Ogre::Quaternion pitchQuat;
pitchQuat.FromAngleAxis(Ogre::Radian(pitch), norm);
Ogre::Matrix3 pitchMat;
pitchQuat.ToRotationMatrix(pitchMat);
Ogre::Matrix4 toPivot(1, 0, 0, pivotPoint.x,
0, 1, 0, pivotPoint.y,
0, 0, 1, pivotPoint.z,
0, 0, 0, 1);
Ogre::Matrix4 newPosMat = pos * pitchMat * yawMat * toPivot;
newPosMat = newPosMat.inverse();
Ogre::Vector3 newPos = newPosMat.getTrans();
mRealPosition.set(-newPos.x, -newPos.y, -newPos.z);
setPosition(mRealPosition);
lookAt(pivotPoint.x, pivotPoint.y, pivotPoint.z);
adjustDistance();
mMousePosLastFrame = mMouse->getPosition();
mRightButtonPressedLastFrame = true;
}
示例11: roll
//-----------------------------------------------------------------------------------------
void CCameraEditor::roll(const Ogre::Radian &value)
{
Ogre::Quaternion q;
Ogre::Vector3 axis = mOrientation->get() * Ogre::Vector3::UNIT_Z;
q.FromAngleAxis(value, axis);
q.normalise();
mOrientation->set(q * mOrientation->get());
}
示例12: yaw
//-----------------------------------------------------------------------------------------
void CCameraEditor::yaw(const Ogre::Radian &value)
{
Ogre::Quaternion q;
q.FromAngleAxis(value, Ogre::Vector3::UNIT_Y);
q.normalise();
mOrientation->set(q * mOrientation->get());
}
示例13: setGlobalRotation
void OgrePointSpecification::setGlobalRotation(const VEHA::RotationVector& orientation)
{
Ogre::Quaternion q;
Ogre::Vector3 v(orientation.x,orientation.y,orientation.z);
q.FromAngleAxis(Ogre::Radian(orientation.angle),v);
if(getParent())
q=shared_dynamic_cast<OgrePointSpecification>(_parent)->_node->convertWorldToLocalOrientation(q);
_node->setOrientation(q);
_node->_update(true,true);
}
示例14: fix_gta_coord
void fix_gta_coord(Ogre::Quaternion& quat)
{
swap(quat.y, quat.z);
Ogre::Radian angle;
Ogre::Vector3 axis;
quat.ToAngleAxis(angle, axis);
//swap(axis.y, axis.z);
axis = Ogre::Quaternion(Ogre::Degree(-90), Ogre::Vector3::UNIT_X) * axis;
quat.FromAngleAxis(angle, axis);
}
示例15: frameEnded
bool frameEnded(const Ogre::FrameEvent &evt)
{
Ogre::Quaternion q;
q.FromAngleAxis(Ogre::Degree(360 * ((float) timer.getMilliseconds()) / 5000), Ogre::Vector3(0, 1, 0));
for (auto node = nodes.begin(); node != nodes.end(); node++)
{
(*node)->setOrientation(q);
}
return true;
}