OpenGL geometry Loader( Arrays, Vectors, or Link_lists

Started by
15 comments, last by zacaj 12 years, 9 months ago
I am currently working on my own C++ geometry loader for OpenGL games. and i am wondering if i should use one of the following when loading geometry from a file to memory. Arrays, Vectors, or Link_lists are the methodologies I am investigating as far as pros and cons are concerned. if there is a better way or if you have knowledge on which of these would be the best that would be awesome.

thanks for your time

Green :)
J-GREEN

Greenpanoply
Advertisement
Loading which part of the geometry? What type of file are you loading from?
I'm loading from obj files. and i am loading the vertices.
J-GREEN

Greenpanoply
In that case, vectors are probably your best bet. Linked lists wont work well, since you will want to pass all the vertices to opengl as a chunk of memory, and linked lists are spaced out. For efficiency, it would be best to prescan your file to get a count of all the vertices, then preallocate a normal array before you read them in, but thats most likely overkill. In the end, you shouldnt be using OBJ for production, but for prototyping (and there for not efficiency heavy), its great.
what do you mean prototyping?
J-GREEN

Greenpanoply
Obj files are supported by every modeller, and theyre easy to parse, so theyre good to get your game up and running with. However, theyre also limited (no animation, for instance), and much slower to parse than most other formats. So theyre good to use to get your game up and running, but once your game is past the prototyping stage, youll probably want to switch to a more complex (possibly custom) format, which would tell you in advance how many vertices it has, for instance, so you wouldnt incur the overhead of using a vector (although small) when loading them
if I am making this geometry in 3ds max what file type do you recommend and how would i make my own file type if there are only a list of specified ones given. also when you say switch to a custom format do you mean like after i know exactly what my geometry will look like i can write something to make the game more affection with that particular amount of vertices and what not in mind? like have all of the geometry read from one large file that has all of the geometry verts and meshes and what not written to it by me?
J-GREEN

Greenpanoply
Sortof. There are upsides and downsides to all the different formats supported my 3ds max. WHen you make your own file type, usually the easiest thing to do would just make a converter, that would read the old file type that you had been using for prototyping, and print out only the relevant information that you need. (for example, you dont really need group names from OBJ files, so those wouldnt be included). You would basically look at your rendering code, and figure out what data was needed, and just store that so that you could easily load just that data later. Or, you could learn the 3DS Max SDK, and code a custom exporter, but that seems much more complex.

You would still store youre geometry individually, not in one giant file though. I found a very easy route was to use Assimp, which handles loading many different formats for you, and then gives you all the data, so you can render it, or output the data however you want for your custom format. Not only does it load OBJ files, but also more complex formats, like COLLADA or 3ds, etc
every time i try to use assimp or any collada library i get build error and i spend most of my days trying to figure out what is not working with this things. i have not successfully found one the will run or an example using vs2010 and that is mainly why i am building my own loader. you would not have a simple example or know where i could find one to learn how to properly us Assimp would you?
J-GREEN

Greenpanoply
Im using assimp for my project with vs2010. Do you get the build error when linking with assimp, or when building assimp? Ill see if I can whip together a quick demo project

This topic is closed to new replies.

Advertisement