View Full Version : texture coordinates reading from .*obj file

01-18-2010, 04:50 AM
Hello, everyone. This is my first time writing here. I am beginner at OpenGL (i thing it is goind to be my hobby). So, my mission is to get texture coordinates from *.obj file. I have read this format description and structure (http://www.eg-models.de/formats/Format_Obj.html), but due my low programming skills i cannot write a function, that is going to read coordinates from file. Maybe someone of u already did it, i would appreciate any help. Thanks anyway!
P.S. I also have found some code here : http://www.graphixer.com.cn/ShowWorks.asp?Type=1&From=ShowWorks&ID=25, but comments are written in chineese so i cant understand :)

01-18-2010, 07:53 AM
well essentially for each line(or row if you prefer that) you read you have to do two things.
1. determine what kind of data is on this line
2. parse it into a data structure

so for #1 i use a statement like this
if (!strncmp (line,"vt ",3)) parse_vt(&line[2]);

then for #2 i have a function that basically just calls
sscanf (line,"%f%f",&u, &v); and inserts it into a data structure

and that's about it, the only hard thing to parse is the faces since there could be many different layouts of this, but i leave that to you