POV-Ray : Newsgroups : povray.binaries.images : Make Money with POV-Ray (literally). : Re: Make Money with POV-Ray (literally). Server Time
30 Jul 2024 06:30:45 EDT (-0400)
  Re: Make Money with POV-Ray (literally).  
From: Jaime Vives Piqueres
Date: 8 Oct 2012 05:29:08
Message: <50729ce4@news.povray.org>
On 08/10/12 10:36, B. Gimeno wrote:
> Physics...Even with the risk of being caught by the law of gravity.
> :-)

   Yes, it's a real risk... there is something fascinating in looking at
things falling and colliding on slow motion.

   My technique is easy because I use a scripting tool which exports to
POV-Ray SDL, so I only have to customize the exported code and then
render. The nice thing about Koppi's playground, is that it allows to
construct scenes the way you will do on POV-Ray, with loops, and if's,
and lots of random values here and there...

   The tool consists on a LUA interpreter, which is the "interface" to
the Bullet Physics Library. There are some bindings in place which allow
to create simple collision objects, and to add them to the physics
simulation. Then you run the simulation, and the whole thing is rendered
in openGL on real time. You can export each frame to POV-Ray format too, 
and that's the actual good thing about it.

   Here is how a simple LUA script looks like:

----------------------------------------
plane = Plane(0,1,0)
plane.pos = btVector3(0, 0, 0)
plane.col = "#999999"
v:add(plane)

function explosion(N,H)
   for i = 1,N do
     local d = Cube()
     d.pos =
btVector3(-.5+math.random(0,10)*.1,H-.5+math.random(0,10)*.1,-.5+math.random(0,10)*.1)
     d.col = "#ff9900"
     d.friction = .5
     d.restitution = .9
     v:add(d)
   end
end

explosion(260,25)
----------------------------------------

   This would export a POV file for each frame, with a plane{} and 260
box{} objects with the matrix transformations required:

-----------------------------------------
plane { <0, 1, 0>, 0
   pigment { rgb <0.0666667, 0.0666667, 0.0666667> }
}

box { <-0.5, -0.5, -0.5>, <0.5, 0.5, 0.5>
       pigment { rgb <1, 0, 0> }
   matrix <0.00928936,0.999722,-0.0216712,
         0.835221,-0.0196738,-0.549562,
         -0.549835,-0.0129952,-0.835172,
         -10.6849,0.479277,-109.289>
}
// ...and 259 more
-----------------------------------------

   The, I do some automated search&replace to put there my own objects,
with the same or similar shape and dimensions, leaving the matrix in


   Unfortunately, the program is in very-alpha state, although it is
really promising. The version on github has some flaws that I already
corrected on my local copy, but the main problem is that it segfaults
with more than 200-250 objects, and debugging that is beyond my
abilities (though I did try and failed as expected, BTW).

   Regards,

--
Jaime


Post a reply to this message

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