本文整理汇总了C++中ogre::SkeletonPtr::getPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ SkeletonPtr::getPointer方法的具体用法?C++ SkeletonPtr::getPointer怎么用?C++ SkeletonPtr::getPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SkeletonPtr
的用法示例。
在下文中一共展示了SkeletonPtr::getPointer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Ogre::Skeleton *ESKOgre::createOgreSkeleton(Ogre::SceneManager *mSceneMgr) {
Ogre::SkeletonPtr mSkel = Ogre::SkeletonManager::getSingleton().create(name, XENOVIEWER_RESOURCE_GROUP, true);
if (bones.size()) {
buildBone(0, mSkel.getPointer(), NULL);
}
resources_created = true;
createFakeEntity(mSceneMgr);
skeleton = mSkel.getPointer();
return mSkel.getPointer();
}
示例2:
void CMonster3D::setupSkeleton(std::string skeletonFile)
{
Ogre::SkeletonPtr pSkeletonBody = Ogre::SkeletonManager::getSingleton().getByName(m_meshName + ".skeleton");
Ogre::Skeleton::BoneHandleMap boneHandleMap;
Ogre::SkeletonPtr pNewSkeleton = Ogre::SkeletonManager::getSingleton().load(skeletonFile, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::Animation *pSrcAnimation = pNewSkeleton->getAnimation(0);
std::string newAnimationName = pSrcAnimation->getName() + "::" + m_pMonsterNode->getName();
Ogre::Animation *pNewAnimation = pNewSkeleton->createAnimation(newAnimationName, pSrcAnimation->getLength());
Ogre::Animation *pCloneAnimation = pNewSkeleton->getAnimation(0)->clone(newAnimationName);
*pNewAnimation = *pCloneAnimation;
pNewSkeleton->removeAnimation(pSrcAnimation->getName());
pNewSkeleton->_buildMapBoneByHandle(pNewSkeleton.getPointer(), boneHandleMap);
pSkeletonBody->_mergeSkeletonAnimations(pNewSkeleton.getPointer(), boneHandleMap);
Ogre::SkeletonManager::getSingleton().remove(skeletonFile);
m_pBodyEntity->getSkeleton()->_refreshAnimationState(m_pBodyEntity->getAllAnimationStates());
}
示例3: 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" : "", "", "" );
//.........这里部分代码省略.........
示例4: doExportSkeleton
//.........这里部分代码省略.........
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);
Ogre::Bone* ogreparent = ogreskel->getBone(bone->szParentName);
if (ogrechild == 0)
{
msg = "Error: could not locate child bone '" +
Ogre::String(bone->szName) + "'";
logMgr.logMessage(msg);
continue;
}
if (ogreparent == 0)
{
msg = "Error: could not locate parent bone '"
+ Ogre::String(bone->szParentName) + "'";
logMgr.logMessage(msg);
continue;
}
// Make child
ogreparent->addChild(ogrechild);
}
}
logMgr.logMessage("Bone hierarchy established.");
// Create the Animation(s)
doExportAnimations(pModel, ogreskel);
// Create skeleton serializer & export
Ogre::SkeletonSerializer serializer;
msg = "Exporting skeleton to " + Ogre::String(szFile);
logMgr.logMessage(msg);
serializer.exportSkeleton(ogreskel.getPointer(), szFile);
logMgr.logMessage("Skeleton exported");
msg = "Linking mesh to skeleton file '" + skelName + "'";
Ogre::LogManager::getSingleton().logMessage(msg);
mesh->_notifySkeleton(ogreskel);
return ogreskel;
}
示例5: EngineSetup
//.........这里部分代码省略.........
ManualObject->position(1, 1, 1);
ManualObject->triangle(18, 19, 20);
ManualObject->position(1, 0, 0);
ManualObject->position(1, 1, 1);
ManualObject->position(1, 0, 1);
ManualObject->triangle(21, 22, 23);
//face 5
ManualObject->position(0, 1, 0);
ManualObject->position(1, 1, 0);
ManualObject->position(0, 1, 1);
ManualObject->triangle(24, 25, 26);
ManualObject->position(1, 1, 0);
ManualObject->position(1, 1, 1);
ManualObject->position(0, 1, 1);
ManualObject->triangle(27, 28, 29);
//face 6
ManualObject->position(0, 0, 0);
ManualObject->position(0, 1, 1);
ManualObject->position(0, 0, 1);
ManualObject->triangle(30, 31, 32);
ManualObject->position(0, 0, 0);
ManualObject->position(0, 1, 0);
ManualObject->position(0, 1, 1);
ManualObject->triangle(33, 34, 35);
ManualObject->end();
Ogre::MeshPtr MeshPtr = ManualObject->convertToMesh("Animation");
Ogre::SubMesh* sub = MeshPtr->getSubMesh(0);
Ogre::SkeletonPtr Skeleton = Ogre::SkeletonManager::getSingleton().create("Skeleton", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
MeshPtr.getPointer()->_notifySkeleton(Skeleton);
Ogre::Bone *Root1 = NULL;
Ogre::Bone *Child1 = NULL;
Ogre::Bone *Child2 = NULL;
Root1 = Skeleton.getPointer()->createBone("Root");
Root1->setPosition(Ogre::Vector3(0.0, 0.0, 0.0));
Root1->setOrientation(Ogre::Quaternion::IDENTITY);
Child1 = Root1->createChild(1);
Child1->setPosition(Ogre::Vector3(4.0, 0.0, 0.0));
Child1->setOrientation(Ogre::Quaternion::IDENTITY);
Child2 = Root1->createChild(2);
Child2->setPosition(Ogre::Vector3(5.0, 0.0, 0.0));
Child2->setOrientation(Ogre::Quaternion::IDENTITY);
Ogre::VertexBoneAssignment Assignment;
Assignment.boneIndex = 0;
Assignment.vertexIndex = 0;
Assignment.weight = 1.0;
Skeleton->setBindingPose();
sub->addBoneAssignment(Assignment);
Assignment.vertexIndex = 1;
sub->addBoneAssignment(Assignment);
Assignment.vertexIndex = 2;
sub->addBoneAssignment(Assignment);
Ogre::Animation *Animation = MeshPtr->createAnimation("HandAnimation", 100.0);
Ogre::NodeAnimationTrack *Track = Animation->createNodeTrack(0, Root1);
Ogre::TransformKeyFrame *KeyFrame = NULL;
for (float FrameTime = 0.0; FrameTime < 100.0; FrameTime += 0.1)
{
KeyFrame = Track->createNodeKeyFrame(FrameTime);
KeyFrame->setTranslate(Ogre::Vector3(10.0, 0.0, 0.0));
}
Root1->setManuallyControlled(true);
Child1->setManuallyControlled(true);
Child2->setManuallyControlled(true);
MeshPtr->load();
MeshPtr.getPointer()->_notifySkeleton(Skeleton);
// Ogre::SkeletonSerializer skeletonSerializer;
// skeletonSerializer.exportSkeleton(Skeleton.get(), "C:\\Users\\Ilya\\Documents\\Visual Studio 2010\\Projects\\Recipes\\media\\models\\testskeleton.skeleton");
// Ogre::MeshSerializer ser;
// ser.exportMesh(MeshPtr.get(), "C:\\Users\\Ilya\\Documents\\Visual Studio 2010\\Projects\\Recipes\\media\\models\\testskeleton.mesh");
Ogre::Entity *Entity = SceneManager->createEntity("Animation", "Animation"/*"testskeleton.mesh"*/);
Ogre::SceneNode *SceneNode = SceneManager->getRootSceneNode()->createChildSceneNode();
SceneNode->attachObject(Entity);
Entity->setDisplaySkeleton(true);
m_AnimationState = Entity->getAnimationState("HandAnimation");
m_AnimationState->setEnabled(true);
m_AnimationState->setLoop(true);
m_Camera->setPolygonMode(Ogre::PolygonMode::PM_WIREFRAME);
Root->renderOneFrame();
}
开发者ID:southerlies,项目名称:OGRE-3D-1.7-Application-Development-Cookbook-Code,代码行数:101,代码来源:SceletalAnimationView.cpp
示例6: 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;
}