LWJGL using multiple textures


I made a picture of the model. As you can see the texture cliches and that one misplaced vertex on the right hand. Error is not in the .obj file, and the reader works correctly also. So the problem is probably in prepareVBO method. But i dont understand, where can this kind of error come in. When i use the VBO i used at the beginning the one that works with drawArrays, the model comes out fine, no errors no nothing, i just cant multitexture it. Now i remade the code to support drawElements, and im getting this bug.
Maybe someone else can spot the error in my code.

I have a question about the .OBJ file. I did some calculation and i found out that the total amount of vt lines is less than total amount of v lines or vn lines. I investigated bit more and found out that the amount of v lines equals to the amount of vn lines. And since the .OBJ is separated into 3 objects: Cape, hair, body, i looked into the amount of lines in each individual object. in Cape amount of v equals the amount of vt equals the amount of vn. In hair there are 22 more vt lines than there are v or vn. In body there is 1105 vt lines less than there is v or nv. Is this ok, or is something wrong with the exporting? Or do i need to make the shading stuff also before i can fully get the texture working?

Edited: Fixed the finger. In the array creation i had put one index wrongly. Texture still messed up.

public void prepareVBO(){

		vboIndeciesID = glGenBuffers();
		vboVertexID = glGenBuffers();
		int x = 0;
		int e = 11;

		
		for(int i = 0; i < faces.size(); i++){
			total += faces.get(i).size();
		}
		float[] buffer = new float[33 * total];
		FloatBuffer vertexBuffer = BufferUtils.createFloatBuffer(33* total);
		IntBuffer indeciesBuffer = BufferUtils.createIntBuffer(33*total);


		
		for(int i = 2; i < faces.size(); i++){
			for(Face face : faces.get(i)){
				Material material = face.material;
				indeciesBuffer.put((int) (face.vertex.x - 1)).put((int) (face.vertex.y - 1)).put((int) (face.vertex.z - 1));

				
				x = (int) face.vertex.x - 1;
				Vector3f v1 = vertices.get((int) face.vertex.x - 1);
				Vector3f n1 = normals.get((int) face.normal.x - 1);
				Vector2f t1 = texture.get((int) face.texture.x - 1);
				buffer[e*x] = v1.x;
				buffer[e*x+1] = v1.y;
				buffer[e*x+2] = v1.z;
				buffer[e*x+3] = n1.x;
				buffer[e*x+4] = n1.y;
				buffer[e*x+5] = n1.z;
				buffer[e*x+6] = material.getDiffuse().x;
				buffer[e*x+7] = material.getDiffuse().y;
				buffer[e*x+8] = material.getDiffuse().z;
				buffer[e*x+9] = t1.x;
				buffer[e*x+10] = 1-t1.y;
				
				x = (int) face.vertex.y - 1;
				Vector3f v2 = vertices.get((int) face.vertex.y - 1);
				Vector3f n2 = normals.get((int) face.normal.y - 1);
				Vector2f t2 = texture.get((int) face.texture.y - 1);
				buffer[e*x] = v2.x;
				buffer[e*x+1] = v2.y;
				buffer[e*x+2] = v2.z;
				buffer[e*x+3] = n2.x;
				buffer[e*x+4] = n2.y;
				buffer[e*x+5] = n2.z;
				buffer[e*x+6] = material.getDiffuse().x;
				buffer[e*x+7] = material.getDiffuse().y;
				buffer[e*x+8] = material.getDiffuse().z;
				buffer[e*x+9] = t2.x;
				buffer[e*x+10] = 1 - t2.y;
				
				x = (int) face.vertex.z -1;
				Vector3f v3 = vertices.get((int) face.vertex.z - 1);
				Vector3f n3 = normals.get((int) face.normal.z - 1);
				Vector2f t3 = texture.get((int) face.texture.z - 1);
				buffer[e*x] = v3.x;
				buffer[e*x+1] = v3.y;
				buffer[e*x+2] = v3.z;
				buffer[e*x+3] = n3.x;
				buffer[e*x+4] = n3.y;
				buffer[e*x+5] = n3.z;
				buffer[e*x+6] = material.getDiffuse().x;
				buffer[e*x+7] = material.getDiffuse().y;
				buffer[e*x+8] = material.getDiffuse().z;
				buffer[e*x+9] = t3.x;
				buffer[e*x+10] = 1 - t3.y;
			}			
			koht.add(indeciesBuffer.position());
		}
			vertexBuffer.put(buffer);

			indeciesBuffer.rewind();
			vertexBuffer.rewind();


			
			glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndeciesID);
			glBufferData(GL_ELEMENT_ARRAY_BUFFER, indeciesBuffer, GL_STATIC_DRAW);
			glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
			
			glBindBuffer(GL_ARRAY_BUFFER, vboVertexID);
			glBufferData(GL_ARRAY_BUFFER, vertexBuffer , GL_STATIC_DRAW);
			glBindBuffer(GL_ARRAY_BUFFER, 0);

		
	}

