3D图形采摘 - 什么是这种情况的最佳方法这种情况、图形、方法

2023-09-08 10:43:55 作者:雾气环绕

我工作的一个项目,它允许用户挑选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的采摘 - 使用pixelbuffer,给出了一个独特的颜色,以每一个对象,但随着拖动操作,这意味着多个渲染和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.