Page 1 of 2
simple obj to custom format converter
Posted: Sun Jul 06, 2014 1:04 am
by djmauro
Now iv spent quite a bit of time trying to figure out the format of the model - and iv got it down to bare minimum that is actually needed (my other thread).
But i lack any c++ or similar language skills to actually build a basic converter.
It doesn't need bones or animations.
Code: Select all
[filemask="*.msh"]
struct mesh08
{
cstr [len=6] modelType; //MESH08
i16 numMesh; // number of models in the file
child mshblock [count=numMesh];
}
struct mshblock
{
cstr [len=100] objectName;
cstr [len=100] meshLink;
repeat 4 {
i32 x;
i32 x;
i32 x;
i32 x;
}
//D3DMATRIX
repeat 4 {
float X;
float Y;
float Z;
float W;
}
repeat 4 {
i32 x;
i32 x;
i32 x;
i32 x;
}
i32 x;
i16 x;
cstr [len=200] texture; // must have drive,folder,filename like C:\tex\image.DDS
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i32 x;
i16 x;
i8 x;
i16 numVerts;
repeat numVerts
{
//D3DXVECTOR4 x y z w
float Vertex_x;
float Vertex_y;
float Vertex_z;
float Vertex_w;
//normals
float normal_x;
float normal_y;
float normal_z;
float normal_w;
//uv map
float tu1;
float tv1;
float tu2;
float tv2;
float tu3;
float tv3;
float tu4;
float tv4;
}
//faces
i16 numFaces;
repeat numFaces
{
i16 faceBuff;
}
i16 x; // 0
}
Here is the basic structure it has - where all the x values are 00 - filler.
i32 = 4bytes, i16 = 2bytes, i8 1 byte
The bone name can be filled manually in hex ( or a input in the converter?) same with the texture part.
Mainly need the matrix, vertex list ( vert, norm, uv) and face lis tafter that ( which is basically just a list of 2 byte values with a max of vertexnum/3)
samplefile:
https://mega.co.nz/#!7Y4HGKYI!y-6cdQJU- ... 4BKQoCGplE
Re: simple obj to custom format converter
Posted: Sun Jul 06, 2014 3:06 pm
by pivke
When I understood you right, you want a software that auto-imports obj-files, saves it's data and writes it in a custom format?
I think that's a nice idea. As I'm developing software for several years in C++, I would be ready to develop a small plugin-based software. It would be the easiest, when using simple DLL's as plugins, that can be written with poor C/C++-knowledge. But I don't know if beginners are going to do that.
Another option would be, to let the modders write their own plugins in python, but then the whole story is going to be more complex. Since then the software would need a python-interpreter like Boost::Python and and and...
So as you can see, this simple idea can easily grow to a bigger task. When several people here are going to like your idea, im ready to start developing.
Re: simple obj to custom format converter
Posted: Sun Jul 06, 2014 4:44 pm
by djmauro
yeah - i know php mainly btu thats not a good option to deal with data intensive job like that.
It would have to read all the data into into arrays - and then write it out based off the custom format structure.
The first part would be common yea - and not even too complicated. Then you could theoretically use plugins or some scripting language to allow the program write the data back into the custom file.
PHP would most likely crash trying to parse several mb of 3d data.
In my case - actually all it needs is 2 things - the 3d/texture data and matrix. The face list can be just generated ( divide vertex count by 3 and create a list of 2 byte numbers) - rest is just filler data and simple stuff.
Also - obj may not be the best option perhaps ( since it has two files - mtl separately, so a bit more messy).
Re: simple obj to custom format converter
Posted: Sun Jul 06, 2014 6:31 pm
by MichaelDarkAngel
If I'm following you, you want to take an OBJ file and convert it to another universal format... Now this is where I get lost.
Just not sure I understand what the goal of this new file is.
-- MDA
Re: simple obj to custom format converter
Posted: Sun Jul 06, 2014 6:45 pm
by djmauro
no this is far from universal format - its a custom format the game uses.
Re: simple obj to custom format converter
Posted: Sun Jul 06, 2014 7:52 pm
by MichaelDarkAngel
Ok, understanding a little more.
Are you creating a game? Are you attempting to import new models into an existing game? Are you attempting to import models from one game to another?
Assuming the last, why not skip OBJ altogether? If you know the formats of both it shouldn't be too much of a stretch to write something to go from one format to the other. You cut out any middle-ware and are less likely to lose any information.
Learning a new programming language isn't that difficult if you have some programming background. Visual Studio Express is free and powerful enough to help you learn while using. I started out with BASIC on a C64 many years ago and have self-taught myself numerous languages over the years. While I may not be the most efficient at programming, what I can do gets the job done. Put your mind to it, and you can do anything.
-- MDA
Re: simple obj to custom format converter
Posted: Sun Jul 06, 2014 8:31 pm
by djmauro
its new models into the game.
And cutting out the conversion adds a lot of extra work - u would have to create a platform specific plugin for what ever 3d tool you are using ( for ex autodesk).
Also, are there easier formats to use besides obj ( that has similar structure already - instead of having separate .obj and .mtl files).
Unless u know of something that would already take care of majority of it - so u would only have to deal with exporting the data to ur own format.
Re: simple obj to custom format converter
Posted: Sun Jul 06, 2014 9:30 pm
by pivke
djmauro wrote:
It would have to read all the data into into arrays - and then write it out based off the custom format structure.
With a plugin-system, there is a way more efficient way dealing with that.
djmauro wrote:
PHP would most likely crash trying to parse several mb of 3d data.
Why should PHP crash? PHP is just fine as well as every language else. When configuring your server right, you can simply work with Gigabyte of data in PHP. There are just a few problems with multithreading, as that goes too far for PHP. (When I remember it correctly, that was a main-problem of PHP version <5?)
djmauro wrote:
The first part would be common yea - and not even too complicated. Then you could theoretically use plugins or some scripting language to allow the program write the data back into the custom file.
Don't understand me wrong, but as it seems, you really dont have any idea about softwareprogramming. So you shouldn't try to manage anything around that. Just try to support.
djmauro wrote:
Also - obj may not be the best option perhaps ( since it has two files - mtl separately, so a bit more messy)
...
OBJ is just fine. Why should the seperate mtl-files be more messy? You just have to know if you want to support bone-animation or not, because OBJ only stores static meshes.
Re: simple obj to custom format converter
Posted: Sun Jul 06, 2014 10:04 pm
by djmauro
djmauro wrote:
The first part would be common yea - and not even too complicated. Then you could theoretically use plugins or some scripting language to allow the program write the data back into the custom file.
Don't understand me wrong, but as it seems, you really dont have any idea about softwareprogramming. So you shouldn't try to manage anything around that. Just try to support.
Why is that?
There is nothing wrong with that way of doing things.
You would use your x language for the main part of the tool.
You parse/read the data from .. for ex. obj/mtl into arrays.
Now you have all the data.
You ether support user made same language plugins to reformat and arrange the data for their file - or a simple scripting language that guides the tool to format it instead.
You often deal with ether binary or text based formats and mainly just loads of floats. Just in a different order with different indexing.
So im not sure where you took the " i have no idea about programming" - i do php, i can read any language - even those i haven't seen before ( reverse engineering purposes) - and do minor fixes.
I do not however simply have the experience to just write one from scratch and with plenty of php work, reverse engineering game file formats, hosting a server - and updating/maintaining it - i simply don't have the luxury to learn a language enough to write it from scratch.
Re: simple obj to custom format converter
Posted: Sun Jul 06, 2014 11:15 pm
by pivke
As I said, please don't understand me wrong. I'm sorry if you misunderstood me, there was no offense meant. Maybe there are some language-complications, english is not my mother-tongue
What you wrote just sounded like: "you just have to do that and that... and then it is finished". Maybe that's what made my angry. Over the years I've got some bad expierence with people saying "lets do x, y, z" and in the end, you did everything, and they did nothing.
Just try to do the things, you are good at. And everyone else will too. Then things, like those little projects here, will be finished.

