本文整理汇总了Python中mesh.Mesh.setPositions方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.setPositions方法的具体用法?Python Mesh.setPositions怎么用?Python Mesh.setPositions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mesh.Mesh
的用法示例。
在下文中一共展示了Mesh.setPositions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import setPositions [as 别名]
class ImagePlane:
## Constructor
def __init__(self, image):
self._image = to32F(image)
self._geometry = Mesh()
self._initGeometry()
def mesh(self):
return self._geometry
def gl(self):
self._geometry.gl()
def boundingBox(self):
return self._geometry.boundingBox()
def setDepth(self, D_32F):
D_flat = D_32F.ravel()
self._points[:, 2] = D_flat
self._geometry.setPositions(self._points)
@timing_func
def _initPoints(self, h, w):
ys = np.linspace(h-1, 0, h)
xs = np.linspace(0, w-1, w)
px, py = np.meshgrid(xs, ys, sparse=False)
px = px.ravel()
py = py.ravel()
pz = np.zeros(len(py))
return np.array([px, py, pz]).T
@timing_func
def _initIndexArray(self, h, w):
ys = np.arange(h - 1)
xs = np.arange(w - 1)
fx, fy = np.meshgrid(xs, ys, sparse=False)
fx = fx.ravel()
fy = fy.ravel()
f1 = w * fy + fx
f2 = f1 + 1
f3 = f2 + w
f4 = f3 - 1
return np.array([f1, f2, f3, f4]).T
@timing_func
def _initGeometry(self):
h, w = self._image.shape[:2]
self._points = self._initPoints(h, w)
colors = self._image.reshape(-1, self._image.shape[2])
index_array = self._initIndexArray(h, w)
self._geometry.setPositions(self._points)
self._geometry.setVertexColors(colors)
self._geometry.setInexArray(index_array)