36 vi->setViewportPosition(0.7, 0.05, 0.28, 0.28);
37 vi->setCloneView(
"main");
38 vi->setTransparent(
true);
39 vi->getCamera().setAzimuthDegrees(45);
40 vi->getCamera().setElevationDegrees(45);
41 vi->getCamera().setZoomDistance(10);
48 mrpt::make_aligned_shared<opengl::CGridPlaneXY>(
49 -20, 20, -20, 20, 0, 1);
50 obj->setColor(0.4, 0.4, 0.4);
51 theScene->insert(
obj);
57 obj->enableTickMarks();
58 obj->setAxisLimits(-10, -10, -10, 10, 10, 10);
59 theScene->insert(
obj);
64 obj->setWireframe(
false);
65 obj->setColor(1, 0, 0);
66 obj->setLineWidth(3.0);
68 theScene->insert(
obj);
73 obj->setColor(0, 0, 1);
75 obj->setLocation(0, 0, 1);
76 obj->setName(
"ball_1");
77 theScene->insert(
obj);
81 obj->setColor(1, 0, 0);
83 obj->setLocation(-1, -1, 1);
84 obj->setName(
"ball_2");
85 theScene->insert(
obj);
90 obj->setColor(0, 1, 0);
92 obj->setLocation(0, 0, 0);
93 obj->setName(
"USER_MOUSE_PICK");
94 theScene->insert(
obj);
98 win.unlockAccess3DScene();
100 win.captureImagesStart();
103 win.addTextMessage(0.05, 0.05,
"This is a 2D message");
105 win.setCameraElevationDeg(25.0f);
109 cout <<
"Control with mouse or keyboard. Valid keys:" << endl;
110 cout <<
" ESC -> Exit" << endl;
111 cout <<
" Left/right cursor arrow -> Camera azimuth" << endl;
116 while (!
end &&
win.isOpen())
123 obj1->getPoseX() + cos(obj1->getPoseY() / 2) * 0.05,
124 obj1->getPoseY() - sin(obj1->getPoseX() / 2) * 0.09,
125 obj1->getPoseZ() - sin(obj1->getPoseX() / 2) * 0.08);
127 obj1 = theScene->getByName(
"ball_2");
129 obj1->getPoseX() + cos(obj1->getPoseY() / 2) * 0.05,
130 obj1->getPoseY() - sin(obj1->getPoseX() / 2) * 0.09,
131 obj1->getPoseZ() - sin(obj1->getPoseX() / 2) * 0.08);
135 "ball#1 pos: %.02f %.02f %.02f ", obj1->getPoseX(),
136 obj1->getPoseY(), obj1->getPoseZ()),
143 win.unlockAccess3DScene();
147 std::this_thread::sleep_for(10ms);
154 const string s =
format(
"GRAB_%06i.png", ++i);
156 printf(
"Saved frame image to: %s \r",
s.c_str());
167 int key =
win.getPushedKey(&kmods);
169 "Key pushed: %c (%i) - modifiers: 0x%04X\n",
char(key), key,
175 win.setCameraAzimuthDeg(
win.getCameraAzimuthDeg() + 5);
177 win.setCameraAzimuthDeg(
win.getCameraAzimuthDeg() - 5);
193 catch (std::exception& e)
195 std::cout <<
"MRPT exception caught: " << e.what() << std::endl;
200 printf(
"Untyped exception!!");