Go to the documentation of this file.
32 #include <QMouseEvent>
33 #include <QWheelEvent>
34 #include <QApplication>
35 #include <QVBoxLayout>
37 #include <OgreCamera.h>
38 #include <OgreSceneNode.h>
44 , left_mouse_down_(false)
45 , middle_mouse_down_(false)
46 , right_mouse_down_(false)
55 #if (OGRE_VERSION < OGRE_VERSION_CHECK(13, 0, 0))
58 scene_manager_ =
root_->createSceneManager(Ogre::DefaultSceneManagerFactory::FACTORY_TYPE_NAME,
66 QVBoxLayout* layout =
new QVBoxLayout;
67 layout->setContentsMargins(0, 0, 0, 0);
78 Ogre::Light* directional_light =
scene_manager_->createLight(
"MainDirectional");
79 directional_light->setType(Ogre::Light::LT_DIRECTIONAL);
80 directional_light->setDirection(Ogre::Vector3(0, -1, 1));
81 directional_light->setDiffuseColour(Ogre::ColourValue(1.0
f, 1.0
f, 1.0
f));
90 for (
int i = -50; i < 50; ++i )
92 line->
addPoint( Ogre::Vector3( i*2, 0.0
f, -1.0
f ) );
95 for (
int i = 0; i < 5; ++i )
97 line->
addPoint( Ogre::Vector3( 4.0
f, 0.0
f, i ) );
131 Ogre::SceneNode* scene_node =
scene_manager_->getRootSceneNode()->createChildSceneNode();
139 std::vector<PointCloud::Point> points;
140 int32_t xcount = 200;
141 int32_t ycount = 100;
142 int32_t zcount = 100;
145 for (int32_t x = 0; x < xcount; ++x)
147 for (int32_t y = 0; y < ycount; ++y)
149 for (int32_t z = 0; z < zcount; ++z)
157 point.
setColor(x * 0.1, y * 0.1, z * 0.1);
158 points.push_back(point);
163 printf(
"size: %d\n", (
int)points.size());
164 pointCloud->
addPoints(&points.front(), points.size());
165 scene_node->attachObject(pointCloud);
168 catch (Ogre::Exception& e)
170 printf(
"Fatal error: %s\n", e.what());
185 root_->renderOneFrame();
187 printf(
"Render took [%f] msec\n", (end -
start).toSec() * 1000.0
f);
196 switch (event->button())
201 case Qt::MiddleButton:
204 case Qt::RightButton:
214 switch (event->button())
219 case Qt::MiddleButton:
222 case Qt::RightButton:
232 int32_t diff_x =
event->x() -
mouse_x_;
233 int32_t diff_y =
event->y() -
mouse_y_;
238 bool cmd =
event->modifiers() & Qt::ControlModifier;
239 bool shift =
event->modifiers() & Qt::ShiftModifier;
240 bool alt =
event->modifiers() & Qt::AltModifier;
258 if (event->angleDelta().y() != 0)
260 bool cmd =
event->modifiers() & Qt::ControlModifier;
261 bool shift =
event->modifiers() & Qt::ShiftModifier;
262 bool alt =
event->modifiers() & Qt::AltModifier;
268 int main(
int argc,
char** argv)
270 QApplication
app(argc, argv);
273 frame.resize(800, 600);
274 frame.setWindowTitle(
"I hope this is not all black.");
A visual representation of a set of points.
An orbital camera, controlled by yaw, pitch, distance, and focal point.
An object that displays a multi-segment line strip rendered as billboards.
Ogre::Camera * getOgreCamera()
Get the Ogre camera associated with this camera object.
void setLineWidth(float width)
virtual void setPosition(const Ogre::Vector3 &position)
Set the position of the camera.
int main(int argc, char **argv)
void setAlpha(float alpha, bool per_point_alpha=false)
void setColor(float r, float g, float b, float a) override
Set the color of the object. Values are in the range [0, 1].
An arrow consisting of a cylinder and a cone.
void addPoints(Point *points, uint32_t num_points)
Add points to this point cloud.
void setOrientation(const Ogre::Quaternion &orientation) override
Set the orientation.
RenderSystem * render_system_
QtOgreRenderWindow * render_panel_
virtual void mouseLeftDrag(int diff_x, int diff_y, bool ctrl, bool alt, bool shift)=0
Handle a left mouse button drag.
void mouseReleaseEvent(QMouseEvent *event) override
virtual void mouseRightDrag(int diff_x, int diff_y, bool ctrl, bool alt, bool shift)=0
Handle a right mouse button drag.
void setMaxPointsPerLine(uint32_t max)
virtual void mouseMiddleDrag(int diff_x, int diff_y, bool ctrl, bool alt, bool shift)=0
Handle a middle mouse button drag.
Representation of a point, with x/y/z position and r/g/b color.
void setHeadColor(float r, float g, float b, float a=1.0f)
Set the color of the arrow's head. Values are in the range [0, 1].
MyFrame(QWidget *parent=nullptr)
void setHeight(uint32_t count)
void mouseMoveEvent(QMouseEvent *event) override
void mousePressEvent(QMouseEvent *event) override
void setColor(float r, float g, float b, float a=1.0)
void setBackgroundColor(Ogre::ColourValue color)
void setDimensions(float width, float height, float depth)
Set the dimensions of the billboards used to render each point.
An object that displays a set of X/Y/Z axes, with X=Red, Y=Green, Z=Blue.
Displays a grid of cells, drawn with lines.
void setRenderMode(RenderMode mode)
Set what type of rendering primitives should be used, currently points, billboards and boxes are supp...
void setShaftColor(float r, float g, float b, float a=1.0f)
Set the color of the arrow's shaft. Values are in the range [0, 1].
void setCamera(Ogre::Camera *camera)
void wheelEvent(QWheelEvent *event) override
Ogre::SceneManager * scene_manager_
void setAutoRender(bool auto_render)
virtual void scrollWheel(int diff, bool ctrl, bool alt, bool shift)=0
Handle a scrollwheel change.
void setPosition(const Ogre::Vector3 &position) override
Set the position of this object.
void setCommonDirection(const Ogre::Vector3 &vec)
See Ogre::BillboardSet::setCommonDirection.
void setColor(float r, float g, float b, float a) override
Set the color of the object. Values are in the range [0, 1].
void setCommonUpVector(const Ogre::Vector3 &vec)
See Ogre::BillboardSet::setCommonUpVector.
void addPoint(const Ogre::Vector3 &point)
rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Dec 13 2024 03:31:02