Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Voxels

This thread is locked; no one can reply to it. rss feed Print
Voxels
empty
Member #1,919
February 2002
avatar

I tried to make a voxelcode, to make voxelunits like the one in RedAlert 2. But somehow, i failed. Does anybody have a sourcecode i can take a look at? Or any idea how to code it.

I did make pictures be placed over each other, with sprite_rotate or something, but it didnt draw right, and it didnt rotate...

Just need an example for ONE 10x10x6 voxel tank. Rest can i do myself.

Torbjörn Josefsson
Member #1,048
September 2000
avatar

I have NO idea how to do that - just want to compliment you on your ambition :)

Was it Tiberian Sun that used voxels?.. Damn game - waited feverishly for it, bought it, threw it in the trash.. don't know what was wrong with it - it just sucked.. don't bee Too earger in copying it ;)

--
Specialization is for insects

empty
Member #1,919
February 2002
avatar

It is possible to make a "voxel" in PSP. Thats how i tested my theory in first place:
make a tanks layer for layer, from bottom to top. Remember to draw differtent lights, or the "voxel" will look flat, and that empty places must be transparent. Then you take the bottom layer, rotate as much as the tanks should be rotated. Then you scale the picture lower to get the illusion of that it stands "3d", like a isometric view. Then you do the same with the next layer, but this time you place it one pixel over the last picture. Something like that, but how are i going to make allegro do that itself? (im still newbie)

Trezker
Member #1,739
December 2001
avatar

Outcast, Delta force 2, Tiberian sun.
That's the ones I know about, and I don't think any one of them got really big on the market.

I had a voxeleditor once, I think it was made in qb. But I never got to coding anything.

gnolam
Member #2,030
March 2002
avatar

Well, you could start by making a "voxel" heightmapper. It should give you a few ideas on how to proceed - and it's a good programming exercise, it looks good and it can easily be coded in an afternoon :). There's a great tutorial on Flipcode on 4 DOF (degrees of freedom) landscape engines here.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

DumTiriDum
Member #2,833
October 2002

I haven't done voxels, but here is an idea:

Each voxel is a 3d pixel, right ? therefore, the X, Y, Z coordinates of each voxel should be stored somewhere in a struct.

When it is time to display the 3d model, the following transformations should be taken place:

1) transform the original coordinates to the game coordinates

2) rotate the new coordinates according to camera

3) sort the coordinates according to Z; remove invisible voxels

4) draw each voxel; a voxel should be drawn as a small cube rotated and scaled according to the object's position in the gameworld.

Oscar Giner
Member #2,207
April 2002
avatar

4) a voxel is just a square. If you have the x and y screen coordinates and the distance from the camera, just draw a square centered in (x, y), and size inverse proportional to z. However, if you want voxels for making a 2D game, like Tiberian Sun, then all voxels have the same size, so z is only usefull for sorting.

Trezker said:

Outcast, Delta force 2, Tiberian sun.
That's the ones I know about, and I don't think any one of them got really big on the market.

What about Comanche? It was a great game. Not much time ago they released Comanche 4.

Thomas Harte
Member #33
April 2000
avatar

But Commanche 4, and possibly 3, are not voxel heightmap based like the older ones because its a bad selection of technology for the current range of 3d accelerators.

Anyway, you don't need a tutorial to figure out voxel heightmaps. They are a trivial extension of floor mappers, themselves a trivial specialisation of polygon fillers or sprite stretchers. Indeed something like a SNES would have the computing power to do voxel heightmaps if only Nintendo didn't always specialise their chips quite so much.

empty
Member #1,919
February 2002
avatar

I did it!!!!
Download:
http://www.home.no/empty/ex_voxel.zip
ops.. i meant /empty/EX_VOXEL.ZIP

see what i meant with voxel units...

Mike Vox
Member #2,701
September 2002
avatar

I tried running it but I got a black screen with some garbage graphics on the top and bottom. I'm running Windows XP. Is this the famous "black screen of death" that I hear about with earlier versions of Allegro 4? I'll try compiling if it doesn't work on my other PC.

Mike_Vox

Johnny13
Member #805
October 2000
avatar

before download any file in this forum(from newbie),read my Lesson first!:(

Alg3D Praise my Games!!<code>#define SPAMMER (post>=666&&postperday>=6)</code><Mr.spellcaster>What post? <Mr.spellcaster>A useful post by me.

LEDominant
Member #2,218
April 2002
avatar

Downloaded it. Works nicely for me on Windows XP. Strange thing is I've been using voxel map of this sort for ages and I never thought of using rotate_sprite.:-[

--------------------------------------------------------
Life is a trip, watch your face when you hit the ground.

Mike Vox
Member #2,701
September 2002
avatar

I tried it on my other PC that has XP also and it works fine, so I suspect it may be a problem in my setup on this one computer. Maybe I need to update the Allegro DLL ::).

I messed with the code today to see if I can get it to rotate around the x-axis, also. I was trying to figure out a way it can be rotated in any direction the same way the freeware unit editors do for Tiberium Sun.

I've had some success using stretch-blit to flatten each layer as it turns around the x-axis. But that only gets you so far around the rotation. At a certain point you need to stop the flattening algorithm, and switch to another algorithm that shifts the layers in the y direction. In theory, you'd have to alternate between those two methods as it rotates around the x-axis.

Mike_Vox

empty
Member #1,919
February 2002
avatar

It should work to rotate it against or away from the screen if you shrinked the slices before placed them on screen...

II
V
[Image]
A
II

...i think... :P

Go to: