POV-Ray : Newsgroups : povray.newusers : meshes and rotation : Re: meshes and rotation Server Time
30 Jul 2024 18:21:13 EDT (-0400)
  Re: meshes and rotation  
From: Mike Williams
Date: 20 Nov 2003 23:32:33
Message: <U+zGgFAOUZv$EwsQ@econym.demon.co.uk>
Wasn't it Justin Smith who wrote:
>I'm trying to use a mesh to generate a clump of grass. I'm having a problem
>because apparently I can't rotate the individual triangles within the mesh.
>I'll show the erroneous code I'm using, so you can see what I am trying to
>do:

You could use syntax like this to rotate the points individually and
then use the rotated points to form the mesh

#declare grassclump =
mesh
{
  #local numblades = 0;
  #local maxblades = 60+int((rand(randseed)*40));
  #while(numblades < maxblades)
    #local rotationx = rand(randseed)*30;
    #local rotationy = rand(randseed)*360;
    triangle
    {
      #declare P1 = vrotate(<.02,0,0>,<rotationx,rotationy,0>);
      #declare P2 = vrotate(<-.02,0,0>,<rotationx,rotationy,0>);
      #declare P3 = vrotate(<.018,1.2,0>,<rotationx,rotationy,0>);
      P1,P2,P3
    }
    triangle
    {
      #declare P1 = vrotate(<-.02,0,0>,<rotationx,rotationy,0>);
      #declare P2 = vrotate(<-.018,1.2,0>,<rotationx,rotationy,0>);
      #declare P3 = vrotate(<.018,1.2,0>,<rotationx,rotationy,0>);
      P1,P2,P3
    }
    triangle
    {
      #declare P1 = vrotate(<-.018,1.2,0>,<rotationx,rotationy,0>);
      #declare P2 = vrotate(<.018,1.2,0>,<rotationx,rotationy,0>);
      #declare P3 = vrotate(<0,2.5,0>,<rotationx,rotationy,0>);
      P1,P2,P3
    }
    #local numblades = numblades+1;
  #end
  texture
  {
    pigment
    {
      color rgb <.1,1,.26>
    }
  }
}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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