让等距离顶点的球 [英] Make a sphere with equidistant vertices

查看:143
本文介绍了让等距离顶点的球的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使光线的球形爆裂检查碰撞的目的,但其基于什么,或者每个射线命中特异性相互作用发生。因此为什么我使用光线而不是简单的东西,如 OverlapSphere

I'm trying to make a spherical burst of rays for the purpose of checking collision, but having specific interactions happen based upon what or where each ray hit. Hence why I'm using rays rather then something simpler such as OverlapSphere.

我在寻找如何使球体是因为我可以使用相同的数学对我的光线,通过让他们去哪里的球会是顶点的原因。但是,每一个方式,我可以找到制作领域具有线接近的接近极点,这是有道理的,因为它的pretty容易做到的。但是,正如你可以想像,它不是用我的当前项目。

The reason I'm looking for how to make a sphere is because I can use the same math for my rays, by having them go to the vertices of where the sphere would be. But every way I can find for making a sphere has the lines get closer the near to the poles, which makes sense, as its pretty easy to do. But as you can imagine, its not that useful for my current project.

TL; DR:
我如何用等距顶点的球?如果它不是的非常的等距离其优良的,它只是需要pretty接近。如果发生这种情况,这将是巨大的,如果你能给的差异将是多少,在哪里(如果适用)。

TL;DR: How do I make a sphere with equidistant vertices? If its not perfectly equidistant its fine, it just needs to pretty close. If this happens, it would be great if you could give how much the difference would be, and where, if applicable.

附加说明:
我看着并的这个,但数学的办法的在我的头上,所以我所一直在寻找可能刚刚被这整个时间盯着我的脸。

Extra notes: I've looked at this and this, but the math is way over my head, so what I've been looking for might've just been staring me in the face this whole time.

推荐答案

您知道,由Unity 的其实是在设计

Are you aware that the sphere given to you by Unity is in fact designed

即内置到Unity球的整个存在的理由是,点是相当顺利的空间......距离大致相等,因为你句话吧。

ie, the entire raison d'etre of the sphere built-in to Unity is that the points are fairly smoothly space ...... roughly equidistant, as you phrase it.

在这里输入的形象描述

要打开这样一个球体团结,只是这样做:

To bring up such a sphere in Unity, just do this:

在这里输入的形象描述

您可以然后瞬间访问该绿党,你知道

You can then instantly get access to the verts, as you know

Mesh mesh = GetComponent<MeshFilter>().mesh;
Vector3[] vv = mesh.vertices;
int kVerts=vv.Length
for (int i=0; i<kVerts; ++i)
  Debug.Log ... vv[i] 

请注意,你可以很容易地检查的球体的一部分,他们是由(例如)检查他们从你的城市有多远(或其他),或只检查(例如)z值这半球他们在..等等。

Note you can easily check "which part of the sphere" they are on by (for example) checking how far they are from your "cities" (or whatever) or just check (for example) the z values to see which hemisphere they are in .. et cetera.

请注意。至于为希望做你的整体原因:

Please note. Regarding your overall reason for wanting to do this:

但有基于特异性相互作用发生什么,或在每个射线命中

but having specific interactions happen based upon what or where each ray hit

请注意,它不能更容易做到这一点使用PhysX物理。 (这家完全内置在Unity游戏物理)。事实上,我已经永远,永远,看着没有做具体根据一些碰撞在那里打了!

Note that it could not be easier to do this using PhysX. (The completely built-in game physics in Unity.) Indeed, I have never, ever, looked at a collision without doing something "specific" depending on "where it hit!"

例如,您可以得到在接触与 HTTP点://文档。 unity3d.com/ScriptReference/RaycastHit-point.html

You can for example get the point where the contact was with http://docs.unity3d.com/ScriptReference/RaycastHit-point.html

值得注意的是绝对不可想象的人能写的东西逼近轻松编程PhysX物理性能。

It's worth noting it is absolutely inconceivable one could write something approaching the performance of PhysX in casual programming.

我希望这是事情变得更容易!

I hope this makes things easier!

这篇关于让等距离顶点的球的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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