简体   繁体   English

Android OpenGL:将一个对象的质心移动到另一个复杂对象的特定点

[英]Android OpenGL: Moving the centroid of one object to a specific point on another complex object

I'm developing a medical app that involves android OpenGL for some data visualization. 我正在开发一个涉及Android OpenGL的医疗应用程序,用于一些数据可视化。 In my app, I have a complex brain object (with some 80000 vertices) and a small sphere. 在我的应用中,我有一个复杂的大脑对象(约有80000个顶点)和一个小球体。 I'm trying to figure out a way where I can move the centroid of that sphere to one of the vertices on the brain. 我试图找出一种方法,可以将该球的质心移动到大脑的一个顶点上。

The way I see it, this can be broken down into two problems (both of which I don't have great solutions to). 从我的角度来看,这可以分为两个问题(我都没有很好的解决方案)。 The first problem is determining which vertex I want to move the sphere to. 第一个问题是确定要将球体移动到哪个顶点。 Ideally, it would be great if I could simply touch a location on the brain and select the closest vertex that way. 理想情况下,如果我可以简单地触摸大脑上的某个位置并以这种方式选择最接近的顶点,那就太好了。 I've tried converting window coordinates to world coordinates using glUnProject unsuccessfully. 我尝试使用glUnProject将窗口坐标转换为世界坐标失败。 Another idea I had was to simply take my camera's location, and find the closest vertex to the camera. 我的另一个想法是简单地获取相机的位置,并找到与相机最接近的顶点。

The 2nd problem is determining how to move the sphere to that vertex. 第二个问题是确定如何将球体移动到该顶点。 This is the part that I thought I had sound logic, but it isn't working correctly. 这是我以为我有合理的逻辑的部分,但工作不正常。 I have the sphere's initial position. 我有球体的初始位置。 When the user touches the brain (for my first attempt described earlier) or moves the camera (for my second attempt described earlier), I basically iterated through all the vertices of the brain, and using the distance formula, found the vertex with the minimum distance from my either my touch location or my camera. 当用户触摸大脑(对于前面所述的第一次尝试)或移动摄像头(对于前面所述的第二次尝试)时,我基本上遍历了大脑的所有顶点,并使用距离公式,找到了顶点最小的那个顶点。距我的触摸位置或相机的距离。 I saved this vertex and then proceeded to translate the sphere. 我保存了该顶点,然后继续平移球体。 Basically, my translation involved taking the new vertex, subtracting the sphere's current position, and translating the sphere by that amount. 基本上,我的翻译涉及获取新顶点,减去球体的当前位置,然后以该量平移球体。 I'd then save the new current position of the sphere as the new vertex's position. 然后,我将球体的新当前位置保存为新顶点的位置。

For me, the biggest headscratcher from this all is that my sphere doesn't translate to any points on the brain. 对我而言,最大的难题是我的领域不会转化为大脑的任何点。 It moves when I tell it to, and generally in the right direction, but it's centroid doesn't sit on any of the vertices 当我告诉它时,它通常会朝正确的方向移动,但它的质心不在任何顶点上

So all in all, these are my 2 big questions: 总而言之,这是我的两个大问题:

  1. For my 1st problem, does anyone have any opinions on which might be a better way of picking a vertex (which one is easier or more efficient?). 对于我的第一个问题,是否有人会认为哪种方法是选择顶点的更好方法(哪种方法更容易或更有效?)。 If someone thinks the 1st way is better, are there in depth tutorials on the parameters of glUnProject? 如果有人认为第一种方法更好,是否有关于glUnProject参数的深入教程? I'm having trouble understanding the "view" parameter. 我在理解“视图”参数时遇到了麻烦。
  2. For my 2nd problem, is there anything wrong with my logic? 对于第二个问题,我的逻辑有什么问题吗? Once I find a vertex, i just perform a linear translation on the sphere and it should move to that new vertex, correct? 一旦找到顶点,我就在球上执行线性平移,它应该移至该新顶点,对吗?

没关系,原来比例因子在我的代码中丢失了,我没有应用它们,现在这些点位于正确的位置。

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

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