如何使所有三角形受到光线或一组光线的影响? [英] How to get all triangles affected by light or by a set of rays?

查看:192
本文介绍了如何使所有三角形受到光线或一组光线的影响?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我在一个航空测绘应用程序中工作,该应用程序试图确定从航空摄影机查看地形的哪一部分.首先,我从现有的.tif文件中渲染了DEM(数字高程模型),并通过.tif位置和值生成了网格的所有三角形.我找到了使用RayMeshGeometry3DHitTestResult的解决方案,并从相机发送了不同的光线.问题是性能非常低,因为命中测试需要重复数千次并且变得太慢:


Hi Everyone!

I´m working in an aerial mapping application which tries to determine what part of the terrain is viewed from an aerial camera. First I have rendered DEM (Digital Elevation Model) from existing .tif file, generating all the triangles of the mesh by .tif positions and values. I found a solution using RayMeshGeometry3DHitTestResult, and sending different rays from the camera. The problem is that performance is very low because the hit test needs to be repeated thousands of times and it becomes too slow:


private static RayMeshGeometry3DHitTestResult rayHit;
       public static RayMeshGeometry3DHitTestResult SurfaceRayHit(Point3D p, Vector3D v)
       {
           RayHitTestParameters hitParams = new RayHitTestParameters(p,v);
           VisualTreeHelper.HitTest(App.AppDemModel, null, new HitTestResultCallback(MainDemHitPoint), hitParams);
           return rayHit;
       }

       public static HitTestResultBehavior MainDemHitPoint(HitTestResult result)
       {

           if (result.VisualHit == App.AppDemModel)
           {
               rayHit = (RayMeshGeometry3DHitTestResult)result;
               //rList.Add(hit);
               return HitTestResultBehavior.Stop;
           }


           return HitTestResultBehavior.Continue;
       }



我尝试过的事情:

我认为它必须由ViewPort3D(在我的情况下为HelixViewport)在内部实现,因为灯光仅照射Geometry3D中的某些三角形,但是我找不到找到受光照影响的三角形(顶点)列表的方法.

在此先感谢您,所有帮助将不胜感激.



What I have tried:

I think it must be internally implemented by ViewPort3D (HelixViewport in my case) since lights are hitting only certain triangles in a Geometry3D, but I couldn´t find a way to obtain the list of triangles(Vertices) affected by light.

Thanks in advance, any help will be really apreciated.

推荐答案

有很多关于该主题或相关主题的研究论文,并使用了几种策略.最常见的方法之一是细分网格并检查每个划分.通常,这是通过将网格划分为四分之一,然后对每个四分之一进行一次命中检查,然后对命中的部分重复该过程,这意味着将每个网格划分为四分之一并测试每个.
另一种方法是先确定相机正在查看的区域,而不是光线跟踪方法.然后,您可以仅检查三角形是否在该区域中.也可以使用细分.如果保留这些数据,则以四边形形式检查网格可能会更容易.

如果您通过计算向量的大小来使用距离检查,则可以执行一项简单的性能优化操作,因此不必计算平方根,因为它通常是很慢的操作.您可以比较幅度的平方(无平方根),并更快地获得相同的结果.仅在需要实际距离且不需要比较时才取平方根.
There are tons of research papers written on this topic or relatives of it and there are several tactics used. One of the most common is subdividing the mesh and checking each division. Generally this is done by dividing the mesh in quarters and doing a hit check on each quarter and then for the sections hit, repeat the process which means dividing each of them in quarters and testing each of those.

Another way is to determine the area being viewed by camera first instead of the ray tracing method. Then you can just check if triangles are in that region. Subdivision can be used also. It might be easier to check the mesh in its quadrilateral form, if you keep that data around.

If you use distance checking by computing the magnitude of a vector one easy performance optimization you can do there is don''t compute the square root because it is usually a slow operation. You can compare the square of the magnitude (without the square root) and get the same results quicker. Only take the square root when you need the actual distance and for comparison purposes you do not need it.


这篇关于如何使所有三角形受到光线或一组光线的影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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