Пример #1
0
 Player::Player (MWRender::Player *renderer, const ESM::NPC *player, MWWorld::World& world) :
   mCellStore (0), mRenderer (renderer), mWorld (world), mClass (0), mCollisionMode (true)
 {
     mPlayer.base = player;
     mName = player->name;
     mMale = !(player->flags & ESM::NPC::Female);
     mRace = player->race;
     mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0;
     mClass = new ESM::Class (*world.getStore().classes.find (player->cls));
 }
Пример #2
0
std::pair<std::string, float> MWScene::getFacedHandle (MWWorld::World& world)
{
    std::string handle = "";
    float distance = -1;

    //get a ray pointing to the center of the viewport
    Ray centerRay = getCamera()->getCameraToViewportRay(
        getViewport()->getWidth()/2,
        getViewport()->getHeight()/2);

    // get all objects touched by the ray
    getRaySceneQuery()->setRay (centerRay );
    RaySceneQueryResult &result = getRaySceneQuery()->execute();

    RaySceneQueryResult::iterator nearest = result.end();

    for (RaySceneQueryResult::iterator itr = result.begin();
        itr != result.end(); itr++ )
    {
        // there seem to be omnipresent objects like the caelum sky dom,
        // the distance of these objects is always 0 so this if excludes these
        if ( itr->movable && itr->distance >= 0.1)
        {
            // horrible hack to exclude statics. this must be removed as soon as a replacement for the
            // AABB raycasting is implemented (we should not ignore statics)
            MWWorld::Ptr ptr = world.getPtrViaHandle (itr->movable->getParentSceneNode()->getName());
            if (ptr.getType()==typeid (ESM::Static))
                break;

            if ( nearest == result.end() )  //if no object is set
            {
                nearest = itr;
            }
            else if ( itr->distance < nearest->distance )
            {
                nearest = itr;
            }
        }
    }

    if ( nearest != result.end() )
    {
        handle = nearest->movable->getParentSceneNode()->getName();
        distance = nearest->distance;
    }

    return std::pair<std::string, float>(handle, distance);
}
Пример #3
0
    Player::Player (MWRender::Player *renderer, const ESM::NPC *player, MWWorld::World& world) :
      mCellStore (0), mRenderer (renderer), mWorld (world), mClass (0),
      mAutoMove (false), mForwardBackward (0)
    {
        mPlayer.base = player;
        mPlayer.ref.refID = "player";
        mName = player->name;
        mMale = !(player->flags & ESM::NPC::Female);
        mRace = player->race;

        float* playerPos = mPlayer.mData.getPosition().pos;
        playerPos[0] = playerPos[1] = playerPos[2] = 0;

        mPlayer.mData.setBaseNode(renderer->getNode());
        /// \todo Do not make a copy of classes defined in esm/p records.
        mClass = new ESM::Class (*world.getStore().classes.find (player->cls));
    }