POV-Ray : Newsgroups : povray.text.tutorials : How to create .df3 files Server Time
30 Apr 2024 01:27:51 EDT (-0400)
  How to create .df3 files (Message 1 to 7 of 7)  
From: Peter Popov
Subject: How to create .df3 files
Date: 2 Sep 1998 15:31:51
Message: <35ed8f17.0@news.povray.org>
Hiya all.

I just wanted to share a way I found to create df3 files nice and easy. All
you need is a painting program that can output grayscale raw images. The df3
format is just a six-byte header and then 3D raw data ordered as x-y planes
stacked along z like folders in a drawer. So you just draw all your layers,
keeping in mind that white is high density and black is low, and save them
as grayscale raw headerless files. Of course they have to be of equal
dimensions. Then, to create the header, make a new grayscale picture sized
6x1 pixel on a black background. This are the six bytes of the header. Use
precise rgb color picking and using a pencil-sized tool fill in the header
yourself and save the file as headerless raw again. For example, if your df3
will be 100x50x20 voxels, leave the first header pixel black, the second
should be 100 (out of 255) white, the third 0, then 50, 0, and 20.

After you have all the layers and the header saved in different files, you
only have to assemble them. I find the DOS copy command useful for that. So
go on, make a flaming copy of yourself in POV or render your computer
made of hazy misty green fog!

Hope this helps someone.

Peter


Post a reply to this message

From: Roland Mas
Subject: Re: How to create .df3 files
Date: 2 Sep 1998 22:39:47
Message: <m3zpci9dok.fsf@rpc66.acr.atr.co.jp>
"Peter Popov" <pet### [at] usanet> writes:

> Hiya all.
> 
> I just wanted to share a way I found to create df3 files nice and
> easy.

  Yeah, nice and easy. I like it. But you can also make .df3 "by
hand", I mean with a program of your own. That allows you to plot any
kind of shape into your density file. I might write a small
application for that purpose, if requested. It'll probably be simple C
and provide functions like load from .df3 file, save to .df3 file,
resize a density field, get a particular voxel value, and set a
particular voxel value. Could easily be turned into a library and
reused for any purpose.

  Has someone already done that (I don't have time for reinventing the
wheel)? Are many people interested in it? Can I hope cooperation and
help if need be?

Roland.
-- 
Les francophones m'appellent Roland Mas,
English speakers call me Rowlannd' Mass,
Nihongode hanasu hitoha [Lolando Masu] to iimasu.
Choisissez ! Take your pick ! Erande kudasai !


Post a reply to this message

From: Peter Popov
Subject: Re: How to create .df3 files
Date: 3 Sep 1998 01:26:10
Message: <35ee1a62.0@news.povray.org>
Roland Mas wrote in message ...
>  Yeah, nice and easy. I like it. But you can also make .df3 "by
>hand", I mean with a program of your own. That allows you to plot any
>kind of shape into your density file. I might write a small
>application for that purpose, if requested. It'll probably be simple C
>and provide functions like load from .df3 file, save to .df3 file,
>resize a density field, get a particular voxel value, and set a
>particular voxel value. Could easily be turned into a library and
>reused for any purpose.
>
>  Has someone already done that (I don't have time for reinventing the
>wheel)? Are many people interested in it? Can I hope cooperation and
>help if need be?
>
>Roland.
>--
>Les francophones m'appellent Roland Mas,
>English speakers call me Rowlannd' Mass,
>Nihongode hanasu hitoha [Lolando Masu] to iimasu.
>Choisissez ! Take your pick ! Erande kudasai !

Well, for the very beginning, a utility can be made to just collect the
layers in one file. For example, create a new df3 file sized 150x50x10, and
paste each layer in the utility (featuring some simple GUI). Automatic
crop/resize may be done for you. Then the utility just spits out the df3. No
3D graphics editor or such stuff.

I will be soon doing a simple proggie to do linear filtering to df3 files
(like blur, sharpen, etc.) The problem is that I don't know if these linear
functions will easily generalize for 3D. But I may try.

Regards,

Peter


Post a reply to this message

