POV-Ray : Newsgroups : povray.general : smooth weed - grass macro (YAGM) Server Time
2 Aug 2024 12:21:08 EDT (-0400)
  smooth weed - grass macro (YAGM) (Message 1 to 2 of 2)  
From: Rafal 'Raf256' Maj
Subject: smooth weed - grass macro (YAGM)
Date: 5 Nov 2004 23:02:25
Message: <Xns959933A4EEDA5raf256com@203.29.75.35>
Weed = "leaf" of grass ofcourse ;)

How to make it smooth - I have a 2d infinetely thin surface build from 
triangles, reassembling a grass leaf, looking like:


HC*.........*HD
  :      ...:
  :   ...   :
  :...      :         
 C*---------*D
  |      ...|
  |   ...   |  <-- current segment
  |...      |
 A*---------*B
  :      ...:
  :   ...   :
  :...      :         
HA*.........*HB

So A-B-D-C is a squere (or in general a 4 point 2d polygon).
I draw it by:
      triangle { A B D } 
      triangle { A D C }
in a mesh.

Assume I now previous two points - HA and HB (Hinting-A, Hinting-B), and 
next two points HC and HD.

Using this HA HB HC HD - how can I use smooth triangle, so that current 
segment will have normal nicely blended with previous and next one?

Some image would be posted in p.b.images soon.

Btw, ofcourse grass leaf is distored, it's not build of nice reular 
rectangles as in draft above.


-- 
http://www.raf256.com/3d/
Rafal Maj 'Raf256', home page - http://www.raf256.com/me/
Computer Graphics


Post a reply to this message

From: "Jérôme M. Berger"
Subject: Re: smooth weed - grass macro (YAGM)
Date: 6 Nov 2004 03:19:13
Message: <418c8901$1@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rafal 'Raf256' Maj wrote:
| Weed = "leaf" of grass ofcourse ;)
|
| How to make it smooth - I have a 2d infinetely thin surface build from
| triangles, reassembling a grass leaf, looking like:
|
|
| HC*.........*HD
|   :      ...:
|   :   ...   :
|   :...      :
|  C*---------*D
|   |      ...|
|   |   ...   |  <-- current segment
|   |...      |
|  A*---------*B
|   :      ...:
|   :   ...   :
|   :...      :
| HA*.........*HB
|
| So A-B-D-C is a squere (or in general a 4 point 2d polygon).
| I draw it by:
|       triangle { A B D }
|       triangle { A D C }
| in a mesh.
|
| Assume I now previous two points - HA and HB (Hinting-A,
Hinting-B), and
| next two points HC and HD.
|
| Using this HA HB HC HD - how can I use smooth triangle, so that
current
| segment will have normal nicely blended with previous and next one?
|
	Easiest is to simply average the normals of the adjoining triangles.
For example at point A, you'd average the normals of triangles ABD,
ADC and AHAB, giving you the following code:

<code>

#macro TriangleNormal (A, B, C)
~  vnormalize (vcross (B-A, C-A))
#end

...
// Point A normal:
vnormalize (TriangleNormal (A, B, C) + TriangleNormal (A, D, C) +
~            TriangleNormal (A, HA, B))

</code>

	Note that the order of points is important: you must follow the same
order for all triangles or you will have normals pointing to both
sides of your grass.

		Jerome

- --
******************************
*      Jerome M. Berger      *
* mailto:jbe### [at] ifrancecom *
*  http://jeberger.free.fr/  *
******************************
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBjIkAqIYJdJhyixIRAk9PAJ4tlAEEOMUX3H1N7JJiFvm+h0WaEwCfV4QQ
qnjHsbdOxwuXHKTUC1s8pZg=
=YhkY
-----END PGP SIGNATURE-----


Post a reply to this message

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