How can I load 3d models?
tommy tinpo

I don't know how can I load 3d models, and if I can make them whith a specific program such as: 3d studio etc....

tnx a lot at all!
and excuse me for my poor English!:'(

X-G

Find file format somewhere. Read it and parse into your mesh structure. Where is the problem here? You need to ask a more specific question.

23yrold3yrold

Right. Just create the data structure to load the data into, then load the file into it, and you're done.

gnolam

I agree with Secretary of State X-G.

Anyway, for a file format to implement I suggest the Wavefront OBJ format - it's an ASCII format, and about as simple as a 3d model format can be (at least if you ignore the NURBS stuff). And as a bonus, most decent modelers can export to .obj so you won't have to write your own converters.

Thomas Harte

Grrrr, and I wasted my life on a 3ds importer!

tommy tinpo

I understand what you say, but now, can you suggest me some tutorials of allegro opengl or something about 3d programming with allegro?

FMC

tutorials about OpenGL: NEHE
allegrogl version of nehes tutorials: http://www.allegrodeveloper.org/

also have a look at the redbook(programming guide for opengl) and at the bluebook(reference for opengl)

tommy tinpo

Somebody can suggest me a program to convert 3d models into file to parse into mesh structure.

thanks a lot at all!

X-G

3D models ARE files you can parse into a mesh structure. What do you need?

FMC

Game Tutorials scroll down the page, you will find tutorials on how to load some 3d models format in your prog

tommy tinpo

I have another problem... I have a 3d model with 2 animations, how can I use the animations of the model?:P

X-G

Load both and display them at the appropriate time, of course.

Ask more specific questions, damn it. :P

tommy tinpo

Mithrandir I have sent you a private message!

Rampage
Quote:

Mithrandir I have sent you a private message!

Ah, the irony...

Archon

Ive been trying to load 3D models but I just use someone elses ;). But the code to load a MD2 format (or MDL or MD3) are like 5 pages long :-\

deps

So? Start typing! :)

Archon

I WOULD but, I like stuff to be easy but with control. Thats why I wanna dissect the MD2 Loader and make it a header that I can use in any AllegroGL project... Instead of full on DirectX

pantz

MD2 is actually a pretty easy format to load and display. The downside is that it's pretty aged and still uses frames and not a skeletal animation system. I hacked up a small MD2 loader last weekend for my game, to see how hard it actually is to load/display them. (see attached file) It uses C++, Allegro and AllegroGL, and it's not 5 pages long ;) It could be even shorter by using a single fread to load the data. Anyway, maybe it gets you started.

Some things to note:
- the animation is hard-coded to the single "stand" animation of the model. There's a list with the different animations and how many frames they use somewhere

- the animation is a bit bumpy, that's because only the key frames are displayed, there is no interpolation done

- it's my first try at MD2 and 3d models in general, so it's not perfect ;)

Archon

Hmm, I envy your ability to learn something Im TRYING to learn pantz. I downloaded your MD2 example but I am having problems with Allegro.h for some reason... Never done this before

--------- EDIT -----------
BTW, any other stuff youve integrated into Allegro / AllegroGL that might be useful for me? :D

--------- UPDATE ------------
Ok, I fixed the problem by removing the includes to stdio.h and string.h.
And it says the FPS is 100 - 130, but I see what you mean by its jumpy. Would you know how to fix it?

pantz

Do you have vsync on? I get like 1400fps without vsync. To get smooth movement you have to interpolate between the current frame and the next frame. That means computing the vertices of the triangles on your own, depending on the display duration between the single keyframes.

Archon

You didnt do that? :(

And NFI whether I do :-\

--------- EDIT ---------
Ok, I think Im having troubles with the fread stuff but thats coz i skipped a chapter in my ironically correct book "Complete Idiots Guide to C++" :P

--------- EDIT 2 ---------
Ok, It is starting to make sense as I am using a hex editor + reading the code...

pantz

I didn't implement it because it was just a test and my game will only need few (if any at all) animations, it's a space shooter :)

But it shouldn't be that hard to implement it. I think all you have to do is to get the difference between each current vertex and the next vertex, divide this distance by the number of steps (smoothness) and add this number to the current vertex position.

steps = 10
distance = new_x - old_x
amount = distance / steps
vertex_x = old_x + amount

for x, y and z. Maybe it's easier to use vectors though.

Archon

Its all making sense now!!! But since I havent read all of MD2.cpp, which function would that go in?
Also I dont know what the 'status' is of vsync.

-------- EDIT --------
OK, I am getting the hang of this... Are all models loaded like this (but different ways). I mean like they all have structs of vertices, triangles etc and rendered a similar way?

Tobias Dammers

No, some do also feature NURBS and other mathematical surfaces that can either be passed to the GL or transformed into poly's at run-time.
There are also a few games (very few, actually) that use some kind of voxel models, especially for terrain.

Archon

I think I mightve hijacked the thread... :-/

tommy tinpo: Did you try out pantz's MD2 (Quake 2 Models) loader?

jakerohs

Have you tried L3DS? It's...a 3ds loading library. With some type of free-ish license I believe.

Thread #383711. Printed from Allegro.cc