ehhhh
大家好我尝试了在搅拌机中制成的加载UV质感。在搅拌机中还可以图装好,材料装好。但是纹理问题..我不知道错误的原因是cos im在纹理3d中是新的。(始终仅对opengl使用2d quad。
这里是我的简单多维数据集的obj文件
# Blender v2.72 (sub 0) OBJ File: '' # www.blender.org mtllib ncube.mtl o Cube v 1.000000 -1.000000 -1.000000 v 1.000000 -1.000000 1.000000 v -1.000000 -1.000000 1.000000 v -1.000000 -1.000000 -1.000000 v 1.000000 1.000000 -0.999999 v 0.999999 1.000000 1.000001 v -1.000000 1.000000 1.000000 v -1.000000 1.000000 -1.000000 vt 0.000100 0.250000 vt 0.250000 0.250000 vt 0.250000 0.499900 vt 0.499900 0.499900 vt 0.499900 0.250000 vt 0.749800 0.250000 vt 0.250000 0.750000 vt 0.250000 0.999900 vt 0.000100 0.999900 vt 0.250000 0.000100 vt 0.499900 0.000100 vt 0.250000 0.749800 vt 0.000100 0.499900 vt 0.749800 0.499900 vt 0.000100 0.750000 vt 0.499900 0.749800 usemtl Material s off f 2/1 3/2 4/3 f 8/4 7/5 6/6 f 1/7 5/8 6/9 f 2/10 6/11 7/5 f 7/5 8/4 4/3 f 1/12 4/3 8/4 f 1/13 2/1 4/3 f 5/14 8/4 6/6 f 2/15 1/7 6/9 f 3/2 2/10 7/5 f 3/2 7/5 4/3 f 5/16 1/12 8/4
对于opengl,我以错误的方式修复了cos面,因此我解析时修复为f = f-1。如果不减去我没有得到正确的立方体。如果立方体没有纹理而不是面孔,请看:f 2 3 4;因此,修复后看起来正确:f 1 2 3;
但是当我导出带有纹理的obj文件时,而不是带有斜杠1/13 2/1 4/3的面孔,我不知道其他面孔需要什么。它是第一个
这里是我的课上的人物
public class TestUV { private FloatBuffer mVertexBuffer; public FloatBuffer mColorBuffer; public FloatBuffer mColorBufferKs; public FloatBuffer textureBuffer; private ShortBuffer mIndexBuffer; private short indicesF[]; private float vertices[]; private float textureCoords[]; private float matcolors[]; private float matcolorsKs[]; OBJLoader loader; public int tempo[]; public float tempFloat[]; public TestUV(Context context, String filename) { loader = new OBJLoader(context); loader.loadVertAndInd(filename); tempFloat=loader.indices; short indices[] = new short[tempFloat.length]; for (int i = 0; i < tempFloat.length; i++) { indices[i] = (short)tempFloat[i]; } indicesF=indices; vertices=loader.vertices; matcolors=loader.materialsKd; matcolorsKs=loader.materialsKs; textureCoords=loader.Vtextures; String temp = ""+matcolors.length; String temp1 = ""+matcolorsKs.length; Log.e("","LENGTH OF MATCOmatcolors.length "+temp+" KS = "+temp1); ByteBuffer byteBuf = ByteBuffer.allocateDirect(vertices.length * 4); byteBuf.order(ByteOrder.nativeOrder()); mVertexBuffer = byteBuf.asFloatBuffer(); mVertexBuffer.put(vertices); mVertexBuffer.position(0); byteBuf = ByteBuffer.allocateDirect(matcolors.length * 4); byteBuf.order(ByteOrder.nativeOrder()); mColorBuffer = byteBuf.asFloatBuffer(); mColorBuffer.put(matcolors); mColorBuffer.position(0); byteBuf = ByteBuffer.allocateDirect(matcolorsKs.length * 4); byteBuf.order(ByteOrder.nativeOrder()); mColorBufferKs = byteBuf.asFloatBuffer(); mColorBufferKs.put(matcolorsKs); mColorBufferKs.position(0); ByteBuffer ibb = ByteBuffer.allocateDirect(indices.length*4); ibb.order(ByteOrder.nativeOrder()); mIndexBuffer = ibb.asShortBuffer(); mIndexBuffer.put(indices); mIndexBuffer.position(0); byteBuf = ByteBuffer.allocateDirect(textureCoords.length * 4); byteBuf.order(ByteOrder.nativeOrder()); textureBuffer = byteBuf.asFloatBuffer(); textureBuffer.put(textureCoords); textureBuffer.position(0); } public float xPos=0; public float yPos=0; public float zPos=0; public void setX(float x){xPos=x;} public void setY(float y){yPos=y;} public void setXYZ(float x,float y,float z) { xPos=x; yPos=y; zPos=z; } // draw our object /** WORK WITH LIGHT **/ //**********************************************************/ //float[] pos = {0.0f, 0.0f, -3.0f, 1.0f}; //2 float lightX = 0; float lightY =0; float[] red={1.0f, 0.0f, 1.0f, 1.0f}; float[] lightpos = {0,0,-1,1}; float[] lightpos1 = {0,0,0,0}; float[] lightdir ={-0.5f,-0.6f,-0.7f}; float[] lightdir1 ={0.5f,0.6f,0.7f}; public final static int SS_SUNLIGHT = GL10.GL_LIGHT0; public final static int SS_SUNLIGHT1 = GL10.GL_LIGHT1; public final static int SS_SUNLIGHT2 = GL10.GL_LIGHT2; public FloatBuffer makeFloatBuffer(float p[]){ ByteBuffer vbb = ByteBuffer.allocateDirect(p.length * 4); vbb.order(ByteOrder.nativeOrder()); FloatBuffer fb = vbb.asFloatBuffer(); // create a floating point buffer from the ByteBuffer fb.put(p); // add the coordinates to the FloatBuffer fb.position(0); return fb; } public void draw(GL10 gl,float xR,float yR) { gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); gl.glFrontFace(GL10.GL_CW); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer); gl.glColorPointer(4, GL10.GL_FLOAT, 0, mColorBuffer); gl.glTranslatef(xPos, yPos, zPos); gl.glRotatef(xR, 0, 1, 0); //rotate around y-axis gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_SPECULAR, mColorBufferKs); gl.glLightfv(GL10.GL_LIGHT1, GL10.GL_SPECULAR, mColorBufferKs); gl.glEnable(GL10.GL_LIGHTING); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_NEAREST); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST); gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]); //enable texture //ENABLES gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_COLOR_ARRAY); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer); gl.glDrawElements(GL10.GL_TRIANGLES, indicesF.length, GL10.GL_UNSIGNED_SHORT,mIndexBuffer); //ENABLE TEXTURE!!!!! gl.glEnable(GL10.GL_TEXTURE_2D); //DISABLES gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); gl.glDisableClientState(GL10.GL_COLOR_ARRAY); } private int[] textures = new int[1]; //////================================================================= public void loadTexture(GL10 gl, Context context,int count) { // loading texture Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), count); // generate one texture pointer gl.glGenTextures(1, textures, 0); // ...and bind it to our array gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]); // create nearest filtered texture gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); // Use Android GLUtils to specify a two-dimensional texture image from our bitmap GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0); // Clean up bitmap.recycle(); } }
代码非常糟糕,因此无法清洁。纹理和屏幕快照在设备上的外观
请帮助某人:(我不知道该怎么办我的解析器工作corrcet。只是不明白怎么了。
ehhhh大家好,我尝试加载我在搅拌机中制成的UV纹理。在搅拌机中就可以了图加载正常,材料加载正常。但是纹理问题..我不知道这是什么错误,因为我在...
对于我认为的提问者来说为时已晚,但对于在此问题上绊脚石的任何人来说,你说: