[英]Labeling parts of 3D model with Android and OpenGL ES/Rajawali
I have imported a model (eg a teapot) using Rajawali into my scene. 我已将使用Rajawali的模型(例如茶壶)导入场景。 What I would like is to label parts of the model (eg the lid, body, foot, handle and the spout) using plain Android views, but I have no idea how this could be achieved.
我想使用简单的Android视图标记模型的各个部分(例如,盖子,身体,脚,手柄和壶嘴),但我不知道如何实现。 Specifically, positioning the labels on the right place seems challenging.
具体来说,将标签放置在正确的位置似乎具有挑战性。 The idea is that when I transform my model's position in the scene, the tips of the labels are still correctly positioned
想法是,当我变换模型在场景中的位置时,标签的尖端仍正确定位
Rajawali tutorial show how Android views can be placed on top of the scene here https://github.com/Rajawali/Rajawali/wiki/Tutorial-08-Adding-User-Interface-Elements . Rajawali教程在https://github.com/Rajawali/Rajawali/wiki/Tutorial-08-Adding-User-Interface-Elements处展示了如何将Android视图放置在场景顶部。 I also understand how using the transformation matrices a 3D coordinate on the model can be transformed into a 2D coordinate on the screen, but I have no idea how to determine the exact 3D coordinates on the model itself.
我也了解如何使用转换矩阵将模型上的3D坐标转换为屏幕上的2D坐标,但是我不知道如何确定模型本身的确切3D坐标。 The model is exported to OBJ format using Blender, so I assume there is some clever way of determining the coordinates in Blender and exporting them to a separate file or include them somehow in the OBJ file (but not render those points, only include them as metadata), but I have no idea how I could do that.
使用Blender将模型导出为OBJ格式,因此,我认为有一些聪明的方法可以在Blender中确定坐标并将其导出到单独的文件中,或者以某种方式将其包括在OBJ文件中(但不渲染这些点,仅将它们包括为元数据),但我不知道该怎么做。
Any ideas are very appreciated! 任何想法都非常感谢! :)
:)
I would use a screenquad, not a view. 我会使用screenquad,而不是视图。 This is a general GL solution, and will also work with iOS.
这是一般的GL解决方案,也可以在iOS上使用。
You must determine the indices of the desired model vertices. 您必须确定所需模型顶点的索引。 Using the text rendering algo below, you can just fiddle them until you hit the right ones.
使用下面的文本渲染算法,您可以摆弄它们直到找到正确的。
The performance bottleneck is #7 since the entire bitmap must be copied to GL texture memory, every frame. 性能瓶颈是#7,因为必须将每个位图的整个位图都复制到GL纹理内存中。 Try to keep the bitmap as small as possible, maintaining aspect ratio.
尝试保持位图尽可能小,并保持宽高比。 Maybe let the user toggle the labels.
也许让用户切换标签。
Note that the copy to GL texture memory is redundant since in OpenGL-ES, GL memory is just regular memory. 请注意,复制到GL纹理内存是多余的,因为在OpenGL-ES中,GL内存只是常规内存。 For compatibility reasons, a redundant chunk of regular memory is reserved to artificially enforce the copy.
出于兼容性原因,保留了常规内存的冗余块以人为地强制执行副本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.