将立方体变形为球体 [英] morphing a cube into sphere

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

问题描述

这是来自Apple文档的图像.它们显示了从立方体到球体以及一些随机几何体的变换.

This is an image from apple's documentation. They show a transform from a cube to sphere and also to some random geometry.

它们只声明了以下几行:

Only a few lines lower they state:

可以从场景文件或 以编程方式创建.基本几何和所有目标几何 必须在拓扑上相同-也就是说,它们必须包含相同的拓扑 顶点的数量和结构排列.

A morpher and its target geometries may be loaded from a scene file or created programmatically. The base geometry and all target geometries must be topologically identical—that is, they must contain the same number and structural arrangement of vertices.

有人可以解释这一段,因为显然我听不懂. 由于球体永远不会具有与立方体相同的顶点结构排列(至少我认为如此),因此无法进行变换.但是,嘿,我们都在图片中看到了.我也尝试过进行转换,但没有得到预期的结果.那么,如何从球面变为立方体,反之亦然?

Could someone explain this paragraph because apparently I don't understand it. Since a sphere will never have the same structural arrangement of vertices as cube(at least I think so), it is impossible to make transformation. But hey, we all see it in the picture. I also tried do to the transformation and I don't get the expected results. So how do you go from sphere to cube or vice versa?

推荐答案

拓扑相同"是指必须保留网格中顶点之间的关系,但它们在空间中的位置可以更改.这是2D模式的示例:

"Topologically identical" means that the relationships between vertices in a mesh must be preserved, but their locations in space can change. Here's an example of that in 2D:

这两个网格具有相同的八个顶点,它们以相同的方式彼此连接,但是它们的位置(因此它们形成的形状)也不同.

These two meshes have the same eight vertices, connected to each other in the same ways, but their positions (and thus the shape they form) differ.

要使用SceneKit在3D中执行相同的操作,您需要自定义顶点数据-SceneKit可以为您生成的基本形状(例如SCNSphereSCNBox等)都具有不同的拓扑,因此它们不能用作变体目标.

To do the same in 3D with SceneKit, you need custom vertex data — the primitive shapes that SceneKit can generate for you (like SCNSphere, SCNBox, and whatnot) all have different topologies, so they can't be used as morpher targets.

如果要将框变形为球体,则需要生成具有相同拓扑的自己的框和球体. Apple图示中的某种随机形状"暗示了您可能会如何执行-它似乎是超椭球.如果在该Wikipedia页面中使用方程式,则可以生成一组点,这些点可以在球体或立方体上,具体取决于其他参数.更改这些参数以生成几个网格,从这些网格创建SCNGeometry,您将获得有效的SCNMorpher目标.

If you want to morph a box into a sphere, you'll need to generate your own box and sphere with identical topology. The "some random shape" in Apple's illustration is a hint at how you might do that — it appears to be one of the variants of a superellipsoid. If you use the equations in that Wikipedia page you can generate a set of points that can be either on a sphere or on a cube depending on other parameters. Vary those parameters to generate a couple of meshes, create SCNGeometry from those meshes, and you've got valid SCNMorpher targets.

您可以在Apple的

You can see a simpler example of morphing in Apple's SceneKit WWDC 2014 Slides sample app.

这篇关于将立方体变形为球体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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