Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change Shape Matching Constraints at Runtime
#1
Hi,
first of all, you created amazing engine, kudos.

I'm not able to change shape matchig constraints at runtime.
My scenario: 1 solver has 1 softbody

I want to be able to change max deformation and deformation resistance at runtime. I really tried to do this based on what you write in http://obi.virtualmethodstudio.com/tutor...aints.html, but no luck.
First question -> you did write this "there's only one skin constraint per particle", where can I get info on how many actor constraints are for particle in softbody?


I tried this:
Code:
var shapeConstraints = softbody.GetConstraintsByType(Oni.ConstraintType.ShapeMatching) as ObiConstraints<ObiShapeMatchingConstraintsBatch>;
var solverConstraints = softbody.solver.GetConstraintsByType(Oni.ConstraintType.ShapeMatching) as ObiConstraints<ObiShapeMatchingConstraintsBatch>;

var softbodyBatch = shapeConstraints.batches[0];
int offset = softbody.solverBatchOffsets[(int)Oni.ConstraintType.ShapeMatching][0];

for (int i = 0; i < shapeConstraints.batches.Count; i++) {
    var solverBatch = solverConstraints.batches[i];
    for (int j = 0; j < softbodyBatch.activeConstraintCount; ++j) {
        int index = i + offset;
        solverBatch.materialParameters[0] = 0.1f; //deformationResistance
        solverBatch.materialParameters[4] = 0.9f; //maxDeformation
    }
}


And quite few variants but, I can't get it right.
Reply


Messages In This Thread
Change Shape Matching Constraints at Runtime - by richienko - 25-05-2021, 09:29 PM