 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
I'm making an image with a big HF in the foreground. I want to put grass on
the HF but only on the flat areas. What is the most conventional way to do
this? I can make an image that describes which areas should and shouldn't
have grass by using world forge, but I still wouldn't know how to apply the
image to a macro for placing grass. Thanks in advance!
Corey
http://www.4gigs.com/~schitzo/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On Mon, 30 Sep 2002 00:08:23 -0400, "Corey Woodworth" <cdw### [at] mpinet net>
wrote:
> I can make an image that describes which areas should and shouldn't
> have grass by using world forge, but I still wouldn't know how to apply the
> image to a macro for placing grass.
as function based on pattern as image ?
ABX
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Corey Woodworth wrote:
>I'm making an image with a big HF in the foreground. I want to put grass on
>the HF but only on the flat areas. What is the most conventional way to do
>this? I can make an image that describes which areas should and shouldn't
>have grass by using world forge, but I still wouldn't know how to apply the
>image to a macro for placing grass. Thanks in advance!
>
>Corey
>http://www.4gigs.com/~schitzo/
>
First, declare your heightfield picture and your grass-info-picture each as
a function (see "6.1.6.5 Declaring User-Defined Color Functions" in your
POV-documentation)
Then use a loop to randomly 'try' where grass can be (where the
grass-function is above 0.5, i.e.).
Last, get the height info from your heightfield function where to put the
grass in y-direction.
It will be a bit tricky to get the right coordinates and to compensate the
scaling of your heightfield, but that's the best way I thing.
Any other ideas?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
I've written some macros for just that purpose, though
they're still experimental and not yet fully finished. See my
homepage's WIP section, or some rather old images
I posted to the newsgroups.
Though they're not fully up to what you'd like, you
could perhaps use the source to learn from, at least
for placement etc.
Regards,
Tim
--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html
Email: Tim### [at] gmx de
> I'm making an image with a big HF in the foreground. I want to put grass
on
> the HF but only on the flat areas. What is the most conventional way to do
> this? I can make an image that describes which areas should and shouldn't
> have grass by using world forge, but I still wouldn't know how to apply
the
> image to a macro for placing grass. Thanks in advance!
>
> Corey
> http://www.4gigs.com/~schitzo/
>
>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Corey Woodworth wrote:
>
> I'm making an image with a big HF in the foreground. I want to put grass on
> the HF but only on the flat areas. What is the most conventional way to do
> this? I can make an image that describes which areas should and shouldn't
> have grass by using world forge, but I still wouldn't know how to apply the
> image to a macro for placing grass. Thanks in advance!
The easiest is usually to use 'trace()'. You can use the returned normal
vector to determine the slope at the position.
Christoph
--
POV-Ray tutorials, IsoWood include,
TransSkin and more: http://www.tu-bs.de/~y0013390/
Last updated 13 Aug. 2002 _____./\/^>_*_<^\/\.______
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Corey Woodworth wrote:
>
> I'm making an image with a big HF in the foreground. I want to put grass on
> the HF but only on the flat areas. What is the most conventional way to do
> this? I can make an image that describes which areas should and shouldn't
> have grass by using world forge, but I still wouldn't know how to apply the
> image to a macro for placing grass. Thanks in advance!
Vegetate it -
http://www.geocities.com/SiliconValley/Program/9231/povray.html
--
Ken Tyler
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> The easiest is usually to use 'trace()'. You can use the returned normal
> vector to determine the slope at the position.
>
> Christoph
I've seen lots of cool stuff done with trace but I've never dabbled with it
myself. I read the docs on it and I'm a bit confused. I have a heightfield
named canyon, and this is a nested loop to test for an intersection. It
should always intersect so it should always generate a sphere (I havn't the
slightest how to test for the slope yet), but it loops infinetly and I dunno
why. I'm not too good at Macros yet. =)
Here is my code, can someone point me in the right direction?
#declare Norm = <0, 0, 0>;
#declare Start = <0, 2, 0>;
#declare End = <0, 0, 0>;
#declare Counter = 100;
#declare xCount = Counter;
#declare zCount = Counter;
#while (xCount != 0)
#while (zCount != 0)
#declare End = <xCount/Counter,0,zCount/Counter>;
#declare Start = End + <0,2,0>;
#declare Inter = trace ( canyon, Start, End, Norm );
#if (vlength(Norm)!=0)
sphere {
Inter, .2
texture {
pigment {color green 1}
}
}
#declare zCount = zCount - 1;
#end
#declare xCount = xCount - 1;
#end
Corey
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3d9b7fe7@news.povray.org>,
"Corey Woodworth" <cdw### [at] mpinet net> wrote:
> I've seen lots of cool stuff done with trace but I've never dabbled with it
> myself. I read the docs on it and I'm a bit confused. I have a heightfield
> named canyon, and this is a nested loop to test for an intersection. It
> should always intersect so it should always generate a sphere (I havn't the
> slightest how to test for the slope yet), but it loops infinetly and I dunno
> why. I'm not too good at Macros yet. =)
> Here is my code, can someone point me in the right direction?
Well, your first problem is that you are testing for equality in your
loop conditions...almost always a Bad Thing. Scalar variables in POV-Ray
are double-precision floating point numbers, and numeric errors could
cause them to go right past 0 without ever being exactly equal to it.
Normally, you loop while the counter variable is higher or lower to a
value instead of while it is not equal to a certain value.
You are also looping down, this is just odd, since usually people loop
up unless they have a good reason, but it works, there isn't any reason
not to.
Finally, and probably the real reason you have a problem, the trace()
function takes a ray direction, not an end point. All your trace() calls
are going off in a plane perpendicular to the y axis and passing through
< 0, 2, 0>. Use "trace(Canyon, Start, -y, Norm)" instead.
Oh, and you are missing an #end...I assume this just got lost in editing
for the post, because the code doesn't do anything without it.
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tag povray org
http://tag.povray.org/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> Well, your first problem is that you are testing for equality in your
> loop conditions...almost always a Bad Thing. Scalar variables in POV-Ray
> are double-precision floating point numbers, and numeric errors could
> cause them to go right past 0 without ever being exactly equal to it.
> Normally, you loop while the counter variable is higher or lower to a
> value instead of while it is not equal to a certain value.
That was code copied strait from the docs =) I didn't, and still don't
completely understand how and what trace returns. What I'm aiming for is
something that detects if the given point on the HF is somewhat flat and if
so put a sphere there.
> You are also looping down, this is just odd, since usually people loop
> up unless they have a good reason, but it works, there isn't any reason
> not to.
It just seemed more intuitive to me at the time. =)
> Finally, and probably the real reason you have a problem, the trace()
> function takes a ray direction, not an end point. All your trace() calls
> are going off in a plane perpendicular to the y axis and passing through
> < 0, 2, 0>. Use "trace(Canyon, Start, -y, Norm)" instead.
Ah! That makes sense. I thought it was an endpoint. Thats why I moved End in
relation to Start.
> Oh, and you are missing an #end...I assume this just got lost in editing
> for the post, because the code doesn't do anything without it.
Whoops =)
Ok. Here is the updated code, but it still doesn't work.
#declare Norm = <0, 0, 0>;
#declare Start = <0, 2, 0>;
#declare Counter = 1000;
#declare xCount = Counter;
#declare zCount = Counter;
#while (xCount != 0)
#while (zCount != 0)
#declare Start = <xCount/Counter,2,zCount/Counter>;
#declare Inter = trace(canyon, Start, -y, Norm);
#if (vlength(Norm)!=0)
sphere {
Inter, .5
texture {
pigment {color green 1}
}
}
#end
#declare zCount = zCount - 1;
#end
#declare xCount = xCount - 1;
#end
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Corey Woodworth" <sch### [at] hotmail com> wrote in message
news:3d9daca5$1@news.povray.org...
> #if (vlength(Norm)!=0)
> sphere {
> Inter, .5
> texture {
> pigment {color green 1}
> }
> }
> #end
All that (vlength(Norm)!=0) is checking is that you've hit your hf (the only
time when vlength is 0 is when you've missed the object).
I haven't used trace for a while now, but iirc what you want to do is check
whether Norm.x and Norm.z are under a certain range. I think the following would
only place a sphere if the point was perfectly flat:
#if(Norm.x = 0 & Norm.z = 0 & Norm.y != 0)
sphere {
Inter, .5
texture {
pigment {color green 1}
}
}
#end
or, with a bit more give and take...
#if(abs(Norm.x) < 0.1 & abs(Norm.z) < 0.1 & Norm.y != 0)
sphere {
Inter, .5
texture {
pigment {color green 1}
}
}
#end
... but wait for corrections from others (untested).
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3d9daca5$1@news.povray.org>,
"Corey Woodworth" <sch### [at] hotmail com> wrote:
> That was code copied strait from the docs =) I didn't, and still don't
> completely understand how and what trace returns.
It takes an object and the beginning point and direction of a ray, and
optionally a variable to put the surface normal in. If the ray hits the
object, it sets the normal variable to the surface normal at the point
where it hit, and returns the intersection point. If it doesn't hit the
object, it sets the normal to < 0, 0, 0> (an impossible value for a
normal) and could return anything for the point, that value is
unpredictable.
> What I'm aiming for is something that detects if the given point on
> the HF is somewhat flat and if so put a sphere there.
How easy that is depends on how you define "flat"...you could check the
y value of the normal. If it is perfectly horizontal, it will equal 1,
perfectly vertical it will equal 0, you will probably want some
leeway...placing spheres only if the y value is larger than 0.7, for
example. It will be the sine of the angle to a horizontal plane, so some
simple trig could be used to set the threshold to a specific angle if
you want this.
This is only affected by the normal of the surface at that point
though...it could be a bump on the side of a steep cliff, or the ground
at that point could be extremely rough.
> Ok. Here is the updated code, but it still doesn't work.
How does it not work? It still infinitely loops? Or it just doesn't
place the spheres?
Here's a (untested) corrected (and reformatted to be closer to the way I
write code, just ignore that) version:
#declare Norm = <0, 0, 0>;
#declare Counter = 1000;
#declare xCount = Counter;
#declare zCount = Counter;
#while(xCount > 0)
#while(zCount > 0)
#declare Start = <xCount/Counter, 100, zCount/Counter>;
#declare Inter = trace(canyon, Start, -y, Norm);
#if(vlength(Norm) > 0.0001)
sphere {Inter, .5
texture {pigment {color green 1}}
}
#end
#declare zCount = zCount - 1;
#end
#declare xCount = xCount - 1;
#end
I increased the "height" the rays are cast from to 100...I don't know
how tall your canyon object is, if it went higher than 2 there would
have been a problem.
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tag povray org
http://tag.povray.org/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3d9dbd7c$1@news.povray.org>,
"Tom Melly" <tom### [at] tomandlu co uk> wrote:
> I haven't used trace for a while now, but iirc what you want to do is check
> whether Norm.x and Norm.z are under a certain range. I think the following
> would only place a sphere if the point was perfectly flat:
Just checking y would be easier. If it is very near 1, both x and y must
be near 0. It is equal to the sine of the angle to a horizontal plane.
And if it is non-0, the intersection is valid, so you don't even have to
check for < 0, 0, 0> any more.
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tag povray org
http://tag.povray.org/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Christopher James Huff" <chr### [at] mac com> wrote in message
news:chr### [at] netplex aussie org...
>
> Just checking y would be easier. If it is very near 1, both x and y must
> be near 0. It is equal to the sine of the angle to a horizontal plane.
That's the bit I couldn't quite remember (i.e. whether trace could return
<1,1,1> as a vector).
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3da182f8$1@news.povray.org>,
"Tom Melly" <tom### [at] tomandlu co uk> wrote:
> That's the bit I couldn't quite remember (i.e. whether trace could return
> <1,1,1> as a vector).
Well, it can't return that either, and never will...unless I am very
wrong, it always returns either a normalized vector or < 0, 0, 0>.
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tag povray org
http://tag.povray.org/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Christopher James Huff" <chr### [at] mac com> wrote in message
news:chr### [at] netplex aussie org...
> Well, it can't return that either, and never will...unless I am very
> wrong, it always returns either a normalized vector or < 0, 0, 0>.
>
Well, exactly (I think). BTW, what is the normalised vector of <1,1,1>? Oh, hang
on, there must be a function for that....
#debug vstr(3, vnormalize(<1,1,1>), ", ",2,5)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3da2a000$1@news.povray.org>,
"Tom Melly" <tom### [at] tomandlu co uk> wrote:
> Well, exactly (I think). BTW, what is the normalised vector of <1,1,1>? Oh,
> hang
> on, there must be a function for that....
>
> #debug vstr(3, vnormalize(<1,1,1>), ", ",2,5)
The normalized vector is < x, y, z>/sqrt(x*x + y*y + z*z), so the result
is < 1, 1, 1>/sqrt(3). This can't be perfectly represented in decimal or
binary form, so you will get a lot of decimals from that #debug
statement. You probably don't need to know this unless you are trying to
simplify algebraic expressions.
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tag povray org
http://tag.povray.org/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |