POV-Ray : Newsgroups : povray.advanced-users : Grass Again Server Time
24 Dec 2024 12:49:42 EST (-0500)
  Grass Again (Message 1 to 8 of 8)  
From: Mick Hazelgrove
Subject: Grass Again
Date: 20 Sep 2000 13:34:47
Message: <39c8f537@news.povray.org>
Hi

I wouldn't dream of calling you a trouble maker warp :) honest!  It's me
that causes the trouble, twas always that way I fear.

Herre's the relevant section of the code. The points go off in the wrong
direction.

#macro
akeBlade( RotX,RotY,segLength,NoSegs,XPos,ZPos,SF,Dim,bladeW,foldDepth)

#local P1=vaxis_rotate(<bladeW+XPos,0,0>*SF,y,RotY);
#local PM=vaxis_rotate(<0+XPos,0,foldDepth>*SF,y,RotY);
#local P2=vaxis_rotate(<-bladeW+XPos,0,0>*SF,y,RotY);
#local RVec = vnormalize(P1-P2);

#local Ct = 0;

           #while(Ct<NoSegs)

                   #local N1
=vaxis_rotate(<P1.x,P1.y+(segLength*SF),P1.z>*Dim,RVec,RotX);
                    #local NM
=vaxis_rotate(<PM.x,PM.y+(segLength*SF),PM.z>*Dim,RVec,RotX);
                   #local N2
=vaxis_rotate(<P2.x,P2.y+(segLength*SF),P2.z>*Dim,RVec,RotX);

                      file://Left side

#write(filehandle,"triangle{",P1,",",PM,",",N1,"texture{GrassTex}}\n")

#write(filehandle,"triangle{",PM,",",N1,",",NM,"texture{GrassTex}}\n")
                      file://Right side

#write(filehandle,"triangle{",PM,",",P2,",",N2,"texture{GrassTex}}\n")

#write(filehandle,"triangle{",PM,",",NM,",",N2,"texture{GrassTex}}\n")
                                 file://Points

                            #local Ct=Ct+1;
                            #local P1 = N1;
                            #local PM = NM;
                            #local P2 = N2;
file://This is the problem section where I am tyrying to add a point to the
grass

           /* #if(Ct=NoSegs)
                 #local EPt
=vaxis_rotate(<NM.x,NM.y+(segLength*SF)*Dim,NM.z>,RVec,RotX);

#write(filehandle,"triangle{",P1,",",PM,",",EPt,"texture{GrassTex}}\n")

#write(filehandle,"triangle{",PM,",",EPt,",",P2,"texture{GrassTex}}\n")
           #end*/

          #end//while loop

#end//macro





----------------------------------------------------------------------------
----


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Grass Again
Date: 20 Sep 2000 13:50:52
Message: <39C8F8CF.C4300845@hotmail.com>
Mick Hazelgrove wrote:

> Hi
>
> I wouldn't dream of calling you a trouble maker warp :) honest!  It's me
> that causes the trouble, twas always that way I fear.
>
> Herre's the relevant section of the code. The points go off in the wrong
> direction.

Can you please give an example on how to call your macro or/and
explain the parameters. Then it will be easier to debug your code.


Regards,

Tor Olav
--
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html


Post a reply to this message

From: Mick Hazelgrove
Subject: Re: Grass Again
Date: 20 Sep 2000 14:02:39
Message: <39c8fbbf@news.povray.org>
Hi

> Can you please give an example on how to call your macro or/and
> explain the parameters. Then it will be easier to debug your code.

OK here's the full version. I was trying to save space. Pic in p.b.a.

Mick

// ----------------------------------------
camera
{
  location  <0.0, 5, -50.0>
  direction 1.5*z
  right     4/3*x
  look_at   <0.0, 5.0,  0.0>
}

sky_sphere
{
  pigment
  {
    gradient y
    color_map { [0.0 color blue 0.6] [1.0 color rgb 1] }
  }
}

