POV-Ray : Newsgroups : povray.programming : Density File format Server Time
29 Jul 2024 08:10:25 EDT (-0400)
  Density File format (Message 1 to 2 of 2)  
From: Twyst
Subject: Density File format
Date: 7 Jul 1998 02:26:32
Message: <35a1b188.0@news.povray.org>
Ok. The question I have... the description of a density file is this:
(from the pov 3.1 docs)

The df3 format consists of a 6 byte header of three 16-bit integers with
high order byte first. These three values give the x,y,z size of the data in
pixels (or more appropriately called voxels). This is followed by x*y*z
unsigned integer bytes of data. The data in the range of 0 to 255 is scaled
into a float value in the range 0.0 to 1.0. It remains at 0.0 for all areas
beyond the unit cube. The pattern occupies the unit cube regardless of the
dimensions in voxels.

Does this mean the file is like:
<XX> <YY> <ZZ>
<lots of X data>
<lots of Y data>
<lots of Z data>?

or
<XX> <YY> <ZZ>
<x,y,z>
<x,y,z>
....

?
I'm planning on creating a simple density file maker...

Possible ideas:
Import of TGA height_fields for each of X,Y, and Z
Semi-Preview ( I know NOTHING of 3-d programming ), but show each of the
"sides" in a graphical box.
"Painting" ability ... so you can simply make a image by painting...

Sadly, it'll be in VB, as I C++ makes my head hurt. =/

Twyst=====================================
pov-ray news, reviews and tutorials
http://twysted.net
e-mail: twy### [at] twystednet
==========================================


Post a reply to this message

From: Ron Parker
Subject: Re: Density File format
Date: 20 Jul 1998 19:06:02
Message: <35b3bf4a.0@news.povray.org>
On Mon, 6 Jul 1998 23:24:35 -0700, Twyst <twy### [at] twystednet> wrote:
>Ok. The question I have... the description of a density file is this:
>(from the pov 3.1 docs)
>
>The df3 format consists of a 6 byte header of three 16-bit integers with
>high order byte first. These three values give the x,y,z size of the data in
>pixels (or more appropriately called voxels). This is followed by x*y*z
>unsigned integer bytes of data. The data in the range of 0 to 255 is scaled
>into a float value in the range 0.0 to 1.0. It remains at 0.0 for all areas
>beyond the unit cube. The pattern occupies the unit cube regardless of the
>dimensions in voxels.
>

The file has the first six bytes as documented.  For example, the spiral.df3
file has 
  
  00 32 00 32 00 05

which means that the voxmap is 50 units in the X direction, 50 in the Y 
direction, and 5 in the Z direction.  

Next, it contains all of the information for the "layer" of voxels at Z=0.
In the case of spiral.df3, there are five such "layers" of 2500 pixels each.

I'm assuming that Y is the next most significant variable.  This certainly 
makes more sense than if X were.  If it is, then the first 50 bytes of each
voxel consist of the row of voxels with Y=0, the next 50 are for y=.025, and
so on.  Within a row, the first voxel has X=0, the next X=.025, and so on.

Here's a Perl script that will dump the layers of a .df3 file so you can
visualize its contents.  It's deliberately simple; I really do know about
pack and unpack, but I elected not to use them here so the structure would
be more evident.

--------->8======== cut here =========
#!perl
binmode STDIN;
undef $/;

@a=split( '', <STDIN> );

$c = 0;

$h=ord(shift(@a));
$l=ord(shift(@a));
$x=$h*256+$l;

$h=ord(shift(@a));
$l=ord(shift(@a));
$y=$h*256+$l;

$h=ord(shift(@a));
$l=ord(shift(@a));
$z=$h*256+$l;

print "$x $y $z\n";

for $zz (1..$z) {
  for $yy (1..$y) {
    for $xx (1..$x) {
      $c=ord(shift(@a));
      if ( $c < 64 ) {print " ";}
      elsif ( $c < 128 ) {print ".";}
      elsif ( $c < 192 ) {print "o";}
      else {print "O"};
    }
    print "\n";
  }
  print "\n","-"x $x,"\n\n";
}
--------->8======== cut here =========


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.