Question about Hair Dynamics Expression

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  10 October 2009
Question about Hair Dynamics Expression

Hi all:
I have been reverse engineering a Dynamic Bones script by Wade Ryer.
Its a rig in which a bone chain is partially controlled by a dynamic hair curve.
Its a cool setup and I have it all figured out except this expression which controls the Hair System:
//////  Live Update Expression  /////////////////////
       disconnectAttr time1.outTime (""+$SetUpName+"_HairSystemShape.currentTime");
       string $DynUpdExp = (
       	 "if (frame > "+$SetUpName+"_HairSystemShape.startFrame) { "+$SetUpName+"_HairSystemShape.currentTime += 1;	float $refresh = "+$SetUpName+"MainDynLocUpdate.translateX;}\n"
       	+"else "+$SetUpName+"_HairSystemShape.currentTime = "+$SetUpName+"_HairSystemShape.startFrame;"
       expression -n "DynamicUpdateExpr" -s $DynUpdExp;

I haven't worked with expressions too much, but it appears to me that the expression does the following:
1) Disconnects the Hair System from the Main timeline.
2) Set the currentTime of the HairSystem to be one frame less than the main timeline.
3) $refresh does not appear to be used.
4) Rewind the Hair System when the current time is set to 0.

2 Questions:
1. Is my analysis correct?
2. What is the purpose of the expression?


Last edited by EightBit : 10 October 2009 at 04:54 AM.
  10 October 2009
I just love talking to myself late at nite...
So I see that this expression does what it says - it makes the chain interactive by divorcing the hair system from the main time. Dragging it around on any frame above 0 forces the hair system to update interactively, which is pretty cool. I've also discovered that the $refresh var is necessary, else it doesn't work. I assume it forces a refresh, but all it is doing is grabbing the XTran of a locator which is pointConstrained within the rig, so how does that force a refresh?
  if (frame > TEST_HairSystemShape.startFrame) { TEST_HairSystemShape.currentTime += 1;	float $refresh = TESTMainDynLocUpdate.translateX;}
  else TEST_HairSystemShape.currentTime = TEST_HairSystemShape.startFrame;
  // Fails:
  if (frame > TEST_HairSystemShape.startFrame) { TEST_HairSystemShape.currentTime += 1;}
  else TEST_HairSystemShape.currentTime = TEST_HairSystemShape.startFrame;
  10 October 2009
I'm not sure I'm right, but it seems to me that the $refresh forces the re-evaluation of the expression in order for the $refresh = loc.tx to be exact all the time even if there's already a connection on the translate.
BTW the pointConstraint actually changes the value of the translate as opposed to a simple parent/child relation, so it would be good to know if this trick works with a parent instead of the pointConstraint.

Hope that helps,


PS: sorry for my english.
No one can destroy the Metal, the Metal will live on !
  10 October 2009
I don't think that's quite right. I think the expression will eval on every frame by default.
A bit more analysis:
The TESTMainDynLocUpdate locator is pointConstrained to 5 other "DynLocUpdate" locators, each of which is pointConstrained to an FK joint in the rig (the rig is driven by the FK joints). So by grabbing it's XTrans, I'd assume that the location of each of the other "DynLocUpdate" locators is also queried.
The screen grab below shows the connection between TESTMainDynLocUpdate and the expression and the HairSystem and also the HG w/the DynLocUpdate removed from the expression. I don't see why it is necessary to force the Hair System to update.
Attached Images
File Type: gif MayaHairDynHG01.gif (10.9 KB, 42 views)
  10 October 2009
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 01:02 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.