void Awake() { actor = GetComponent <ObiActor>(); pick = GameObject.Find("Pick"); end = GameObject.Find("End"); pick_orig_pos = pick.transform.position; end_orig_pos = end.transform.position; }
public override void Initialize() { actor = GetComponent <ObiActor> (); c = GetComponent <Collider> (); e = GameObject.FindObjectOfType <EnemyManager> (); if (!trainingMode) { MaxStep = 0; } c.enabled = true; actor.ResetParticles(); softBody.deformationResistance = 0.7f; }
private void Cloth_OnEndStep(ObiActor actor, float substepTime) { if (Mathf.Approximately(maxForce, 0)) { return; } var dc = cloth.GetConstraintsByType(Oni.ConstraintType.Distance) as ObiConstraints <ObiDistanceConstraintsBatch>; var sc = cloth.solver.GetConstraintsByType(Oni.ConstraintType.Distance) as ObiConstraints <ObiDistanceConstraintsBatch>; if (dc != null && sc != null) { float sqrTime = substepTime * substepTime; for (int j = 0; j < dc.batches.Count; ++j) { var batch = dc.batches[j] as ObiDistanceConstraintsBatch; var solverBatch = sc.batches[j] as ObiDistanceConstraintsBatch; for (int i = 0; i < batch.activeConstraintCount; i++) { // divide lambda by squared delta time to get force in newtons: int offset = cloth.solverBatchOffsets[(int)Oni.ConstraintType.Distance][j]; float force = -solverBatch.lambdas[offset + i] / sqrTime; int p1 = batch.particleIndices[i * 2]; int p2 = batch.particleIndices[i * 2 + 1]; if (cloth.solver.invMasses[cloth.solverIndices[p1]] > 0 || cloth.solver.invMasses[cloth.solverIndices[p2]] > 0) { forces[p1] += force; forces[p2] += force; counts[p1]++; counts[p2]++; } } } // average force over each particle, map to color, and reset forces: for (int i = 0; i < cloth.solverIndices.Length; ++i) { int solverIndex = cloth.solverIndices[i]; cloth.solver.colors[solverIndex] = gradient.Evaluate((forces[i] / counts[i] - minForce) / (maxForce - minForce)); forces[i] = 0; counts[i] = 0; } } }
public void Awake() { actor = GetComponent <ObiActor>(); }
private void Awake() { rb = GetComponent <Rigidbody>(); col = GetComponent <Collider>(); actor = GetComponent <ObiActor>(); }
void Start() { actor = GetComponent <ObiActor> (); c = GetComponent <Collider> (); e = GameObject.FindObjectOfType <EnemyManager> (); }
private void Softbody_OnEndStep(ObiActor actor, float substepTime) { if (Mathf.Approximately(deformationScaling, 0)) { return; } var dc = softbody.GetConstraintsByType(Oni.ConstraintType.ShapeMatching) as ObiConstraints <ObiShapeMatchingConstraintsBatch>; var sc = softbody.solver.GetConstraintsByType(Oni.ConstraintType.ShapeMatching) as ObiConstraints <ObiShapeMatchingConstraintsBatch>; if (dc != null && sc != null) { for (int j = 0; j < dc.batches.Count; ++j) { var batch = dc.batches[j] as ObiShapeMatchingConstraintsBatch; var solverBatch = sc.batches[j] as ObiShapeMatchingConstraintsBatch; for (int i = 0; i < batch.activeConstraintCount; i++) { // use rotation-invariant Frobeniums norm to get amount of deformation. int offset = softbody.solverBatchOffsets[(int)Oni.ConstraintType.ShapeMatching][j]; // use frobenius norm to estimate deformation. //Tansel: the line below was giving problem. 06/01/2021 //float deformation = solverBatch.linearTransforms[offset + i].FrobeniusNorm() - 2; float deformation = 1; for (int k = 0; k < batch.numIndices[i]; ++k) { int p = batch.particleIndices[batch.firstIndex[i] + k]; int or = softbody.solverIndices[p]; if (softbody.solver.invMasses[or] > 0) { norms[p] += deformation; counts[p]++; } } } } // average force over each particle, map to color, and reset forces: for (int i = 0; i < softbody.solverIndices.Length; ++i) { if (counts[i] > 0) { int solverIndex = softbody.solverIndices[i]; softbody.solver.colors[solverIndex] = gradient.Evaluate(norms[i] / counts[i] * deformationScaling + 0.5f); norms[i] = 0; counts[i] = 0; } } var surfaceBlueprint = softbody.softbodyBlueprint as ObiSoftbodySurfaceBlueprint; if (surfaceBlueprint != null && skin != null && skin.sharedMesh != null) { for (int i = 0; i < colors.Length; ++i) { int particleIndex = surfaceBlueprint.vertexToParticle[i]; colors[i] = softbody.solver.colors[particleIndex]; } skin.sharedMesh.colors = colors; } } }
private void Awake() { actor = GetComponent <ObiActor>(); }
void Awake() { actor = GetComponent <ObiActor>(); Debug.Log("obi actor awake!!"); }