Jump to content
  • Advertisement
Sign in to follow this  
Anddos

writing 3D Model data to the game executable?

This topic is 2079 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement

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).

Share this post


Link to post
Share on other sites

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..

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!