POV-Ray : Newsgroups : povray.pov4.discussion.general : Request for *.df4 format (ASCII text based) Server Time
18 May 2024 16:15:17 EDT (-0400)
  Request for *.df4 format (ASCII text based) (Message 15 to 24 of 34)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Nicolas Alvarez
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 4 Mar 2008 12:51:33
Message: <47cd8c25$1@news.povray.org>

> Tor Olav Kristensen <tor### [at] TOBEREMOVEDgmailcom> wrote:
> 
>> But some might want to use POV-Ray SDL to write them...
> 
> Yes. Sometimes ago I needed to write df3 files from SDL, but that's impossible.
> On the other side, Povray read only df files in binary format. I think that one
> would want to create df3 files in his macros...
> 

Yep, so let's add binary-file-writing capabilities to POV SDL, like Warp 
said. Not make an ASCII-based df3.


Post a reply to this message

From: Woody
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 8 Dec 2008 08:20:00
Message: <web.493d1e87f13a83cf3182ed980@news.povray.org>
Nicolas Alvarez <nic### [at] gmailisthebestcom> wrote:

> > Tor Olav Kristensen <tor### [at] TOBEREMOVEDgmailcom> wrote:
> >
> >> But some might want to use POV-Ray SDL to write them...
> >
> > Yes. Sometimes ago I needed to write df3 files from SDL, but that's impossible.
> > On the other side, Povray read only df files in binary format. I think that one
> > would want to create df3 files in his macros...
> >
>
> Yep, so let's add binary-file-writing capabilities to POV SDL, like Warp
> said. Not make an ASCII-based df3.

that sounds like a fine idea. my main objection with the binary versuses the
ascii formats was that all the tutirials on the df3 binary format made things
alot more complicated with stuff like big indian and little indian. but im
assuming that if the ability to write binaries would make this trival, at the
very least there would be documentation as it applies to pov as opposed to
general computing


Post a reply to this message

From: bapt
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 26 Aug 2010 17:45:01
Message: <web.4c76df5af13a83cfa3b8d9490@news.povray.org>
Hi list,

I'm trying to use a density file in povray for the first time and the page is
always blank.

I use an external program to generate a file data.dat which looks like this,

10 10 10
0 0 0 240
1 0 0 240
2 0 0 240
3 0 0 240
4 0 0 240
5 0 0 240
6 0 0 240
7 0 0 240
8 0 0 240
etc ...

where the first line gives the dimensions, the first three columns are xyz
coordinates and last column the density value.

I use the c++ code posted here to create a df3 file. OK so far, I think.
Unfortunately, my basic example shows a blank page with nothing in it. I don't
know if the df3 file is incorrect or if it's a problem with the povray file
below,


background { color rgb <1.0,1.0,1.0> }
global_settings {
ambient_light <0.3,0.3,0.3>
}

#include "colors.inc"
#include "textures.inc"

light_source{<10,10,-10> color White}
#declare dist = 1.5;


camera {location <dist , dist ,dist>
right <0, 4/3, 0>
 up    <0,0,1>
 look_at  <0.0 , 0.0 , 0.0>}


#declare theinterior = interior {
   media {
      density {
         density_file df3 "data.df3"
         interpolate 1
         color_map {
            [0.00 rgb <0,0,0>]
            [0.2 rgb <0,0,1>]
            [0.4 rgb <0,1,0>]
            [1.00 rgb <1,0,0>]
         }
      }
   }
}

box {
   <0,0,0>, <1,1,1>
   pigment { rgbf 1 }
   interior { theinterior }
   hollow
}


I'll appreciate any advice.

Regards,

baptiste



