在 3d 视图中实现操作手柄的方法 [英] Ways to implement manipulation handles in 3d view

查看:20
本文介绍了在 3d 视图中实现操作手柄的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个简单的实体建模应用程序.用户需要能够在正交视图和透视视图中操作对象.例如,当屏幕上有一个框并且用户点击它来选择它时,它需要在角落和中心获得手柄",以便用户可以将鼠标移动到这样的手柄上并将其拖动到放大或移动框.

I'm building a simple solid modeling application. Users need to be able to manipulate object in both orthogonal and perspective views. For example, when there's a box in the screen and the user clicks on it to select it, it needs to get 'handles' at the corners and in the center so that the user can move the mouse over such a handle and drag it to enlarge or move the box.

有哪些策略可以做到这一点,哪一种是最好的?我能想到两个明显的:

What strategies are there to do this, and which one is the best one? I can think of two obvious ones:

1) 将手柄视为 3d 对象.IE.对于盒子,在主"盒子的角落添加小盒子到场景中.问题:这在透视图中不起作用,我需要确定相对于当前缩放级别的框的大小(无论用户放大/缩小多远,手柄都需要具有相同的大小)

1) Treat the handles as 3d objects. I.e. for a box, add small boxes to the scene at the corners of the 'main' box. Problems: this won't work in perspective view, I'd need to determine the size of the boxes relative to the current zoom level (the handles need to have the same size no matter how far the user is zoomed in/out)

2) 在场景渲染后添加手柄.渲染到屏幕外缓冲区,以某种方式确定角落的 2d 位置,并使用常规的 2d 绘图技术绘制手柄.问题:我将如何进行命中测试?我还需要做一个两阶段的测试方法;如何在 3d 渲染图像上绘制 2d 图像?回退到 GDI?

2) Add the handles after the scene has been rendered. Render to an offscreen buffer, determine the 2d locations of the corners somehow and use regular 2d drawing techniques to draw the handles. Problems: how will I do hittesting? I'd need to do a two-stage hittesting approach, as well; how do I draw in 2d on a 3d rendered image? Fall back to GDI?

这两种方法可能存在更多问题.是否有解决此问题的行业标准方法?

There are probably more problems with both approaches. Is there an industry-standard way of tackling this problem?

我正在使用 OpenGL,如果这有区别的话.

I'm using OpenGL, if that makes a difference.

推荐答案

我会将手柄视为 3D 对象.这提供了许多优点 - 它更一致,它们表现良好,命中测试很容易等.

I would treat the handles as 3D objects. This provides many advantages - it's more consistant, they behave well, hit testing is easy, etc.

如果您希望手柄保持恒定大小,您仍然可以将它们视为 3D 对象,但您必须根据到相机的距离适当地缩放它们的大小.这有点麻烦,但由于通常只有几个句柄,而且这些通常是小对象,因此在性能方面应该是不错的.

If you want the handles to be a constant size, you can still treat them as 3D objects, but you will have to scale their size as appropriate based off the distance to camera. This is a bit of a hassle, but since there are typically only a few handles, and these are usually small objects, it should be fine performance wise.

但是,我实际上会说让手柄随场景缩放.只要您为手柄选择一种使它们脱颖而出的渲染样式(即:亮橙色框等),透视效果(背景中较小的手柄)实际上使最终用户在许多方面更容易使用它们.很难从 3D 场景中获得深度感 - 手柄上的透视效果有助于提供更多关于手柄进入屏幕深度"的视觉线索.

However, I'd actually say let the handles scale with the scene. As long as you pick a rendering style for the handle that makes them stand out (ie: bright orange boxes, etc), the perspective effects (smaller handles in the background) actually makes working with them easier for the end-user in many ways. It is difficult to get a sense of depth from a 3D scene - the perspective effects on the handles help provide more visual clues as to how "deep" the handle is into the screen.

这篇关于在 3d 视图中实现操作手柄的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