为正方形计算法线 [英] Computing normals for squares

查看:199
本文介绍了为正方形计算法线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我已经从一个JSON文件(每个瓦/ W大量的bool的高度,坡度,平整,存储等)加载的模型。然后,我计算面法线为所有它的脸部,并将其复制到每个他们verticies的。我现在想要做的(一直试图日)是平滑的顶点法线,在可能的最简单的方法。我想要做的是设置每个顶点垂直于它归之和周边的面法线。现在,我的问题是这样的:

I've got a model that I've loaded from a JSON file (stored as each tile /w lots of bools for height, slope, smooth, etc.). I've then computed face normals for all of it's faces and copied them to each of their verticies. What I now want to do (have been trying for days) is to smooth the vertex normals, in the simplest way possible. What I'm trying to do is set each vertex normal to a normalized sum of it's surrounding face normals. Now, my problem is this:

这两个圆圈的顶点应该结束了完美的镜像法线。但是,一个在左边有2个光面孔和4黑暗的面孔。在一个在右边有1个光的脸和6暗面。因此,他们都结了完全不同的法线。

The two circled vertices should end up with perfectly mirrored normals. However, the one on the left has 2 light faces and 4 dark faces. The one on the right has 1 light face and 6 dark faces. As such, they both end up with completely different normals.

我不能工作是如何正确地做到这一点。怎么面对我应该总结?也许有,我应该使用一个完全不同的方法?我所有的努力,到目前为止已拿出垃圾和/或由数百个(几乎可以肯定没有意义的)特殊情况的。

What I can't work out is how to do this properly. What faces should I be summing up? Or perhaps there is a completely different method I should be using? All of my attempts so far have come up with junk and / or consisted of hundreds of (almost certainly pointless) special cases.

感谢您的任何意见,詹姆斯

Thanks for any advice, James

编辑:其实,我只是要试试何去何从的思考。只会增加基础上每个三角形的百分比的角度工作(如果是有道理的)。我的意思是,对于左,顺时针:×1/8,×1/8,×1/4,1/8,×1/8,×1/4 ??? 然后不归呢?

Actually, I just had a thought about what to try next. Would only adding a percentage of each triangle based on it's angle work (if that makes sense). I mean, for the left, clockwise: x1/8, x1/8, x1/4, x1/8, x1/8, x1/4 ??? And then not normalize it?

这是解决方案,表现的很出色。最终结果是:

That solution worked wonderfully. Final result:

推荐答案

根据它看起来像你可能要采取一切的平均图像上的唯一的所有相邻面的法线。这样就避免了重复计算面临着相同的标准。

Based on the image it looks like you might want to take the average of all unique normals of all adjacent faces. This avoids double counting faces with the same normal.

这篇关于为正方形计算法线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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