From: Peter Popov
Subject: Re: How to create .df3 files
Date: 3 Sep 1998 10:13:25
Message: <35ee95f5.0@news.povray.org>
Following myself here with a somewhat important note: by default, in POV +y
is up  (no "z is up" war, please, here's not the place), and in paint
programs +y is down, so you'll have to flip the image vertically before
saving it.

Here's another way to do df3 files, this time using POV and a graphic
conversion utility.

For this example I'll again assume a left-handed coordinate system since
that's what the df3 file uses. If you use a right-handed one you'll have to
do the transformations yourself.

The idea is that you place some objects in the unit cube and render and
animation that slices into the cube in the positive z direction. I'll do a
blobby example here but you can use just about anything. Remember, keep
everything in grayscale, because the df3 format uses only one byte for each
voxel density.

Here's file df3make.pov

// -------------------- code ---------------------

#include "colors.inc"
#default { finish { ambient 1 } }
intersection
{
  blob
  { threshold 0.425
    sphere { <0.45,0.5,0.5>, 0.5, 0.475 }
    sphere { <0.2,0.7,0.3>, 0.3, 0.4 }
    sphere { <0.6,0.3,0.7>, 0.2, 0.35 }
  }

  plane { -z, -clock+0.00001 }
  plane { z, clock+0.00001 }
  texture
  { pigment { White }
    finish { ambient 1 }
  }
}

camera { location <0.5,0.5,-2> up y right x look_at <0.5,0.5,0> angle 30
orthographic }

// -------------------- end code --------------------

I render this with the +kff49 +w50 +h50 option to make a 50x50x50 df3. The
+w option determines the x size of the df3, +h is y and +kff is z. Use
whatever resolution suits you but do not touch camera settings to correct
aspect ratio. Remember that the density_file is fit into the unit cube?

OK, so what you've got now are 50 files calles df3mak00.tga, df3mak01.tga
... df3mak49.tga. Pass them to a batch process of a graphic conversion
utility that can convert them to grayscale, flip them vertically and save
them as raw. I use Photoshop actions, DOS loop features, or a program my
brother made called "for_each". Then you make the header in a separate
6-bytes file using the method I suggested, a binary editor, a program you
made or whatever can come up with (maybe even POV 3.1's file functions).
Glue the files in the appropriate order (header first, then the files sorted
by name) and your df3 is ready.

This method is easier than the first one since you can actually model your
df3 in POV. I hope this selps and I am looking forward for posted pictures!

Peter


Post a reply to this message

From: PoD
Subject: Re: How to create .df3 files
Date: 3 Sep 1998 14:15:31
Message: <35EECE97.136A@merlin.net.au>
Peter Popov wrote:
> 
> Following myself here with a somewhat important note: by default, in POV +y
> is up  (no "z is up" war, please, here's not the place), and in paint
> programs +y is down, so you'll have to flip the image vertically before
> saving it.
> 
> Here's another way to do df3 files, this time using POV and a graphic
> conversion utility.
> 
> For this example I'll again assume a left-handed coordinate system since
> that's what the df3 file uses. If you use a right-handed one you'll have to
> do the transformations yourself.
> 
> The idea is that you place some objects in the unit cube and render and
> animation that slices into the cube in the positive z direction. I'll do a
> blobby example here but you can use just about anything. Remember, keep
> everything in grayscale, because the df3 format uses only one byte for each
> voxel density.
> 
> Here's file df3make.pov
> 
> // -------------------- code ---------------------
> 
> #include "colors.inc"
> #default { finish { ambient 1 } }
> intersection
> {
>   blob
>   { threshold 0.425
>     sphere { <0.45,0.5,0.5>, 0.5, 0.475 }
>     sphere { <0.2,0.7,0.3>, 0.3, 0.4 }
>     sphere { <0.6,0.3,0.7>, 0.2, 0.35 }
>   }
> 
>   plane { -z, -clock+0.00001 }
>   plane { z, clock+0.00001 }
>   texture
>   { pigment { White }
>     finish { ambient 1 }
>   }
> }
> 
> camera { location <0.5,0.5,-2> up y right x look_at <0.5,0.5,0> angle 30
> orthographic }
> 
> // -------------------- end code --------------------
> 
> I render this with the +kff49 +w50 +h50 option to make a 50x50x50 df3. The
> +w option determines the x size of the df3, +h is y and +kff is z. Use
> whatever resolution suits you but do not touch camera settings to correct
> aspect ratio. Remember that the density_file is fit into the unit cube?
> 
> OK, so what you've got now are 50 files calles df3mak00.tga, df3mak01.tga
> ... df3mak49.tga. Pass them to a batch process of a graphic conversion
> utility that can convert them to grayscale, flip them vertically and save
> them as raw. I use Photoshop actions, DOS loop features, or a program my
> brother made called "for_each". Then you make the header in a separate
> 6-bytes file using the method I suggested, a binary editor, a program you
> made or whatever can come up with (maybe even POV 3.1's file functions).
> Glue the files in the appropriate order (header first, then the files sorted
> by name) and your df3 is ready.
> 
> This method is easier than the first one since you can actually model your
> df3 in POV. I hope this selps and I am looking forward for posted pictures!
> 
> Peter

Funny that this thread should appear just now, I was going to post a
little proggy that assembles a series of TGA files into a df3 yesterday
but couldn't get into this news sever.

This program reads a series of 24bit uncompressed TGAs and makes a df3
file. Note it doesn't do any checking at the moment but if you use POV
to make the TGAs then they will be legal ;)
The EXE is Win32 console but the source is there, it should work in DOS,
not sure about other OSs.
I'd forgotten about the upside down coords but then my converter is too
dumb to do anything about that anyway :)

Cheers, PoD.


Post a reply to this message


Attachments:
Download 'tga2df3.exe.dat' (49 KB) Download 'us-ascii' (3 KB)

From: Peter Popov
Subject: Re: How to create .df3 files
Date: 4 Sep 1998 14:53:15
Message: <35f0290b.0@news.povray.org>
Well, this util works and I even think it compensates for that v-flip. Check
out binaries.images for a sample pic of a keyboard blueprint I made.

Peter

P.S. Could you post your util in binaries.utilities (it really belongs
there,
you know...)


Post a reply to this message

From: PoD
Subject: Re: How to create .df3 files
Date: 4 Sep 1998 17:09:56
Message: <35F0490F.5A77@merlin.net.au>
Oops, sorry I thought I was in binaries.utilities <sheepish grin>


Post a reply to this message

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