本文整理汇总了C++中ogre::Entity::attachObjectToBone方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::attachObjectToBone方法的具体用法?C++ Entity::attachObjectToBone怎么用?C++ Entity::attachObjectToBone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Entity
的用法示例。
在下文中一共展示了Entity::attachObjectToBone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AttachMeshToBone
bool EC_Mesh::AttachMeshToBone(QObject* targetMesh, const QString& boneName)
{
if (!entity_)
return false;
// First make sure that the target mesh is valid, and the bone can be found
EC_Mesh* targetMeshPtr = dynamic_cast<EC_Mesh*>(targetMesh);
if (!targetMeshPtr)
return false;
Ogre::Entity* targetEntity = targetMeshPtr->GetEntity();
if (!targetEntity)
return false;
std::string boneNameStd = boneName.toStdString();
Ogre::SkeletonInstance* skeleton = targetEntity->getSkeleton();
if (!skeleton)
return false;
if (!skeleton->hasBone(boneNameStd))
return false;
// We are ready to go. Detach the entity from its normal scene node first
DetachMeshFromBone();
DetachEntity();
bone_tagpoint_ = targetEntity->attachObjectToBone(boneNameStd, entity_);
bone_parent_mesh_ = targetMeshPtr;
bone_parent_mesh_->bone_attached_mesh_ = this;
attached_to_bone_ = true;
// Force the adjustment for the tagpoint now
OnAttributeUpdated(&nodeTransformation);
return true;
}
示例2: createScene
void OgreAppLogic::createScene(void)
{
// setup some basic lighting for our scene
mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8);
// make a cube to bounce around
Entity *ent1;
SceneNode *boxNode;
ManualObject *cmo = createCubeMesh("manual", "");
cmo->convertToMesh("cube");
ent1 = mSceneMgr->createEntity("Cube", "cube.mesh");
ent1->setCastShadows(true);
boxNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
boxNode->attachObject(ent1);
boxNode->setScale(Vector3(0.1,0.1,0.1)); // for some reason converttomesh multiplied dimensions by 10
mSceneMgr->setAmbientLight(ColourValue(0.3, 0.3, 0.3));
mSceneMgr->createLight()->setPosition(20, 80, 50);
// create a floor mesh resource
MeshManager::getSingleton().createPlane("floor", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Plane(Vector3::UNIT_Y, -30), 1000, 1000, 10, 10, true, 1, 8, 8, Vector3::UNIT_Z);
// create a floor entity, give it a material, and place it at the origin
Entity* floor = mSceneMgr->createEntity("Floor", "floor");
floor->setMaterialName("Examples/BumpyMetal");
mSceneMgr->getRootSceneNode()->attachObject(floor);
mSceneMgr->getRootSceneNode()->attachObject(mSceneMgr->createEntity("Head", "ogrehead.mesh"));
mSceneMgr->setSkyBox(true, "Examples/GridSkyBox");
Ogre::Entity* ent = mSceneMgr->createEntity("Sinbad.mesh"); //1x1_cube.mesh //Sinbad.mesh //axes.mesh
mObjectNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("cube");
mObjectNode->setOrientation(Quaternion(Degree(90.f), Vector3::UNIT_X));
Ogre::Real scale = 22;
mObjectNode->setPosition(10, 10, 10*scale);
mObjectNode->setScale(Ogre::Vector3::UNIT_SCALE*scale);
mObjectNode->attachObject(ent);
mObjectNode->setVisible(true);
// create swords and attach them to sinbad
Ogre::Entity* sword1 = mSceneMgr->createEntity("SinbadSword1", "Sword.mesh");
Ogre::Entity* sword2 = mSceneMgr->createEntity("SinbadSword2", "Sword.mesh");
ent->attachObjectToBone("Sheath.L", sword1);
ent->attachObjectToBone("Sheath.R", sword2);
mAnimState = ent->getAnimationState("Dance");
mAnimState->setLoop(true);
mAnimState->setEnabled(true);
}
示例3: CharacterController
OgreCharacterController::OgreCharacterController(Ogre::Camera * Camera, const Ogre::String& name, const Ogre::Vector3& position)
: CharacterController(Camera, position, name, "Sinbad.mesh", Ogre::Vector3(3, 3, 3)), lastTop(0), lastBase(0),
mSword1(0), mSword2(0), swordsOut(false), sliceDir(false), animTimer(0)
{
Ogre::SceneManager * smgr = Camera->getSceneManager();
Ogre::Entity * ent = getEntity();
ent->getSkeleton()->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);
mSword1 = smgr->createEntity("Sword1", "Sword.mesh");
mSword2 = smgr->createEntity("Sword2", "Sword.mesh");
ent->attachObjectToBone("Sheath.L", mSword1);
ent->attachObjectToBone("Sheath.R", mSword2);
getTargetNode()->setFixedYawAxis(true);
}