예제 #1
0
Viewpoint AutoCPSensing::current_viewpoint() {
  geometry_msgs::Quaternion orientation = ToGeometryMsgsQuaternion(
      camera_->getOrientation());
  geometry_msgs::Point position = ToGeometryMsgsPoint(camera_->getPosition());
  geometry_msgs::Point focus;
  QuaternionToFocus(orientation, position, &focus);
  return Viewpoint(ToOgreVector3(position), ToOgreVector3(focus));
}
void EC_OgreMovableTextOverlay::SetOffset(const Vector3df& offset)
{
    if (!node_)
        return;

    node_->setPosition(ToOgreVector3(offset));
}
예제 #3
0
 void EC_OgreLight::SetDirection(const Vector3df& direction)
 {
     light_->setDirection(ToOgreVector3(direction));
 }
void EC_OgreMovableTextOverlay::CreateOverlay(const Vector3df& offset)
{
    if (renderer_.expired())
        return;

    // Return if already created
    if (node_)
        return;

    // Create SceneNode
    Ogre::SceneManager *scene_mgr = renderer_.lock()->GetSceneManager();
    node_ = scene_mgr->createSceneNode();

    // Set the node position to an user-specified offset
    node_->setPosition(ToOgreVector3(offset));

    // Overlay
    overlayName_ = renderer_.lock()->GetUniqueObjectName();
    overlay_ = Ogre::OverlayManager::getSingleton().create(overlayName_);

    // Container
    containerName_ = renderer_.lock()->GetUniqueObjectName();
    container_ = static_cast<Ogre::OverlayContainer*>
        (Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", containerName_));
    overlay_->add2D(container_);

    // Font
    ///\todo user-defined font
    std::string fontName = "Console";
    Ogre::FontManager::getSingleton().load(fontName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    font_ = (Ogre::Font*)Ogre::FontManager::getSingleton().getByName(fontName).getPointer();
    font_->setParameter("size", "16");

    // Overlay text
    text_element_ = checked_static_cast<Ogre::TextAreaOverlayElement*>
        (Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", overlayName_));
//        text_element_ = Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", "shapeNameText");
    text_element_->setDimensions(0.8, 0.8);
    text_element_->setMetricsMode(Ogre::GMM_PIXELS);
    text_element_->setPosition(1, 2);
    text_element_->setParameter("font_name", fontName);
    text_element_->setParameter("char_height", font_->getParameter("size"));
//        text_element_->setCharHeight(0.035f);
    text_element_->setParameter("horz_align", "left");
    fontColor_ = Color(0, 0, 0, 1);
    text_element_->setColour(Ogre::ColourValue::Black);
    container_->addChild(text_element_);

    if(text_ != "")
    {
        textDim_ = GetTextDimensions(text_);
        container_->setDimensions(textDim_.x, textDim_.y);
    }

    SetMaterial("BlueTransparent"/*baseMaterialName_*/);

    if (visible_)
        overlay_->show();
    else
        overlay_->hide();

    overlay_->setZOrder(100);
}