Jump to content

  • Log In with Google      Sign In   
  • Create Account


writing 3D Model data to the game executable?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Anddos   Members   -  Reputation: 478

Like
0Likes
Like

Posted 11 November 2013 - 05:14 PM

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


:)

Sponsor:

#2 __SKYe   Members   -  Reputation: 977

Like
1Likes
Like

Posted 11 November 2013 - 07:04 PM

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



#3 Anddos   Members   -  Reputation: 478

Like
0Likes
Like

Posted 12 November 2013 - 01:18 AM

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


:)

#4 frob   Moderators   -  Reputation: 19635

Like
2Likes
Like

Posted 12 November 2013 - 01:54 AM

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.


Check out my personal indie blog at bryanwagstaff.com.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS