Jump to content

  • Log In with Google      Sign In   
  • Create Account

Writing model 3D Model data to a new file as a new 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
12 replies to this topic

#1 Anddos   Members   -  Reputation: 515

Like
1Likes
Like

Posted 17 April 2014 - 05:08 AM

I am just wondering if its possible to write 3d model data to a file,instead of directly working with md5 files i would like to convert to my own format,the information i want to write to the file are vertices,normals,vertex weights,texture coords,so far i have written the model data to a text file but now i would like to write it to my own file format using fopen,fwrite as binary data, or should i stick to just md5 files in the game directory?


:)

Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 7991

Like
2Likes
Like

Posted 17 April 2014 - 06:19 AM

It is possible and a lot of games, including my own, do it this way. Thought I wouldn't recommend md5 as basic format (it has its restrictions), but either FBX or Collada from which you should create your own files.



#3 TheComet   Crossbones+   -  Reputation: 1640

Like
1Likes
Like

Posted 17 April 2014 - 07:32 AM

You might also want to consider using a library to save you from writing your own exporter/importer.


YOUR_OPINION >/dev/null

#4 Anddos   Members   -  Reputation: 515

Like
0Likes
Like

Posted 17 April 2014 - 09:36 AM

It is possible and a lot of games, including my own, do it this way. Thought I wouldn't recommend md5 as basic format (it has its restrictions), but either FBX or Collada from which you should create your own files.

 

 

What are the restrictions?


:)

#5 Ashaman73   Crossbones+   -  Reputation: 7991

Like
3Likes
Like

Posted 17 April 2014 - 11:06 PM


What are the restrictions?

The restrictions are just what the format does not provides , but what you need. MD5 was developed for id tech engines with their needs, but sometimes your engine need additional data, eg vertex color, different uv coords, multiple textures etc. which might not be covered by MD5. Collada/FBX on the other hand contains a lot of stuff, most which you dont need. It depends on what you need. If MD5 contains all data you need, than use it :D


Edited by Ashaman73, 17 April 2014 - 11:07 PM.


#6 ferrous   Members   -  Reputation: 2146

Like
0Likes
Like

Posted 18 April 2014 - 01:54 PM

This is probably obvious, but the md5 format itself doesn't have restrictions, but the model that is in md5 format may have restrictions.  For example:  You can't just grab a doom model, write it out to your new format and use it in your game that you are making money on (I doubt they'd care if it was just some open source game), and even someone's custom model may have some rights attached (though I'm a bit murky on that one)


Edited by ferrous, 18 April 2014 - 01:56 PM.


#7 DiegoSLTS   Members   -  Reputation: 1870

Like
0Likes
Like

Posted 18 April 2014 - 03:23 PM

If you want a file format for 3D models that lets you store some custom information try with PLY. You can define the name and the type of a property of the vertex in the header and then for each vertex you store the values for each property in one line. Here's an example of one file with only vertex position (x, y and z) and faces, and other example with vertex position AND colors, faces and "edges" (you can add new elements if you need too): http://www.mathworks.com/matlabcentral/fx_files/5459/1/content/ply.htm



#8 Eric Lengyel   Crossbones+   -  Reputation: 2483

Like
4Likes
Like

Posted 18 April 2014 - 06:18 PM

There is also the new OpenGEX format:

 

http://www.opengex.org/



#9 Buckeye   Crossbones+   -  Reputation: 6214

Like
2Likes
Like

Posted 18 April 2014 - 09:33 PM


i would like to write it to my own file format using fopen,fwrite as binary data, or should i stick to just md5 files in the game directory?

I'd suggest using your own binary format. The first step is to determine an efficient way to load the model data which supports how your app creates the model internally, in what order you want position, normal, texcoord, blend indices, blend weights, etc., to write into your buffer or structure. Then design the file format to support that process.

 

Only as an example, if you have  a vertex comprised of position, normal, diffuse color, 2 tex coords - read in your md5 file, setup your model with that vertex structure, open an output binary file, write a header describing the number of vertices and the format/stride, etc., and write the binary data out in vertex order. You can then read in that file by reading the header, creating a buffer of appropriate size and load data directly into the buffer. You may want to consider extras like texture names, etc.


Edited by Buckeye, 18 April 2014 - 09:34 PM.

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


#10 Ashaman73   Crossbones+   -  Reputation: 7991

Like
0Likes
Like

Posted 18 April 2014 - 10:29 PM

There is also the new OpenGEX format:

 

http://www.opengex.org/

Hmmm. looks really interesting, thought a few month too late for me (refactored my converter from the over-engineered collada to the proprietary FBX format), thought there is one question:

What I really miss from all this exchange formats, especially when using them to export stuff for a game engine, is the lacking support of custom attributes. You can add custom attributes in modelling tools, but you never got them exported to Collada/FBX. It is possible with OpenGex ?


Edited by Ashaman73, 18 April 2014 - 10:30 PM.


#11 Eric Lengyel   Crossbones+   -  Reputation: 2483

Like
1Likes
Like

Posted 19 April 2014 - 07:01 PM


What I really miss from all this exchange formats, especially when using them to export stuff for a game engine, is the lacking support of custom attributes. You can add custom attributes in modelling tools, but you never got them exported to Collada/FBX. It is possible with OpenGex ?

 

It depends on exactly what kind of custom attributes you're talking about. OpenGEX supports custom per-vertex data and custom material attributes, but intentionally does not allow for general custom data all over the place. The reason for this is to avoid the creation of software-specific standards like you see in the Collada format through the use of the <technique> elements, making it necessary for importers to understand information whose format is specified over multiple poorly-maintained documents. Now if you're just talking about custom user-defined key-value properties like those supported in 3DS Max, then I can tell you that support for these is being considered for the next version of OpenGEX, and it's something that can easily be added to the existing exporters.



#12 jbadams   Senior Staff   -  Reputation: 19330

Like
0Likes
Like

Posted 19 April 2014 - 07:29 PM


This is probably obvious, but the md5 format itself doesn't have restrictions, but the model that is in md5 format may have restrictions.

You're talking about a different type of restriction than the above posts; you're talking about legal restrictions in how you can use a particular model, whilst Ashaman73 was talking about the fact that some data isn't stored in the md5 format.  If you don't need that data anyway this restriction doesn't matter to you, but if you do need that data it's probably worth investigating other formats. smile.png



#13 Ashaman73   Crossbones+   -  Reputation: 7991

Like
0Likes
Like

Posted 19 April 2014 - 10:06 PM


Now if you're just talking about custom user-defined key-value properties like those supported in 3DS Max, then I can tell you that support for these is being considered for the next version of OpenGEX, and it's something that can easily be added to the existing exporters.

Yes, I'm talking about this kind of additional information. There's is always some kind of game (engine) specific information I like to export properly which can't be mapped to Collada/FBX (animation specific sampling rate, if a bone is a item link etc). Either you need to write your own exporter or you use some hacky name-convention information hidding.






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.



PARTNERS