light_source
{
  0*x // light's position (translated below)
  color red 1.0  green 1.0  blue 1.0  // light's color
  translate <-30, 30, -30>
}

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

#declare GrassTex = texture {
    pigment{Green}
        finish{specular 1 roughness .01}
             normal{bozo .01 scale <.1,5,.1> scallop_wave}
  }
file://-------------------------Make Blade------------------------------
#macro
akeBlade( RotX,RotY,segLength,NoSegs,XPos,ZPos,SF,Dim,bladeW,foldDepth)

#local P1=vaxis_rotate(<bladeW+XPos,0,0>*SF,y,RotY);
#local PM=vaxis_rotate(<0+XPos,0,foldDepth>*SF,y,RotY);   file://make z A
variable - foldDepth
#local P2=vaxis_rotate(<-bladeW+XPos,0,0>*SF,y,RotY);
#local RVec = vnormalize(P1-P2);

#local Ct = 0;

           #while(Ct<NoSegs)

                   #local N1 =
vaxis_rotate(<P1.x,P1.y+(segLength*SF),P1.z>*Dim,RVec,RotX);
                    #local NM =
vaxis_rotate(<PM.x,PM.y+(segLength*SF),PM.z>*Dim,RVec,RotX);
                   #local N2 =
vaxis_rotate(<P2.x,P2.y+(segLength*SF),P2.z>*Dim,RVec,RotX);

                      file://Left side

#write(filehandle,"triangle{",P1,",",PM,",",N1,"texture{GrassTex}}\n")

#write(filehandle,"triangle{",PM,",",N1,",",NM,"texture{GrassTex}}\n")
                      file://Right side

#write(filehandle,"triangle{",PM,",",P2,",",N2,"texture{GrassTex}}\n")

#write(filehandle,"triangle{",PM,",",NM,",",N2,"texture{GrassTex}}\n")
                                 file://Points

                            #local Ct=Ct+1;
                            #local P1 = N1;
                            #local PM = NM;
                            #local P2 = N2;

            #if(Ct=NoSegs)
                 #local EPt =
vaxis_rotate(<NM.x,NM.y+(segLength*SF)*Dim,NM.z>,RVec,RotX);

#write(filehandle,"triangle{",P1,",",PM,",",EPt,"texture{GrassTex}}\n")

#write(filehandle,"triangle{",PM,",",EPt,",",P2,"texture{GrassTex}}\n")
           #end

          #end//while loop

#end//macro
file://-------------------------------------------------------------------
#macro
MakePatch(XnBlades,ZnBlades,Spacing,NoSegs,segLength,RotX,Dim,bladeW,foldDep
th)
#declare fname = "GMF.inc"
#fopen filehandle fname write
#write(filehandle,"#declare Grass = mesh{\n")

#declare RdN = seed(1549);

#local ZPos =-(XnBlades)*Spacing;
#local XPos =-(ZnBlades)*Spacing;

   #while(XPos<(XnBlades)*Spacing)
     #local ZPos = -(XnBlades)*Spacing;//reset ZLoop
       #while(ZPos<(ZnBlades)*Spacing)

           #declare RotX = RotX+(rand(RdN)/10);
           #declare RotY=rand(RdN)*360;
           #declare SF = rand(RdN);


MakeBlade(RotX,RotY,segLength,NoSegs,XPos,ZPos,SF,Dim,bladeW,foldDepth)

                #local ZPos = ZPos+Spacing;
       #end//ZLoop
                #local XPos=XPos+Spacing;

   #end file://XLoop
                        #write(filehandle,"}")
                        #fclose filehandle

#end file://macro
file://-------------------------------------------------------------------



MakePatch( 3,  file://Horizontal(X) number of blades in Patch
           5,  file://Horizontal(Z) number of blades in Patch
           3,  file://spacing between blades,default 3
          10,  file://Number of segments in blade
           3,  // Length of blade segment
           5,   file://Rotation of Blade in degrees, default 2
           0.9125// amount by which blade gets thinner towards end between
.9 and 1 file://.9125
           .7, file://blade start width
           .75 file://depth of fold
)


