Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎲 GameMaker

reading a .OBJ file....

Started by OpenGL_Guru Jun 30, 2004 at 10:00 AM 3 replies 550+ views
Original Post
OpenGL_Guru
OpenGL_Guru
i had added a .OBJ as a header file but MSVC 6 complains as follows: Compiling... objReader.cpp c:\program files\microsoft visual studio\vc98\myprojects\objreader\tags60.h(4) : error C2143: syntax error : missing ';' before 'constant' c:\program files\microsoft visual studio\vc98\myprojects\objreader\tags60.h(4) : error C2501: 'v' : missing storage-class or type specifiers c:\program files\microsoft visual studio\vc98\myprojects\objreader\tags60.h(4) : fatal error C1004: unexpected end of file found Error executing cl.exe. objReader.exe - 3 error(s), 0 warning(s) here are the first few lines of the header... # PRT_MTL_C1_BLUE # usemtl UNKNOWN g Obj_PRT_MTL_C1_BLUE v 19.93078 8.480025 13.46143 v 19.93369 8.476611 13.46908 v 19.96644 8.476611 13.47785 v 19.96644 8.479101 13.47598 v 19.96644 8.480025 13.47302 v 19.99907 8.476611 13.46915 v 20.00493 8.476611 13.46535 ...... ...... v of course stands for vertex. maybe i am just not thinking today but im sure there is something i can change simple so the compiler wont care... thanks for your help!
heh
ApochPiQ
ApochPiQ
The "header" file isn't valid C/C++ code, so including it as a header won't work. What exactly are you trying to do? If you want to include the data in your EXE, you'll need to use a resource script. If you just want to have the file visible in your workspace, you can add it to the project but don't #include it anywhere.
OpenGL_Guru
OpenGL_Guru
its a 3-D model that i modeled in Maya. what i want to do now is read in all the vertices, vertex normals, etc etc and put it in a display list and then render it in my openGL scene. thats why i put it as a header b/c i have to read the data in...any ideas?
heh
ApochPiQ
ApochPiQ
Using it as a header doesn't "read" the data; it tries to make the data part of your program. What you need to do is actually read the .OBJ file from your program, not try to compile it in.

Here's a few tutorials and discussions on reading and writing files to get you started; there are a lot of different ways to do this, so pick whichever one you are most comfortable with.
http://www.gamedev.net/reference/articles/article1127.asp
http://www.gamedev.net/reference/articles/article707.asp
http://www.gamedev.net/community/forums/topic.asp?topic_id=229891

You can get more from Google by searching for "file i/o tutorial."
OpenGL_Guru
OpenGL_Guru
oh ok i gotcha, yeah i know that i can just do a infile.open("file_name"), but since i wanted to look at inside my workspace i was having problems.. i moved the header to the resource files folder and the compiler gives me no problems.. thanks for the help..
heh

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.