• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Xperience

File for storing meshes

11 posts in this topic

Hi, I have a problem with choosing good file format for storing geometry data. Until now, I've used m3d format(created by Frank Luna), but it is not suitable for using in games(As example to learn is perfect).

I want to find format which can do this:

1. Loading from memory(I have a Resource Cache system in which I load every needed file in single call and then I work with memory)

2. Fast

3. Easy importing from Graphics programs(3DS Max, Maya etc)

I found FBX, but I don't know if it can be loaded from memory. Thank you for your opinions(I'm using C++ and D3D11).

0

Share this post


Link to post
Share on other sites

You read too quickly: Frank Luna made up the m3d ("model 3d") format for his D3D10/11 books. Id used the MD3 format. blink.png

Edited by Buckeye
2

Share this post


Link to post
Share on other sites

No, it isn't my mistake. It is m3d as pointed Buckeye.

Thank you for advice. I'm thought that this is only option, but I didn't know if it is good option(common for  used).

I have a small problem with creating my own binary format(rather with storing and loading strings)

First I tried to save and load whole object at once, but it failed. I found, that error is inside loading string.

 

Now I'm saving and loading strings as:
1. I save a size of string
2. I save a string

But isn't there a better way to do this?

0

Share this post


Link to post
Share on other sites

You read too quickly: Frank Luna made up the m3d ("model 3d") format for his D3D10/11 books. Id used the MD3 format. blink.png

Ohh, thanks for the heads up.


But isn't there a better way to do this?

Save direct values. Not strings. Values don't need to be parsed.

 

Your own format would be defined like:

 

byte position where vertex data starts.

byte position where normal data starts.

vertex data (which is just triplets of floats)

vertex data ends.

normal data starts (again, triplets of floats)

normal data ends.

etc.

 

And the whole format header shenanigans that goes beyond just putting byte positions for sections.

 

So when you read a file, you know the first 4 bytes (an int) are the position where vertex data starts, the following 4 bytes are the position where normal data starts (again, an int), and then you can read until you reach the vertex data position, and you know that for each 4 bytes you got a float, and for each 3 floats you got a vertex, and so on.

 

You could read that link to Id's MD3 format. It might give you some idea how binary formats work, how they store data, how a header looks, etc.

0

Share this post


Link to post
Share on other sites

Strings are a pain, but sometimes you have to save/load them. However, they are, in fact, similar to other arrays. E.g., you read in an int to get the number of vertices, create a buffer, then read in numVertices*3*sizeof(float). Strings you read in an int to get the number of characters, create a buffer (sized for 1 extra character), then read in that many characters. NOTE, however, if you're using null-ended string, the buffer into which you read a string should leave space for that terminating null. That's the "1 extra character." Don't forget to add that terminating null.

1

Share this post


Link to post
Share on other sites

Depending on your requirements and the flexibility you desire you could use the Visual Studio 2012+ graphics content pipeline .CMO format (which is created at build time from a .FBX etc). I have used this previously with Blender exporting to .FBX.

 

DirectXTK has a reader for the .cmo file format.

1

Share this post


Link to post
Share on other sites

 

You read too quickly: Frank Luna made up the m3d ("model 3d") format for his D3D10/11 books. Id used the MD3 format. blink.png

Ohh, thanks for the heads up.


But isn't there a better way to do this?

Save direct values. Not strings. Values don't need to be parsed.

 

Your own format would be defined like:

 

byte position where vertex data starts.

byte position where normal data starts.

vertex data (which is just triplets of floats)

vertex data ends.

normal data starts (again, triplets of floats)

normal data ends.

etc.

 

And the whole format header shenanigans that goes beyond just putting byte positions for sections.

 

So when you read a file, you know the first 4 bytes (an int) are the position where vertex data starts, the following 4 bytes are the position where normal data starts (again, an int), and then you can read until you reach the vertex data position, and you know that for each 4 bytes you got a float, and for each 3 floats you got a vertex, and so on.

 

