 |
 |
|
 |
|
 |
|  |
|  |
|
 |
From: Thomas de Groot
Subject: Re: the Utah teapot is older than you think!
Date: 6 Feb 2009 03:20:57
Message: <498bf2e9@news.povray.org>
|
|
 |
|  |
|  |
|
 |
"Bill Pragnell" <bil### [at] hotmail com> schreef in bericht
news:web.498a2d248d7f70a2219167190@news.povray.org...
> Taking a break from Lego, I thought of a nice efficient method of placing
> objects relatively evenly over the surface of another object. This only
> took
> about 10-15 seconds to parse, and a good deal of that was building the
> rock
> mesh...
>
> I haven't tested it thoroughly yet, but I think it should work on
> everything -
> csg, meshes, open meshes, patches, the lot.
>
> :)
>
Nice work!
Interestingly, Tim Attwood posted something similar in povray.advanced-users
on January 22nd, 2007,
http://news.povray.org/povray.advanced-users/thread/%3C45b52eed%241%40news.povray.org%3E/?ttop=299803&toff=100
and which I have used a couple of times. Would be interesting to compare
methods...
Thomas
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Thomas de Groot" <tDOTdegroot@interDOTnlANOTHERDOTnet> wrote:
> Interestingly, Tim Attwood posted something similar in povray.advanced-users
[snip]
> and which I have used a couple of times. Would be interesting to compare
> methods...
Aha, I didn't know about that, but I'd be very surprised if nobody had done this
before in some form! Tim's method is similar, but he's picking random starting
points within the bounding box from which to fire test rays, whereas I'm
looping over a grid of starting points.
It would, as you say, be interesting to see the differences. I shall
investigate. :)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Bill Pragnell" <bil### [at] hotmail com> wrote:
> It's basically just a macro that loops over voxels in the target object's
> bounding box, testing each one for proximity to a surface by firing a few rays
> around.
Duh. One of those "you just gotta have the idea" ideas.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Hells, I'd just like to see anything of this caliber...I'm in desperate need
of anything vnormalize/vtransform/trace related...because thats currently
all a black box to me...
Feel free to send your macro even in its most unclean incarnation Bill!
Its still damn good from where I'm sitting.
;-D
ian
"Bill Pragnell" <bil### [at] hotmail com> wrote in message
news:web.498c02132cee23ee6dd25f0b0@news.povray.org...
> "Thomas de Groot" <tDOTdegroot@interDOTnlANOTHERDOTnet> wrote:
>> Interestingly, Tim Attwood posted something similar in
>> povray.advanced-users
> [snip]
>> and which I have used a couple of times. Would be interesting to compare
>> methods...
>
> Aha, I didn't know about that, but I'd be very surprised if nobody had
> done this
> before in some form! Tim's method is similar, but he's picking random
> starting
> points within the bounding box from which to fire test rays, whereas I'm
> looping over a grid of starting points.
>
> It would, as you say, be interesting to see the differences. I shall
> investigate. :)
>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Bill Pragnell" <bil### [at] hotmail com> wrote:
> "Thomas de Groot" <tDOTdegroot@interDOTnlANOTHERDOTnet> wrote:
> > Interestingly, Tim Attwood posted something similar in povray.advanced-users
> [snip]
> > and which I have used a couple of times. Would be interesting to compare
> > methods...
>
> Aha, I didn't know about that, but I'd be very surprised if nobody had done this
> before in some form! Tim's method is similar, but he's picking random starting
> points within the bounding box from which to fire test rays, whereas I'm
> looping over a grid of starting points.
>
> It would, as you say, be interesting to see the differences. I shall
> investigate. :)
Well, it seems Tim's method produces a very similar result to mine, with maybe
just a little more clumping. It does take a lot longer to parse, however -
although it's difficult to compare exactly because he sets a max loop counter,
not a max hit counter, and mine just takes a grid spacing.
I am going to fiddle a little more with mine, then I'll post the source.
Bill
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Right, here's the magic incantation:
// 'Encase' places objects over the surface of another object.
// Call this macro from inside union or merge for greater flexibility.
//
// baseobj - object identifier - the target object (must not be infinite).
// componentobj - object identifier - the object to be copied over the surface
of the target object.
// randy - yes/no - should componentobj be randomly rotated around the normal
when placed? (yes for grass etc)
// randxy - yes/no - should componentobj be randomly oriented before scaling and
placement? (yes for rocks etc)
// dx - float - grid size; probably similar to average object separation after
placement.
// scal1 - float - scale factor of componentobj in-plane (relative to dx)
// scal2 - float - scale factor of componentobj along normal (relative to dx)
// sd - seed - the random seed to be used.
//
#macro Encase(baseobj, componentobj, randy, randxy, dx, scal1, scal2, sd)
#local minext = min_extent(baseobj);
#local maxext = max_extent(baseobj);
#local xwid = maxext.x - minext.x;
#local ywid = maxext.y - minext.y;
#local zwid = maxext.z - minext.z;
#local norm = <0, 0, 0>;
#local dirs = array[6] { x, -x, y, -y, z, -z }
#local zp = minext.z + dx/2;
#while (zp < maxext.z)
#local yp = minext.y + dx/2;
#while (yp < maxext.y)
#local xp = minext.x + dx/2;
#while (xp < maxext.x)
#local startpos = <xp+dx*(rand(sd)-0.5), yp+dx*(rand(sd)-0.5),
zp+dx*(rand(sd)-0.5)>;
#local n = 0;
#local trans = transform { rotate x*rand(sd)*90 rotate y*rand(sd)*90 }
#while ((n < 6))
#local dir = vtransform(dirs[n], trans);
#local spoint = trace(baseobj, startpos, dir, norm);
#local sdist = vlength(spoint-startpos);
#if ((sdist < dx) & (vlength(norm) > 0))
object {
componentobj
#if (randy) rotate y*rand(sd) #end
#if (randxy) rotate x*rand(sd)*360 rotate y*rand(sd)*360 #end
scale <scal1*dx, scal2*dx, scal1*dx>
Point_At_Trans(norm) translate spoint }
#end
#local n = n + 1;
#end // direction loop
#local xp = xp + dx;
#end // x loop
#local yp = yp + dx;
#end // y loop
#local zp = zp + dx;
#end // z loop
#end
// usage example:
#declare TestTorus = torus { 2, 1 }
#declare TestBall = sphere { <0,0,0>, 1 }
#declare r1 = seed(0);
Encase(TestTorus, TestBall, no, no, 0.2, 0.5, 0.5, r1)
Hope it's useful!
Bill
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Bill Pragnell" <bil### [at] hotmail com> schreef in bericht
news:web.498da8842cee23ee219167190@news.povray.org...
>
> Well, it seems Tim's method produces a very similar result to mine, with
> maybe
> just a little more clumping. It does take a lot longer to parse, however -
> although it's difficult to compare exactly because he sets a max loop
> counter,
> not a max hit counter, and mine just takes a grid spacing.
>
I think Tim said in one of his posts that his macro was brute force, so
probably not entirely parse *efficient*. As long as the job is done, that is
not too much of a problem, except, I guess, when a large number of objects
are involved.
> I am going to fiddle a little more with mine, then I'll post the source.
>
That is good!
Thomas
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Thomas de Groot
Subject: Re: the Utah teapot is older than you think!
Date: 8 Feb 2009 03:05:39
Message: <498e9253@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Excellent! Thank you!
Thomas
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Thank you, Bill. :-D
I will begin my attempts at vivisection shortly.
As a random side note, I bet (C# <--> SDL loops) wouldn't be too annoying,
for the most part...
Further random side note...I think I might try to create an XML definition
file for the basic POV objects, and maybe a C# GUI frontend to modify their
basic params, just for fun...
BTW your teapot looks quite nice. ;-D
ian
"Bill Pragnell" <bil### [at] hotmail com> wrote in message
news:web.498df5d42cee23ee7da89d350@news.povray.org...
> Right, here's the magic incantation:
>
> // 'Encase' places objects over the surface of another object.
> // Call this macro from inside union or merge for greater flexibility.
> //
> // baseobj - object identifier - the target object (must not be infinite).
> // componentobj - object identifier - the object to be copied over the
> surface
> of the target object.
> // randy - yes/no - should componentobj be randomly rotated around the
> normal
> when placed? (yes for grass etc)
> // randxy - yes/no - should componentobj be randomly oriented before
> scaling and
> placement? (yes for rocks etc)
> // dx - float - grid size; probably similar to average object separation
> after
> placement.
> // scal1 - float - scale factor of componentobj in-plane (relative to dx)
> // scal2 - float - scale factor of componentobj along normal (relative to
> dx)
> // sd - seed - the random seed to be used.
> //
> #macro Encase(baseobj, componentobj, randy, randxy, dx, scal1, scal2, sd)
> #local minext = min_extent(baseobj);
> #local maxext = max_extent(baseobj);
> #local xwid = maxext.x - minext.x;
> #local ywid = maxext.y - minext.y;
> #local zwid = maxext.z - minext.z;
> #local norm = <0, 0, 0>;
> #local dirs = array[6] { x, -x, y, -y, z, -z }
> #local zp = minext.z + dx/2;
> #while (zp < maxext.z)
> #local yp = minext.y + dx/2;
> #while (yp < maxext.y)
> #local xp = minext.x + dx/2;
> #while (xp < maxext.x)
> #local startpos = <xp+dx*(rand(sd)-0.5), yp+dx*(rand(sd)-0.5),
> zp+dx*(rand(sd)-0.5)>;
> #local n = 0;
> #local trans = transform { rotate x*rand(sd)*90 rotate
> y*rand(sd)*90 }
> #while ((n < 6))
> #local dir = vtransform(dirs[n], trans);
> #local spoint = trace(baseobj, startpos, dir, norm);
> #local sdist = vlength(spoint-startpos);
> #if ((sdist < dx) & (vlength(norm) > 0))
> object {
> componentobj
> #if (randy) rotate y*rand(sd) #end
> #if (randxy) rotate x*rand(sd)*360 rotate y*rand(sd)*360 #end
> scale <scal1*dx, scal2*dx, scal1*dx>
> Point_At_Trans(norm) translate spoint }
> #end
> #local n = n + 1;
> #end // direction loop
> #local xp = xp + dx;
> #end // x loop
> #local yp = yp + dx;
> #end // y loop
> #local zp = zp + dx;
> #end // z loop
> #end
>
> // usage example:
> #declare TestTorus = torus { 2, 1 }
> #declare TestBall = sphere { <0,0,0>, 1 }
> #declare r1 = seed(0);
> Encase(TestTorus, TestBall, no, no, 0.2, 0.5, 0.5, r1)
>
>
> Hope it's useful!
> Bill
>
>
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Bill Pragnell
Subject: Re: the Utah teapot is older than you think!
Date: 8 Feb 2009 19:21:27
Message: <498f7707@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Just a couple more teapots from my playing with object placement.
Post a reply to this message
Attachments:
Download 'teapot_ugly.jpg' (119 KB)
Download 'teapot_damaged.jpg' (95 KB)
Preview of image 'teapot_ugly.jpg'

Preview of image 'teapot_damaged.jpg'

|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |