[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):
随机推荐
- C#利用反射实现两个类的对象之间相同属性的值的复制
http://blog.csdn.net/u013093547/article/details/53584591 今天在拷贝对象的时候,看着代码实在是有点烦,一堆一样的代码,还是找找有没有直接反射拷贝 ...
- A - ACM Rank Table
ACM contests, like the one you are participating in, are hosted by the special software. That softwa ...
- Web(一)
Tomcat 服务器 B/S 浏览器/服务器 C/S 客户端/服务器 URI :大 广 /项目名 URL: 小 http://lo ...
- ERP项目实施记录01
工厂8月中与某ERP服务商签约,至今已经过去4个月,顾问服务了13人天,进行了10次培训. 内部产生项目文档1个:物料编码方案 制度:0个 流程:无 因ERP服务商不是针对本行业的,在BOM和生产计划 ...
- JQuery登录代码
$(function () { $("#login").submit(function(event) { event.preventDefault(); if ($("# ...
- 洛谷P1182 数列分段【二分】【贪心】
题目:https://www.luogu.org/problemnew/show/P1182 题意: 有n个数,要分成连续的m段.将每段中的数相加,问之和的最大值的最小值是多少. 思路: 和P1316 ...
- Codeforces 1132D - Stressful Training - [二分+贪心+优先队列]
题目链接:https://codeforces.com/contest/1132/problem/D 题意: 有 $n$ 个学生,他们的电脑有初始电量 $a[1 \sim n]$,他们的电脑每分钟会耗 ...
- Exception 06 : org.hibernate.NonUniqueObjectException: A different object with the same identifier value was already associated with the session :
异常名称: org.hibernate.NonUniqueObjectException: A different object with the same identifier value was ...
- Ubuntu16.04开机蓝屏问题解决
写在前面:本博客为本人原创,严禁任何形式的转载!本博客只允许放在博客园(.cnblogs.com),如果您在其他网站看到这篇博文,请通过下面这个唯一的合法链接转到原文! 本博客全网唯一合法URL:ht ...
- Chap3:区块链的衍生技术[《区块链中文词典》维京&甲子]