Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Editing skinned cloth blueprint properties in script
#1
Hello,

I am generating skinned cloth blueprint at runtime through script. I would like to change the properties (like skin backstop, skin radius, etc.) of some particles in the blueprint before or immediately after generating the blueprint through script. 
Could you please guide me as to how I can implement this through script. 

Thanks and cheers!
Reply
#2
(06-08-2020, 11:47 AM)TsuYoung Wrote: Hello,

I am generating skinned cloth blueprint at runtime through script. I would like to change the properties (like skin backstop, skin radius, etc.) of some particles in the blueprint before or immediately after generating the blueprint through script. 
Could you please guide me as to how I can implement this through script. 

Thanks and cheers!

Hi,

Sure, all you got to do is get the appropriate constraints from the blueprint (in this case skin constraints) and then modify the contents of the batch data arrays. For this you use the GetConstraintsByType() method of the blueprint:

Code:
// get the skin constraints:
var skinConstraints = blueprint.GetConstraintsByType(Oni.ConstraintType.Skin) as ObiConstraints<ObiSkinConstraintsBatch>;

// grab the first and only skin constraints batch:
var skinBatch = skinConstraints[0];

// the skinRadiiBackstop array contains 3 floats per constraint: the skin radius, the collision radius and the collision backstop distance:
skinBatch.skinRadiiBackstop[constraintIndex*3] = <skin radius>;
skinBatch.skinRadiiBackstop[constraintIndex*3+1] = <collision radius>;
skinBatch.skinRadiiBackstop[constraintIndex*3+2] = <collision backstop>;

constraint index should be the index of the constraint you want to modify. In the specific case of skin constraints, there's one constraint per particle, so the constraint index and particle index are the same.
Reply
#3
Thanks! It worked and helped me achieve what I wanted to do in my project!
Reply