本文整理汇总了C++中ogre::SkeletonPtr::createBone方法的典型用法代码示例。如果您正苦于以下问题:C++ SkeletonPtr::createBone方法的具体用法?C++ SkeletonPtr::createBone怎么用?C++ SkeletonPtr::createBone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SkeletonPtr
的用法示例。
在下文中一共展示了SkeletonPtr::createBone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doExportSkeleton
Ogre::SkeletonPtr MilkshapePlugin::doExportSkeleton(msModel* pModel, Ogre::MeshPtr& mesh)
{
Ogre::LogManager &logMgr = Ogre::LogManager::getSingleton();
Ogre::String msg;
//
// choose filename
//
OPENFILENAME ofn;
memset (&ofn, 0, sizeof (OPENFILENAME));
char szFile[MS_MAX_PATH];
char szFileTitle[MS_MAX_PATH];
char szDefExt[32] = "skeleton";
char szFilter[128] = "OGRE .skeleton Files (*.skeleton)\0*.skeleton\0All Files (*.*)\0*.*\0\0";
szFile[0] = '\0';
szFileTitle[0] = '\0';
ofn.lStructSize = sizeof (OPENFILENAME);
ofn.lpstrDefExt = szDefExt;
ofn.lpstrFilter = szFilter;
ofn.lpstrFile = szFile;
ofn.nMaxFile = MS_MAX_PATH;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = MS_MAX_PATH;
ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
ofn.lpstrTitle = "Export to OGRE Skeleton";
if (!::GetSaveFileName (&ofn))
return Ogre::SkeletonPtr();
// Strip off the path
Ogre::String skelName = szFile;
size_t lastSlash = skelName.find_last_of("\\");
skelName = skelName.substr(lastSlash+1);
// Set up
logMgr.logMessage("Trying to create Skeleton object");
Ogre::SkeletonPtr ogreskel = Ogre::SkeletonManager::getSingleton().create(skelName,
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
logMgr.logMessage("Skeleton object created");
// Complete the details
// Do the bones
int numBones = msModel_GetBoneCount(pModel);
msg = "Number of bones: " + Ogre::StringConverter::toString(numBones);
logMgr.logMessage(msg);
int i;
// Create all the bones in turn
for (i = 0; i < numBones; ++i)
{
msBone* bone = msModel_GetBoneAt(pModel, i);
Ogre::Bone* ogrebone = ogreskel->createBone(bone->szName);
msVec3 msBonePos, msBoneRot;
msBone_GetPosition(bone, msBonePos);
msBone_GetRotation(bone, msBoneRot);
Ogre::Vector3 bonePos(msBonePos[0], msBonePos[1], msBonePos[2]);
ogrebone->setPosition(bonePos);
// Hmm, Milkshape has chosen a Euler angle representation of orientation which is not smart
// Rotation Matrix or Quaternion would have been the smarter choice
// Might we have Gimbal lock here? What order are these 3 angles supposed to be applied?
// Grr, we'll try our best anyway...
Ogre::Quaternion qx, qy, qz, qfinal;
qx.FromAngleAxis(Ogre::Radian(msBoneRot[0]), Ogre::Vector3::UNIT_X);
qy.FromAngleAxis(Ogre::Radian(msBoneRot[1]), Ogre::Vector3::UNIT_Y);
qz.FromAngleAxis(Ogre::Radian(msBoneRot[2]), Ogre::Vector3::UNIT_Z);
// Assume rotate by x then y then z
qfinal = qz * qy * qx;
ogrebone->setOrientation(qfinal);
Ogre::LogManager::getSingleton().stream()
<< "Bone #" << i << ": " <<
"Name='" << bone->szName << "' " <<
"Position: " << bonePos << " " <<
"Ms3d Rotation: {" << msBoneRot[0] << ", " << msBoneRot[1] << ", " << msBoneRot[2] << "} " <<
"Orientation: " << qfinal;
}
// Now we've created all the bones, link them up
logMgr.logMessage("Establishing bone hierarchy..");
for (i = 0; i < numBones; ++i)
{
msBone* bone = msModel_GetBoneAt(pModel, i);
if (strlen(bone->szParentName) == 0)
{
// Root bone
msg = "Root bone detected: Name='" + Ogre::String(bone->szName) + "' Index="
+ Ogre::StringConverter::toString(i);
logMgr.logMessage(msg);
}
else
{
Ogre::Bone* ogrechild = ogreskel->getBone(bone->szName);
//.........这里部分代码省略.........
示例2: aabb
Ogre::Entity*
ModelFile::GetModel( const ModelInfo& info )
{
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" );
int number_of_bones = GetU8( 0x02 );
int number_of_parts = GetU8( 0x03 );
int offset_to_bones = GetU32LE( 0x0c );
int offset_to_parts = GetU32LE( 0x10 );
Ogre::Bone* root1 = skeleton->createBone( "0", 0 );
Ogre::Bone* root2 = skeleton->createBone( "1", 1 );
root1->addChild( root2 );
for( int i = 0; i < number_of_bones; ++i )
{
Bone bone;
bone.parent_id = ( i != 0 ) ? ( s8 )GetU8( offset_to_bones + i * 0x04 + 0x03 ) : -1;
bone.length = ( s16 )GetU16LE( offset_to_bones + i * 0x04 + 0x00 );
m_Skeleton.push_back(bone);
Ogre::Bone* bone1 = skeleton->createBone( Ogre::StringConverter::toString( i * 2 + 2 ), i * 2 + 2 );
Ogre::Bone* bone2 = skeleton->createBone( Ogre::StringConverter::toString( i * 2 + 3 ), i * 2 + 3 );
LOGGER->Log( "Add skeleton bone: bone_id = " + Ogre::StringConverter::toString( i ) + ", length = " + Ogre::StringConverter::toString( bone.length ) + ", parent = " + Ogre::StringConverter::toString( bone.parent_id ) + ".\n" );
if( bone.parent_id == -1 )
{
skeleton->getBone( 1 )->addChild( bone1 );
}
else
{
skeleton->getBone( bone.parent_id * 2 + 3 )->addChild( bone1 );
}
bone1->addChild( bone2 );
}
AnimationExtractor( skeleton, info, m_Skeleton );
// draw skeleton
{
//DrawSkeleton( m_Skeleton, mesh );
}
for( int i = 0; i < number_of_parts; ++i )
{
MeshExtractor( info.data, "ffix/field_model/" + info.data.name, this, offset_to_parts + i * 0x28, textures, mesh );
}
// <OGRE> ///////////////////////////////
skeleton->optimiseAllAnimations();
Ogre::SkeletonSerializer skeleton_serializer;
skeleton_serializer.exportSkeleton( skeleton.getPointer(), "exported/models/field/units/" + 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/field/units/" + info.data.name + ".skeleton" );
Ogre::MeshSerializer ser;
ser.exportMesh( mesh.getPointer(), "exported/models/field/units/" + info.data.name + ".mesh" );
// create and export textures for model
//if (textures.size() > 0)
{
Vram* vram = new Vram();
File* tex = new File( "./data/field/5/1b/2/4/1.tim" );
LoadTimFileToVram( tex, 0, vram );
delete tex;
tex = new File( "./data/field/5/1b/2/4/2.tim" );
LoadTimFileToVram( tex, 0, vram );
delete tex;
vram->Save( "1.jpg" );
CreateTexture( vram, info.data, "exported/models/field/units/" + info.data.name + ".png", textures );
delete vram;
}
CreateMaterial( "ffix/field_model/" + info.data.name, "exported/models/field/units/" + info.data.name + ".material", ( textures.size() > 0 ) ? "models/field/units/" + info.data.name + ".png" : "", "", "" );
//.........这里部分代码省略.........
示例3: 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;
}