Reading an obj file for JOGL

Ok, I know JOGL probably isn’t the best code to use for this because of efficiency but I’m just trying to get this in for a project for class and eventually use it just for fun.

I have no idea how to read an obj file from blender and I can’t seem to find much help when I just google some keywords. I have a bunch of questions.

  1. What does ‘v’ mean in the obj file? I’m guessing ‘vertex’ but it could mean ‘vector’ too.

  2. I’m guessing ‘vn’ means vector normal except I don’t know how to use this in JOGL. Can someone give a code example?

  3. What does ‘vt’ mean and how do I use it? Does it mean vertex texture?

  4. what does ‘f’ mean? I heard from someone that it means face and that its used for making the polygons in code. But how is this done?

  5. I downloaded some example and opened the obj file in gvim to see these parameters at the begining of every string but I didn’t see anything that looked like a color spec because the sample file I looked at doesn’t have color. What would a color spec look like and how would I interpret it for good use?

  6. Lastly, the example i looked at had about 250,000 lines. Judging by my pc’s capabilities, this would take way to long to load and manipulate. Is this a common file size for obj files?

Thanks for the help and if you haven’t figured out by now, yes i’m a noob/newb to blender. Please have mercy! T_T.

Erik

All the answers you need powered by Google:
http://www.royriggs.com/obj.html

250 000 lines would take a program in C about 0.1s to parse and allocate. I haven’t really used Java, so I can’t say how will the garbage collector feel about such amount of allocations.

Try to parse the file in two passes. First count the number of vertices and faces, then allocate the required memory in one big chunk and load the data in the second pass.

Ok so two passes is the way to go. Plus it would be a good way to avoid vector data objects or linked lists. And now I know that I’m dealing with vertices in the file and not vectors but what does all the other stuff in the file mean?