Tested my code with some other models, and i have the same problem with textures. So the problem is either VBO preparation or .OBJ loader. OR could it be that the textures are in tga format while the console gives me
Tue Jan 28 14:56:25 EET 2014 INFO:Use Java PNG Loader = true

Report back once you have nailed down the problem.

I converted textures into PNG, i tried the texture class that is posted in the tutorial under the tutorials section. I built the shader stuff(dunno if it works). And still i have the same problem.

So through process of elimnation i have eliminated that the problem isnt caused by texture import. And i doubt that blender can export faulty .obj file twice. So, its either my .obj loader or my prepareVBO.

public class OBJLoader{
	public static Model loadModel(File f) throws FileNotFoundException, IOException{
		BufferedReader reader = new BufferedReader(new FileReader(f));
		Model m = new Model();
		String line;
		Material material = null;
		ArrayList<Face> face = new ArrayList<Face>();
		int i = -1;
		while((line = reader.readLine()) != null){
			if(line.startsWith("mtllib ")){
				MTLLoader.loadMaterial(m, "src/" +line.split(" ")[1]);
			}else if(line.startsWith("o ")){
				i++;
				if(i == 0){
					continue;
				}
				m.faces.add(face);
				face = new ArrayList<Face>();
			}else if(line.startsWith("v ")){
				float x = Float.valueOf(line.split(" ")[1]);
				float y = Float.valueOf(line.split(" ")[2]);
				float z = Float.valueOf(line.split(" ")[3]);
				m.vertices.add(new Vector3f(x,y,z));
			} else if(line.startsWith("vn ")){
				float x = Float.valueOf(line.split(" ")[1]);
				float y = Float.valueOf(line.split(" ")[2]);
				float z = Float.valueOf(line.split(" ")[3]);
				m.normals.add(new Vector3f(x,y,z));
			} else if(line.startsWith("vt ")){
				float x = Float.valueOf(line.split(" ")[1]);
				float y = Float.valueOf(line.split(" ")[2]);
				m.textured = true;
				m.texture.add(new Vector2f(x,y));
			} else if(line.startsWith("usemtl ")){
				material = m.materials.get(line.split(" ")[1]);
			} else if(line.startsWith("f ")){
				Vector3f vertexIndices = new Vector3f(Float.valueOf(line.split(" ")[1].split("/")[0]),
													  Float.valueOf(line.split(" ")[2].split("/")[0]),
													  Float.valueOf(line.split(" ")[3].split("/")[0]));
				Vector3f normalIndices = new Vector3f(Float.valueOf(line.split(" ")[1].split("/")[2]),
						  							  Float.valueOf(line.split(" ")[2].split("/")[2]),
						  							  Float.valueOf(line.split(" ")[3].split("/")[2]));
				if(m.textured){
				Vector3f textureIndices = new Vector3f(Float.valueOf(line.split(" ")[1].split("/")[1]),
						  							   Float.valueOf(line.split(" ")[2].split("/")[1]),
						  							   Float.valueOf(line.split(" ")[3].split("/")[1]));
				face.add(new Face(vertexIndices, textureIndices, normalIndices, material));
				}else{
					face.add(new Face(vertexIndices, null, normalIndices, material));
				}
				
			}
		}
		reader.close();
		m.faces.add(face);
		m.prepareVBO();
		return m;
	}
}

Anyone any ideas? I havent been able to figure this one out.

I just had an idea. what it, instead of taking the texture coordinates i will take the RGB values of each point, and il just use the color to texture my model. Would that work, or is it rubbish idea?