3D 图形选择 - 这种情况的最佳方法是什么 [英] 3D Graphics Picking - What is the best approach for this scenario

查看:22
本文介绍了3D 图形选择 - 这种情况的最佳方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开展一个项目,该项目允许用户在场景中选择 3d 对象,我想知道每个人都认为什么是处理这种特定场景的最佳方式.

I am working on a project which allows users to pick 3d objects in a scene and I was wondering what everyone thought would be the best way to approach this particular scenario.

基本上,我们有一个包含至少 100 个对象(它们是低多边形但由至少约 12-15 个三角形组成)和多达大约 1000-2000 个对象的场景.

Basically we have a scene with at least 100 objects (they are low-poly but made from at least ~12-15 triangles) and up to about 1000-2000 objects.

并非所有对象都始终是可拾取的",因为有些对象会遮挡其他对象,因此可拾取"的对象可能落在 800-1500 之间(取决于场景的复杂性).

Not all the objects will be "pickable" at all times because some objects will occlude others so "pickable" objects probably land in the range between 800-1500 (depending on the complexity of the scene).

当一个对象被选择"时,我们希望它以某种方式突出显示,所以这意味着以不同的方式渲染它,这是微不足道的,但我们希望不仅在单击时而且在拖动时完成选择 - 这意味着我们想要在短时间内大量运行拣选算法.理想情况下,用户会在仍处于拖动"操作中的对象看到突出显示的对象 -(意味着可能应该异步完成拾取,以免延迟主渲染?).

When an object is "picked" we want it to be highlighted in some way so this means rendering it differently, this is trivial but we want picking to be done not only on single clicks but also drags - which means we want to run the picking algorithm a lot in a short space of time. Ideally the user would see objects highlighted while they were still in a "drag" operation - (meaning the picking should probably be done asynchronously as to not lag the main rendering?).

我尝试过简单的光线追踪拾取,但这显然很慢,因为我们遍历场景中的所有三角形以找到对象.

I have tried simple ray trace picking but this is obviously quite slow as we loop through all triangles in the scene to find the object.

我也尝试过基于 GPU 的拾取 - 使用像素缓冲区渲染场景,为每个对象提供独特的颜色,但通过拖动操作,这意味着多次渲染和 GPU 到 CPU 的数据传输没有很好的性能.

I have also tried GPU-based picking - rendering the scene using a pixelbuffer that gives a unique color to each object but with the dragging operation this means multiple renders and GPU-to-CPU data transfer which doesn't have great performance.

我是否可以探索其他任何可能性来尝试获得我想要的性能和功能?

Are there any other possibilities I could explore to try and get the performance and functionality I want?

感谢您的时间.

推荐答案

我以前用过 八叉树 来处理这种事情,它似乎是我最好的选择.每个对象都可以放置在相应的节点中,并通过通常的八叉树协议进行测试.真正的好处来自当当前节点为空时将光线投射到空间节点的末尾.这肯定会给您带来比蛮力强制的显着收益.

I have used an Octree before for this sort of thing and it seemed to be my best option. Every object can be placed in the corresponding node and tested through the usual Octree protocol. The real benefits come from offsetting the ray cast to the end of a spatial node when the current node is empty. This will surely give you significant gains over brute-forcing it.

以下链接应为您提供 八叉树 的基础及其设置方式:八叉树介绍

The following link should give you a base with Octree's and how it is set up: Introduction to Octrees

虽然链接只是给你一个基础,八叉树的使用只是为了减少必要的检查,所以从你的问题来看,你似乎已经掌握了执行实际操作所需的知识采摘.

While the link is only giving you a base, the use of the Octree is simply for reducing necessary checks, so judging by your question, you seem to already have the knowledge required to perform the actual picking.

这篇关于3D 图形选择 - 这种情况的最佳方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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