[RESOLVED] 3D fileformat for opengl in .NET
Hi,
The question:
I was just wondering what kind of file format you guys use for your opengl projects? I have a lot of problems with this.
No C# support
What amazes me a bit is that there is so little C# support. OpenGL doesn't support anything from the box, so I figured I have to write my own file-reader. There are plenty of opensource projects for that in C++. But I have not seen any in C# so far. (In fact I searched on several sites like google and sourceforge.net, opengl.org,...)
A suggestion for a file format
So now I am writting some own data format that should look something like the following.:
Code:
<TEXTURE src="firstimage.gif" name="txtbricks"/> //Texture declarations
<TE...RE/>
<OBJECT name="my first object">
<FACE drawingmethod="GLTRIANGLES">
<POINT colorr="" colorg="" colorb="" x="" y="" z=""> //collored face
<POINT colorr="" colorg="" colorb="" x="" y="" z="">
<POINT colorr="" colorg="" colorb="" x="" y="" z="">
<POINT texturename="txtbricks" texturex="" texturey="" x="" y="" z=""> //face with texture
<POINT texturename="txtbricks" texturex="" texturey="" x="" y="" z="">
<POINT name="shoulder-junction" texturename="txtbricks" texturex="" texturey="" x="" y="" z=""> //giving certain points names will allow me to write animations later
<PO..../POINT> //more points
</FACE>
<FA..../FACE> //more faces
</OBJECT>
<OBJ..../OBJECT> //more objects
Some advantages I see:
Well I think the advantages are obvious:
- It's a simple format, easy to understand, no unncessary junk
- Because it's XML based it's easy to parse from .NET
- The structure fits the way it is going to be drawn. Textures will be declared first with the opengl functions "Texture = new OpenGLTexture2D(@"texture file"); " and next they will be painted face by face based on a drawingmethod specified in GlBegin(drawingmethod) followed by the vertexes.
Next problem:
The same problem remains! I still need to write a converter because my format will not be supported by any program. (Somebody suggested an Exporter for 3D Studio Max but that would be in C++ again. And I just don't know enough C++ to write something like that). So I am going to write a X3D converter now (X3D is some kind of XML-based VRML).
I can not imagine that I am actually the first person that is serious about writing OpenGL in C#. There must be somebody else that had the same problem? So, if you are that kind of person and are reading this, do not hesitate to let me know :).
1 Attachment(s)
Re: 3D fileformat for opengl in .NET
Just wanted to add my classdiagram of it. :). Lol, I finally got my VS2005 DVD yesterday and immediatly fell I love with those UML-like diagrams. :afrog: My vacation started yesterday so this will probably be finished by the end of the week.
Re: 3D fileformat for opengl in .NET
While you guys are trying to remember what filetype you used (for which I am very grateful :p) ... I can let you know that my X3D converter is starting to work pretty well. :thumb:
1 Attachment(s)
Re: 3D fileformat for opengl in .NET
just wanted to show off my screenshots :p
1) A blender file exported in X3D
2) the X3D converted to B3D (my own format)
3) Added some color
4) Showed in opengl
Re: 3D fileformat for opengl in .NET
Wow, great progress. Looks like it works really well. I've never usedd C# but I've been trying to learn OpenGL for C++ the past month or so, but haven't done much with it.
Good luck on this project!
Re: 3D fileformat for opengl in .NET
Thanks fatman. I wish you good luck with your C++ adventure in opengl. OpenGL is quiet challenge isn't it? It took me 5 years to understand it. :afrog:
The first time I tried to do someting in 3D I tried directx5 in VB6 I think. But I didn't understand a thing of what I was doing. It had so many dll calls and commands I had no idea what they were doing. So, after a while I gave up :(
A bit later I tried again with directx6. I assumed that would have been simular. But it wasn't! everything was changed. :confused: And it was just as hard as the time before. I quit shortly after.
I retried with directx7.1 but it was just the same problem.
I bit later I wanted to give it another shot with directx8. Again everything looked different and I failed. :sick:
So, I a year later I retried with "managed" directx9 for C#. I downloaded this huge SDK. And it seemed that this trash was so slow that even the samples from the tutorials could not run on my computer at decent speed. :mad:
So instead I tried opengl. Because I was getting a bit used to directx, opengl seemed very different for me. I started to understand things better but a week later I gave up again because I didn't really know how to get from the ground. Also in opengl you can't load .x files (as in Directx). So pretty soon I gave up because I got tired of drawing just triangles and lines. :rolleyes:
Years went by... I learned some more java and C#. I learned about inheritance, polymorphism, ... I learned all about design patterns and the model-view-control stuff. I did a supermario clone game. That all went flawless. And now I finally retried and it's really easy now. ;)
Seems like I just was not ready for it at that time. Also I must have been a fool to try directx in Visual Basic 6. It's impossible to write a 3D engine in a language that is not even object oriented. That's just rubbish. :p
I really like all those tutorials out there that concentrate on drawing. But real beginners shouldn't start out with those tutorials. They should start out with making a paint-application or something like that. Something that redraws the screen by using a thread. I think that's why so many people (including me) fail several times before getting it. I think another reason why a lot of people fail, is that there is no standard function to load files. You can't expect a beginner to write all that stuff himself. :duck: And as long as you are not able to load files it's not going to get you far anyway.
If I were better at C++ I would do it in C++ for sure. That's really a big advantage you have (all those opensource projects)! But I only know the very basic of C++. So, I am cursed to use C# and java for the rest of my live :D
1 Attachment(s)
Re: 3D fileformat for opengl in .NET
The last days I've been puzzled with lightning effects. The following screenshot is a ball with 120 000 points that's turning around while there's a light pointed at it. The model was made in Blender (Free modeling software) and exported to X3D. Next I imported it and converted it to my own format. The X3D file did not contain information about the normals. That was a bit of a problem, because without normals you can not make lightning effects in opengl. To solve this I wrote a function to split every face into 4 triangles and calculate the normals for them by multiplying vectors. Quiet a challenge!
This makes it time to call this topic resolved! It's too bad there are so little opengl developers on this forum. I guess DirectX is a lot more popular? I wonder why though. From my personal experiences it's both harder and slower.
Re: [RESOLVED] 3D fileformat for opengl in .NET
I just created a blog where this project continues:
Ant Wars Blog
See you later all!