Sat, Nov 9, 4:12 PM CST

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: Positioning hair room hairs


Cage ( ) posted Sun, 08 April 2007 at 1:23 AM · edited Thu, 07 November 2024 at 5:20 PM

file_374154.jpg

I'm trying to see what I can do to make hair room hair creation more accessible.  I really want to use the hair room, but I can never master the tools for positioning the hairs.  No parameter dials!  Argh!

So I'm working on this script.  Right now it succeeds in positioning the hairs along a path defined by the positioning of a series of parented props.  But each of the hairs literally follows the path, so all of them end up with the same shape and the hairs tend to overlap.  See the images in this post and the following ones.  I think something needs to be worked out to position these hairs as a group, relative to one another, but I can't seem to work it out.  I've tried all sorts of offsets and adjustments, but nothing's really quite right.

So I thought I'd ask here if anyone has any thoughts.  How can these hair verts be made to follow the path as a group, so they retain a certain distance from one another and don't collapse into a plane or cross that plane and overlap like this?  Any ideas?  Hints?

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


Cage ( ) posted Sun, 08 April 2007 at 1:24 AM

file_374155.jpg

A rendered view of the previous image.

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


Cage ( ) posted Sun, 08 April 2007 at 1:24 AM

file_374156.jpg

Another "pose", showing the overlap problem....

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


Cage ( ) posted Sun, 08 April 2007 at 1:25 AM · edited Sun, 08 April 2007 at 1:27 AM

file_374157.jpg

Rendered view of the overlap.  It's really rather craptacular....

Any thoughts?  If this can be worked out, the script may be worth posting.  Otherwise, I'm not sure it will really prove useful....

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


Cage ( ) posted Sun, 08 April 2007 at 10:50 PM

file_374218.doc

Wow.  This forum doesn't seem to get a lot of traffic these days....

I don't think I'm going to get any further with this concept unless I achieve some unlikely breakthrough in understanding vector math.  So I'm going to go ahead and post these, so someone else can tinker with the idea if they so desire.

This first script sets up the poseable prop chain.  To use it, create and select a hair room group before running the script.  The script will create a prop chain which can be used with any selected hair group and the second script, assuming the hair group has the same number of vertices per hair as the one which was selected when the props were created.  Run the first script, then pose the chain, then run the second script after re-selecting the hair prop.

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


Cage ( ) posted Sun, 08 April 2007 at 10:51 PM

file_374219.doc

This second script positions the hairs.  Use as instructed above.  this is the version which produces the problematic overlaps.

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


Cage ( ) posted Sun, 08 April 2007 at 10:55 PM

file_374220.doc

This one is an experiment to try to make the second script work better, but it doesn't work as desired.  I think the kernel of the idea should be sound, but I'm not implementing things properly.  This tries to take the hairs as a group and use line-plane intersection to determine where to place the verts.  My thought is that the "plane" of the extrusion at a joint should be rotated, basically, to keep the proportions ot the extrusion constant.  But it doesn't work out that way.  Much of the code here is adapted (probably completely incorrectly) from Spanki's working line-plane collision code for TDMT.

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


Cage ( ) posted Mon, 09 April 2007 at 11:33 PM · edited Mon, 09 April 2007 at 11:36 PM

file_374329.jpg

Am I the only one who's interested in this idea?  Hurm.

Anyway, I just can't leave it alone.  :-P  I think I've found a way to get it to work.  It uses one of my patented kludge-workarounds to avoid vector or matrix math.  But now we're successfully extruding the hairs along the correct path.

I'm going to put a bit more work into this, after all.  Some refinements and a few extra tools for the process, and this might make a useful hair room utility....

A couple of sample images....

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


Cage ( ) posted Mon, 09 April 2007 at 11:34 PM

file_374330.jpg

And a rendered view of the same.

I've added a gui to the script and merged the two above posted versions.  My plan had been to avoid a gui, in hopes of making it Mac accessible, but my process grew too complicated for that.  It was either a gui or 57 sub-scripts to be hand-loaded....

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


Cage ( ) posted Fri, 13 April 2007 at 12:55 AM · edited Fri, 13 April 2007 at 12:59 AM

file_374596.doc

Here's the in-progress GUI version.  It has the two versions of tube-pose rotation shown above, as well as straightening, lengthening, translation, scaling, and smoothing of hairs.  Hairs can be selected by group, then by polygon (each hair is a poly), then by vertices, allowing some flexibility in applying shape changes.  Shapes can be altered by "baking" the hair mesh, or they can be added as morphs so they can be combined for a final shape or deleted.  There is a function to bake the morphed shape to the mesh.  Custom poses can be saved and loaded for the hair tube, so that positions can be easily saved and recreated.