#include"GMF.inc"
object{Grass
scale 1
}

file://plane{y,0 pigment{Tan}}


Post a reply to this message

From: Warp
Subject: Re: Grass Again
Date: 21 Sep 2000 03:14:43
Message: <39c9b562@news.povray.org>
Mick Hazelgrove <mic### [at] mhazelgrovefsnetcouk> wrote:
:                       file://Left side

  Using outlook perhaps?
  I have always wondered, what's the idea behind this. I can't imagine ANY
useful use of this property. If it put "http:" before the "//" then it might
make a little bit more sense (it would still be horrible, but at least there
would be an idea behind it), but "file:" doesn't make any sense to me.
  Is it possible to even turn it off?

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Grass Again
Date: 21 Sep 2000 05:12:06
Message: <39C9D0AE.64AE9950@hotmail.com>
Mick Hazelgrove wrote:

> Hi
>
> > Can you please give an example on how to call your macro or/and
> > explain the parameters. Then it will be easier to debug your code.
>
> OK here's the full version. I was trying to save space. Pic in p.b.a.
> ...

I have now had a look at your code. And I'm not quite sure what you're after.

But you could try to replace this:

#local EPt=vaxis_rotate(<NM.x,NM.y+(segLength*SF)*Dim,NM.z>,RVec,RotX);

with this:

#local EPt =
  vaxis_rotate(<NM.x, NM.y + segLength*SF, NM.z>*Dim, RVec, RotX);


I have also tried to optimize your code a little bit. See code below.

(I tried to pass the file-handle as a parameter parameter from the
MakeBlade macro to the  MakePatch macro, but this did not
seem to work. Does anyone have any ideas about this ?)

Btw.:
Are there any reasons for why you're applying the texture in the
MakeBlade macro and not in the MakePatch macro or in the
final object statement ?


Regards,

Tor Olav
--
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.1;

#include "colors.inc"
#include "textures.inc"

global_settings { ambient_light 1.5 }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Macros that do not use a file

#macro MakeBlade1(XRot, YRot, SegmLength, NoSegs,
                  XPos, ZPos, SF, Dim, BladeW, FoldDepth, BladeTexture)

  #local pO1 = SF*vrotate(XPos*x +    BladeW*x, YRot*y);
  #local pOM = SF*vrotate(XPos*x + FoldDepth*z, YRot*y);
  #local pO2 = SF*vrotate(XPos*x -    BladeW*x, YRot*y);
  #local vRot = vnormalize(pO1 - pO2);
  #local vGr = SF*SegmLength*y;
  #local Cnt = 0;
  #while (Cnt < NoSegs)
    #local pN1 = Dim*vaxis_rotate(pO1 + vGr, vRot, XRot);
    #local pNM = Dim*vaxis_rotate(pOM + vGr, vRot, XRot);
    #local pN2 = Dim*vaxis_rotate(pO2 + vGr, vRot, XRot);
    triangle { pOM, pO1, pN1 texture { BladeTexture } }
    triangle { pOM, pNM, pN1 texture { BladeTexture } }
    triangle { pOM, pO2, pN2 texture { BladeTexture } }
    triangle { pOM, pNM, pN2 texture { BladeTexture } }
    #local pO1 = pN1;
    #local pOM = pNM;
    #local pO2 = pN2;
    #local Cnt = Cnt + 1;
  #end // while
  #local pEM = Dim*vaxis_rotate(pNM + vGr, vRot, XRot);
  triangle { pOM, pO1, pEM texture { BladeTexture } }
  triangle { pOM, pO2, pEM texture { BladeTexture } }

#end // macro MakeBlade1


