AuthorTopic: PHUR v1.4 (Read 24963 times)

I didn't use any known algorithms for it (known to me anyway), so my method is probably not the most efficient, nor is the distribution perfect. But here goes:

Find the midpoint of the polygon. Put that and the vertices of that polygon into an array

Divide each edge of the polygon into subsections the same length as the spacing you desire. Toss those into the array as well

Now loop through each edge point (including the subsections) and do this:

Create an imaginary edge from the midpoint to the edge point

Divide that edge into subsections the same length as the spacing desired

At each subsection, compare its distance to all of the points in the array so far

If none of the distances are less than the desired spacing, push that imaginary point into the array

Do this for each polygon, but ignore shared edges when pushing into the array

All of those points in the array are now the origins for the grass

A flaw with this is that regardless of how small the polygon is, there is guaranteed to be an origin at every original vertex and midpoint of every polygon. Also, like I said, the distribution won't be perfect. But they will be spaced pretty consistently, as you can see if you test out tiny spacing on a single quad. You probably don't have to use the midpoint and can instead pick any point on the edge for the second step -- I just preferred to make sure the midpoint was always in there.

I'm not a huge fan of that method, but it worked well enough, and I'm a pragmatic person For a game engine, if everything is triangulated you end up having a higher concentration of edges and midpoints, and therefore more origins regardless of what kind of spacing you desire.

Attached is an image that shows how my distribution looks on a quad that gets divided multiple times. As you can see, there's a pattern on each polygon that you can make out, when the spacing is very low -- this pattern probably won't be noticeable at all on terrain, however. To help reduce the pattern, you can loop through all of the origins and randomly take out a number of them, prior to generating the grass.

"Make my own PHUR Strands?To implement your own strands, take note of these things:When modeling a strandIt must have STRAND_PHUR at the beginning of its nameIt must have the same material as the PHUR and base".

You can place the strand anywhere, the script doesn't use its location in world space. So long as it has "STRAND_PHUR" in front of its name, and has the same material as the PHUR and base mesh, it'll work.

[edit]Note that you can't delete it, or else PHUR won't be able to use it. You can just tuck it away somewhere out of sight.

Nice pic, cooldude234! To increase strand amount without subdividing, you have to set the spacing pretty low. The spacing is in Anim8or units, so if the length of the edges are smaller than the spacing, or if the distance between the midpoint and outer vertices are smaller than the spacing, you won't see any extra strands popping up. Even a spacing of 10 is usually too high unless you're working on very large polygons.

johnar, I honestly have no idea what to say, haha. Nice job with the hair dynamics.

I found a BUG raxx!!! It was crawling on my screen, then it landed on my desk, it was an ant!But I also found a bug in the script, when I group the phur and base object together, the phur dissapears. I'm not even sure if this is just the way anim8or want's to handle it or if its fixable in the script code itself, but I thought I'd let you know anyway.

EDIT: it crashed when I ungrouped it ):

EDIT: the image shows spacing at 1, it's not super dense at all, and spacing at 10 was ridiculously spaced apart

This looks pretty good Raxx. Amazing in fact. I'd try it once I find a keyboard with a numpad- my laptop has none. I'm too dependent on my hotkeys. xD I suppose this is just static phur? Sorry if it was mentioned. Just skimmed through the posts.

cooldude234, I neglected to mention that grouped meshes were ignored. Parametric shapes get regenerated when grouped (but not when ungrouped), so if the base mesh was grouped with the parametric mesh, then the parametric mesh no longer has an ungrouped mesh to work with. Not sure why it crashed, but to be safe don't group the fur (other weird things happen as well). There isn't much reason to group PHUR anyway (don't seriously generate PHUR unless you're satisfied with the base mesh, and you'll be fine). I would implement groups if it wasn't so...complicated...

Janro, thought you disappeared for good! Glad you're back. Yes, PHUR is static in that it doesn't go swishing around by itself. It's generated in the object editor, so at best you can rig it and animate it or use morphs on it. You can however comb it or give it a random bending direction in the parameters.

Johnar, referring to your ghost post, as you probably found out parametric shapes don't work with morph targets. It's a nice idea however, and I think would be great if it were implemented. A long time ago an old member named Howitzer had created a tool called MorphEnvy, perhaps you can find it somewhere (if you don't already have it), and it might convert between parametric shapes (assuming they have the same number of divisions, and they are converted to mesh first).

I think I'm about done regularly working on PHUR. I went ahead and updated to v1.3a, with two bug fixes:

Where if you rotate the PHUR it doesn't revert back to original rotation when OK'ed again.

Hi Raxx. Thanks for your reply, and that link is good for 'MorphEnvy and Watergen. Cheers. Plenty of possibilities here, with Phur, to keep busy for quite a while. A gr8 tool to hav. Thanks again.

sorry to say, but I think i'm missing something when it comes to using Combs....?

I made a sphere, converted to mesh, added Phur, with length of 50, and spacing of 5. Added a comb, resized and rotated it, and moved it onto the sphere mesh so it was covering half the mesh and the Phur on that half... (So far, so good... luv the way you can manipulate the comb, is in keeping with other Anim8or tools.) But, its like, how to 'apply' the comb to make an effect. I double clicked the comb, and thought by clicking 'ok' it would act like an 'apply' button. ? But nothings happening....? Sorry if i've missed something obvious...

Janro Gr8 to c u. Have also been absent for some time. Good to see another familiar face reappearing.

Unfortunately you can't use one shape to refresh another. So instead of double clicking the comb to see its immediate effects, you have to double click the PHUR shape. Also, make sure you set the Direction parameter in the PHUR shape to '1' for its strongest effect, with any value between 0 and 1, 1 and 2, and 2 and 3 having different weights for the normal vs combed vs random effects. Sounds complicated in writing, but if you test out the range of values you'll see it's pretty easy to figure out.