# LongRunGames

Members

0

122 Neutral

• Rank
Newbie
1. ## parsing obj files

Ok so I have an algorithm that imports .obj files which works fine but it was very blocky, like my model in blender. I applied smoothing in blender and when I imported the new .obj file into my game the vertices were mostly ok but there were some major spikes and vertices in random positions. is there a different approach between an object file with s off and with s 1? Graham
2. ## parsing obj files

Thanks for the replies. I see now that option 2 and 3 that I mentioned are just two different ways of doing the same thing and I knew option 1 was not the way to go. I have a script which extracts the data from the .obj file and creates 3 text files one for the vertices in the correct order, one for the normals in the correct order and one for the indices, which I then read in in my game.
3. ## parsing obj files

It seems my question was not specific enough. As far as I can see there are 3 ways of converting an obj file to arrays of vertices and normals and I was wondering which Is the best / industry standard way of doing it. E.g. For the following obj file v 1.0 0.0 0.0 v 0.0 -0.5 -1.0 v -1.0 0.0 0.0 v 0.0 -0.5 1.0 vn 0.0 0.707106 0.707106 vn 0.0 0.707106 -0.707106 f 1//2 2//2 3//2 f 1//1 3//1 4//1 You could Option 1: have the normals averaged as I currently do Vertices = 1.0 0.0 0.0 0.0 -0.5 -1.0 -1.0 0.0 0.0 0.0 -0.5 1.0 Normals = 0.0 1.0 0.0 0.0 0.707106 -0.707106 0.0 1.0 0.0 0.0 0.707106 0.707106 Indices = 1 2 3 1 3 4 Or option 2: sort the data into the vertex order described by the faces section Vertices = 1.0 0.0 0.0 0.0 -0.5 -1.0 -1.0 0.0 0.0 1.0 0.0 0.0 -1.0 0.0 0.0 0.0 -0.5 1.0 Normals = 0.0 0.707106 -0.707106 0.0 0.707106 -0.707106 0.0 0.707106 -0.707106 0.0 0.707106 0.707106 0.0 0.707106 0.707106 0.0 0.707106 0.707106 Indices = 1 2 3 4 5 6 Or option 3: start with the vertices in the order defined and add any with multiple normal values to the end Vertices = 1.0 0.0 0.0 0.0 -0.5 -1.0 -1.0 0.0 0.0 0.0 -0.5 1.0 1.0 0.0 0.0 -1.0 0.0 0.0 Normals = 0.0 0.707106 -0.707106 0.0 0.707106 -0.707106 0.0 0.707106 -0.707106 0.0 0.707106 0.707106 0.0 0.707106 0.707107 0.0 0.707107 0.707106 Indices = 1 2 3 5 6 4 Option 1 is the current way I do it, option 2 seems like the easiest but option 3 seems like it could be the best in terms of data size but would be the hardest algorithm to implement. Hopefully that makes my question more clear
4. ## parsing obj files

Hi All,   does anyone know any good tutorials on parsing an object file into your program, specifically with regards to when a vertex has multiple normal values defined in the faces section?   Much appreciated, Graham