#macro MakePatch1(XnBlades, ZnBlades, Spacing,
                  NoSegs, SegmLength, XRot,
                  Dim, BladeW, FoldDepth, Seed, GrassTexture)

  #local RdN = seed(Seed);
  #local XCnt = -ZnBlades;
   #while(XCnt < XnBlades)
     #local ZCnt = -XnBlades;
     #while (ZCnt < ZnBlades)
       #local XRot = XRot + rand(RdN)/10;
       #local YRot = rand(RdN)*360;
       #local SF = rand(RdN);
       MakeBlade1(XRot, YRot,
                  SegmLength, NoSegs,
                  XCnt*Spacing, ZCnt*Spacing,
                  SF, Dim, BladeW, FoldDepth,
                  GrassTexture)
       #local ZCnt = ZCnt + 1;
     #end // while
     #local XCnt = XCnt + 1;
   #end // while

#end // macro MakePatch1

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Macros that do use a file

#macro MakeBlade2(XRot, YRot, SegmLength, NoSegs,
                  XPos, ZPos, SF, Dim, BladeW, FoldDepth)

  #local pO1 = SF*vrotate(XPos*x    + BladeW*x, YRot*y);
  #local pOM = SF*vrotate(XPos*x + FoldDepth*z, YRot*y);
  #local pO2 = SF*vrotate(XPos*x    - BladeW*x, YRot*y);
  #local vRot = vnormalize(pO1 - pO2);
  #local vGr = SF*SegmLength*y;
  #local Str1 = "  triangle { "
  #local Str2 = "texture { GrassTex } }\n"
  #local Cnt = 0;
  #while (Cnt < NoSegs)
    #local pN1 = Dim*vaxis_rotate(pO1 + vGr, vRot, XRot);
    #local pNM = Dim*vaxis_rotate(pOM + vGr, vRot, XRot);
    #local pN2 = Dim*vaxis_rotate(pO2 + vGr, vRot, XRot);
    #write (FileHandle, Str1, pOM, ", ", pO1, ", ", pN1, Str2)
    #write (FileHandle, Str1, pOM, ", ", pNM, ", ", pN1, Str2)
    #write (FileHandle, Str1, pOM, ", ", pO2, ", ", pN2, Str2)
    #write (FileHandle, Str1, pOM, ", ", pNM, ", ", pN2, Str2)
    #local pO1 = pN1;
    #local pOM = pNM;
    #local pO2 = pN2;
    #local Cnt = Cnt + 1;
  #end // while
  #local pEM = Dim*vaxis_rotate(pNM + vGr, vRot, XRot);
  #write (FileHandle, Str1, pOM, ", ", pO1, ", ", pEM, Str2)
  #write (FileHandle, Str1, pOM, ", ", pO2, ", ", pEM, Str2)

#end // macro MakeBlade2


#macro MakePatch2(XnBlades, ZnBlades, Spacing,
                  NoSegs, SegmLength, XRot,
                  Dim, BladeW, FoldDepth, Seed, FileName)

  #fopen FileHandle FileName write
  #write (FileHandle, "mesh {\n")
  #local RdN = seed(Seed);
  #local XCnt = -ZnBlades;
   #while (XCnt < XnBlades)
     #local ZCnt = -XnBlades;
     #while (ZCnt < ZnBlades)
       #local XRot = XRot + rand(RdN)/10;
       #local YRot = rand(RdN)*360;
       #local SF = rand(RdN);
       MakeBlade2(XRot, YRot,
                  SegmLength, NoSegs,
                  XCnt*Spacing, ZCnt*Spacing,
                  SF, Dim, BladeW, FoldDepth)
       #local ZCnt = ZCnt + 1;
     #end // while
     #local XCnt = XCnt + 1;
   #end // while
   #write (FileHandle, "}\n")
   #fclose FileHandle

#end // macro MakePatch2

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Do it without a file