The gui still needs a bit of work.  Right now it's confusing, with most functions hidden away in the file menu.  There is an incomplete version of tube posing which uses rotation matrices.  It isn't working yet.  

For the time being, the main rotation function is a bit of a kludge, but it seems to work.  Triangle props are created along the hairs and these actors are rotated to match the pose of the hair tube, so we can use the rotated tris to apply the correct location for the hair verts.  Creation and deletion of the tris can be slow if you're working with a large hair group.

The "straighten along group normals" and "translate along group normals" functions both use the normals of the polys in the hair group of the parent object from which the hair prop was generated, in the hair room.  If the parent prop lacks a group with the same name as the hair prop, the normals functions won't work.

The hair prop selection listbox looks for props with a parameter dial named "Dynamics" to decide what to display, right now.  So it is possible to fool the script into selecting the wrong type of prop if a dial with that name is present in, for instance, a cloth prop in the scene.

So far so good, hopefully.  I hope to add actual matrix math for the vertex rotations.  It occurs to me that what's being done here is really a sort of low-grade skeletal deformation.  The basic process, if the matrix rotations can be figured out, could perhaps be used to import a Blender figure or a .md5 model and pose it within Poser (applying the vertex weights), using a skeletal rig made of props.  At the very least, perhaps a new sort of deformer system could be developed from this.

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


Cage ( ) posted Fri, 13 April 2007 at 9:23 PM

Well, fazz bazz.  My "kludge" rotation method fails, now that I'm appying some more robust tests.  So the core function of this script is not really yet in place, and the script as posted above is still knackered.  😊  My apologies to all two of you who are following this thread.  :-P

3D rotations are tricky beasts.

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


jewell ( ) posted Mon, 23 August 2010 at 11:29 AM

just got around to really messing with hair functionality, but i found your ideas interesting. looks like a LOT of work you put in.


R_Hatch ( ) posted Fri, 27 August 2010 at 2:46 AM

waves hand this forum doesn't really exist...

Cool script, I might just give it a shot, but I also rarely mess about in the Hair Room. Of course, if this makes things easier, that could change :)


Crimmy ( ) posted Tue, 11 January 2011 at 1:05 PM

I would definitely be interested. I find the hair room very unintuitive and kludgy!


Cage ( ) posted Tue, 11 January 2011 at 1:38 PM

I find the hair room design tools impossible to use effectively.  Poser has never been very reliable, in my experience, when it comes to anything that requires dragging the mouse through the preview window to position an object.  In order for the hair room to be useful for me, it will require better tools.  Less awkward interface dragging and more numerical inputs, say.  Or better interface dragging.  :lol:

Unfortunately, the effort I made in this thread (some years ago now) quickly ran up against my limited mathematical knowledge and ability.  I'm self-taught (no math education beyond algebra and basic geometry) and, sadly, I've never been able to master any math which involves rotations.  The script in this thread was ultimately all about rotational math.  :sad:

If anyone with more ability wants to tackle the idea, it would make me very happy.  Unfortunately, I took this as far as I could, which wasn't far enough for it to be useful.  This script represents an area where Python could presumably help make Poser a better program.

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


Michael314 ( ) posted Sat, 14 January 2012 at 1:29 PM

Hello,

how about marrying polygon hair and strand based hair?

There is plenty of polygon based hair out on the markets, and it is complex and has a lot of styling. It lacks good shaders / textures, they often have a lot of burnt-in specular and are not very realistic. 

Some of the polygon hair items may be suitable for the following approach. I noticed that often, the same maps are used for all materials. The uv mapping is often done such that the hairs in the texture maps are eith parallel to the u or the v gradient.

If one could now obtain the uv mapping from this polygon hair, grow strand hair on top of the polygon hair, and direct the guide hairs along the u or v gradient, such that the guide hairs essentially follow the polygon hair surface. Then the strand hair would cover  the polygon hair to a large extent and could provide the appearance (with the texture maps of the polygon hair still in the background to avoid bald spots).

Don't know if this would be too complex to implement (and if it would look good at all, given the guide hairs have been positioned as described).

 

Best regards,

   Michael

 


Cage ( ) posted Sat, 14 January 2012 at 1:59 PM

I would love to be able to easily derive dynamic hair from polygonal hair.  It hadn't occurred to me to use the UV mapping of a hair set to try to determine the proper flow for the hairs.  That is an interesting idea.

There are complications I can imagine at the outset.  Poser dynamic hair has a very special relationship with the scalp prop or skullcap to which it is attached.  There are potential problems in dealing with hair groups and hair root positions on the scalp prop which might interfere with the ability to effectively automate any kind of polygonal-to-strand conversion for hair.

But the basic idea is good, and it's something I'll think about.  Not sure offhand how it could be implemented, but maybe something will click and the idea could lead somewhere.  :laugh:

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.