POV-Ray : Newsgroups : povray.general : Grass macro Server Time
28 Nov 2024 23:00:01 EST (-0500)
  Grass macro (Message 1 to 5 of 5)  
From: cogitas3d
Subject: Grass macro
Date: 30 Jun 2006 05:00:01
Message: <web.44a4e7cebd0e156f2d7d33060@news.povray.org>
Hi!

I'm learned about POV-Ray and parallel I use it in my 3d projects, but I
have a problem when I need to use macros how that make grass (Oyobale). I
alread print the files that have ont the site, but I didnt understand
anithing.

Where I found a documentation that explain how to use macros? More
especifically "grass" macros.

I use Linux.

A big hug


Post a reply to this message

From: Jonathan
Subject: Re: Grass macro
Date: 7 Jul 2006 13:23:10
Message: <44ae987e@news.povray.org>
Gilles Tran's grass macro, I presume?
You should start my including the mgrass.pov into the scene you intend to 
use.
#include "mpatch.pov"

The MakeGrassPatch macro is probally the one you will use the most,
It is the macro the front end that makes the grouping of grass, see the 
mgrass.pov under the approiate section for exact parameters. It calls the 
MakeBlade macro to assemble the mesh object that you will use.
From the example file:

#declare 
objectPatch=object{MakeGrassPatch(lPatch,nBlade,ryBlade,segBlade,lBlade,wBlade,wBladeEnd,doSmooth,startBend,vBend,pwBend,rd,stdposBlade,stdrotBlade,stdBlade,stdBend,dofold,dofile,fname)}

Note that the mesh resulting mesh is put into it's own object in this case. 
This can then be put as a parameter into the MakePrairie macro; notice the 
fifth parameter:

MakePrairie(lPatch,nxPrairie,addPatches,nzPrairie,objectPatch,rd,stdscale,stdrotate,doTest)

Another use would be the trace() function:
#declare lPatch=1;               // size of patch
#declare nBlade=2;                // number of blades per line (there will 
be nBlade x nBlade blades)
#declare ryBlade = 0;            // initial y rotation of blade
#declare segBlade= 15;            // number of blade segments
#declare lBlade = 25;             // length of blade
#declare wBlade = 1;              // width of blade at start
#declare wBladeEnd = 0.3;         // width of blade at the end
#declare doSmooth=false;          // true makes smooth triangles
#declare startBend = <0,1,0.3>;   // bending of blade at start (<0,1,0>=no 
bending)
#declare vBend = <0,-0.5,0>;         // force bending the blade (<0,1,1> = 

#declare pwBend = 3;              // bending power (how slowly the curve 
bends)
#declare rd = 459;                // seed
#declare stdposBlade = 1;         // standard deviation of blade position 
0..1
#declare stdrotBlade = 360;       // standard deviation of rotation
#declare stdBlade = 1.2;           // standard deviation of blade scale;
#declare stdBend = 2;            // standard deviation of blade bending;
#declare dofold = true;          // true creates a central fold in the blade 
(twice more triangles)
#declare dofile = false;          // true creates a mesh file
#declare fname = "fgrass1.inc"     // name of the mesh file to create

#declare Surface = isosurface {
  function { z + f_noise3d(x, y, 0) }
  contained_by { box { <-5,-1,-5>, <5,1,5> } }
  accuracy 0.001
  max_gradient 4

}

object {Surface pigment { Tan }}

#local Z=-6;
#while (Z < 6)
        #local X=-6;
        #while (X < 6)

                #declare Norm = <0, 0, 0>;
                #declare Start = <X, 2, Z>;
                #declare Inter= trace ( Surface, Start, <X, 0, Z>-Start, 
Norm );

                #if (vlength(Norm)!=0)
                       
object{MakeGrassPatch(lPatch,nBlade,ryBlade,segBlade,lBlade,wBlade,wBladeEnd,doSmooth,startBend,vBend,pwBend,rd,stdposBlade,stdrotBlade,stdBlade,stdBend,dofold,dofile,fname)

translate Inter pigment { color Green }}
                        #end
                #local X=X+2;
                #end
        #local Z=Z+2;

        #end

You might consider incorporating randomness using seed() and rand(). And you 
probally should look at the trace() help and example. There are samples of 
using the trace() function in several of the sample scene files that is 
included with PovRay.

I realize that this ain't much, but I hope it is enough to get you started.

Good luck,
Jonathan
red### [at] redmasqcom





"cogitas3d" <cic### [at] yahoocombr> wrote in message 
news:web.44a4e7cebd0e156f2d7d33060@news.povray.org...
> Hi!
>
> I'm learned about POV-Ray and parallel I use it in my 3d projects, but I
> have a problem when I need to use macros how that make grass (Oyobale). I
> alread print the files that have ont the site, but I didnt understand
> anithing.
>
> Where I found a documentation that explain how to use macros? More
> especifically "grass" macros.
>
> I use Linux.
>
> A big hug
>
>


Post a reply to this message

From: cogitas3d
Subject: Re: Grass macro
Date: 14 Jul 2006 23:20:00
Message: <web.44b85e2ea2c43723a6890270@news.povray.org>
Hi Jonathan!

Primally I laked to thank tou for the attention.

What you write is necessary that I wanted, to work with mgrass.

I read for many times the text that you write and I don't undertand yet how
I can to link a object to where the grasses will cover. For a example. I
make a scene:

//---------------------------------------------------------------------

 #include "colors.inc"

background { color rgb <225,245,246>/255 }
camera {
location <-2,1,-5> //<-2,4,-4>
look_at <0,1,0>
}

//------------floor box--------------
box {
<-3,0,-3>
<3,0,3>
texture {pigment {color rgb<155,155,200>/255}}
}



//----------- sample box-------------
box {
<-1,0,-1>
<1,2,1>
texture {pigment{color Red}}
}



light_source {
<-1,10,-4>
color White}

//-----------------------------------------------------------

If I want that the grass cover only the "floor box", what I have to do? And,
if I want to cover only the "sample box" with grass?

Do you understand? :) (Oh, so bad English)

I need to cover some meshes in scene that represent the garden.

Well, is this. If I continue white this way you don't understand more
anything :P

Thanks very much!


Post a reply to this message

From: Jonathan
Subject: Re: Grass macro
Date: 17 Jul 2006 11:34:15
Message: <44bbadf7@news.povray.org>
This should get you started. Note that to cover only the floor that I had to 
take the difference of the area. The translate -y is to move the cube down 
to intersect the floor. That difference object is never put into the scene 
but only used as a reference for the trace() function. I did not implement 
rotation or random placement to make the grass look more "natural" random 
placement should be calculated before the trace() function is used. If the 
area your trying to cover is viewed from a distance, do not worry about 
blade intersection; however, if viewed up-close, the bounding box or the 
trace() function (which would allow closer blades at the cost of 
calculations and multiple testing, perhaps a hybrid method?) could be used 
to make sure blades don't intersect.  Again I hope this gets you started. 
Sorry my last post wasn't of much use.

Thanks,
Jonathan

#include "functions.inc"
#include "colors.inc"
#include "mgrass.pov"

#declare Which = 0;             //0= Sample 1=Floor

#declare lPatch=1;               // size of patch
#declare nBlade=2;                // number of blades per line (there will 
be nBlade x nBlade blades)
#declare ryBlade = 0;            // initial y rotation of blade
#declare segBlade= 15;            // number of blade segments
#declare lBlade = 25;             // length of blade
#declare wBlade = 1;              // width of blade at start
#declare wBladeEnd = 0.3;         // width of blade at the end
#declare doSmooth=false;          // true makes smooth triangles
#declare startBend = <0,1,0.3>;   // bending of blade at start (<0,1,0>=no 
bending)
#declare vBend = <0,-0.5,0>;         // force bending the blade (<0,1,1> = 

#declare pwBend = 3;              // bending power (how slowly the curve 
bends)
#declare rd = 459;                // seed
#declare stdposBlade = 1;         // standard deviation of blade position 
0..1
#declare stdrotBlade = 360;       // standard deviation of rotation
#declare stdBlade = 1.2;           // standard deviation of blade scale;
#declare stdBend = 2;            // standard deviation of blade bending;
#declare dofold = true;          // true creates a central fold in the blade 
(twice more triangles)
#declare dofile = false;          // true creates a mesh file
#declare fname = "fgrass1.inc"     // name of the mesh file to create


background { color rgb <225,245,246>/255 }
camera {
location <-2,1,-5> //<-2,4,-4>
look_at <0,1,0>
}

//------------floor box--------------
#declare Floor=box {
<-3,0,-3>
<3,0,3>
texture {pigment {color rgb<155,155,200>/255}}
}



//----------- sample box-------------
#declare Sample = box {
<-1,0,-1>
<1,2,1>
texture {pigment{color Red}}
}



 #if (Which)
  #declare Surface=difference { object {Floor} object {Sample translate -y}}
  #declare Area=3;
  #declare Step=1.5;
 #else
   #declare Surface=object {Sample}
   #declare Area=1;
   #declare Step=.5;
 #end

light_source {
<-1,10,-4>
color White}

//-----------------------------------------------------------


object {Sample}
object {Floor}

#local Z=-Area;
#while (Z < Area)
        #local X=-Area;
        #while (X < Area)

                #declare Norm = <0, 0, 0>;
                #declare Start = <X, 4, Z>;
                #declare Inter= trace ( Surface, Start, <X, 0, Z>-Start, 
Norm );

                #if (vlength(Norm)!=0)
                       
object{MakeGrassPatch(lPatch,nBlade,ryBlade,segBlade,lBlade,wBlade,wBladeEnd,doSmooth,startBend,vBend,pwBend,rd,stdposBlade,stdrotBlade,stdBlade,stdBend,dofold,dofile,fname)
scale .1 translate Inter pigment { color Green }}
                        #end
                #local X=X+Step;
                #end
        #local Z=Z+Step;

        #end


Post a reply to this message

From: cogitas3d
Subject: Re: Grass macro
Date: 20 Jul 2006 13:20:01
Message: <web.44bfba83a2c43726b5ff3b80@news.povray.org>
Hi Jonathan!

Really really thanks!

All let's ok now! I get to understand the sufficient to study the code with
more accurate.

I download some tutorial about macros, declares and etc, to help my learn.
But the main part is your explanation.

You write very well, why do you don't make a mgrass tutorial? (This way you
explain only once)

Thanks very much!

POV-Ray, Blender, Inkscape, Qcad, Linux... tutorials in portughese, visit:
http://cogitas3d.site.vu


Post a reply to this message

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