Warp <war### [at] tagpovrayorg> wrote:
> Woody <nomail@nomail> wrote:
> > If you every have a few moments do you think you could modify the source code
> > you posted at http://news.povray.org/4799ff49%40news.povray.org, so that it can
> > take one or more *.txt files specified in the command line (instead of the
> > testdata.txt) and output them into df3 format with the same name (except for
> > the txt extension).
>
>   You mean with the same input file format?
>   How about this:
>
>
> #include <iostream>
> #include <fstream>
> #include <vector>
> #include <string>
> #include <cstdio>
>
> int main(int argc, char* argv[])
> {
>     // Limit the size of the df3 dimensions (safeguard against invalid input).
>     // Maximum df3 size will be SIZE_LIMIT*SIZE_LIMIT*SIZE_LIMIT.
>     const size_t SIZE_LIMIT = 256;
>
>     if(argc < 2)
>     {
>         std::cout << "Usage: " << argv[0] << " <files>\n";
>         return 0;
>     }
>
>     for(int i = 1; i < argc; ++i) // for each input file
>     {
>         std::ifstream is(argv[i]);
>         if(!is.good())
>         {
>             std::cerr << "Couldn't open ";
>             std::perror(argv[i]);
>             continue;
>         }
>
>         size_t xSize, ySize, zSize;
>         is >> xSize >> ySize >> zSize;
>         if(xSize > SIZE_LIMIT || ySize > SIZE_LIMIT || zSize > SIZE_LIMIT)
>         {
>             std::cout << "Skipping " << argv[i] << " (invalid input)\n";
>             continue;
>         }
>
>         std::vector<char> data(xSize*ySize*zSize + 6, 0);
>
>         // Setup df3 header:
>         data[0] = xSize/256; data[1] = xSize%256;
>         data[2] = ySize/256; data[3] = ySize%256;
>         data[4] = zSize/256; data[5] = zSize%256;
>
>         // Read input data and create df3 data:
>         while(true)
>         {
>             size_t x, y, z, value;
>             is >> x >> y >> z >> value;
>             if(!is.good()) break;
>             const size_t ind = x + y*xSize + z*xSize*ySize + 6;
>             if(ind < data.size())
>                 data[ind] = char(value);
>         }
>
>         // Write df3 file:
>         std::string filename = argv[i];
>         size_t ind = filename.find_last_of('.');
>         if(ind != filename.npos) filename.resize(ind);
>         filename += ".df3";
>         std::ofstream os(filename.c_str(), std::ios::binary);
>         os.write(&data[0], data.size());
>         std::cout << argv[i] << " -> " << filename << std::endl;
>     }
> }


Post a reply to this message

From: clipka
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 26 Aug 2010 18:38:24
Message: <4c76ece0$1@news.povray.org>
Am 26.08.2010 23:40, schrieb bapt:

> #declare theinterior = interior {
>     media {
>        density {
>           density_file df3 "data.df3"
>           interpolate 1
>           color_map {
>              [0.00 rgb<0,0,0>]
>              [0.2 rgb<0,0,1>]
>              [0.4 rgb<0,1,0>]
>              [1.00 rgb<1,0,0>]
>           }
>        }
>     }
> }

You might consider this a case of "POV-Ray fails to help you with a 
useful error message": Your media has a density, but no type. Is it 
supposed to be absorbing, emitting or scattering?


Post a reply to this message

From: bapt
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 27 Aug 2010 01:40:00
Message: <web.4c774f79f13a83cfa3b8d9490@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 26.08.2010 23:40, schrieb bapt:
>
> > #declare theinterior = interior {
> >     media {
> >        density {
> >           density_file df3 "data.df3"
> >           interpolate 1
> >           color_map {
> >              [0.00 rgb<0,0,0>]
> >              [0.2 rgb<0,0,1>]
> >              [0.4 rgb<0,1,0>]
> >              [1.00 rgb<1,0,0>]
> >           }
> >        }
> >     }
> > }
>
> You might consider this a case of "POV-Ray fails to help you with a
> useful error message": Your media has a density, but no type. Is it
> supposed to be absorbing, emitting or scattering?

I see, I added the following but still get a blank page,

#declare theinterior = interior {
   media {
    emission <1,1,1> / 10
     absorption <1,1,1> / 30
     scattering { 1, <0,0,0> }
      density {
         density_file df3 "data.df3"
         interpolate 1
         color_map {
            [0.00 rgb <0,0,0>]
            [0.2 rgb <0,0,1>]
            [0.4 rgb <0,1,0>]
            [1.00 rgb <1,0,0>]
         }
      }
   }
}

Thanks for helping,

