本文整理汇总了C++中ogre::Skeleton类的典型用法代码示例。如果您正苦于以下问题:C++ Skeleton类的具体用法?C++ Skeleton怎么用?C++ Skeleton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Skeleton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetBornNum
int MyLink::GetBornNum()
{
Ogre::Skeleton *tmp = mEntity->getSkeleton();
if(tmp)
{
return tmp->getNumBones();
}
return 0;
}
示例2: GetBone
Ogre::Bone* EC_Mesh::GetBone(const QString& boneName) const
{
std::string boneNameStd = boneName.toStdString();
if (!entity_)
return 0;
Ogre::Skeleton* skel = entity_->getSkeleton();
if (skel && skel->hasBone(boneNameStd))
return skel->getBone(boneNameStd);
else
return 0;
}
示例3: _behaviorMove
void NPCCharacter::_behaviorMove(const Ogre::Vector3& target)
{
//Check for duplicate move calls and update lua function call with that info
//std::cout << target << std::endl;
if(_destination.squaredDistance(target) >= 5)
{
updateDestination(target,false);
_destination = target;
}
if(destinationReached())
{
_isBhvFinished = true;
}
else
{
_isBhvFinished = false;
}
//point the character in the direction it's traveling
Ogre::Vector3 vel = getVelocity();
float speed = vel.length();
vel.y = 0;
vel.normalise();
if(speed > .2f)
{
Ogre::Vector3 src = _node->getOrientation() * Ogre::Vector3::NEGATIVE_UNIT_Z;
src.y = 0;
//moving sufficiently fast, change to moving animation and point character
Utility::rotateToTarget(_node,vel,true);
//change animation if needed.
if(_animHandler.getSource() != nullptr)
{
Ogre::AnimationState* target = _animHandler.getTarget();
//this relies on the properties of the '&&' construct used by C++(if the first is false,
//then the if-statement is false. It DOESN'T check both fields.
if((target == nullptr && _animHandler.getSource()->getAnimationName() != "Walk") ||
(target != nullptr && target->getAnimationName() != "Walk"))
{
_animHandler.blend("Walk",AnimationBlender::BlendWhileAnimating,.2f,true);
}
}
}
//also have to reset the head, since I'm manually controlling it.
Ogre::Skeleton* skel = static_cast<Ogre::Entity*>(_movableObject)->getSkeleton();
Ogre::Bone* headBone = skel->getBone("Bip01_Head");
//not sure how to do this.
}
示例4: OnTimer
void CBlendingAnimationsView::OnTimer(UINT_PTR nIDEvent)
{
CEngine *Engine = ((CBlendingAnimationsApp*)AfxGetApp())->m_Engine;
Ogre::Root *Root = Engine->GetRoot();
Ogre::SceneNode *RobotNode = Root->getSceneManager("Walking")->getSceneNode("Robot");
Ogre::Entity *RobotEntity = Root->getSceneManager("Walking")->getEntity("Robot");
Ogre::Skeleton *Skeleton = RobotEntity->getSkeleton();
if (m_WeightDlg->m_IsAverage)
{
Skeleton->setBlendMode(Ogre::SkeletonAnimationBlendMode::ANIMBLEND_AVERAGE);
}
else
{
Skeleton->setBlendMode(Ogre::SkeletonAnimationBlendMode::ANIMBLEND_CUMULATIVE);
}
double WalkWeight;
double SlumpWeight;
switch(nIDEvent)
{
case 1:
WalkWeight = m_WeightDlg->m_WalkWeight.GetPos() / 10.0;
SlumpWeight = m_WeightDlg->m_SlumpWeight.GetPos() / 10.0;
m_WalkAnimation->setWeight(WalkWeight);
m_SlumpAnimation->setWeight(SlumpWeight);
m_WalkAnimation->addTime(0.01);
m_SlumpAnimation->addTime(0.01);
break;
case 2:
m_WalkAnimation->addTime(0.01);
break;
case 3:
m_SlumpAnimation->addTime(0.01);
break;
}
Root->renderOneFrame();
CView::OnTimer(nIDEvent);
}
开发者ID:southerlies,项目名称:OGRE-3D-1.7-Application-Development-Cookbook-Code,代码行数:52,代码来源:BlendingAnimationsView.cpp
示例5: ExampleAnimationSystem
AnimationSystem::AnimationSystem( Ogre::Entity* entity )
: ExampleAnimationSystem()
, m_animations( NULL )
{
assert( entity );
m_animations = entity->getAllAnimationStates();
bool entityIsAnimated = ( entity->getAllAnimationStates() != NULL );
assert( entityIsAnimated );
Ogre::Skeleton* skeleton = entity->getSkeleton();
skeleton->setBlendMode( Ogre::ANIMBLEND_CUMULATIVE );
}
示例6: _actionIdle
//This is basically just a time-waster
void NPCCharacter::_actionIdle()
{
//want the head to point straight ahead when it's idling
Ogre::Bone* headBone;
Ogre::Skeleton* skel = static_cast<Ogre::Entity*>(_movableObject)->getSkeleton();
headBone = skel->getBone("Bip01_Head");
if(headBone->isManuallyControlled())
{
//rotate it to be aligned with the body.
}
_isActFinished = true;
}
示例7: skeleton__get_bone_matrices
//void _getBoneMatrices(Matrix4* pMatrices);
void skeleton__get_bone_matrices(SkeletonHandle handle, coiMatrix4* matrices[])
{
Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle);
// Borrowed from OgreEntity.cpp
unsigned short num = skeleton->getNumBones();
Ogre::Matrix4* BoneMatrices = static_cast<Ogre::Matrix4*>(OGRE_MALLOC_SIMD(sizeof(Ogre::Matrix4) * num, Ogre::MEMCATEGORY_ANIMATION));
skeleton->_getBoneMatrices(BoneMatrices);
for (unsigned short current = 0; current != num; ++current)
{
Ogre::Matrix4 o_matrix = *BoneMatrices;
ogre_matrix4_to_llcoi_matrix4(o_matrix, *matrices[current]);
}
}
示例8: loadResource
void NIFSkeletonLoader::loadResource(Ogre::Resource *resource)
{
Ogre::Skeleton *skel = dynamic_cast<Ogre::Skeleton*>(resource);
OgreAssert(skel, "Attempting to load a skeleton into a non-skeleton resource!");
Nif::NIFFile::ptr nif(Nif::NIFFile::create(skel->getName()));
const Nif::Node *node = static_cast<const Nif::Node*>(nif->getRoot(0));
try {
buildBones(skel, node);
}
catch(std::exception &e) {
std::cerr<< "Exception while loading "<<skel->getName() <<std::endl;
std::cerr<< e.what() <<std::endl;
return;
}
}
示例9: OgreContainer
//!
//! Create new scene.
//! \return True if the scene was successfully created, otherwise False.
//!
bool Model2SceneNode::createEntity(QString name, QString fileName)
{
// destroy the entity through its scene manager
Ogre::SceneManager *sceneManager = OgreManager::getSceneManager();
// create a new OGRE entity for each vertex
m_entity = sceneManager->createEntity(name.toStdString(), fileName.toStdString());
if (m_entity) {
// set cumulative blend mode instead of Ogre::ANIMBLEND_AVERAGE which is default
if (m_entity->hasSkeleton()) {
Ogre::Skeleton *skeleton = m_entity->getSkeleton();
skeleton->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);
}
}
// create a container for the entity
m_entityContainer = new OgreContainer(m_entity);
m_entity->setUserAny(Ogre::Any(m_entityContainer));
return true;
}
示例10: moveBone
void CAnimatedEntity::moveBone(const std::string &bone, float pitch) {
Ogre::Bone * entityBone = _entity->getSkeleton()->getBone(bone);
entityBone->reset();
Ogre::Skeleton * skel = _entity->getSkeleton();
//entityBone->setManuallyControlled(true);
unsigned short boneHandle = entityBone->getHandle();
Ogre::AnimationStateIterator animStateIt = _entity->getAllAnimationStates()->getAnimationStateIterator();
while( animStateIt.hasMoreElements() )
{
Ogre::AnimationState *pAnimState = animStateIt.getNext();
// ignore disabled animations
skel->getAnimation(pAnimState->getAnimationName())->destroyNodeTrack(boneHandle);
}
entityBone->pitch(Ogre::Radian(pitch));
}
示例11: _actionLook
void NPCCharacter::_actionLook(const Ogre::Vector3& target)
{
Ogre::Bone* headBone;
std::string n = _node->getName();
Ogre::Skeleton* skel = static_cast<Ogre::Entity*>(_movableObject)->getSkeleton();
headBone = skel->getBone("Bip01_Head");
headBone->setManuallyControlled(true);
headBone->setInheritOrientation(true);
int nAnim = skel->getNumAnimations();
//have to do this to allow the head to turn properly.
for(int i = 0; i < nAnim; ++i)
{
skel->getAnimation(i)->destroyNodeTrack(headBone->getHandle());
}
Ogre::Vector3 test = headBone->_getDerivedPosition() * CHARACTER_SCALE_FACTOR + _node->getPosition();
Ogre::Vector3 dir = target - test;
Ogre::Quaternion nodeRot,boneRot;
Ogre::Euler boneEuler; boneEuler.setDirection(dir,true,false);
/*boneRot = _node->convertLocalToWorldOrientation(_node->getOrientation()) * headBone->_getDerivedOrientation();
Ogre::Vector3 boneTest = boneRot * Ogre::Vector3::UNIT_Z;*/
//Ogre::Vector3 boneTest = headBone->getOrientation() * Ogre::Vector3::UNIT_Z;
//turns the direction vector into a 2D normalized vector on the X/Z axis.
dir.y = 0;
dir.normalise();
//All of this ray query stuff is to make sure that the AI can "see" the target before attempting to look at it.
Ogre::SceneManager* scene = _node->getCreator();
Ogre::Ray ray(headBone->_getDerivedPosition() * CHARACTER_SCALE_FACTOR + _node->getPosition(),dir);
Ogre::RaySceneQuery* query = scene->createRayQuery(ray);
query->setSortByDistance(true);
query->setQueryMask(CHARACTER_MASK | SCENERY_MASK);
Ogre::RaySceneQueryResult results = query->execute();
bool withinView = false;
if(results.size() == 0)
{
withinView = true;
}
else
{
if(results.begin()->movable->getParentNode()->getName() == getName())
{
if(results.size() == 1)
{
withinView = true;
}
}
if(!withinView && results.size() > 1 && std::next(results.begin())->distance > test.distance(target))
{
withinView = true;
}
}
scene->destroyQuery(query);
if(withinView)
{
Ogre::Euler node;
Ogre::Euler t = headOrientation.getRotationTo(dir);
t.limitYaw(Ogre::Radian(3.0));
t.limitPitch(Ogre::Radian(0.0));
headOrientation = headOrientation + t;
headOrientation.limitYaw(Ogre::Degree(100));
headOrientation.limitPitch(Ogre::Degree(60));
headBone->setOrientation(headOrientation);
/*headBone->rotate(boneTest.getRotationTo(dir),Ogre::Node::TS_WORLD);
Ogre::Quaternion boneRotation = _node->convertLocalToWorldOrientation(_node->getOrientation()) * headBone->_getDerivedOrientation() * (Ogre::Quaternion(Ogre::Degree(180),Ogre::Vector3::UNIT_Y));
Ogre::Quaternion nodeRotation = _node->_getDerivedOrientation();
Ogre::Quaternion diff = nodeRotation.Inverse() * boneRotation;*/
}
_isActFinished = true;
}
示例12: skeleton_reset
//void reset(bool resetManualBones = false);
void skeleton_reset(SkeletonHandle handle, int reset_manual_bones)
{
Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle);
skeleton->reset(reset_manual_bones);
}
示例13: skeleton_remove_animation
//void removeAnimation(const String& name);
void skeleton_remove_animation(SkeletonHandle handle, const char* name)
{
Ogre::Skeleton* skeleton = static_cast<Ogre::Skeleton*>(handle);
skeleton->removeAnimation(Ogre::String(name));
}
示例14: while
//!
//! Clones an Ogre::MovableObject.
//!
//! Is needed because OGRE does not provide clone functions for cameras and
//! lights.
//!
//! \param movableObject The object to clone.
//! \param name The name to use for the object.
//! \param sceneManager The scene manager to use for creating the object.
//! \return The cloned object.
//!
Ogre::MovableObject * OgreTools::cloneMovableObject ( Ogre::MovableObject *movableObject, const QString &name, Ogre::SceneManager *sceneManager /* = 0 */ )
{
// make sure the given object is valid
if (!movableObject) {
Log::error("The given movable object is invalid.", "OgreTools::cloneMovableObject");
return 0;
}
// make sure a valid scene manager is available
if (!sceneManager)
sceneManager = movableObject->_getManager();
if (!sceneManager) {
Log::error("No valid scene manager available.", "OgreTools::cloneMovableObject");
return 0;
}
Ogre::MovableObject *result = 0;
Ogre::String typeName = movableObject->getMovableType();
if (typeName == "Entity") {
// clone entity
Ogre::Entity *entity = dynamic_cast<Ogre::Entity *>(movableObject);
//movableObjectCopy = entity->clone(name.toStdString());
Ogre::Entity *entityCopy = sceneManager->createEntity(name.toStdString(), entity->getMesh()->getName());
Ogre::AnimationStateSet *animationStateSet = entity->getAllAnimationStates();
Ogre::AnimationStateSet *animationStateSetCopy = entityCopy->getAllAnimationStates();
// set the same blend mode on entity copy
if (entity && entityCopy) {
if (entity->hasSkeleton() && entityCopy->hasSkeleton()) {
Ogre::Skeleton *skeleton = entity->getSkeleton();
Ogre::Skeleton *skeletonCopy = entityCopy->getSkeleton();
skeletonCopy->setBlendMode(skeleton->getBlendMode());
}
}
// copy all animation states
if (animationStateSet && animationStateSetCopy) {
Ogre::AnimationStateIterator animationStateIter = animationStateSet->getAnimationStateIterator();
Ogre::AnimationStateIterator animationStateCopyIter = animationStateSetCopy->getAnimationStateIterator();
while (animationStateIter.hasMoreElements()) {
if (!animationStateCopyIter.hasMoreElements())
break;
Ogre::AnimationState *animationState = animationStateIter.getNext();
Ogre::AnimationState *animationStateCopy = animationStateCopyIter.getNext();
animationStateCopy->setLoop(animationState->getLoop());
//bool enabled = animationState->getEnabled();
//animationStateCopy->setEnabled(animationState->getEnabled());
animationStateCopy->setEnabled(true);
animationStateCopy->setTimePosition(animationState->getTimePosition());
}
}
// create a new container for the cloned entity
OgreContainer *entityCopyContainer = new OgreContainer(entityCopy);
entityCopy->setUserAny(Ogre::Any(entityCopyContainer));
if (!entity->getUserAny().isEmpty()) {
OgreContainer *entityContainer = Ogre::any_cast<OgreContainer *>(entity->getUserAny());
if (entityContainer) {
QObject::connect(entityContainer, SIGNAL(animationStateUpdated(const QString &, double)), entityCopyContainer, SLOT(updateAnimationState(const QString &, double)));
QObject::connect(entityContainer, SIGNAL(boneTransformUpdated(const QString &, double, double, double, double, double, double)), entityCopyContainer, SLOT(updateBoneTransform(const QString &, double, double, double, double, double, double)));
}
}
result = dynamic_cast<Ogre::MovableObject *>(entityCopy);
} else if (typeName == "Light") {
// clone light
Ogre::Light *light = dynamic_cast<Ogre::Light *>(movableObject);
Ogre::Light *lightCopy = sceneManager->createLight(name.toStdString());
lightCopy->setType(light->getType());
lightCopy->setDiffuseColour(light->getDiffuseColour());
lightCopy->setSpecularColour(light->getSpecularColour());
lightCopy->setAttenuation(light->getAttenuationRange(), light->getAttenuationConstant(), light->getAttenuationLinear(), light->getAttenuationQuadric());
lightCopy->setPosition(light->getPosition());
lightCopy->setDirection(light->getDirection());
if (lightCopy->getType() == Ogre::Light::LT_SPOTLIGHT)
lightCopy->setSpotlightRange(light->getSpotlightInnerAngle(), light->getSpotlightOuterAngle(), light->getSpotlightFalloff());
lightCopy->setPowerScale(light->getPowerScale());
lightCopy->setCastShadows(light->getCastShadows());
// create a new container for the cloned light
OgreContainer *lightCopyContainer = new OgreContainer(lightCopy);
lightCopy->setUserAny(Ogre::Any(lightCopyContainer));
if (!light->getUserAny().isEmpty()) {
OgreContainer *lightContainer = Ogre::any_cast<OgreContainer *>(light->getUserAny());
if (lightContainer)
QObject::connect(lightContainer, SIGNAL(sceneNodeUpdated()), lightCopyContainer, SLOT(updateLight()));
}
result = dynamic_cast<Ogre::MovableObject *>(lightCopy);
} else if (typeName == "Camera") {
// clone camera
Ogre::Camera *camera = dynamic_cast<Ogre::Camera *>(movableObject);
Ogre::Camera *cameraCopy = sceneManager->createCamera(name.toStdString());
//.........这里部分代码省略.........
示例15: frameRenderingQueued
bool OgreSmartBody::frameRenderingQueued(const Ogre::FrameEvent& evt)
{
if(mWindow->isClosed())
return false;
//Need to capture/update each device
mKeyboard->capture();
mMouse->capture();
if(mKeyboard->isKeyDown(OIS::KC_ESCAPE))
return false;
// smartbody
if (!m_pScene)
return true;
SmartBody::SBSimulationManager* sim = m_pScene->getSimulationManager();
sim->setTime((Ogre::Root::getSingleton().getTimer()->getMilliseconds() / 1000.0f) - mStartTime);
m_pScene->update();
int numCharacters = m_pScene->getNumCharacters();
if (numCharacters == 0)
return true;
const std::vector<std::string>& characterNames = m_pScene->getCharacterNames();
for (size_t n = 0; n < characterNames.size(); n++)
{
SmartBody::SBCharacter* character = m_pScene->getCharacter(characterNames[n]);
if (!this->getSceneManager()->hasEntity(characterNames[n]))
continue;
Ogre::Entity* entity = this->getSceneManager()->getEntity(characterNames[n]);
Ogre::Skeleton* meshSkel = entity->getSkeleton();
Ogre::Node* node = entity->getParentNode();
SrVec pos = character->getPosition();
SrQuat ori = character->getOrientation();
//std::cout << ori.w << ori.x << " " << ori.y << " " << ori.z << std::endl;
node->setPosition(pos.x, pos.y, pos.z);
node->setOrientation(ori.w, ori.x, ori.y, ori.z);
// Update joints
SmartBody::SBSkeleton* sbSkel = character->getSkeleton();
int numJoints = sbSkel->getNumJoints();
for (int j = 0; j < numJoints; j++)
{
SmartBody::SBJoint* joint = sbSkel->getJoint(j);
try
{
SrQuat orientation = joint->quat()->value();
Ogre::Vector3 posDelta(joint->getPosition().x, joint->getPosition().y, joint->getPosition().z);
Ogre::Quaternion quatDelta(orientation.w, orientation.x, orientation.y, orientation.z);
Ogre::Bone* bone = meshSkel->getBone(joint->getName());
if (!bone)
continue;
bone->setPosition(bone->getInitialPosition() + posDelta);
bone->setOrientation(quatDelta);
}
catch (Ogre::ItemIdentityException& ex)
{
// Should not happen as we filtered using m_mValidBones
}
}
}
return true;
}