What is UVIndex and how do I use it on OpenGL?

Posted by Delta on Game Development See other posts from Game Development or by Delta
Published on 2011-11-10T18:48:45Z Indexed on 2011/11/11 18:28 UTC
Read the original article Hit count: 278

I am a noob in OpenGL ES 2.0 (for WebGL) and I'm trying to draw a simple model I've made with a 3D tool and exported to .fbx format. I've been able to draw some models that only have: A vertex buffer, a index buffer for the vertices, a normal buffer and a texture coordinate buffer, but this model now has a "UVIndex" and I'm not sure where am I supposed to put this UVIndex. My code looks like this:

GL.bindBuffer(GL.ARRAY_BUFFER, this.Model.House.VertexBuffer);
GL.vertexAttribPointer(this.Shader.TextureAndLighting.Attribute["vPosition"],3,GL.FLOAT, false, 0, 0);
GL.bindBuffer(GL.ARRAY_BUFFER, this.Model.House.NormalBuffer);
GL.vertexAttribPointer(this.Shader.TextureAndLighting.Attribute["vNormal"], 3, GL.FLOAT, false, 0, 0);
GL.bindBuffer(GL.ARRAY_BUFFER, this.Model.House.TexCoordBuffer);
GL.vertexAttribPointer(this.Shader.TextureAndLighting.Attribute["TexCoord"], 2, GL.FLOAT, false, 0, 0);

GL.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, this.Model.House.IndexBuffer);

GL.bindTexture(GL.TEXTURE_2D, this.Texture.HTex1);
GL.activeTexture(GL.TEXTURE0);

GL.drawElements(GL.TRIANGLES, this.Model.House.IndexBuffer.Length, GL.UNSIGNED_SHORT, 0);

But my model renders totally incorrect and I think it has to do with the fact that I am ignoring this "UVIndex" in the .fbx file, since I've never drawn any model that uses this UVIndex I really have no clue on what to do with it.

This is the json file containing the model's data: http://pastebin.com/raw.php?i=G294TVmz

© Game Development or respective owner

Related posts about opengl

Related posts about textures