GLBasic forum

Main forum => Off Topic => Topic started by: Scott_AW on 2010-Apr-30

Title: Sprite to voxel(for real)
Post by: Scott_AW on 2010-Apr-30
New Post:
Almost have it down, some issues with tiny parts dissapearing.  You'll find out what I mean if you test the fridge.bmp file in the program, parts of the handle don't get read for some reason.  Was ignoring the first color picked...

Aside from that, it now creates a simple color palette so your VOX files will have color in Slab6.  However the color is limited to 255(last index is for an empty voxel) and if your image exceed that you'll see some weirdness I'm sure, haven't tested it.

Idealy the max (not tested) size of an image you can use is 255x255 with 255 frames.  This may take awhile so I've added some loading bars to show you its just being slow and not dead.  So far I've only tested a 32x32 image with 8 frames, the fridge.   I've added a doorframe sample too, but this one is just 16x16.
Download strip2voxel043010.zip (http://host-a.net/scott_aw/strip2voxel043010.zip) Some bug in it...

Hopefully I'll get a chance to test some larger sprite strips.

Old Post:

A little while back I started playing with the idea of a fake voxel like dungeon game.  It would generate 3d models based on 16^3 array of cubes.  Then I thought, why couldn't I have it make real voxel files?  So I did!  But currently no color info is transfered yet, but it shouldn't be too difficult now that I've figured out the file format.

Make 16^3 voxels for VOXLAP, no color info yet...

Original topic (http://www.glbasic.com/forum/index.php?topic=4298.0)Last released version, makes models (http://host-a.net/scott_aw/Cube16_test3.zip)

Download Cube16wVOX.zip (http://host-a.net/scott_aw/Cube16wVOX.zip)

Find Slab6 here (http://advsys.net/ken/download.htm)
Title: Re: Sprite to voxel(for real)
Post by: Schranz0r on 2010-Apr-30
I give it a try at home!
Title: Re: Sprite to voxel(for real)
Post by: Ian Price on 2010-Apr-30
Either this takes an absolute age to set up (more than two minutes on a pretty fast machine) or all I get is a blank screen.

If it is the former, then it would be nice to inform/warn the user of such. If it is the latter, then there's a problem somewhere.

I gave up in the end.

:(
Title: Re: Sprite to voxel(for real)
Post by: Scott_AW on 2010-Apr-30
My fault, I forgot the font file.  I'm replacing the zip.  Its looking for "sysfont.png" for a quick fix.
Title: Re: Sprite to voxel(for real)
Post by: Kitty Hello on 2010-Apr-30
(http://www.glbasic.com/pix/tnCube16_3_.png.png) (http://www.glbasic.com/pix/Cube16_3_.png.png)

Aces!!!!
Title: Re: Sprite to voxel(for real)
Post by: Ian Price on 2010-Apr-30
That is indeed neat (now that it's working!) :)
Title: Re: Sprite to voxel(for real)
Post by: Scott_AW on 2010-Apr-30
I'll try and get it finished soon, I want to play around with it myself.

I've started the project over and gutted a lot of now unneeded stuff.  It still will display the model though.  The main effort is going to be in the coloring and palette system.  I'm going to do it simple for now, just a palette based on image colors.  However this will mean that you can only use 256 color images.

There is one thing I learned about voxels is that you actually don't want too much variations in coloring, you can get a lot of it from basic shading and lighting.  I'll have some examples when its ready.
Title: Re: Sprite to voxel(for real)
Post by: Scott_AW on 2010-May-01
Small bug in the current release is actually very simple, its ignoring the first color grabbed and marking it as transparent!!!  Quick fix, use a color you'll never use on the top left corner pixel of the first frame.

But this more about a larger test for you guys to check out, it may stall a few times due to the size, I need to add two more progress bars, one for when the view model is created and one for when the vox file is written.

I wanted to make a model, and this was the first object I found.  No, I did not take it apart to get the look of the guts.
(http://i206.photobucket.com/albums/bb140/scott_aw/th_calculator.png) (http://s206.photobucket.com/albums/bb140/scott_aw/?action=view&current=calculator.png)

And here's it in Slab6, all voxely and a destroyed version.
(http://i206.photobucket.com/albums/bb140/scott_aw/th_calc_cap1.png) (http://s206.photobucket.com/albums/bb140/scott_aw/?action=view&current=calc_cap1.png)
(http://i206.photobucket.com/albums/bb140/scott_aw/th_calc_cap2.png) (http://s206.photobucket.com/albums/bb140/scott_aw/?action=view&current=calc_cap2.png)
Title: Re: Sprite to voxel(for real)
Post by: Schranz0r on 2010-May-01
NICE!
Title: Re: Sprite to voxel(for real)
Post by: MrTAToad on 2010-May-01
Rather good - get around 59FPS here
Title: Sprite2voxel, bug free...maybe.
Post by: Scott_AW on 2010-May-02
http://host-a.net/scott_aw/strip2voxel050210.zip

Should be working now.  There is four loading intensive phases now accompanied by loading bars.  Theres the prepping(clears out a 255^3 grid space), reading of the image, building and optimizing the display model, and finally creating the voxel file.

Included are an updated fridge.png, with a few more layers and junk inside.  Also the a large test model calculator displayed before.

I could reduce or negate the prepping time.  Although I will still need it for doing a batch of images, just it won't need to clear the whole area.
Title: Fixed up some.
Post by: Scott_AW on 2010-May-05
Download strip2voxel050410.zip (http://host-a.net/scott_aw/strip2voxel050410.zip)

A bunch of little changes.  Most important is that I moved the model creation part, which is not really needed, to the end of the program, and now its entirely optional to display the model.  This is good to skip if you're generating large models which will run horribly as a polygon based model.  Unless you have some beast of a system.

Also a quick fix for the getpixel error, a prompt at the beginning will as to set a black range, 0-20.  0 if you experience no rouge black pixels on your objects, 20 if you're not sure how to check how off they are from true black.

Some feedback on limits...256x256 with 10 frames is a bit sketchy.  I wouldn't show a model of it, just escape after the vox files is made.  I didn't include my latest test because they're kind of brutal to my systems.  But if you're super curious how well you machine can handle this, create a image thats 128*128 x 128 and just generate grayscale noise.  64^3 models I've tested, took forever to make the model on a netbook.  If you have a fast system you can pull it off.
Title: Re: Sprite to voxel(for real)
Post by: Kitty Hello on 2010-May-05
http://kyucon.com/qblock/ (http://kyucon.com/qblock/) can you make some editor like that and export to .ddd?
I'd really love to make such a game.
On that size, search by author "Minion" and view "zarch". That would be so cool....
Title: Re: Sprite to voxel(for real)
Post by: matchy on 2010-May-05
That's a fun to use.

http://kyucon.com/qblock/#/15824
Title: Re: Sprite to voxel(for real)
Post by: Ian Price on 2010-May-05
I can't help but think of Rittai Picross (Picross 3D) on Nintendo DS -

(http://dsmedia.ign.com/ds/image/article/915/915575/rittai-picross-screens-20081002095418017_640w.jpg)

(http://farm4.static.flickr.com/3634/3411143404_292439ea41.jpg)

- that game has consumed vast quantities of my spare time!
Title: Re: Sprite to voxel(for real)
Post by: Scott_AW on 2010-May-05
It can produce a DDD, in fact my version prior to this did just that.  However that was limited to 16x16x16 at the time, larger models are kind of pushing the limits though.  I'll do a few test and I can reenable to part that exports a DDD file.  I have a way to optimize the model by expanding faces to adjacent like colors, but this ruins normal values.

There's really good example of voxels for the DS on a game called Flipper by Goodbye Galaxy(blog site)
Title: Sprite>voxel>ddd
Post by: Scott_AW on 2010-May-05
Download s2v_wDDD040510.zip (http://host-a.net/scott_aw/s2v_wDDD040510.zip)

This version will now create a DDD file after it creates the display model.  You'll be prompted to choose if you wish to reduce the faces, doing this can reduce file size up to half in the best case but will cause issues with normals so be weary if you light the model.

Keep in mind, the larger the dimensions of the image, 128+ may hangup when creating models.  Models are 20times larger than the vox files on average and likewise are just as slow.  Of course there is no current way to display vox files without Ken Silverman's programs: Voxlap, Slab6, Build Engine, and EvalDraw.

I've been emailing someone who had been working on an OpenGL voxel engine, but haven't heard back yet as of my last message.
Title: Re: Sprite to voxel(for real)
Post by: Kitty Hello on 2010-May-05
use AUTONORMALS 0 before X_OBJSTART - makes nice "hard" edges.
Title: Re: Sprite to voxel(for real)
Post by: Scott_AW on 2010-May-06
I've used it, the normals get weird because it links up a strip of like faces and just makes one long one.  This results in oddities or imperfect normals at intersections of faces, like a T or such shapes.  Since the face is extended beyond the connection point there is no vectors to properly set the normals there.  At least that's my theory.  That and my method is kind of cheap and easy.

Want to see the code?
Title: Re: Sprite to voxel(for real)
Post by: Kitty Hello on 2010-May-06
No. ;)
Try AUTONORMALS 1 (0 was stupid) and then render the thing with X_CULLMODE 1. If you have holes now, the triangles are in wrong order (outside facing inwards).
Once you have the faces correct with X_CULLMODE 1, the AUTONOMRALS 1 should make really blocky blocks.
Title: Re: Sprite to voxel(for real)
Post by: Scott_AW on 2010-May-06
I have both of those set, you'll see what I'm talking about if you load one of the models and apply lighting.  Make two versions of the model, one without the face combination and one with.  Sometimes its not that noticeable if the object shape is simple, but you'll see a difference.  If its not that big a difference, great, because the reduce  mode is much smaller and faster.  Of course if your not using lighting always do the reduce.