Mayavi - 鼠标悬停交互 & 不同视角绘制同一场景

Mayavi - Mouse hovering interaction & plot same scene from different perspectives

我目前正在努力了解如何以适当的方式与 mayavi 渲染的场景进行交互。

我有一个激光雷达点云,它由函数 points3d() 绘制,现在我在点云之间另外设置了一个围绕汽车的边界框,我想更改点的颜色只要我将鼠标悬停在边界框上,就会在框内。 你能告诉我如何 select bbox 内的点并改变它们的颜色吗?

我的第二个问题是,如何同时在 3d 视图和鸟瞰图中显示相同的点云场景?

非常感谢:]

我找到了关于颜色问题的解决方案 - 我不知道这是否是最佳做法。但我仍然需要帮助来确定边界框内的点。我还想创建一个 gui,使用户能够修改边界框的大小和方向。 [但那是另一个话题]

import numpy as np
from mayavi.mlab import draw, points3d
from tvtk.api import tvtk

# Primitives
N = 3000 # Number of points
ones = np.ones(N) #np.hstack((np.tile(np.array([1]), int(N/2)).T,  np.tile(np.array([4000]),  int(N/2)).T))
scalars = ones #np.arange(N)  # Key point: set an integer for each point

# Define color table (including alpha), which must be uint8 and [0,255]
colors = np.vstack((np.tile(np.array([[255],[255],[0]]), int(N/2)).T,  np.tile(np.array([[0],[0],[255]]),  int(N/2)).T))
# Define coordinates and points
x, y, z = (np.random.random((N, 3))*255).astype(np.uint8).T # Assign x, y, z values to match color
pts = points3d(x, y, z, scale_factor=10) # Create points
#pts.glyph.color_mode = 'color_by_vector' # Color by scalar
# Set look-up table and redraw
#pts.module_manager.scalar_lut_manager.lut.table = colors
pts.glyph.scale_mode = 'scale_by_vector'
sc=tvtk.UnsignedCharArray()
sc.from_array(colors)
pts.mlab_source.dataset.point_data.scalars = sc
draw()