本文整理汇总了C++中ogre::Quaternion::FromRotationMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ Quaternion::FromRotationMatrix方法的具体用法?C++ Quaternion::FromRotationMatrix怎么用?C++ Quaternion::FromRotationMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Quaternion
的用法示例。
在下文中一共展示了Quaternion::FromRotationMatrix方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getLinkTransforms
virtual bool getLinkTransforms(const std::string& link_name,
Ogre::Vector3& visual_position,
Ogre::Quaternion& visual_orientation,
Ogre::Vector3& collision_position,
Ogre::Quaternion& collision_orientation) const
{
unsigned int id = m_model->GetBodyId(link_name.c_str());
if(id >= m_model->X_base.size())
{
visual_position = Ogre::Vector3::ZERO;
visual_orientation = Ogre::Quaternion::IDENTITY;
return true;
}
RigidBodyDynamics::Math::SpatialTransform trans = m_model->X_base[id];
visual_position = Ogre::Vector3(
trans.r.x(), trans.r.y(), trans.r.z()
);
Ogre::Matrix3 mat(
trans.E(0, 0), trans.E(1, 0), trans.E(2, 0),
trans.E(0, 1), trans.E(1, 1), trans.E(2, 1),
trans.E(0, 2), trans.E(1, 2), trans.E(2, 2)
);
visual_orientation.FromRotationMatrix(mat);
return true;
}
示例2:
btMatrix3x3 Utility::convert_OgreMatrix3(const Ogre::Matrix3 &m)
{
btMatrix3x3 mat;
Ogre::Quaternion quat;
quat.FromRotationMatrix(m);
mat.setRotation(Utility::convert_OgreQuaternion(quat));
return mat;
}
示例3:
//-------------------------------------------------------------------------
void
AFile::setFrameRotation( Ogre::TransformKeyFrame* key_frame
, const Ogre::Vector3& v ) const
{
Ogre::Quaternion rot;
Ogre::Matrix3 mat;
mat.FromEulerAnglesZXY( Ogre::Radian(Ogre::Degree( -v.y )), Ogre::Radian(Ogre::Degree( -v.x )), Ogre::Radian(Ogre::Degree( -v.z )) );
rot.FromRotationMatrix( mat );
key_frame->setRotation( rot );
}
示例4: HandleEvent
void SimplePlayerComponent::HandleEvent(std::shared_ptr<Event> e) {
// do not react to any events if this component is disabled
if(!IsEnabled())
return;
if(mMouseEnabled && e->GetType() == "DT_MOUSEEVENT") {
std::shared_ptr<MouseEvent> m = std::dynamic_pointer_cast<MouseEvent>(e);
if(m->GetAction() == MouseEvent::MOVED) {
float factor = mMouseSensitivity * -0.01;
float dx = m->GetMouseState().X.rel * factor;
float dy = m->GetMouseState().Y.rel * factor * (mMouseYInversed ? -1 : 1);
if(dx != 0 || dy != 0) {
// watch out for da gimbal lock !!
Ogre::Matrix3 orientMatrix;
GetNode()->GetRotation().ToRotationMatrix(orientMatrix);
Ogre::Radian yaw, pitch, roll;
orientMatrix.ToEulerAnglesYXZ(yaw, pitch, roll);
pitch += Ogre::Radian(dy);
yaw += Ogre::Radian(dx);
// do not let it look completely vertical, or the yaw will break
if(pitch > Ogre::Degree(89.9))
pitch = Ogre::Degree(89.9);
if(pitch < Ogre::Degree(-89.9))
pitch = Ogre::Degree(-89.9);
orientMatrix.FromEulerAnglesYXZ(yaw, pitch, roll);
Ogre::Quaternion rot;
rot.FromRotationMatrix(orientMatrix);
GetNode()->SetRotation(rot);
}
}
}
}
示例5:
PhysicsRagDoll::RagBone::RagBone(PhysicsRagDoll* creator, OgreNewt::World* world, PhysicsRagDoll::RagBone* parent, Ogre::Bone* ogreBone, Ogre::MeshPtr mesh,
Ogre::Vector3 dir, PhysicsRagDoll::RagBone::BoneShape shape, Ogre::Vector3 size, Ogre::Real mass, Actor* parentActor)
{
mDoll = creator;
mParent = parent;
mOgreBone = ogreBone;
OgreNewt::ConvexCollisionPtr col;
// in the case of the cylindrical primitives, they need to be rotated to align the main axis with the direction vector.
Ogre::Quaternion orient = Ogre::Quaternion::IDENTITY;
Ogre::Vector3 pos = Ogre::Vector3::ZERO;
Ogre::Matrix3 rot;
if (dir == Ogre::Vector3::UNIT_Y)
{
rot.FromEulerAnglesXYZ(Ogre::Degree(0), Ogre::Degree(0), Ogre::Degree(90));
orient.FromRotationMatrix(rot);
}
if (dir == Ogre::Vector3::UNIT_Z)
{
rot.FromEulerAnglesXYZ(Ogre::Degree(0), Ogre::Degree(90), Ogre::Degree(0));
orient.FromRotationMatrix(rot);
}
// make the rigid body.
switch (shape)
{
case PhysicsRagDoll::RagBone::BS_BOX:
col = OgreNewt::ConvexCollisionPtr(new OgreNewt::CollisionPrimitives::Box(world, size, 0));
break;
case PhysicsRagDoll::RagBone::BS_CAPSULE:
col = OgreNewt::ConvexCollisionPtr(new OgreNewt::CollisionPrimitives::Capsule(world, size.y, size.x, 0, orient, pos));
break;
case PhysicsRagDoll::RagBone::BS_CONE:
col = OgreNewt::ConvexCollisionPtr(new OgreNewt::CollisionPrimitives::Cone(world, size.y, size.x, 0, orient, pos));
break;
case PhysicsRagDoll::RagBone::BS_CYLINDER:
col = OgreNewt::ConvexCollisionPtr(new OgreNewt::CollisionPrimitives::Cylinder(world, size.y, size.x, 0, orient, pos));
break;
case PhysicsRagDoll::RagBone::BS_ELLIPSOID:
col = OgreNewt::ConvexCollisionPtr(new OgreNewt::CollisionPrimitives::Ellipsoid(world, size, 0));
break;
case PhysicsRagDoll::RagBone::BS_CONVEXHULL:
col = _makeConvexHull(world, mesh, size.x);
break;
default:
col = OgreNewt::ConvexCollisionPtr(new OgreNewt::CollisionPrimitives::Box(world, size, 0));
break;
}
if (col)
{
if (col->getNewtonCollision() == NULL)
{
col.reset();
}
}
if (!col)
{
LOG_WARNING(Logger::CORE, " error creating collision for '" + ogreBone->getName() + "', still continuing.");
mBody = NULL;
}
else
{
mBody = new OgreNewt::Body(world, col);
mBody->setUserData(Ogre::Any(parentActor));
mBody->setStandardForceCallback();
const OgreNewt::MaterialID* ragdollMat = PhysicsManager::getSingleton().createMaterialID("default");
mBody->setMaterialGroupID(ragdollMat);
Ogre::Vector3 inertia;
Ogre::Vector3 com;
col->calculateInertialMatrix(inertia, com);
mBody->setMassMatrix(mass, inertia * mass);
mBody->setCenterOfMass(com);
mBody->setCustomTransformCallback(PhysicsRagDoll::_placementCallback);
mOgreBone->setManuallyControlled(true);
}
}
示例6: file
void
AnimationFile::GetData( std::vector< s16 >& skeleton_length, const Unit& unit, const int offset_to_animations, const int number_of_animation, const int start_animation, Ogre::SkeletonPtr skeleton)
{
for (int i = 0; i < number_of_animation; ++i)
{
/*LOGGER->Log(LOGGER_INFO, "Animation Header %02x%02x %02x %02x %02x %02x %02x%02x %02x%02x %02x%02x %02x%02x%02x%02x",
GetU8(offset_to_animations + i * 0x10 + 0x00), GetU8(offset_to_animations + i * 0x10 + 0x01), GetU8(offset_to_animations + i * 0x10 + 0x02), GetU8(offset_to_animations + i * 0x10 + 0x03),
GetU8(offset_to_animations + i * 0x10 + 0x04), GetU8(offset_to_animations + i * 0x10 + 0x05), GetU8(offset_to_animations + i * 0x10 + 0x06), GetU8(offset_to_animations + i * 0x10 + 0x07),
GetU8(offset_to_animations + i * 0x10 + 0x08), GetU8(offset_to_animations + i * 0x10 + 0x09), GetU8(offset_to_animations + i * 0x10 + 0x0A), GetU8(offset_to_animations + i * 0x10 + 0x0B),
GetU8(offset_to_animations + i * 0x10 + 0x0C), GetU8(offset_to_animations + i * 0x10 + 0x0D), GetU8(offset_to_animations + i * 0x10 + 0x0E), GetU8(offset_to_animations + i * 0x10 + 0x0F));
*/
AnimationHeader header;
header.number_of_frames = GetU16LE(offset_to_animations + i * 0x10 + 0x00);
header.number_of_bones = GetU8(offset_to_animations + i * 0x10 + 0x02);
header.number_of_frames_translation = GetU8(offset_to_animations + i * 0x10 + 0x03);
header.number_of_static_translation = GetU8(offset_to_animations + i * 0x10 + 0x04);
header.number_of_frames_rotation = GetU8(offset_to_animations + i * 0x10 + 0x05);
header.offset_to_frames_translation_data = GetU16LE(offset_to_animations + i * 0x10 + 0x06);
header.offset_to_static_translation_data = GetU16LE(offset_to_animations + i * 0x10 + 0x08);
header.offset_to_frames_rotation_data = GetU16LE(offset_to_animations + i * 0x10 + 0x0A);
header.offset_to_animation_data = GetU32LE(offset_to_animations + i * 0x10 + 0x0C) - 0x80000000;
m_AnimationHeaders.push_back(header);
}
for (size_t i = 0; (i < static_cast<size_t>(number_of_animation)) && (start_animation + i < unit.animations.size()); ++i)
{
if (unit.animations[start_animation + i] == "" || unit.animations[start_animation + i] == " ")
{
continue;
}
/*
File file(mpBuffer, m_AnimationHeaders[i].offset_to_animation_data, 0x04 + m_AnimationHeaders[i].number_of_bones * 0x08 + m_AnimationHeaders[i].number_of_frames_translation * m_AnimationHeaders[i].number_of_frames * 0x02 + m_AnimationHeaders[i].number_of_static_translation * 0x02 + m_AnimationHeaders[i].number_of_frames_rotation * m_AnimationHeaders[i].number_of_frames);
file.WriteFile(RString((Ogre::String("dump/") + Ogre::String("animation_") + Ogre::StringConverter::toString(i) + Ogre::String("_data")).c_str()));
*/
Ogre::Animation* anim = skeleton->createAnimation(unit.animations[start_animation + i], (float)(m_AnimationHeaders[i].number_of_frames - 1) / 30.0f);
for (u32 j = 0; j < m_AnimationHeaders[i].number_of_frames; ++j)
{
Frame frame;
// root bone
Ogre::Bone* root = skeleton->getBone(0);
Ogre::NodeAnimationTrack* track;
if (j == 0)
{
track = anim->createNodeTrack(0, root);
track->removeAllKeyFrames();
}
else
{
track = anim->getNodeTrack(0);
}
Ogre::TransformKeyFrame* frame_root = track->createNodeKeyFrame((float)j / 30.0f);
Ogre::Quaternion rot;
Ogre::Matrix3 mat;
mat.FromEulerAnglesZXY(Ogre::Radian(Ogre::Degree(180)), Ogre::Radian(Ogre::Degree(0)), Ogre::Radian(Ogre::Degree(0)));
rot.FromRotationMatrix(mat);
frame_root->setRotation(rot);
for (u32 k = 0; k < m_AnimationHeaders[i].number_of_bones; ++k)
{
BonePosition position;
u8 flag = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x00);
u8 rx = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x01);
u8 ry = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x02);
u8 rz = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x03);
u8 tx = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x04);
u8 ty = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x05);
u8 tz = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x06);
// rotation
if (flag & 0x01)
{
position.rotation_x = 360.0f * GetU8(m_AnimationHeaders[i].offset_to_animation_data + m_AnimationHeaders[i].offset_to_frames_rotation_data + rx * m_AnimationHeaders[i].number_of_frames + j) / 255.0f;
}
else
{
position.rotation_x = 360.0f * rx / 255.0f;
}
if (flag & 0x02)
{
position.rotation_y = 360.0f * GetU8(m_AnimationHeaders[i].offset_to_animation_data + m_AnimationHeaders[i].offset_to_frames_rotation_data + ry * m_AnimationHeaders[i].number_of_frames + j) / 255.0f;
}
else
{
position.rotation_y = 360.0f * ry / 255.0f;
}
if (flag & 0x04)
{
position.rotation_z = 360.0f * GetU8(m_AnimationHeaders[i].offset_to_animation_data + m_AnimationHeaders[i].offset_to_frames_rotation_data + rz * m_AnimationHeaders[i].number_of_frames + j) / 255.0f;
}
//.........这里部分代码省略.........
示例7: aabb
Ogre::Entity*
StageFile::GetModel( const StageInfo& info )
{
//DumpSettings("exported/" + info.data.name + ".lua");
VectorTexForGen textures;
Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().create(info.data.name + "export", "General");
Ogre::SkeletonPtr skeleton = Ogre::SkeletonManager::getSingleton().create(info.data.name + "export", "General");
u32 number_of_files = GetU32LE(0);
LOGGER->Log("Number of file " + IntToString(number_of_files) + "\n");
Ogre::Bone* root1 = skeleton->createBone( "0", 0 );
Ogre::Bone* root2 = skeleton->createBone( "1", 1 );
root1->addChild( root2 );
Ogre::Animation* anim = skeleton->createAnimation( "Idle", 1 );
Ogre::NodeAnimationTrack* track1 = anim->createNodeTrack( 0, root1 );
track1->removeAllKeyFrames();
Ogre::TransformKeyFrame* frame1 = track1->createNodeKeyFrame( 0 );
Ogre::Matrix3 matrix;
matrix.FromEulerAnglesYXZ( Ogre::Radian( Ogre::Degree( 0 ) ), Ogre::Radian( Ogre::Degree( -90 ) ), Ogre::Radian( Ogre::Degree( 0 ) ) );
Ogre::Quaternion rot;
rot.FromRotationMatrix( matrix );
frame1->setRotation( rot );
for (u32 i = 1; i < number_of_files - 1; ++i)
{
int offset_to_vertex = GetU32LE(0x04 + i * 0x04);
MeshExtractor(info.data, "ffvii/battle_stage/" + info.data.name, this, offset_to_vertex, textures, mesh, Ogre::StringConverter::toString(i), 1);
}
// <OGRE> ///////////////////////////////
skeleton->optimiseAllAnimations();
Ogre::SkeletonSerializer skeleton_serializer;
skeleton_serializer.exportSkeleton(skeleton.getPointer(), "exported/models/ffvii/battle/stages/" + info.data.name + ".skeleton");
// Update bounds
Ogre::AxisAlignedBox aabb(-999, -999, -999, 999, 999, 999);
mesh->_setBounds(aabb, false);
mesh->_setBoundingSphereRadius(999);
mesh->setSkeletonName( "models/ffvii/battle/stages/" + info.data.name + ".skeleton" );
Ogre::MeshSerializer ser;
ser.exportMesh(mesh.getPointer(), "exported/models/ffvii/battle/stages/" + info.data.name + ".mesh");
// create and export textures for model
if( textures.size() > 0 )
{
int number_of_files = GetU32LE( 0x00 );
int offset_to_texture = GetU32LE( number_of_files * 0x04 );
Vram* vram = Vram::MakeInstance().release();
LoadTimFileToVram( this, offset_to_texture, vram );
//vram->Save( "qqq" );
CreateTexture( vram, info.data, "exported/models/ffvii/battle/stages/" + info.data.name + ".png", textures );
delete vram;
}
CreateMaterial("ffvii/battle_stage/" + info.data.name, "exported/models/ffvii/battle/stages/" + info.data.name + ".material", "models/ffvii/battle/stages/" + info.data.name + ".png", "", "");
Ogre::SceneManager* scene_manager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
Ogre::Entity* thisEntity = scene_manager->createEntity( info.data.name, "models/ffvii/battle/stages/" + info.data.name + ".mesh" );
//thisEntity->setDisplaySkeleton(true);
//thisEntity->setDebugDisplayEnabled(true);
thisEntity->setVisible(false);
thisEntity->getAnimationState( "Idle" )->setEnabled( true );
thisEntity->getAnimationState( "Idle" )->setLoop( true );
Ogre::SceneNode* thisSceneNode = scene_manager->getRootSceneNode()->createChildSceneNode();
thisSceneNode->setPosition( 0, 0, 0 );
thisSceneNode->roll( Ogre::Radian( Ogre::Degree( 180.0f ) ) );
thisSceneNode->yaw( Ogre::Radian( Ogre::Degree( 120.0f ) ) );
thisSceneNode->pitch( Ogre::Radian( Ogre::Degree( 90.0f ) ) );
thisSceneNode->attachObject( thisEntity );
return thisEntity;
}