简体   繁体   English

如何将3D对象表面平坦化为2D阵列?

[英]How to flatten 3D object surface into 2D array?

I've got 3D objects which are represented as numpy arrays. 我有3D对象,表示为numpy数组。 How can I unfold the "surface" of such objects to get a 2D map of values (I don't care about inner values)? 如何展开此类对象的“表面”以获得值的二维图(我不在乎内部值)?

It's similar to unwrapping globe surface, but the shape is varied from case to case. 它类似于展开地球仪的表面,但形状因情况而异。 在此处输入图片说明

This is a vertices problem. 这是一个顶点问题。 Each triangle on the model is a flat surface that can be mapped to a 2D plane. 模型上的每个三角形都是可以映射到2D平面的平面。 So the most naive solution without any assumed structure would be to: 因此,没有任何假定结构的最幼稚的解决方案是:

for triangle in mesh:
    // project to plane defined by normal to avoid stretching

This solution is not ideal as it places all of the uv's on top of each other. 这种解决方案并不理想,因为它会将所有uv放在彼此的顶部。 The next step would be to spread out the triangles to fill a certain space. 下一步将散布三角形以填充一定的空间。 This is the layout stage that defines how the vertices are layed out in the 2D space. 这是布局阶段,用于定义如何在2D空间中对顶点进行布局。

Usually it is ideal to fit the UV's within a unit square. 通常,理想的是将UV放置在一个单位平方内。 This allows for easy UV mapping from a single image. 这允许从单个图像轻松进行UV映射。

Option: 2 选项:2

You surround the object with a known 2D mapped shape and project each triangle onto the shape based on its normal. 用已知的2D映射形状围绕对象,然后根据其法线将每个三角形投影到该形状上。 This provides a mechanism for unwrapping the uv's in a structured manor. 这提供了在结构化的庄园中展开uv的机制。 An example object would be to project onto a cube. 一个示例对象将是投影到多维数据集上。

Option: 3 选项:3

consult academic papers and opensource libraries/tools like blender: https://wiki.blender.org/index.php/Doc:2.4/Manual/Textures/Mapping/UV/Unwrapping 查阅学术论文和像Blender这样的开源库/工具: https ://wiki.blender.org/index.php/Doc:2.4/Manual/Textures/Mapping/UV/Unwrapping

blender uses methods as described above to unwrap arbitrary geometry. blender使用上述方法解开任意几何图形。 There are other methods to accomplish this as described on the blender unwrap page. 如搅拌器展开页面所述,还有其他方法可以完成此操作。 The nice thing about blender is that you can consult the source code for the implementation of the uv unwrap methods. Blender的好处是您可以参考源代码来实现uv unwrap方法。

Hope this is helpful. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM