蔚蓝 发表于 2016-11-23 23:29:48

关于 物体动画显示运动位置的问题

我给一个物体添加了一个动画用channel 添加的,现在想实时的获取这个物体的位置坐标,并且显示 。我的思路是获取这个对象的包围球 但是获取这个包围球的中心坐标 但是我在回调显示坐标的时候这个坐标不是动态变化的 一直都只显示他的初始坐标 是怎么回事呢?或者有没有其他的办法?

bool Rh_posPoint::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa){

        switch (ea.getEventType()){
        case(osgGA::GUIEventAdapter::FRAME):{
        osg::BoundingSphere sp = m_model->getBound();
        m_pos = sp.center();
        std::cout << m_pos << std::endl;
        UpdateText();
                        return true;
                }
        default :
                return false;
       
        }

}

void Rh_posPoint::UpdateText(){

        std::string g = "";
        std::ostringstream os;
        os << "X:" << m_pos << "Y:" << m_pos;
        g = os.str();
        if (m_text.get())
        {
                m_text->setText(g);
        }

页: [1]
查看完整版本: 关于 物体动画显示运动位置的问题