baptiste


Post a reply to this message

From: clipka
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 27 Aug 2010 06:16:21
Message: <4c779075$1@news.povray.org>
Am 27.08.2010 07:39, schrieb bapt:

>> You might consider this a case of "POV-Ray fails to help you with a
>> useful error message": Your media has a density, but no type. Is it
>> supposed to be absorbing, emitting or scattering?
>
> I see, I added the following but still get a blank page,
>
> #declare theinterior = interior {
>     media {
>      emission<1,1,1>  / 10
>       absorption<1,1,1>  / 30
>       scattering { 1,<0,0,0>  }
>        density {
>           density_file df3 "data.df3"
>           interpolate 1
>           color_map {
>              [0.00 rgb<0,0,0>]
>              [0.2 rgb<0,0,1>]
>              [0.4 rgb<0,1,0>]
>              [1.00 rgb<1,0,0>]
>           }
>        }
>     }
> }

- Emission will be invisible, as your background is plain white.

- You can leave out scattering, as with a value of <0,0,0> it does 
nothing (the scattering color specifies how much the red, green and blue 
components of the light will be affected).

- Your absorption is simply too weak. Try absorption <1,1,1>*30 instead. 
Depends on how dense your density map actually is, though. Note that the 
smaller the distances in your scene are, the higher your media 
parameters have to be for the same effect.


Post a reply to this message

From: bapt
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 27 Aug 2010 06:40:00
Message: <web.4c779501f13a83cff7b786010@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 27.08.2010 07:39, schrieb bapt:
>
> >> You might consider this a case of "POV-Ray fails to help you with a
> >> useful error message": Your media has a density, but no type. Is it
> >> supposed to be absorbing, emitting or scattering?
> >
> > I see, I added the following but still get a blank page,
> >
> > #declare theinterior = interior {
> >     media {
> >      emission<1,1,1>  / 10
> >       absorption<1,1,1>  / 30
> >       scattering { 1,<0,0,0>  }
> >        density {
> >           density_file df3 "data.df3"
> >           interpolate 1
> >           color_map {
> >              [0.00 rgb<0,0,0>]
> >              [0.2 rgb<0,0,1>]
> >              [0.4 rgb<0,1,0>]
> >              [1.00 rgb<1,0,0>]
> >           }
> >        }
> >     }
> > }
>
> - Emission will be invisible, as your background is plain white.
>
> - You can leave out scattering, as with a value of <0,0,0> it does
> nothing (the scattering color specifies how much the red, green and blue
> components of the light will be affected).
>
> - Your absorption is simply too weak. Try absorption <1,1,1>*30 instead.
> Depends on how dense your density map actually is, though. Note that the
> smaller the distances in your scene are, the higher your media
> parameters have to be for the same effect.


Hi again,

I really appreciate your comments. Still not working though. I'm using megapov
on a Mac by the way, if it should make any difference.

Is there somewhere I could find a minimal example of what I should export as a
density file, some specification of what coordinates and values I should use to
see something within my box?

box {
   <0,0,0>, <1,1,1>
   pigment { rgbf 1 }
   interior { theinterior }
   }

I'm using R to create a table of values, with the following script

N <- 100
xx <- seq(0,1, length=N)
d <- expand.grid(x=xx,y=xx,z=xx)
d$t <- runif(nrow(d), 0, 255) # random values

cat(file="data.dat", "1 1 1\n")
write.table(d,file="data.dat",row.names = F,
            col.names = F,append=T)


Thanks,

baptiste


Post a reply to this message

From: clipka
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 27 Aug 2010 07:32:09
Message: <4c77a239@news.povray.org>
Am 27.08.2010 12:35, schrieb bapt:

> Is there somewhere I could find a minimal example of what I should export as a
> density file, some specification of what coordinates and values I should use to
> see something within my box?

> I'm using R to create a table of values, with the following script
>
> N<- 100
> xx<- seq(0,1, length=N)
> d<- expand.grid(x=xx,y=xx,z=xx)
> d$t<- runif(nrow(d), 0, 255) # random values
>
> cat(file="data.dat", "1 1 1\n")
> write.table(d,file="data.dat",row.names = F,
>              col.names = F,append=T)

