Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Loading 3D levels

This topic is 6014 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

This may sound a little stupid to the better programmers but, how would you go about saving a 3D world into a file so you can load it exactly as it is later..

Share this post

Link to post
Share on other sites
One way is the toFile( FILE* fp ) way.

Have a method that takes a file pointer first.
Then for every member, just write it out
the way you like.

For example, if it has an array of objects, write how many elements it has first, then call toFile() on the objects it holds.

For reading, just do it the same way, except read it.

class X
int someVariable;
CSomething* pSomePointer;

bool toFile( FILE* fp );
bool fromFile( FILE* fp );

bool X::toFile( FILE* fp )
fprintf( fp, "%d\n", someVariable );
pSomePointer->toFile( fp );

You may want to have it spit out comments also
for debugging purposes.

Share this post

Link to post
Share on other sites
yes, usually you can have 2 projects
one world compiler and one runtime rasterizer

you precalculate your world aabb leafs/portals or
etc data with your compiler and then >>write whole
partitioned leaf data into the file<<

This compiler actually does all hard work.

Then you simply fire up your rasterizer application
and read your compiled fileformat world data into memory

it''s important to understand that runtime part of your
application is usually stupid and no need to say you minimize all
stuffs it must do, that way you keep it fast
mostly all stuffs are taken from precalculated table
(there''s no faster way than look-ups)

Share this post

Link to post
Share on other sites
RickPeek is right, let me if I may add my 2 cents

Read the help files on fread and fwritein your compiler. Borland doies this for you!

Then create your own file format

like struct MyFileFormat
int hp;
int mp;

position etc duh.

then fwrite to save a game to disk, and fread to load a game.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!