[QGLViewer]3D场景鼠标点击位置
2017-05-10 10:55
363 查看
重载鼠标事件:
重载绘制方法
效果:
void AxMapControl::mousePressEvent(QMouseEvent* e) { switch(currentTool) { case AX_DRAW_DIRECTION: { if (e->button() == Qt::LeftButton) { QPoint screenPt=e->pos(); qglviewer::Vec orig1, dir1; camera()->convertClickToLine(screenPt, orig1, dir1); double valueZ=0; double a = ( valueZ- orig1.z) / dir1.z; Pnt.z = valueZ; Pnt.x = orig1.x + dir1.x * a; Pnt.y = orig1.y + dir1.y * a; //QMessageBox::information(this, "PickPoint", QString::number(Pnt.x) + "," + QString::number(Pnt.y)); } break; } } QGLViewer::mousePressEvent(e); }
重载绘制方法
void AxMapControl::draw() { if (pimpl->points.size()>0) { QMutexLocker locker(&pimpl->mutex_); glColor3f(255/255.0, 69/255.0, 0.0); draw_3d_points(pimpl->points); } if (pimpl->pointCloudOneFrame.size()>0) { QMutexLocker locker(&pimpl->mutex_); glColor3f(255/255.0, 69/255.0, 0.0); for (vector<Point3ds>::const_iterator it = pimpl->pointCloudOneFrame.begin();it != pimpl->pointCloudOneFrame.end(); ++it) { const Point3ds& p = *it; if (p.size()>0) { draw_3d_points(p); } } } if (!glImg.isNull()) { glNormal3f(0.0, 0.0, 1.0); glBegin(GL_QUADS); glTexCoord2f(0.0, 1.0-v_max); glVertex2f(-u_max*ratio,-v_max); glTexCoord2f(0.0, 1.0); glVertex2f(-u_max*ratio, v_max); glTexCoord2f(u_max, 1.0); glVertex2f( u_max*ratio, v_max); glTexCoord2f(u_max, 1.0-v_max); glVertex2f( u_max*ratio,-v_max); glEnd(); } if (currentTool==AX_DRAW_DIRECTION) { glBegin(GL_LINES); glColor3f(255/255.0, 0/255.0, 0.0); glVertex3fv(currentPose); glVertex3fv(Pnt); glEnd(); }
效果:
相关文章推荐
- 【Unity 3D学习】鼠标点击控制人物移动到目标位置
- UGUI--------UI以及3D物体显示在鼠标点击位置
- 场景中创建N(两个以上)个物体,鼠标可以选中任何物体,当鼠标选中为非地面时,选中的物体变为红色,之前选中的物体恢复为之前的颜色,鼠标点击到地面时,让之前选中的那个物体移动的当前点击的位置
- DevExpress PopMenu 如何在鼠标点击的位置显示右键菜单
- WPF 3D 获取鼠标在场景的3d坐标
- Unity中获取鼠标位置,且点击鼠标右键则在点击位置显示物体
- (原)python中matplot中获得鼠标点击的位置及显示灰度图像
- 虚幻UE4 添加窗口小部件3D---无需点击运行(Play)即可改变场景中游戏物体的形状
- 获取鼠标点击的屏幕位置坐标
- js获取鼠标点击的位置实现思路及代码
- 点击事件获取鼠标坐标位置(x,y)值
- js获取鼠标点击的位置-火狐IE兼容
- U6数据导出工具项目总结三 鼠标单击或者双击DataGridView控件时获取鼠标点击位置的值
- mfc/vc slider control控件 鼠标左键点击后直接滑到点击的位置
- [JavaScript]获取鼠标点击区域的相对、绝对位置坐标
- 点击 鼠标 图片跟着鼠标的位置
- 获取鼠标点击的位置
- 把小人移动到鼠标点击的位置
- NGUI点击按钮时如何屏蔽场景鼠标事件
- JS获取页面鼠标点击位置的坐标