Sunday, February 22, 2009

crude ascii cube

So... working on some stuff... needed the vertices and indices for cube. The point "0" is set at (x,y,z)

4 .--------. 5
|\ |\ floor : 0,1,2 0,2,3
| \ | \ ceiling : 4,5,6 4,6,7
|7 .--------. 6 back : 0,1,5 0,5,4
| | | | front : 3,7,6 3,6,2
0 .--|-----. 1| left : 0,4,7 0,7,3
\ | \ | right : 1,5,6 1,6,2
\| \|
3 .--------. 2

pushi( vertices, [
x + 0 , y + 0, z + 0 // 0
, x + m , y + 0, z + 0 // 1
, x + m , y + 0, z + m // 2
, x + 0 , y + 0, z + m // 3
, x + 0 , y - m, z + 0 // 4
, x + m , y - m, z + 0 // 5
, x + m , y - m, z + m // 6
, x + 0 , y - m, z + m // 7
] );

btw... Adobe... wtf doesn't Graphics.drawTriangles take a zcoord and do zbuffering? Way to phone it in guys... Flash 11?

Tuesday, February 17, 2009

announcing http://brianin3d-demos.appspot.com/

I've decided to start hosing my demos on http://brianin3d-demos.appspot.com/ instead of just all over the place willy-nilly.

It is pretty bare-bones at the moment, but I plan to grow it.

ppm is a developer's best friend!

OK, that is a crazy overstatement, but it is pretty useful bit to know about.

So what is it? It's a baby-simple image format. Let's say we wanted to write out a 320x240 image. The file would look something like:

P6
320 240
255
{ONE CHARACTER PER R/G/B FOR EACH PIXEL}

So... if the first pixel was black (0x000000), we would write 0, 0, followed by zero. Whereas if it were (0xFFAADD) we'd cleverly write 0xFF, 0xAA, 0xDD.

Ya dig it? Here is a snippet from TextHash2Ppm.hx after I loaded the text file into an array of strings called (creatively enuff) "lines":

out.writeString( 'P6\n' );
out.writeString( lines[ 0 ].length + ' ' + lines.length + '\n' );
out.writeString( '255\n' );

for ( line in lines ) {
for ( i in 0 ... line.length ) {
var char = line.charAt( i ) ;
var value = if ( '#' == char ) 255; else 0;
out.writeByte( value );
out.writeByte( value );
out.writeByte( value );
}
}

Here is a bit I wrote recently to show files like sample_dungeon.txt to
sample_dungeon.ppm which I then converted to

Which I can then use as input to this heightmap viewer even though it looks wonky as heck.

PPM is a handy format for when you need to create images and you don't have or don't want to use an image library to create jpgs, pngs, etc...

Monday, February 9, 2009

bitmap'n it!

So... Like a lot of folks, I've always been really fascinated with bitmap type effects. They're a lot of fun to watch and pretty easy to write.

I collected together a set of small demos of some classic bitmap effects.

Franticly clicking on the demo will reset the current effect and eventually enable you to press the keys to access the different effects:
  1. pixel average: this kooky bit manipulation creates bizarre plasma effects (be patient!)
  2. clouds: different clouds and cloud like effects
  3. hough: use a hough transfer to create trippy sine waves from partial lines
  4. bump: ye olde bumpmap effect using displacement maps from the other demos

See it in action!