下面的顶点中,有纹理坐标,该坐标是在Blender中进行UV贴图后获得的.在纹理坐标之后,有索引.它们是连接顶点的顺序,该顺序决定了多维数据集的绘制顺序.最后,还有法线用于灯光效果. 在Blender中导出时,请确保仅突出显示以下内容: 上下文:所有场景 输出选项:三角剖分,材质,UV,法线,HQ 混合器对象为OBJ :对象这为您提供了两个文件: OBJ 和 MTL MTL包含纹理图像信息,OBJ包含: 顶点,其形式为:v x,y,z v x,y,z 纹理坐标,格式为:vt x,y vt x,y 索引,格式为:f i/j k/l m/n f i/j k/l m/n 成功获取导出的OBJ和MTL文件后,将它们与纹理图像一起添加到项目中,并使用OpenGLOBJLoader类在iOS中进行渲染.I am told that for a simple cube I need 36 vertices when I want to have colors/textures etc. for OpenGL ES application but when I export the colored cube to OBJ format using Blender, I only get 8 vertices and also I don't even get color data in the OBJ not to mention I only get 8 normals in OBJ file but I need normal for each vertex in each triangle ( a total of 36 normals). This is what I get as the content of the OBJ file for a cube that has been colored with different colors on all the faces:# Blender v2.56 (sub 0) OBJ File: ''# www.blender.orgmtllib untitled.mtlo Cubev 1.000000 1.000000 -1.000000v 1.000000 -1.000000 -1.000000v -1.000000 -1.000000 -1.000000v -1.000000 1.000000 -1.000000v 1.000000 0.999999 1.000000v 0.999999 -1.000001 1.000000v -1.000000 -1.000000 1.000000v -1.000000 1.000000 1.000000vn 0.666646 0.666646 0.333323vn 0.408246 0.408246 -0.816492vn -0.408246 0.816492 -0.408246vn -0.666646 0.333323 0.666646vn -0.577349 -0.577349 -0.577349vn -0.577349 -0.577349 0.577349vn 0.816492 -0.408246 -0.408246vn 0.333323 -0.666646 0.666646usemtl Materials 1f 5//1 1//2 4//3f 5//1 4//3 8//4f 3//5 7//6 8//4f 3//5 8//4 4//3f 2//7 6//8 3//5f 6//8 7//6 3//5f 1//2 5//1 2//7f 5//1 6//8 2//7f 5//1 8//4 6//8f 8//4 7//6 6//8f 1//2 2//7 3//5f 1//2 3//5 4//3This is the content of MTL file:# Blender MTL File: ''# Material Count: 1newmtl MaterialNs 96.078431Ka 0.000000 0.000000 0.000000Kd 0.640000 0.640000 0.640000Ks 0.500000 0.500000 0.500000Ni 1.000000d 1.000000illum 2 解决方案 36 vertices for a cube is not right. Possible but unnecessary.A vertex is a kind of coordinate in space, consisting of 3 parameters, x, y, z. As a cube has 8 corners then there should be 8 vertices only.Following vertices, there are texture coordinates which is obtained after UV mapping in Blender.After texture coordinates, there are indices. They are the order of connecting vertices which determines in what order your cube is drawn.And at last, there are normals for lighting effects.While exporting in Blender, make sure you highlight only those:Context:all scenesOutput Options:triangulate, materials, UVs, normals, HQBlender objects as OBJ:objectsThis gives you two files: OBJ and MTLMTL contains texture image info and OBJ contains:vertices in form of:v x, y, zv x, y, ztexture coordinates in form of:vt x, yvt x, yindices in form of:f i/j k/l m/nf i/j k/l m/nAfter you successfully get your exported OBJ and MTL files, add them to your project with the texture image and use OpenGLOBJLoader class to render them in iOS. 这篇关于如何从DCC工具(例如Blender)中的OBJ文件中获取适当数量的顶点,以用于OpenGL ES?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-21 07:57