I'm working on a game engine and just started with mesh loading. I started with the format .obj. I ran into this problem:

The guide I'm following gave me a couple of .obj files to try and they all worked fine. I then asked a friend who is working with 3D animation to give me a couple of .obj files to try in addition, but his files, when opened up in a txt format, contain no newlines to separate the information at all. (Everything was on one line). The loading function I use depends on this to extract the information.

Are the files he gave me bad in some way? Is my function bad because it depends on newlines being there? (I can't see .obj files having any other delimiter character...)

My friend made and exported the 3D models in Blender. This is the guide I'm following.

  • 2
    \$\begingroup\$ What OS does your friend use? Different operating systems use different newline characters, and it's possible that is causing the issue. \$\endgroup\$ – jhocking Jun 14 '13 at 12:27
  • \$\begingroup\$ He is using windows 7, and so am I, but do you really think the blender export function should be affected by that :O ? \$\endgroup\$ – Fredrik Boston Westman Jun 14 '13 at 12:28
  • \$\begingroup\$ dunno, perhaps it uses system default filestream commands. whatever it doesn't matter now, thanks for crossing off that possibility \$\endgroup\$ – jhocking Jun 14 '13 at 12:32
  • 1
    \$\begingroup\$ Windows version doesnt relly matter, locale can affect this too. But it highly probably that its caused by him exporting it with line breaks as \n and you are expecting \n\r. \$\endgroup\$ – Kikaimaru Jun 14 '13 at 12:43
  • \$\begingroup\$ Ok, but to the question at hand, is the file structur of .obj built so you seperate the information via new lines or not :) ? \$\endgroup\$ – Fredrik Boston Westman Jun 14 '13 at 14:02

I'm assuming you opened the file in Notepad. Notepad doesn't recognize some new line formats.

The OBJ format does indeed use newlines as delimiters, and your files likely contain them. It's just not looking that way in Notepad. Try opening them in Notepad++ instead: I'll bet they'll appear correctly.

To make sure your parser function works correctly on all platforms, it should consider both \n (newline) and \r (carriage feed) characters as newlines.

  • \$\begingroup\$ The tutorial code probably assumes you are in the USA and using Windows. \$\endgroup\$ – jhocking Jun 14 '13 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.