41 vi->setViewportPosition(0.7, 0.05, 0.28, 0.28);
42 vi->setCloneView(
"main");
43 vi->setTransparent(
true);
44 vi->getCamera().setAzimuthDegrees(45);
45 vi->getCamera().setElevationDegrees(45);
46 vi->getCamera().setZoomDistance(10);
52 vi->setViewportPosition(
56 vi->setCloneView(
"main");
57 vi->setTransparent(
false);
58 vi->getCamera().setAzimuthDegrees(-95);
59 vi->getCamera().setElevationDegrees(30);
60 vi->getCamera().setZoomDistance(8);
67 mrpt::make_aligned_shared<mrpt::opengl::CText>();
69 vi->setViewportPosition(0, 0, 0.3, 0.3);
70 vi->setTransparent(
true);
72 vi->getCamera().setAzimuthDegrees(0);
73 vi->getCamera().setElevationDegrees(90);
74 vi->getCamera().setZoomDistance(5);
75 vi->getCamera().setOrthogonal(
true);
84 mrpt::make_aligned_shared<opengl::CGridPlaneXY>(
85 -20, 20, -20, 20, 0, 1);
86 obj->setColor(0.8, 0.8, 0.8);
87 theScene->insert(
obj);
93 obj->enableTickMarks();
94 obj->setAxisLimits(-10, -10, -10, 10, 10, 10);
95 theScene->insert(
obj);
100 obj->setWireframe(
false);
101 obj->setColor(1, 0, 0);
102 obj->setLineWidth(3.0);
103 obj->setPose(
TPose3D(10, 0, 0, 0.2, 0.3, 0.1));
104 theScene->insert(
obj);
109 obj->setColor(0, 0, 1);
111 obj->setLocation(0, 0, 1);
112 obj->setName(
"ball_1");
113 theScene->insert(
obj);
117 obj->setColor(1, 0, 0);
119 obj->setLocation(-1, -1, 1);
120 obj->setName(
"ball_2");
121 theScene->insert(
obj);
126 obj->setColor(0, 1, 0);
128 obj->setLocation(0, 0, 0);
129 obj->setName(
"USER_MOUSE_PICK");
130 theScene->insert(
obj);
134 win.unlockAccess3DScene();
138 0.01, 0.85,
"This is a 2D message",
TColorf(1, 1, 1),
"sans", 11,
141 win.setCameraElevationDeg(25.0f);
145 cout <<
"Control with mouse or keyboard. Valid keys:" << endl;
146 cout <<
" ESC -> Exit" << endl;
147 cout <<
" Left/right cursor arrow -> Camera azimuth" << endl;
148 cout <<
" P -> Enable / disable 'place object' "
154 bool placeMode =
false;
159 while (!
end &&
win.isOpen())
161 const double t = timer.
Tac();
167 const double W1 = 5.0, Q1 = 3.3;
170 R1 * cos(W1 *
t) * sin(Q1 *
t), R1 * sin(W1 *
t),
171 R1 * cos(W1 *
t) * cos(Q1 *
t));
174 const double W2 = 1.3, Q2 = 7.2;
177 R2 * cos(W2 *
t) * sin(Q2 *
t), R2 * sin(W2 *
t),
178 R2 * cos(W2 *
t) * cos(Q2 *
t));
181 0.01, 0.85,
"This is a 2D message",
TColorf(1, 0, 0),
"sans", 8,
188 "ball#1 pos: %.02f %.02f %.02f ", obj1->getPoseX(),
189 obj1->getPoseY(), obj1->getPoseZ()),
190 TColorf(.8, .8, .8),
"sans", 14,
211 int mouse_x, mouse_y;
213 win.getLastMousePosition(
218 theScene->getViewport(
"main")->get3DRayForPixelCoord(
219 mouse_x, mouse_y, ray);
236 theScene->getByName(
"USER_MOUSE_PICK")
237 ->setLocation(inters_pt.
x, inters_pt.
y, inters_pt.
z);
242 win.unlockAccess3DScene();
246 std::this_thread::sleep_for(20ms);
252 int key =
win.getPushedKey(&kmods);
254 "Key pushed: %c (%i) - modifiers: 0x%04X\n",
char(key), key,
260 win.setCameraAzimuthDeg(
win.getCameraAzimuthDeg() + 5);
262 win.setCameraAzimuthDeg(
win.getCameraAzimuthDeg() - 5);
264 if (key ==
'p' || key ==
'P')
266 placeMode = !placeMode;
267 win.setCursorCross(placeMode);
284 catch (std::exception& e)
286 std::cout <<
"MRPT exception caught: " << e.what() << std::endl;
291 printf(
"Untyped exception!!");