我要发帖 回复

正式会员

10

主题

72

积分

0

专家分

:

私信
发表时间 : 2011-5-3 22:17:24 | 浏览 : 1934    评论 : 11
想要实现的功能, 鼠标移动时,在vega prime window中 在鼠标指针旁边显示当前鼠标坐标信息。 请高手指点!

最近VR访客查看更多↓

xdliutianqiao 评论于2011-5-4 01:44:34
同求
chouyutou0 评论于2011-5-4 23:15:32
谢谢楼主帮我问了个我研究了好久没有研究明白的问题.....
goudan090815 评论于2011-5-5 21:54:21
关键是显示问题,接触vp没多久,研究了一段时间,没搞定。web sample 里面的望远镜的例子 里面有显示字符串的,我也按照那个做法做了,关键是最后一步,vrString::draw(vrDrawContext),这个vrDrawContext 参数拿不到。例子里面这个参数是在vpChannel的notify函数参数里拿到的。但是我不是在vpchannel的notify里用。 是在鼠标的inputSourceFloat 的notify中使用。

也试着用vpWindow的getDrawContext(),但是结果没显示。不清楚怎么做,高手怎么不现身来?
csutest 评论于2011-5-6 09:05:00
看你怎么显示了。可以直接用opengl在post draw里面绘制,也可以叠加个对话框。
lin2418403 评论于2011-5-8 09:09:23
我也想知道
goudan090815 评论于2011-5-27 22:50:53
给个代码最好,呵呵
yinguohua889 评论于2011-5-28 10:59:18
我做过一个捕捉当前鼠标点击位置的例子,其实就是屏幕坐标系向世界坐标系转换的问题,大概是这样:
projInv.invert(channel->getVrChannel()->getProjectionMatrix());
projInv.transformPoint(&mouse);   这一步指的是获得此时屏幕矩阵并将鼠标点的坐标转出

channel->getVrChannel()->getOffsetMatrixInverse().transformPoint(&mouse);//这一步指的是从project到view的偏置等转换

channel->getVrChannel()->getViewMatrix().transformPoint(&mouse)  //这一步指的是转入世界坐标模式

这样就捕获了当前鼠标点击的世界坐标
hithyy 评论于2011-7-13 19:06:47
获取鼠标坐标,这个很不错
goudan090815 评论于2011-8-2 23:45:51
回复 yinguohua889 的帖子

可能理解有点偏差,坐标值我可以获取,但是在屏幕上显示不出来。
shuoyv 评论于2011-8-3 11:40:10
void CVpapp::notify(vsChannel::Event, const vsChannel *channel, vrDrawContext *context)
{
        context->pushElements(true);

        // need to disable the depth buffer since it's enabled by default
        vrDepthTest::Element depthTestElement;
        depthTestElement.m_enable = false;
        context->setElement(vrDepthTest::Element::Id, &depthTestElement);

        // set up an orthographic projection.  In this case we'll just map the
        // channel viewport to 0 to 1 both horizontally and vertically.
        vrTransform::ElementProjection projectionElement;
        projectionElement.makeOrthographic(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
        context->setElement(vrTransform::ElementProjection::Id,
                &projectionElement);


        vuString strText;
        vpObserver *pObserver = *vpObserver::begin();
        double x,y,z,h,p,r;
        pObserver->getTranslate(&x,&y,&z);
        pObserver->getRotate(&h,&p,&r);
        strText.sprintf("x:%.2f   y:%.2f   z:%.2f   h:%.2f   p:%.2f   r:%.2f",x,y,z,h,p,r);
        vuVec4<float> color(1.0f, 0.0f, 0.0f, 1.0f);
       
        m_font->displayStringAt(context, strText.c_str(), color, 0.01, 0.01);
        context->popElements();
}
舞天势专家组 评论于2013-7-23 10:21:14
请问,鼠标坐标值怎么获取啊?谢谢

手机版|VR开发网 统计 津ICP备18009691号
网安备12019202000257

GMT+8, 2023-11-30 07:27 PM

返回顶部