Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Parsing an OBJ  (Read 5945 times)

0 Members and 1 Guest are viewing this topic.

molmasepic

  • Newbie
  • *
  • Posts: 43
    • View Profile
Parsing an OBJ
« on: February 18, 2011, 01:55:23 am »
hey ive been looking around for a while(3 days) and i cant seem to fined a good way to load my .obj mesh into my c++ game....


does anyone know how to parse an obj file or know any tutorials that can help me?


that would be very nice


what im looking for is maybe a way to get started at least(like an outline of some sort)

thanks in advance  :)

Gibgezr

  • Newbie
  • *
  • Posts: 33
    • View Profile
Parsing an OBJ
« Reply #1 on: February 18, 2011, 02:24:36 am »
There are literally thousands of projects floating around the web that demonstrate loading obj files to OpenGL. Try:
http://sourceforge.net/projects/objloader/
or
http://kixor.net/dev/objloader/
for example. The obj format is popular to write loaders for, because it is a very simple format to parse.

molmasepic

  • Newbie
  • *
  • Posts: 43
    • View Profile
Parsing an OBJ
« Reply #2 on: February 18, 2011, 02:37:28 am »
i have tried these before(for 2 hrs straight) and everything i tried ended in an undefined error...

i like this one though(http://kixor.net/dev/objloader/)


what should i be linking in this? ._.


also i want it where i dont have these files in my directory...

is that even possible?

if not then ill *sigh* deal with it


EDIT: tried putting in the directory, didnt work >_<


this works: objLoader *World = new objLoader();
then i get undefined for: World->load("test.obj");

the error says: |undefined reference to `objLoader::load(char*)'|

im not delaying my project for another day........

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Parsing an OBJ
« Reply #3 on: February 18, 2011, 09:37:47 am »
Did you link the libraries?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

molmasepic

  • Newbie
  • *
  • Posts: 43
    • View Profile
Parsing an OBJ
« Reply #4 on: February 19, 2011, 06:44:28 am »
hey im using Perl to convert my obj files so thats not a problem.


BUT

when loading the model, i cant see it ._.


these are what i have used for this

// set input data to arrays
glVertexPointer(3, GL_FLOAT, 0, WorldMap3Dv1Verts);
glTexCoordPointer(2, GL_FLOAT, 0, WorldMap3Dv1TexCoords);

// draw data
glDrawArrays(GL_TRIANGLES, 0, WorldMap3Dv1NumVerts);


also
glEnable(GL_VERTEX_ARRAY);

is there something else im missing?

also i know that its loading because it slows everything down once i enabled

Mars_999

  • Full Member
  • ***
  • Posts: 103
    • View Profile
    • Email
Parsing an OBJ
« Reply #5 on: March 20, 2011, 09:08:09 pm »
Why not look into ASSIMP?

It loads a billion different formats.... Unless you want to learn how to load an .obj which in that case get ready to struggle a bit until you figure it out. I am assuming you just want to load a mesh.

http://assimp.sourceforge.net/