POV-Ray : Newsgroups : povray.general : Grass macro : Re: Grass macro Server Time
3 May 2024 15:44:50 EDT (-0400)
  Re: Grass macro  
From: Jonathan
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

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