我想在android上绘制一个地球地球仪.此时我需要UV纹理坐标的帮助.我正在使用这个地球纹理(kibotu.net/earth.jpg).目前它看起来像这个正面(kibotu.net/earthsphere.png),但90°旋转它看起来像这样(kibotu.net/earthsphere2.png).
由于OpenGL ES不支持Quadrics,并且它没有原生GLUT库,我觉得它很难.所以也许有人遇到同样的问题,可以帮助我.
我的第一种方法是使用Blender并将其导出为OBJ文件并将其加载到我的应用程序中.然而,有两个副作用:完全奇怪的看起来正常(kibotu.net/sphere.png),最重要的是没有纹理坐标.
(我使用过这些Blender导出选项[kibotu.net/blenderobjoptions.png])
我的第二次尝试是使用freeglut库来完成这项工作.现在我有一个漂亮的球体(kibotu.net/sphere5.png).但是也没有纹理坐标.由于它的最后一个版本于2009年11月27日发布,我非常怀疑将很快发布更新.
所以在那之后我尝试应用wiki方法来计算球体uvs.但它看起来像这个kibotu.net/sphere2.png.我在这个问题之后搜索每个stackoverflow线程,并遇到了这种uv方法.然而,没有最终解决方案.我已将它应用于freeglut代码.
static private FloatBuffer sphereVertex;
static private FloatBuffer sphereNormal;
static private FloatBuffer sphereTexture;
static float sphere_parms[]=new float[3];
private static void plotSpherePoints(float radius, int stacks, int slices)
{
sphereVertex = OpenGLUtils.allocateFloatBuffer( 4* 6 * stacks * (slices+1) );
sphereNormal = OpenGLUtils.allocateFloatBuffer( 4* 6 * stacks * (slices+1) );
sphereTexture = OpenGLUtils.allocateFloatBuffer( 4* 4 * stacks * (slices+1) );
int i, j;
float slicestep, stackstep;
stackstep = ((float)Math.PI) / stacks; …Run Code Online (Sandbox Code Playgroud)