POV-Ray : Newsgroups : povray.advanced-users : My first grass. Server Time
1 Nov 2024 11:17:43 EDT (-0400)
  My first grass. (Message 1 to 10 of 16)  
Goto Latest 10 Messages Next 6 Messages >>>
From: Corey Woodworth
Subject: My first grass.
Date: 30 Sep 2002 00:07:55
Message: <3d97ce1b@news.povray.org>
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

From: ABX
Subject: Re: My first grass.
Date: 30 Sep 2002 02:30:52
Message: <borfpuo0greo8tsvd20c0pvusqh63rk5rd@4ax.com>
On Mon, 30 Sep 2002 00:08:23 -0400, "Corey Woodworth" <cdw### [at] mpinetnet>
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

From: J  Diehl
Subject: Re: My first grass.
Date: 30 Sep 2002 02:45:07
Message: <web.3d97f2bc855d30e7f70c33440@news.povray.org>
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

From: Tim Nikias
Subject: Re: My first grass.
Date: 30 Sep 2002 03:54:46
Message: <3d980346$1@news.povray.org>
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] gmxde

> 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

From: Christoph Hormann
Subject: Re: My first grass.
Date: 30 Sep 2002 05:51:47
Message: <3D981EB4.4DECCE3B@gmx.de>
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

From: Ken
Subject: Re: My first grass.
Date: 30 Sep 2002 06:41:35
Message: <3D982A2E.8E9D1F0B@pacbell.net>
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

From: Corey Woodworth
Subject: Re: My first grass.
Date: 2 Oct 2002 19:23:19
Message: <3d9b7fe7@news.povray.org>
> 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

From: Christopher James Huff
Subject: Re: My first grass.
Date: 2 Oct 2002 20:06:18
Message: <chrishuff-4761E3.20031102102002@netplex.aussie.org>
In article <3d9b7fe7@news.povray.org>,
 "Corey Woodworth" <cdw### [at] mpinetnet> 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] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Corey Woodworth
Subject: Re: My first grass.
Date: 4 Oct 2002 10:58:45
Message: <3d9daca5$1@news.povray.org>
> 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

From: Tom Melly
Subject: Re: My first grass.
Date: 4 Oct 2002 12:10:36
Message: <3d9dbd7c$1@news.povray.org>
"Corey Woodworth" <sch### [at] hotmailcom> 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

Goto Latest 10 Messages Next 6 Messages >>>

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