Re: simple obj to custom format converter
Posted: Mon Jul 07, 2014 4:51 pm
by finale00
I would just use Noesis to write the converter. Then you can convert everything into your format.
Re: simple obj to custom format converter
Posted: Mon Jul 07, 2014 7:59 pm
by Seyren
finale00 wrote:I would just use Noesis to write the converter. Then you can convert everything into your format.
Pretty much, i would just use Noesis for your needs, it can load and save in the formats you desire.
I'm not sure if saving as a format is supported tho, but it can open them.
If it doesn't it would be a nice idea to start considering doing it.
Re: simple obj to custom format converter
Posted: Tue Jul 08, 2014 2:30 am
by djmauro
noesis can read - that's what i used to reverse the format - but besides the c+ written dll or built in export supports... i don't see anything.. Not even documentation.
Re: simple obj to custom format converter
Posted: Tue Jul 08, 2014 2:33 am
by chrrox
the included readme shows full export support i also did an xml export tutorial.
Re: simple obj to custom format converter
Posted: Thu Jul 10, 2014 1:22 am
by djmauro
i may skip the obj and look at maxscript. anyone knows some decent tutorials that covers binary format exporting on maxscripts ( so i can skip all the 100-s of basic tutorials - im overall quite familiar with scripting and programming by itself).