Advertisement

writing 3D Model data to the game executable?

Started by November 11, 2013 11:14 PM
2 comments, last by frob 11 years, 3 months ago

in my game programming book it shows an example of writing 3D Model data to a separate executable file,it is using fwrite to write vertices,faces,normals and uv's to the binary file,my question is would it be possible to write this data to the actual program so its built in to it and there is no seperate files to move around,i know about resource files but i am curious if you can do it this way without corrupting the program.

Thanks

:)

One way to do it is to declare the 3D model data (vertices, normals, texture coordinates, etc) as variables inside the code.

Now, i don't know if you just want to know if it's possible, and if you even care about what i'll tell you, but you should never do something like that.

This may be okay for icons, but you should always separate your code (program) from your data (graphics, sounds, 3D models, etc).

Advertisement

Ive only been able to write a cube data as hard coded varibles,complex models with lots of vertices and polys has to be loaded from a file..

:)

There are many programs out there that can convert your data file into exectuable data.

Search for "bin2obj" and you will find a bunch of tools with the same name for various systems that do this sort of thing.

Basically all they do is dump the data into an object file's data segment and then give you a pointer to it. Think of it as a big array with all the data hard coded. You then link to the file the same way you link to any other object or library file.

There are some drawbacks to this method. For one thing the data is now embedded in your executable and is more difficult for you to modify and maintain. You cannot have your tools adjust the data without needing to rebuild that object file. It also takes up resources the entire time the application is loaded.

It is certainly a thing you can do, and it is something that many programs have done and continue to do. While it can be convenient for small projects and small collections of data, it is a practice that most software eventually outgrows. Dynamically loading your data gives much more flexibility in the long run.

This topic is closed to new replies.

Advertisement