POV-Ray : Newsgroups : povray.general : smooth weed - grass macro (YAGM) : Re: smooth weed - grass macro (YAGM) Server Time
2 Aug 2024 10:27:18 EDT (-0400)
  Re: smooth weed - grass macro (YAGM)  
From: "Jérôme M. Berger"
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.