POV-Ray : Newsgroups : povray.advanced-users : Inline calculation for df3/media entries : Re: Inline calculation for df3/media entries Server Time
28 Jul 2024 12:32:07 EDT (-0400)
  Re: Inline calculation for df3/media entries  
From: Lonnie
Date: 6 Nov 2005 23:25:00
Message: <web.436ed59bf6741f3fd5d3b08c0@news.povray.org>
There just is no way to write a df3: file directly from POV :( - they must
be written in binary format.  Fortunately, there's plenty of free software
that will do the job.  Python works, and I have had success using
JustBASIC.  The idea is, with POV, take slices of your object using the CSG
intersect function, then scan them using the trace() function.  Output the
result to a text file, for instance a series of 0s and 1s for
outside/inside the object.  Then read the data into a 3D array in a
language capable of binary output and do your edge detection/density
calculations.  I had been toying with this same idea for several weeks and
I'll try to get an implementation  posted in the next week - just too many
projects and I'm in middle of two day render (see my latest posting in
images forum.)  For the moment, check out this JustBASIC code.  It produces
a 100x100x100 df3: filled with random clouds, which are denser in the
center than at the edges.  I use arrays to hold the "seed" values the
clouds are built around, then write the df3: directly by calculating the
distance from each point in the cube to each of the seeds.

open "clouds.df3" for binary as #myfile
print #myfile, chr$(0)
print #myfile, chr$(100)
print #myfile, chr$(0)
print #myfile, chr$(40)
print #myfile, chr$(0)
print #myfile, chr$(100)

randomize 0.5
dim myx(30)
dim myy(30)
dim myz(30)
for p=0 to 29
  myx(p)=rnd(1)*80+10
  myy(p)=rnd(1)*20+10
  myz(p)=rnd(1)*80+10
  print myx(p),
  print myy(p),
  print myz(p)
next

for x=0 to 99
  for y=0 to 39
    for z=0 to 99
      v=0
      for  p=0 to 29
        d=255-sqr(sqr(abs(myx(p)-x)^2+abs(myy(p)-y)^2)^2+abs(myz(p)-z)^2)*20
        if d>v then v=d
      next
      if v<0 then v=0
      if v>255 then v=255
      print x,y,z,v
      print #myfile, chr$(int(v))
    next
  next
next

close #myfile
print "complete"
end


Post a reply to this message

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