Obi Official Forum
Help Editing skinned cloth blueprint properties in script - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html)
+--- Thread: Help Editing skinned cloth blueprint properties in script (/thread-2405.html)



Editing skinned cloth blueprint properties in script - TsuYoung - 06-08-2020

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!


RE: Editing skinned cloth blueprint properties in script - josemendez - 07-08-2020

(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.


RE: Editing skinned cloth blueprint properties in script - TsuYoung - 11-08-2020

Thanks! It worked and helped me achieve what I wanted to do in my project!