Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!

How to add grouping feature to custom mesh file format

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
8 replies to this topic

#1 Vortez   Crossbones+   -  Reputation: 2704


Posted 07 March 2014 - 11:55 PM

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

Attached Files

Edited by Vortez, 08 March 2014 - 12:04 AM.


#2 Vortez   Crossbones+   -  Reputation: 2704


Posted 08 March 2014 - 04:17 AM

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

#3 Buckeye   Crossbones+   -  Reputation: 6857


Posted 08 March 2014 - 08:12 AM

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, 08 March 2014 - 08:32 AM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

#4 Vortez   Crossbones+   -  Reputation: 2704


Posted 08 March 2014 - 02:58 PM

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, 08 March 2014 - 03:26 PM.

#5 Buckeye   Crossbones+   -  Reputation: 6857


Posted 08 March 2014 - 05:32 PM

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.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

#6 Vortez   Crossbones+   -  Reputation: 2704


Posted 08 March 2014 - 06:51 PM

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, 08 March 2014 - 07:04 PM.

#7 L. Spiro   Crossbones+   -  Reputation: 15671


Posted 08 March 2014 - 09:31 PM

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

It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#8 Alundra   Members   -  Reputation: 965


Posted 08 March 2014 - 09:56 PM

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.

#9 Vortez   Crossbones+   -  Reputation: 2704


Posted 10 March 2014 - 10:10 AM

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

Edited by Vortez, 10 March 2014 - 10:11 AM.

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.