コード例 #1
0
ファイル: scObjectMgr.cpp プロジェクト: Mystler/Lemuria
void scObjectMgr::processScene(SceneManager *sceneMgr) {
    //iterate through the Nodes
    SceneNode *scRootNode = sceneMgr->getRootSceneNode();
    Node::ChildNodeIterator itSceneObject = scRootNode->getChildIterator();
    while(itSceneObject.hasMoreElements()) {
        //get Node
        Node *node = itSceneObject.getNext();

        //get the Name
        String scObjectName = node->getName();
        if(StringUtil::startsWith(scObjectName, "pho_")) {
            //create Physics
            Entity *ent = sceneMgr->getEntity(scObjectName);
            Vector3 pos = node->getPosition();
            Quaternion rot = node->getOrientation();

            BtOgre::StaticMeshToShapeConverter conv(ent);
            btCollisionShape *shape = conv.createTrimesh();
            btDefaultMotionState *state = new btDefaultMotionState(btTransform(BtOgre::Convert::toBullet(rot),
                    BtOgre::Convert::toBullet(pos)));
            btRigidBody *body = new btRigidBody(0, state, shape, btVector3(0, 0, 0));
            phBullet::getInstance().getWorld()->addRigidBody(body);
            phBullet::getInstance().addShape(shape);
            phBullet::getInstance().addBody(body);
        }
    }
}
コード例 #2
0
    //-------------------------------------------------------------------------
    void SkeletonInstance::cloneBoneAndChildren(Bone* source, Bone* parent)
    {
        Bone* newBone;
        if (source->getName().empty())
        {
            newBone = createBone(source->getHandle());
        }
        else
        {
            newBone = createBone(source->getName(), source->getHandle());
        }
        if (parent == NULL)
        {
            mRootBones.push_back(newBone);
        }
        else
        {
            parent->addChild(newBone);
        }
        newBone->setOrientation(source->getOrientation());
        newBone->setPosition(source->getPosition());
        newBone->setScale(source->getScale());

        // Process children
        Node::ChildNodeIterator it = source->getChildIterator();
        while (it.hasMoreElements())
        {
            cloneBoneAndChildren(static_cast<Bone*>(it.getNext()), newBone);
        }
    }
コード例 #3
0
  void RendererSystemComponent::LinkSkeletons(Ogre::SceneNode* sceneNode, RendererSystemComponent::SkeletonList* skeletons)
  {
    SceneNode::ObjectIterator objects = sceneNode->getAttachedObjectIterator();

    while(objects.hasMoreElements())
    {
      MovableObject* object = objects.getNext();

      if(object->getMovableType() == EntityFactory::FACTORY_TYPE_NAME)
      {
        Entity* entity = m_scene->GetSceneManager()->getEntity(object->getName());

        if (entity->hasSkeleton())
        {
          Ogre::Skeleton::BoneIterator boneIterator = entity->getSkeleton()->getBoneIterator();

          while(boneIterator.hasMoreElements())
          {
            Ogre::Bone* oBone = boneIterator.getNext();
            oBone->setManuallyControlled(true);

            /*Entity *axis = m_scene->GetSceneManager()->createEntity(oBone->getName() + "_axis", "/data/entities/meshes/axes.mesh");
            TagPoint* tagPoint = entity->attachObjectToBone(oBone->getName(), axis);
            tagPoint->setScale(0.005f, 0.005f, 0.005f);*/
          }

          skeletons->push_back(entity->getSkeleton());
        }
      }
    }

    Node::ChildNodeIterator children = sceneNode->getChildIterator();

    while(children.hasMoreElements())
    {
      SceneNode* child = static_cast<SceneNode*>(children.getNext());
      this->LinkSkeletons(child, skeletons);
    }
  }