Esempio n. 1
0
    //p* as in physics*
    bool PhysicsModelManager::onAgentLinkedToModel(Agent *agent, ModelId pmid)
    {
        Ogre::String intro = logName() + "::onLinked(): ";

        PhysicsModel *pmodel = at(pmid);
#ifdef DEBUG
        assert(agent->modelId(ModelType::PHYSICS) == pmid);
        assert(agent->model(ModelType::PHYSICS) == pmodel);
#endif

        ModelId omid = agent->ogreModelId();

        if(INVALID_ID == omid)
        {
            Debug::error(intro)("Invalid OgreModel id for agent ")(agent->id()).endl();
            return false;
        }

        OgreModel *omodel = mLevel->ogreModelMan()->at(omid);
        pmodel->init(mWorld, omodel);
        pmodel->setUserPointer(agent);

        // stop the physics simulation in case the agent is selected
        pmodel->setSelected(agent->isSelected());

        return true;
    }