You could read that link to Id's MD3 format. It might give you some idea how binary formats work, how they store data, how a header looks, etc.

 

 

Sorry, but thanks for advice. I probably didnt' explain it enough. I know, how I have to store Vertices and Indices(I know a basic principles about storing data inside binary format).

I mean using strings(saved binary) to indicate which texture want mesh to use, or which effect I can apply on this mesh(or something like that).

 

Strings are a pain, but sometimes you have to save/load them. However, they are, in fact, similar to other arrays. E.g., you read in an int to get the number of vertices, create a buffer, then read in numVertices*3*sizeof(float). Strings you read in an int to get the number of characters, create a buffer (sized for 1 extra character), then read in that many characters. NOTE, however, if you're using null-ended string, the buffer into which you read a string should leave space for that terminating null. That's the "1 extra character." Don't forget to add that terminating null.

 

I do it this way, but I didn't know nothing about null-ended string(Thank you for explain). Is better to use it or miss it? If I saved string like that:

fout.write(str.c_str(), str.size());

is there saved string with null at the end?

 

Depending on your requirements and the flexibility you desire you could use the Visual Studio 2012+ graphics content pipeline .CMO format (which is created at build time from a .FBX etc). I have used this previously with Blender exporting to .FBX.

 

DirectXTK has a reader for the .cmo file format.

 

If I use it, will slow it the build time?

Edited by Xperience
0

Share this post


Link to post
Share on other sites

I do it this way, but I didn't know nothing about null-ended string(Thank you for explain). Is better to use it or miss it? If I saved string like that:

fout.write(str.c_str(), str.size());

is there saved string with null at the end?
 

First: it appears you're writing the string and then the size. Write the size first, so you'll know how many characters to read in. Whenever you write something to be read later, think about how you'll need to read it back in, and what information you'll need to do that.

 

I don't know what your fout function does, so I can't tell you if it stores the terminating null. What does that output look like in the file?

 

You don't have to write out the terminating null. You just need to know whether it's there when you read it in. Probably better to NOT write the terminating null. When you read the string in (read the string length; read in string-length characters), you don't have to worry about whether there's another byte after it or not.

Edited by Buckeye
1

Share this post


Link to post
Share on other sites

 

First: it appears you're writing the string and then the size. Write the size first, so you'll know how many characters to read in. Whenever you write something to be read later, think about how you'll need to read it back in, and what information you'll need to do that.

 

 

Now I'm saving and loading strings as:
1. I save a size of string
2. I save a string

But isn't there a better way to do this?

 

 

 

I don't know what your fout function does, so I can't tell you if it stores the terminating null. What does that output look like in the file?

 

 

I forgot add this(it's simply std::ofstream call):

std::ofstream fout(Filename.c_str(), std::ios_base::binary);
fout.write(str.c_str(), str.size());
0

Share this post


Link to post
Share on other sites


I probably didnt' explain it enough. I know, how I have to store Vertices and Indices(I know a basic principles about storing data inside binary format).

I mean using strings(saved binary) to indicate which texture want mesh to use, or which effect I can apply on this mesh(or something like that).
Ohh yeah, well that's a place where I'm still thinking what to do. I (and probably you) have several options:

 

Serializing the objects directly (with material/mesh data). Bethesda Game Studios games (TES, Fallout) for example serialize .nif files, which are entire scene graph nodes, I'm guessing that at load time they just load the .nif file and plug the data directly in their scene graph.

Storing the mesh data as binary and the material data as an additional file (text, other binary, with markup language, etc).

Storing everything in a single YAML/XML file, maybe compressed with zip/gzip.

You can also index the materials so the files only store mesh data + material indices instead of storing the string name of the material (this one would need to be maintained but its probably the fastest to load).

You could also hash the texture file names and store the hash along the mesh data, that way when you load the mesh you could pass the hash to a texture/asset loader, and it will work out which texture path the hash relates to.

 

There are many options and tradeoffs between ease of use and faster processing.

1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0