• 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
Alundra

Asset file format

5 posts in this topic

Hi all,

I have differents file format : mesh, texture, animation, and surely soon material.

Actually I have differents extension but I would have only one file format ".asset".

My idea is to have a class Asset who has load/save and memory file data.

At the end the asset is just two uint32 who is the type of the asset and the file data size then the file data.

Each class (mesh, texture, animation, material) has function to write to memory and read from memory.

Is it a bad way to handle that and should be done in another way ?

Thanks for the help

Edited by Alundra
0

Share this post


Link to post
Share on other sites
There's nothing particularly wrong with this. It can be beneficial to have separate file types with different extensions, but it's not critically important in any way.

It's easier to write tools that open the files that do some kind of asset-type-specific processing. For instance, a custom image viewer for your texture type, or a model previewer. Including a type marker in the file itself works, but it makes it a bit harder on some OSes.

The format itself that you propose is actually just fine. The one thing I would add is that you want to make the on-disk format and the in-memory format as similar as possible so as to avoid any kind of data transformation or processing necessary when loading the file. This often means choosing data formats that use arrays indices rather than pointers internally, since pointers can't be directly saved to disk. You'll likely still want a data validation step that at least verifies indices are in valid ranges and won't be a gaping security hole, but iterating over a bunch of read-only data and verifying it is much faster than modifying it (and can be parallelized fairly easily).
2

Share this post


Link to post
Share on other sites

Usually there are 2, perhaps 3 situations to be distinguished:

(1) "Raw assets" as are loaded by an editor for the purposes of being viewed and perhaps integrated into the project,

(2) "runtime assets" that are loaded by the game engine,

(3) and perhaps "runtime assets" that are loaded by the game engine, either provided for hot-swapping, software updates, or modding.

 

Raw assets can be stored in the native file format of the DCC or in a common interchange file format (e.g. Collada for meshes), obviously to have a chance to re-load it into the DCC and make changes. These assets are further given by individual files, although a single file may provide more than one asset.

 

Runtime assets are usually provided in a game engine specific file format. The purpose is to yield in fast loading, which means a binary format because it is more compact but also requires less pre-processing in the game engine. The tool-chain is responsible to convert from raw assets to runtime assets.

 

With respect to the normal game play runtime, one don't want to have to open one file per asset. This is because file opening costs time, and having many more or less small files consumes more storage footprint. The solution is to use some kind of package file format. It further allows assets to be sequenced which in turn allows for shorter load times.

 

Now, with respect to hot-swapping, updates, and/or modding, storing assets in a single big package is bad, because replacing an asset in a package is often painful. A solution is to use the same file format but allowing for single, additional files so that the content of these files override the corresponding content of the regular packages. The runtime asset loader can handle this for example if the overriding asset files are stored in a dedicated file directory apart from the main asset files.

 

With packages the question of different file suffixes for runtime assets vanishes obviously. Further, it it easier for the runtime asset loader to handle a single file suffix. It has to investigate the file content anyway. So for me using a single suffix for runtime assets is a good way.

 

Just my 2 Cents.

1

Share this post


Link to post
Share on other sites

Runtime assets are usually provided in a game engine specific file format. The purpose is to yield in fast loading, which means a binary format because it is more compact but also requires less pre-processing in the game engine. The tool-chain is responsible to convert from raw assets to runtime assets.

I'm using that, each class has his file format and asset class is just an header at the end, and one function to just read the header can be added to check the asset type.

I have a PakFile class who uses ZLib for compression, I read from memory from this PakFile, I have an entry table.

Edited by Alundra
0

Share this post


Link to post
Share on other sites

I only throw my tuppence in here as I'm currently undertaking a similar task:

Assimp does this.. a 'aiScene' is loaded which contains meshes, materials, animations - materials contain raw bits of textures, and colour information.  Assimp does a fairly good job of this for many formats - in fact I came this ' ' close to ripping of their code for my dissertation*

Project 1 (An 'editor'):

 - I'm using Assimp to load models with all their materials into MyMesh class, then writing out MyMesh to a binary file optimized for reading into memory quickly (think memcpy over for(i = 0;...) when loading this file)
- include geometry, anim, materials etc in the one file.

Project 2 (A 'game engine'/renderer):
- Load the 'optimized' custom format, use it.

 

On the other hand, there are some compressed binary model file formats out there - I've heard good things about OpenCTM, for example. (Google if curious).

*of course I mean properly referencing, and simply using Assimp instead of writing my own. If anyone can find documentation for the animation chunks in the .3ds file I will give them cookies.
 

0

Share this post


Link to post
Share on other sites

I would recommend you to not have material in mesh class but only MaterialID who is index of material in subset.

Then you can have a MeshComponent who has a mesh pointer (from manager) and array of material (from manager too).

0

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