##

Projector.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GAZEBO_RENDERING_PROJECTOR_HH_
#define GAZEBO_RENDERING_PROJECTOR_HH_
#include <string>
#include <map>
#include <list>
#include <ignition/math/Pose3.hh>
#include <sdf/sdf.hh>
#include <ignition/transport/Node.hh>
#include "gazebo/rendering/ogre_gazebo.h"
#include "gazebo/msgs/msgs.hh"
#include "gazebo/transport/transport.hh"
#include "gazebo/rendering/RenderTypes.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace rendering
{
class GZ_RENDERING_VISIBLE Projector
{
public: explicit Projector(VisualPtr _parent);
public: virtual ~Projector();
public: void Load(sdf::ElementPtr _sdf);
public: void Load(const msgs::Projector &_msg);
public: void Load(const std::string &_name,
const ignition::math::Pose3d &_pose =
ignition::math::Pose3d::Zero,
const std::string &_textureName = "",
const double _nearClip = 0.25,
const double _farClip = 15.0,
const double _fov = IGN_PI * 0.25);
public: void SetTexture(const std::string &_textureName);
public: void Toggle();
public: VisualPtr GetParent();
public: void SetEnabled(bool _enabled);
private: void OnMsg(ConstProjectorPtr &_msg);
private: VisualPtr visual;
private: transport::NodePtr node;
private: transport::SubscriberPtr controlSub;
private: class ProjectorFrameListener : public Ogre::FrameListener
{
public: ProjectorFrameListener();
public: virtual ~ProjectorFrameListener();
public: void Init(VisualPtr _visual,
const std::string &_textureName,
double _near = 0.5,
double _far = 10,
double _fov = 0.785398163);
public: virtual bool frameStarted(const Ogre::FrameEvent &_evt);
public: void SetTexture(const std::string &_textureName);
public: void SetEnabled(bool _enabled);
public: void SetUsingShaders(bool _usingShaders);
public: void SetPose(const ignition::math::Pose3d &_pose);
private: void SetSceneNode();
private: void SetFrustumClipDistance(double _near, double _far);
private: void SetFrustumFOV(double _fov);
private: void AddPassToAllMaterials();
private: void AddPassToVisibleMaterials();
private: void AddPassToMaterials(std::list<std::string> &_matList);
private: void AddPassToMaterial(const std::string &_matName);
private: void RemovePassFromMaterials();
private: void RemovePassFromMaterial(const std::string &_matName);
public: bool enabled;
public: bool initialized;
private: bool usingShaders;
private: std::string nodeName;
private: std::string filterNodeName;
private: std::string textureName;
private: Ogre::Frustum *frustum;
private: Ogre::Frustum *filterFrustum;
private: Ogre::PlaneBoundedVolumeListSceneQuery *projectorQuery;
private: VisualPtr visual;
private: Ogre::SceneNode *node;
private: Ogre::SceneNode *filterNode;
private: Ogre::SceneManager *sceneMgr;
private: std::map<std::string, Ogre::Pass*> projectorTargets;
};
private: ProjectorFrameListener projector;
// Place ignition::transport objects at the end of this file to
// guarantee they are destructed first.
private: ignition::transport::Node nodeIgn;
};
}
}
#endif
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::rendering::Projector::GetParent
VisualPtr GetParent()
Get the parent visual.
system.hh
msgs.hh
gazebo::transport::SubscriberPtr
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
gazebo::transport::NodePtr
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
RenderTypes.hh
rendering
rendering
Definition: RenderEngine.hh:31
gazebo::rendering::Projector::SetEnabled
void SetEnabled(bool _enabled)
Set whether the projector is enabled or disabled.
ogre_gazebo.h
gazebo::msgs::Init
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
gazebo::rendering::Projector::Load
void Load(sdf::ElementPtr _sdf)
Load from an sdf pointer.
gazebo::rendering::Projector::Projector
Projector(VisualPtr _parent)
Constructor.
gazebo::rendering::Projector
Projects a material onto surface, light a light projector.
Definition: Projector.hh:44
gazebo::rendering::VisualPtr
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:114
gazebo::rendering::Projector::SetTexture
void SetTexture(const std::string &_textureName)
Load a texture into the projector.
gazebo::rendering::Projector::Toggle
void Toggle()
Toggle the activation of the projector.
gazebo::rendering::Projector::~Projector
virtual ~Projector()
Destructor.