#declare YellowGrass =
mesh {
  MakePatch1(
    3,       // Horizontal(X) number of blades in Patch
    5,       // Horizontal(Z) number of blades in Patch
    3,       // Spacing between blades, default 3
    10,      // Number of segments in blade
    3,       // Length of blade segment
    5,       // Rotation of Blade in degrees, default 2
    0.9125   // Amount by which blade gets thinner towards end
    0.7,     // Blade start width
    0.75,    // Depth of fold
    217,     // Random seed
    texture { pigment { color Yellow } }
  )
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Do it with a file

#declare GrassTex =
texture {
  normal {
    bozo 0.01
    scale <0.1, 5.0, 0.1>
    scallop_wave
  }
  pigment { color Green }
  finish {
    specular 1
    roughness 0.01
  }
}

#declare GrassFileName = "GMF.inc"

MakePatch2(
  3,       // Horizontal(X) number of blades in Patch
  5,       // Horizontal(Z) number of blades in Patch
  3,       // Spacing between blades,default 3
  10,      // Number of segments in blade
  3,       // Length of blade segment
  5,       // Rotation of Blade in degrees, default 2
  0.9125   // Amount by which blade gets thinner towards end
  0.7,     // Blade start width
  0.75,    // Depth of fold
  1549,    // Random seed
  GrassFileName
)


#declare GreenGrass =
object {
  #include GrassFileName
  scale <3, 4, 3>/4
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Put it all together

object { YellowGrass translate  10*x }
object { GreenGrass  translate -12*x }

plane { y, 0 pigment { Tan } }

sky_sphere {
  pigment {
    gradient y
    color_map {
      [ 0 color Blue*0.6 ]
      [ 1 color White ]
    }
  }
}

light_source { 30*<-1, 1, -1> color White }

camera {
  location <0, 1, -10>*5
  direction 3/2*z
  right 4/3*x
  look_at <0, 5,  0>
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

From: Gail Shaw
Subject: Re: Grass Again
Date: 21 Sep 2000 06:57:34
Message: <39c9e99e@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote in message news:39c9b562@news.povray.org...
> Mick Hazelgrove <mic### [at] mhazelgrovefsnetcouk> wrote:
> :                       file://Left side
>
>   Using outlook perhaps?
>   I have always wondered, what's the idea behind this. I can't imagine ANY
> useful use of this property. If it put "http:" before the "//" then it
might
> make a little bit more sense (it would still be horrible, but at least
there
> would be an idea behind it), but "file:" doesn't make any sense to me.

It's a microsoft feature. Do you expect it to make sense? <grin> <duck>

>   Is it possible to even turn it off?
>

Don't think so. Ptting a space between the // and the comment seems to stop
it.

Gail
--
********************************************************************
* gsh### [at] monotixcoza              * System.dat not found.         *
* http://www.rucus.ru.ac.za/~gail/ * Reformat hard drive Y)es O)k  *
********************************************************************
* If at first you don't succeed, call it version 1.0               *
********************************************************************


Post a reply to this message

From: Warp
Subject: Re: Grass Again
Date: 21 Sep 2000 07:14:13
Message: <39c9ed83@news.povray.org>
Gail Shaw <gsh### [at] monotixcoza> wrote:
:>   Is it possible to even turn it off?

: Don't think so.

  Now, THAT's a typical microsoftism. The program knows better than you
what you want and doesn't even allow you to specify otherwise.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Ron Parker
Subject: Re: Grass Again
Date: 21 Sep 2000 09:16:33
Message: <slrn8sk3as.55m.ron.parker@fwi.com>
On 21 Sep 2000 03:14:43 -0400, Warp wrote:
>Mick Hazelgrove <mic### [at] mhazelgrovefsnetcouk> wrote:
>:                       file://Left side
>
>  Using outlook perhaps?
>  I have always wondered, what's the idea behind this. I can't imagine ANY
>useful use of this property. If it put "http:" before the "//" then it might
>make a little bit more sense (it would still be horrible, but at least there
>would be an idea behind it), but "file:" doesn't make any sense to me.

It's because they see "//" and think you're saying something like
//SERVER/documents/memo.doc.  That is, that you're sending an email to someone
within your organization who has the same shares you do.

In other words, since nobody at Microsoft ever emails anyone from the 
outside world they think it's the same for everyone.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.
Proudly not helping RIAA and SDMI steal my rights -- 
  http://www.eff.org/Misc/EFF/Newsletters/EFFector/HTML/effect13.08.html


Post a reply to this message

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