Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » 3d models

This thread is locked; no one can reply to it. rss feed Print
3d models
duncan perham
Member #15,403
November 2013

Unless there has been some new stuff I havent seen yet, im fairly sure allegro dosent do 3d at all. Thats ok, the stuff i am working on is 2d anyway, and I like it like that. However, it would be very cool if allegro had some functions like.

Init3d;
MyModel=Load3dModel(filename);
...
Draw3dModel(MyModel,ScreenX,ScreenY,RotationXYZ,scale,frame);
...
Free3dModel;

The camera would be fixed, simply rotate the model to get the angle you want, set the scale to get the model to the size you want, and forward the frame to get the frame that you want. What format this would work in??? Something with a skin and skeleton.

Im not into programmming 3d that much, and every time I look at it it blows my old mind (20+ year c programmer). It just seems so overly complicated. The above psuedo code should be all that is required to draw a 3d model in a 2d enviroment.

I know people will want 20 million other options, but if it was kept simple like above, I(any many others) would'nt have to render off millions of little sprites all the time.

So my question is, what would be the easiest way to just achive the above for allegro, or is someone already working on something like this.

Chris Katko
Member #1,881
January 2002
avatar

I'd suggest looking into Allegro 5, or less so, Allegro 4 with the AllegroGL addon, for 3-D. Software transformation and lighting is not something anyone should do these days unless they really like to learn it for the sake of learning it.

Different model file formats are in the hundreds. There's also the issue of what to do with animations. 3-D means you're either using the old method ala Quake 2 of every "frame" of 3-D is specifically defined, or skeletons.

I know people will want 20 million other options, but if it was kept simple like above, I(any many others) would'nt have to render off millions of little sprites all the time.

I'm not really sure how those two scenarios would normally cross paths.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Elias
Member #358
May 2000

It shouldn't be hard creating something like that. The first thing indeed would be to decide on a model format. Myself I just use an unsorted set of triangles, with each triangle looking like this:

X1/Y1/Z1/U1/V1/NX1/NY1/NZ1/R1/G1/B1/A1
X2/Y2/Z2/U2/V2/NX2/NY2/NZ2/R2/G2/B2/A2
X3/Y3/Z3/U3/V3/NX3/NY3/NZ3/R3/G3/B3/A3

(3 vertices each with position, texture coordinates, normal, color)

Each animation frame is a complete triangle set again.

Anyway, in return loading this is trivial and you can just pass it to al_draw_prim to draw the whole model. You can even use the vertex_buffer functions available in 5.1. And you also need a bit of code to deal with the shaders properly.

So yes, your example is possible in Allegro 5, but the functions do not exist yet. I could see a small (probably external) addon for this being quite useful though.

However in a game you very soon will need much more (it should have good performance when displaying 100ds of models, so need LOD and some spatial structures and so on, you'll need non-model things like level geometry/terrain, you'll want to be able to query things about models like feet position or eye position...) - and so then a full 3D engine makes more sense.

--
"Either help out or stop whining" - Evert

duncan perham
Member #15,403
November 2013

I was more kind of trying to create a 2d game, rather than a 3d game, at present I use poser to render off my animations. It would be a lot easier if i could use something like poser/daz/iclone/blender.... to animate the models (using mocap ideally). Then load and draw them in game as easy as 2d stuff.
There are many 3d engines (torque/unity) out there that can do this sort of thing, but they come with there own set of headaches, and 3d is a whole new level of complexity that most simple top down/45 degree or side scrolling games dont actually need.

I know the old md2 format was like frames, but i was under the impression that newer formats had a skin, which was static, then an animated skeleton. If you add up the memory required to store the skin and bone animation, its probably far less than 1000's of sprites. Also far more flexible as if you want to zoom in a bit, or zoom out a bit, the models will draw with the best detail, but sprites are what they are, if you zoom in, they become blocky. Also you might decide to change the angle, in sprites you would have to re-render everything. Then there is facings, on a 45 degree game, ideally you want 360 degrees of graphics, but that would be imense, so we settle for 8 facings. But if it was a 3d model you could do all 360 if you wanted it.

Given that allegro is a 2d enviroment, I would imagine that most people who are using it , want to work in 2d. But programs like poser are the simplest/cheapest way to get graphics into the games.

So how to achieve this, I dont have a great amount of experience in 3d programming,
pointed to the right tutorials, I might be able to do it. But I have not found many good tuts. Do any of u guys know some good tuts on loading/drawing 3d models.

Also what would be the best format. Draw Speed vs look is obviously importiant, so maybe that could be set in the init function. What programs support the file type, and how much do they cost, things like 3dmax are not exactly cheap, or that easy to master. Then there is how much content is available, daz and poser have tons of cheap models.

beoran
Member #12,636
March 2011

Well, there are many open source tools like MakeHuman, Blender, Wings3D, etc, ... And those have model loading code available you could borrow. Also IIRC someone ported the CUBE 3D engine to Allegro 5. Perhaps that combing a few of these things can get you closer to what you want?

ks
Member #1,086
March 2001

duncan perham
Member #15,403
November 2013

Thank you for the above links, i shall look into them. No point reinventing the wheel if someone else has already done it. (on top of that, mine would be square wheels)

Go to: