本文整理汇总了C++中Quaternion::EulerAngles方法的典型用法代码示例。如果您正苦于以下问题:C++ Quaternion::EulerAngles方法的具体用法?C++ Quaternion::EulerAngles怎么用?C++ Quaternion::EulerAngles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quaternion
的用法示例。
在下文中一共展示了Quaternion::EulerAngles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFaceCameraRotation
Quaternion Camera::GetFaceCameraRotation(const Vector3& position, const Quaternion& rotation, FaceCameraMode mode, float minAngle)
{
if (!node_)
return rotation;
switch (mode)
{
case FC_ROTATE_XYZ:
return node_->GetWorldRotation();
case FC_ROTATE_Y:
{
Vector3 euler = rotation.EulerAngles();
euler.y_ = node_->GetWorldRotation().EulerAngles().y_;
return Quaternion(euler.x_, euler.y_, euler.z_);
}
case FC_LOOKAT_XYZ:
{
Quaternion lookAt;
lookAt.FromLookRotation(position - node_->GetWorldPosition());
return lookAt;
}
case FC_LOOKAT_Y:
case FC_LOOKAT_MIXED:
{
// Mixed mode needs true look-at vector
const Vector3 lookAtVec(position - node_->GetWorldPosition());
// While Y-only lookat happens on an XZ plane to make sure there are no unwanted transitions or singularities
const Vector3 lookAtVecXZ(lookAtVec.x_, 0.0f, lookAtVec.z_);
Quaternion lookAt;
lookAt.FromLookRotation(lookAtVecXZ);
Vector3 euler = rotation.EulerAngles();
if (mode == FC_LOOKAT_MIXED)
{
const float angle = lookAtVec.Angle(rotation * Vector3::UP);
if (angle > 180 - minAngle)
euler.x_ += minAngle - (180 - angle);
else if (angle < minAngle)
euler.x_ -= minAngle - angle;
}
euler.y_ = lookAt.EulerAngles().y_;
return Quaternion(euler.x_, euler.y_, euler.z_);
}
default:
return rotation;
}
}
示例2: GetFaceCameraRotation
Quaternion Camera::GetFaceCameraRotation(const Vector3& position, const Quaternion& rotation, FaceCameraMode mode)
{
if (!node_)
return rotation;
switch (mode)
{
default:
return rotation;
case FC_ROTATE_XYZ:
return node_->GetWorldRotation();
case FC_ROTATE_Y:
{
Vector3 euler = rotation.EulerAngles();
euler.y_ = node_->GetWorldRotation().EulerAngles().y_;
return Quaternion(euler.x_, euler.y_, euler.z_);
}
case FC_LOOKAT_XYZ:
{
Quaternion lookAt;
lookAt.FromLookRotation(position - node_->GetWorldPosition());
return lookAt;
}
case FC_LOOKAT_Y:
{
// Make the Y-only lookat happen on an XZ plane to make sure there are no unwanted transitions
// or singularities
Vector3 lookAtVec(position - node_->GetWorldPosition());
lookAtVec.y_ = 0.0f;
Quaternion lookAt;
lookAt.FromLookRotation(lookAtVec);
Vector3 euler = rotation.EulerAngles();
euler.y_ = lookAt.EulerAngles().y_;
return Quaternion(euler.x_, euler.y_, euler.z_);
}
}
}
示例3: name
int RomCommon::ActorManager::GetActorRotation(lua_State* L)
{
lua_State* lState = LuaManager::getInstance()->CheckState(L);
std::string name("");
UINT16 n = lua_gettop(lState);
if(n == 1)
{
LuaManager::getInstance()->GetFunctionArg(name, lState);
}
if(!name.empty())
{
boost::shared_ptr<Actor> actor = ActorManager::getInstance()->FindActorByName(name);
if(actor)
{
Quaternion q = actor->GetOrientation();
Vector3D rotation = q.EulerAngles();
lua_newtable(lState);
n = lua_gettop(lState);
lua_pushstring(lState, "X");
lua_pushnumber(lState, rotation.X);
lua_settable(lState, n);
lua_pushstring(lState, "Y");
lua_pushnumber(lState, rotation.Y);
lua_settable(lState, n);
lua_pushstring(lState, "Z");
lua_pushnumber(lState, rotation.Z);
lua_settable(lState, n);
return 1;
} else {
Logger::getInstance()->Log("ActorManager :: GetActorRotation - Could not find the specified actor", LOG_WARNING);
}
} else {
Logger::getInstance()->Log("ActorManager :: GetActorRotation - No actor name specified", LOG_WARNING);
}
lua_pushboolean(lState, false);
return 1;
}
示例4: Land
void Bird::Land(float timeStep)
{
Vector3 targetDelta = target_ - GetPosition();
if (targetDelta.Length() < 0.5f){
if (!touchDown_){
touchDown_ = true;
animCtrl_->StopAll(0.1f);
animCtrl_->Play("Resources/Models/Land.ani", 0, false, 0.1f);
}
Quaternion rotation = rootNode_->GetWorldRotation();
Vector3 eulerRotation = rotation.EulerAngles();
Quaternion aimRotation = Quaternion(0.0f, eulerRotation.y_, 0.0f);
if (first_) aimRotation = Quaternion(0.0f, rootNode_->GetDirection().x_ > 0.0f? 90.0f : -90.0f, 0.0f);
rootNode_->SetRotation(rotation.Slerp(aimRotation, 5.0f*timeStep));
if (targetDelta.Length() < 0.2f || targetDelta.y_ > 0.0f) {
SetState(BirdState::Standing);
}
}
velocity_ += 23.0f * timeStep * targetDelta.Normalized() * Clamp( targetDelta.Length()*0.5f, 2.0f, 4.0f ) - Finchy::Scale(velocity_, Vector3(0.023f, 0.23f, 0.023f));
velocity_ *= Clamp( 0.2f + targetDelta.Length() * 0.666f, 0.2f, 0.95f );
velocity_.x_ = Clamp(velocity_.x_, -targetDelta.Length(), targetDelta.Length());
velocity_.y_ = Clamp(velocity_.y_, -targetDelta.Length(), targetDelta.Length());
}