Question about loading models.

Started by
4 comments, last by X5-Programmer 18 years, 8 months ago
Hello, I have a question about loading models into a game. In my game I use 3ds models( low poly ), but it takes alot of time to load let say, 30 diffrent models. so how can I improve the loading speed ? maybe load them as text files or something I dont know. I hope anyone can give me an idea how to do this. thanks.
-[ thx ]-
Advertisement
Use a profiler to determine what part of your code takes the most time during loading. Determine if that part could be optimized, and if possible then optimize and check that your optimization has actually resulted in an increase in speed. Repeat until you get acceptable performance.

If optimizing code is not enough, determine what operations which take time during loading must be done at loading time (such as putting the data in memory) and which operations can be done beforehand (such as computing the normals or eliminating useless data from the file). Using your list of precomputable things, create a new file format, a loader that reads this file format (and as such doesn't need to do all the computations that were performed ahead of time, since the results of those computations are in the file), and a compiler that reads the file and precomputes what you decided could be done ahead of time.

Optimize the loading code again. Rinse and repeat until your bottlenecks are the actual reading from disk and putting in memory, at which point you can't solve anything anymore at this level, and have to optimize your game by actually loading less things.
ToohrVyk:

Thanks for your reply I will try it out.
-[ thx ]-
I was facing the problem of slow model load and made the simplest optimization in the book : I traded memory for speed.

In the beginning, I parsed and read my .3ds files from the disk at the same time with consecutive calls to fread. What I do now is read the entire file to memory with a single fread call, parse it afterwards from there and then release memory. Considering that the memory consumption peak lasts only as long as the parsing process and therefore happens only once (and not during render-time), it is a winning decision.

A second optimization you might want to try is to use hash-tables for your vertex normal calculations.

Best of luck!
Let them be converted.

I don't use 3DS so I don't know what all is in it, but I'm sure it has tons of excess garbage you don't need. Why not make a simple converter that weeds out all that garbage and stuff.
thanks guys!
-[ thx ]-

This topic is closed to new replies.

Advertisement