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

How to add grouping feature to custom mesh file format

8 posts in this topic

Im planning on adding some "grouping" feature to my custom file format of 3d models (i made an exporter for 3ds max) but im not sure how, so i would like to hear your sugestion.

 

Btw the file format is binary.

 

Im also attaching the file format spec in case that would help.

 

The file format is pretty simple, you have the file header at the top, and for each objects, the object header and data block .

What method should i use, when exporting multiples mesh, to know if they're grouped or not, i know ill probably need something like a tree i guess (ill figure the 3ds part myself, the question is file format specific).

Edited by Vortez
0

Share this post


Link to post
Share on other sites

Maybe i should assign an id to every objects, and add some fields like parent, numchildrens, childrens[], next/prev sibling ect?

0

Share this post


Link to post
Share on other sites

First: I am not at all saying you shouldn't be designing a custom file format. It's usually the right thing to do if you want to load/save data derived from another more general file format (you mention 3ds Max).

 

The direction of the data flow you're asking about is confusing. Just for clarity, do you want to export data (say, from a modeling program) or import data (into an application) to support rendering a mesh? The reason I ask is that a good file format for importing data can be an excellent addition to an application. That can be supplemented by one or more conversion routines, separate from the application itself, to change (for instance) 3ds Max files to something better for your specific needs.

 

I'm suggesting you should know why you're doing something, i.e., what you want the result to be, before you decide how to do it. You don't mention why you want a custom file format. As your decisions should be based on that, it's difficult to make suggestions to help you go in the right direction.

 

So.. what's the purpose for your particular file format? Speed in loading/saving to reduce disk access time? File size?

 

Do you want it to be flexible (i.e., load any type data in any type of arrangement), or are you looking to save/load data in a specific fashion to fit the specific needs of your application?

 

 

 


when exporting multiples mesh, to know if they're grouped or not

What do you mean by "grouped?"

 

If you're exporting data, you should already know. Or, are you asking how you can tell from the 3ds Max file whether meshes are "grouped" because you want to do something similar?

Edited by Buckeye
0

Share this post


Link to post
Share on other sites

The thing is, the exporter/importer descripted in the attached file already exist, i want to expand on it.

 

What i mean by grouping is, you know, when your in studio max, you can group stuffs(meshs) together in a scene, and then group two or mores other groups together ect, like directory and file in windows explorer for example.

 

I know the file format seem a bit weird but, it's not that bad actually. im basically exporting mesh data in 3 groups, indexed data for curved stuffs, non-indexed data for blocky stuff (ie cubes), and studio max data required for the importer only. Having both indexed and non indexed vertices might seem like a weird choice at first, but it has it's use. I can choose which mode to use when loading them in my engine. I just made a compromise to use them both instead of only one in the file format, so i can use one code path when importing later, i kinda choosed more flexibility at the little cost of a bigger file size if you want. also, since the file format support compression internally, this is not a big problem.

 

The thing with cubes is, if your vertices are indexed, you can't use per face lighting, which look wierd, and you can't texture each face independently either, but a sphere for example don't usually require per-face lighthing and using the same texture uv on a sphere work usually well, but not a cube, that's why i export both way.

 

But, all this dosen't really matter for the question im asking, it's just to clarify the format i used.

Edited by Vortez
0

Share this post


Link to post
Share on other sites

It appears your question is either studio max or 3ds specific, rather than a General Programming question. Though someone with specific studio max API knowledge or a better familiarity with the 3ds format may find your post here, you may want to consider having a moderator move it to a more appropriate forum.

0

Share this post


Link to post
Share on other sites

Im not asking for the code to do this, just what is the best way that i could use to save the different meshs parent/neighborg/childs hiearchy relationship in the file.

 

In other words, how do you save/load a tree to/from a file?

Edited by Vortez
0

Share this post


Link to post
Share on other sites

This is not specific to 3DS Max or Maya; groups exist in a variety of other formats, including FBX.
Support for groups is necessary for modeling the way things are animated in authoring tools (since you can group a pair of objects and then start animating the group, causing the both to move, etc.) within your engine, and it is an error for any custom 3D file format not to have support for groups.


Exporting them is trivial depending on how you have set up your format.
Something else that is necessary to replay animations properly is support for a hierarchy (a scene graph) inside the model data. The arm needs to know it is a child of the body etc.
If this system is not yet in place, place it.


Next every object in the file is part of the scene graph. They all inherit from CEntity or CUnknown or CNode or whatever.
Properties common to all objects in the file will exist as a member of that base class. That means basically a type, name, unique ID, a transformation, and a parent ID.


Every object can parent any other object so any missing objects, such as a light or in this case a group will cause problems. So you need to export all the objects, even if temporarily you aren’t using them. Any objects you don’t use, let it fall back to being a group in your file format until eventually you get to it.


A group is just the CEntity or CNode—whatever—that returns a “GROUP” ID type. Serializing it is otherwise the same.



There is nothing special about exporting a tree/hierarchy to a file; I’ve just described it. You export the unique ID on each object along with its parent ID.
When loading, load everything linearly and then connect them within your run-time structures via actual pointers to loaded objects (for parenting and childing). Parents are found by searching the linear list for the proper ID.
Note that the shared base mesh does not need any form of actual parenting; it is not a run-time structure. Mesh instances need the parenting data only.

 

 

L. Spiro

1

Share this post


Link to post
Share on other sites

As L. Spiro said, Index is enough, and for save/load it's easy using them, x86/x64 same size, you don't need pointer for that.

Take care about group, sometimes you can have problem during export, but the problem is fast found.

The scene is always exported in recursive way so the parent is always valid in order.

0

Share this post


Link to post
Share on other sites

Ok, thank you for your answers, ill look forward into that.

Edited by Vortez
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