3
\$\begingroup\$

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.

\$\endgroup\$
6
  • 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
    Commented Jun 14, 2013 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\$ Commented Jun 14, 2013 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
    Commented Jun 14, 2013 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
    Commented Jun 14, 2013 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\$ Commented Jun 14, 2013 at 14:02

1 Answer 1

5
\$\begingroup\$

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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .