Move a Hair

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 22/09/2011 at 08:12, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   12 
Platform:      
Language(s) :     C++  ;

---------
Hy there,

I made attempts to move a Hair within the calc_constraint Callback of the HairPluginObjectData. It seems that I can't simply move a Hair (by moving the base-point), they seem restraint by the guides.

So I tried to move the guides itself, but setting a new global matrix (SetMg()) has no effect. Do I need another callback, or is there a "correct" way of moving a single Hair in space?

Thank you,
maxx

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 27/09/2011 at 06:56, xxxxxxxx wrote:

I don't know if it's possible to unroot the hairs. It seems as though the hooks are meant to just offset the hair points. I will ask the developers.

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 27/09/2011 at 07:32, xxxxxxxx wrote:

What does it mean, to unroot a Hair? Is it just possible to move a hair when moving the object it is rooted on? I think I don't understand the concepts of hair yet. As I saw in the example (HairGenerator), those hairs don't seem to have a root, as the type is HAIR_ROOT_TYPE_NONE.If it is possible to have a hair without root, can those hairs not be moved at all?

Thank you,
maxx

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 27/09/2011 at 07:39, xxxxxxxx wrote:

Every hair guide has a root. This is basically the first point of the guide. It determines the start position and direction of the guide. As I've found out you can set it through HairGuides::GetRoot/SetRoot.

Here a simple example which flattens all guides along the X axis.

  
static Bool _ConstraintFn(BaseDocument *doc, BaseList2D *op, HairObject *hair, HairGuides *guides, HairGuideDynamics *dyn, Vector *oldpnt, Vector *newpnt, Real *invmass, LONG pcnt, LONG cnt, LONG scnt)  
{  
  BaseContainer *bc=op->GetDataInstance();  
  
  LONG i,l,j;  
  Real strength=bc->GetReal(HAIR_CONSTRAINT_STRENGTH);  
  
  for (i=0;i<cnt;i++)  
  {  
      for (l=0;l<scnt;l++)  
      {  
          j=i*scnt+l;  
  
          if (invmass[j]==0.0) continue;  
  
          //newpnt[j]=Mix(newpnt[j],oldpnt[j],strength);  
          newpnt[j]=oldpnt[j];  
          newpnt[j].x = 0.0;  
      }  
  }  
  
  if (guides)  
  {  
      LONG gcnt = guides->GetCount();  
  
      for (i=0; i<gcnt; i++)  
      {  
          HairRootData rdata = guides->GetRoot(i);  
          rdata.m_P.x = 0.0;  
  
          guides->SetRoot(i, rdata, TRUE);  
      }  
  }  
  
  
  return TRUE;  
}  

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 27/09/2011 at 11:18, xxxxxxxx wrote:

Ok, changing the root works fine!

Thank you,
maxx