Grasshopper's picture

Model Loader: Current State?

Hallo!

I found some promissing discussions about creating a model loader for C#/OpenTK, but they all ended without results or so it seems to me.

What is the current development state?


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
flopoloco's picture

One cool resource (as far as I know) to get started is a nice MS3D loader in Kamujin's OOGL project.
http://sourceforge.net/projects/oogl/

I hope there will be more formats and specs supported the following months.

Inertia's picture

OOGL is the best solution so far, other options are:

  • Take a look at XNA for importing models, which can load .fbx, .x and collada (probably more, not up to date on this)
  • Most model editors allow export to some human-legible ascii format, which is more straightforward to parse than binary.
Grasshopper's picture

OOGL looks good, but I guess there is no documentation/examples and only milkshape?
I don't want to depend on XNA.

I looked at the collada format, looks good to me. Maybe I'll hack something together that just imports triangulated meshes :\

himek's picture

https://collada.org/public_forum/viewtopic.php?f=13&t=676
The example uses XNA for rendering, but you can use just the document loader. I'm going to do so for my project ;)
Also there are loaders for .3ds and .obj in C#, but these formats are very limited and old.

IMHO there's general need for an open-source COLLADA viewer in C# + OpenGL.

JTalton's picture

Here's a simple wavefront .obj model loader. Loads up the data, collapses it down, and renders it as an interleaved array.

ObjMesh objMesh = new ObjMesh("MyModel.obj");
objMesh.Render();
AttachmentSize
ObjMeshLoader.cs5.79 KB
ObjMesh.cs3.12 KB
Inertia's picture

Thanks for sharing the .obj loader! There's also a md5 mesh and animation loader floating around the forum, but cannot find it anymore?!

papageorge's picture

after I use the loader what do I write in opengl loop ?

the objMesh.Render()?

JTalton's picture

Yes

VeliV's picture

I wrote my own .obj loader for my project. Works quite nicely. Generating triangle strips was the only thing I couldn't get to work :)

master2k's picture

Hello World, i'm new to openTK, and tried these objectloader(sample) above in all variants but i dont get anything on my screen, the best result was a white Box , i came from directX there were 3 important things to set, the perspective (z culling i set these z parameters to 1500f), this GL.Translate should be same as device.transformworld , i set the coordinates where to draw my object, i did set camera pos with , and the viewmatrix to set,, i wrapped over to oTK and realized that mostly all settings to apply are be the same thing, i can draw something in my wolrdspace, triangles, quads etc. all works fine for me, but this sample source of the mesh loader give me no object at all or a white box, has someone a clue what im doing wrong?
I debugged the arrays and my console tells me there are 2880 triangles, and 1573 vertices stored correctly in the array buffers, no quads present, so it loads up the things correcty, but theres a problem with displaying the object data

i declared my object like this:

public class mainprogram : GameWindow
{
public static ObjMesh mesh1 = new ObjMesh("E:\\texturedknot.obj");
}

on renderframe {
..
..
mesh1.render();
}

// i found it myself, it's a bug in the parsing engine, i rewrote the parsing engine myself, my code seems a litte bit faster then the other, i do read in completely in an array and process all lines, maybe when i've more time i'll do implement multithreading.
// EOL

best wishes

M2k