当前位置: 首页>>代码示例>>C++>>正文


C++ Bone::getChild方法代码示例

本文整理汇总了C++中ogre::Bone::getChild方法的典型用法代码示例。如果您正苦于以下问题:C++ Bone::getChild方法的具体用法?C++ Bone::getChild怎么用?C++ Bone::getChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ogre::Bone的用法示例。


在下文中一共展示了Bone::getChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetSkeletonDebug

void SkeletonDebug::SetSkeletonDebug(
    Ogre::Entity* entity,
    Ogre::SceneManager* sceneManager,
    const bool enable,
    Ogre::Real boneSize,
    Ogre::Real axisSize)
{
    if (!HasSkeletonDebug(entity))
    {
        GetAxesMaterial();
        GetBoneMaterial();
        GetAxesMesh();
        GetBoneMesh(boneSize);

        const int numBones = entity->getSkeleton()->getNumBones();

        for(unsigned short int iBone = 0; iBone < numBones; ++iBone)
        {
            Ogre::Bone* pBone = entity->getSkeleton()->getBone(iBone);
            if ( !pBone )
            {
                assert(false);
                continue;
            }

            Ogre::Entity *ent;
            Ogre::TagPoint *tp;

            // Absolutely HAVE to create bone representations first. Otherwise we
            // would get the wrong child count because an attached object counts as
            // a child would be nice to have a function that only gets the children
            // that are bones...
            unsigned short numChildren = pBone->numChildren();
            if (numChildren == 0)
            {
                // There are no children, but we should still represent the bone
                // Creates a bone of length 1 for leaf bones (bones without children)
                ent = sceneManager->createEntity(boneName);
                ent->setCastShadows(false);
                tp = entity->attachObjectToBone(
                    pBone->getName(),
                    (Ogre::MovableObject*)ent,
                    Ogre::Quaternion(Ogre::Degree(270.0f), Ogre::Vector3::UNIT_Z));

                const Ogre::Real modBoneSize =
                    boneSize + boneSize * boneSize * 15.0f;

                tp->setScale(modBoneSize, boneSize, modBoneSize);
            }
            else
            {
                for(unsigned short i = 0; i < numChildren; ++i)
                {
                    if (dynamic_cast<Ogre::Bone*>(pBone->getChild(i)))
                    {
                        Ogre::Vector3 childPosition = pBone->getChild(i)->getPosition();
                        // If the length is zero, no point in creating the bone representation
                        float length = childPosition.length();
                        if(length < 0.00001f)
                            continue;

                        Ogre::Quaternion rotation = Ogre::Vector3::UNIT_Y.getRotationTo(
                            childPosition);

                        ent = sceneManager->createEntity(boneName);
                        ent->setCastShadows(false);
                        tp = entity->attachObjectToBone(
                            pBone->getName(),
                            (Ogre::MovableObject*)ent,
                            rotation);

                        const Ogre::Real modBoneSize =
                            boneSize + boneSize * length * 15.0f;

                        tp->setScale(modBoneSize, length, modBoneSize);
                    }
                }
            }

            ent = sceneManager->createEntity(axesName);
            ent->setCastShadows(false);
            tp = entity->attachObjectToBone(pBone->getName(), (Ogre::MovableObject*)ent);
            // Make sure we don't wind up with tiny/giant axes and that one axis doesnt get squashed
            tp->setScale(
                (axisSize/entity->getParentSceneNode()->getScale().x),
                (axisSize/entity->getParentSceneNode()->getScale().y),
                (axisSize/entity->getParentSceneNode()->getScale().z));
        }
    }

    if (enable)
    {
        ShowSkeletonDebug(entity);
    }
    else
    {
        HideSkeletonDebug(entity);
    }
}
开发者ID:Bewolf2,项目名称:LearningGameAI,代码行数:99,代码来源:SkeletonDebug.cpp


注:本文中的ogre::Bone::getChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。