I'm sorry, I have no idea what "R" is.

To make sure what I told you would indeed to the trick, I generated a 
sample density file by adding the following additional statements at the 
beginning of the scene file you provided:

   #include "arrays.inc"

   #declare A = array[2][2][2] {
     { { 0.1, 0.2 }, { 0.3, 0.4 } },
     { { 0.5, 0.6 }, { 0.7, 0.8 } }
   }

   ARRAYS_WriteDF3(A, "data.df3", 8)

(using POV-Ray 3.7 beta 38; it won't work with POV-Ray 3.6)

This would correspond to a 2x2x2 grid, with cells filled as follows:

   0,0,0   26
   0,0,1   51
   0,1,0	  77
   0,1,1  102
   1,0,0  153
   1,0,1  179
   1,1,0  204

This does work - for example - with absorption <1,1,1>*30 on a white 
background, or emission<1,1,1>*10 on a black background.

If you still can't get this to work, then something's broken in your 
workflow. Otherwise, you're just still too cautious about the absorption 
values to get your own density files working. Be bold to try out some 
insanely large values - you can't physically break anything ;-)


Post a reply to this message

From: bapt
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 27 Aug 2010 11:25:00
Message: <web.4c77d867f13a83cff7b786010@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 27.08.2010 12:35, schrieb bapt:
>
> > Is there somewhere I could find a minimal example of what I should export as a
> > density file, some specification of what coordinates and values I should use to
> > see something within my box?
>
> > I'm using R to create a table of values, with the following script
> >
> > N<- 100
> > xx<- seq(0,1, length=N)
> > d<- expand.grid(x=xx,y=xx,z=xx)
> > d$t<- runif(nrow(d), 0, 255) # random values
> >
> > cat(file="data.dat", "1 1 1\n")
> > write.table(d,file="data.dat",row.names = F,
> >              col.names = F,append=T)
>
> I'm sorry, I have no idea what "R" is.
>
> To make sure what I told you would indeed to the trick, I generated a
> sample density file by adding the following additional statements at the
> beginning of the scene file you provided:
>
>    #include "arrays.inc"
>
>    #declare A = array[2][2][2] {
>      { { 0.1, 0.2 }, { 0.3, 0.4 } },
>      { { 0.5, 0.6 }, { 0.7, 0.8 } }
>    }
>
>    ARRAYS_WriteDF3(A, "data.df3", 8)
>
> (using POV-Ray 3.7 beta 38; it won't work with POV-Ray 3.6)
>
> This would correspond to a 2x2x2 grid, with cells filled as follows:
>
>    0,0,0   26
>    0,0,1   51
>    0,1,0   77
>    0,1,1  102
>    1,0,0  153
>    1,0,1  179
>    1,1,0  204
>
> This does work - for example - with absorption <1,1,1>*30 on a white
> background, or emission<1,1,1>*10 on a black background.
>
> If you still can't get this to work, then something's broken in your
> workflow. Otherwise, you're just still too cautious about the absorption
> values to get your own density files working. Be bold to try out some
> insanely large values - you can't physically break anything ;-)

Damn, it's so close but... no luck. I cannot install POV-Ray 3.7 for some reason
(Mac) and the values above run through the c++ script still give me a blank
page. Would you mind posting the df3 and pov files so I can rule out the
conversion and know for sure that my povray is broken? I have cranked up the
absorption well above reasonable values and it's still all white.

Thanks,

baptiste


Post a reply to this message

From: clipka
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 27 Aug 2010 14:48:28
Message: <4c78087c$1@news.povray.org>
Am 27.08.2010 17:23, schrieb bapt:

> Damn, it's so close but... no luck. I cannot install POV-Ray 3.7 for some reason
> (Mac) and the values above run through the c++ script still give me a blank
> page. Would you mind posting the df3 and pov files so I can rule out the
> conversion and know for sure that my povray is broken? I have cranked up the
> absorption well above reasonable values and it's still all white.

Posted it in povray.binary.scene-files, I hope it helps. I must say that 
I assume your c++ program is broken in some way.


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

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