[QGLViewer]3D场景鼠标点击位置
重载鼠标事件:
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();
}
效果:
[QGLViewer]3D场景鼠标点击位置的更多相关文章
- Unity 弹出界面时屏蔽对3D场景的点击
注:这里的UI制作用的是NGUI插件 如题,在游戏中经常会遇到这种情况,场景中点击相关物体或者按钮弹出对应的2D界面,这时候除了2D界面上的可点击按钮等,应该屏蔽掉对3D场景的点击或者拖动事件. 在这 ...
- js 获取页面高度和宽度(兼容 ie firefox chrome),获取鼠标点击位置
<script> //得到页面高度 var yScroll = (document.documentElement.scrollHeight >document.documentEl ...
- u3d 鼠标点击位置,物体移动过去。 U3d mouse clicks position, objects move past.
u3d 鼠标点击位置,物体移动过去. U3d mouse clicks position, objects move past. 作者:韩梦飞沙 Author:han_meng_fei_sha 邮箱: ...
- 每天一个JavaScript实例-铺货鼠标点击位置并将元素移动到该位置
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- (二)Three光线检测-实现摄像机向鼠标点击位置滑动动画
(二)Three.js光线检测 摘要:使用three.js中的光线检测 Raycaster() ,实现一下效果: 通过点击处的坐标,修改摄像机位置,实现摄像机由远及近的过渡动态效果(由远景到近景) 1 ...
- C# winform 获取鼠标点击位置
说明:该篇随笔的代码内容并非出自本人,是在其他网站搜寻的,出处已经不记得了,本次随笔只为记录,目的帮助自己,帮助他人. 实现的原理也不做多的赘述,直接上代码. 第一个类是需要用到的Windows AP ...
- 3D场景鼠标点选择物体
对于以下几种选择: (1)点云: (2)线框: (3)网格: 针对以上准备三个函数: (1)获取点和线段最短距离函数: (2)获取线段和线段最短距离函数: (3)获取三角面片和线段最短距离函数: 算法 ...
- (原)python中matplot中获得鼠标点击的位置及显示灰度图像
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6182474.html 参考网址: http://matplotlib.org/examples/pyl ...
- 获取鼠标点击相对于Canva位置的2种方法
如果给Canvas添加 onmousedown事件,获取到的鼠标位置都是相对于当前文档的位置(x,y):
随机推荐
- 【代码审计】XYHCMS V3.5任意文件删除漏洞分析
0x00 环境准备 XYHCMS官网:http://www.xyhcms.com/ 网站源码版本:XYHCMS V3.5(2017-12-04 更新) 程序源码下载:http://www.xyhc ...
- 《Python3网络爬虫开发实战》
推荐:★ ★ ★ ★ ★ 第1章 开发环境配置 第2章 网页基础知识 第3章 网络爬虫基础 第4章 基本库的使用 第5章 解析库的使用 第6章 数据存储 第7章 Ajax数据爬取 第8章 动态渲染页面 ...
- File /hbase/.tmp/hbase.version could only be replicated to 0 nodes instead of minReplication (=1).
File /hbase/.tmp/hbase.version could only be replicated to 0 nodes instead of minReplication (=1). 这 ...
- 除了/etc/init.d/加启动脚本 或者在/etc/rc.local中加启动命令,还可以通过crontab来完成服务器重启后自动启动服务的操作
@reboot /bin/sh /opt/soft/percona/bin/mysqld_safe --defaults-file=/mnt/perconadata/my.cnf --basedir= ...
- C# 数组转json
////////试题信息///////////////// // 已知 // h.d两个数组分别表示表头和内容 // 要求 // 编写函数一:rs2Array // 返回一个数组,每一项为一个对象. ...
- F - Toy Storage
来源poj 2398 Mom and dad have a problem: their child, Reza, never puts his toys away when he is finish ...
- Nginx高级配置,同1台机器部署多个tomcat、配置多个域名,每个域名指向某一个tomcat下的项目,共用Nginx80端口访问;
需求说明: 只有一台服务器和一个公网IP,多个项目部署在这台机器上面,且每个项目使用一个单独的域名访问,域名访问时都通过Nginx的80端口访问.(如下图所示) 配置过程: 一.tomcat的serv ...
- window.history.go(-1)返回且刷新页面 点击返回上一层
windows窗口对象(历史)history.go(),history.back(),history.forward(). 因为windows对象引用不是必须的.所以windows.history.g ...
- .NET Core开发日志——Action
在叙述Controller一文中,有一处未做解释,即CreateControllerFactory方法中ControllerActionDescriptor参数是如何产生的.这是因为其与Action的 ...
- ubuntu下能ping通ssh不通的解决思路
1.首先看看是否能ping通,如果ping不通可能就要考虑网线.路由等问题了: 2.看防火墙是否关闭,sshd是否开启 3.ssh -v 服务器的ip号,根据提示寻找可能的问题: 我的问题在这一步之后 ...