public void UpdateColliderIndices(ObiColliderGroup group) { // Set solver constraint data: for (int i = 0; i < pinOffsets.Count; i++) { // each time the collider list changes, update pin constraint indices. // each time the collider group changes, update pin constraint indices, adding the collider to the new group if needed. // if a collider group exists, get collider indices: if (group != null) { int colliderIndex = group.GetIndexOfCollider(pinBodies[i]); // if the collider does not exists in the collider group, insert it at the end. if (colliderIndex == -1) { colliderIndex = group.ColliderCount; group.AddCollider(pinBodies[i]); } solverIndices[i * 2 + 1] = colliderIndex; } else { solverIndices[i * 2 + 1] = -1; } } }
static void CreateObiSolverWithColliderGroup() { GameObject c = new GameObject("Obi Solver"); Undo.RegisterCreatedObjectUndo(c, "Create Obi Solver"); ObiSolver solver = c.AddComponent <ObiSolver>(); ObiColliderGroup group = c.AddComponent <ObiColliderGroup>(); solver.colliderGroup = group; }
static void CreateObiClothWithSolver() { GameObject c = new GameObject("Obi Cloth"); Undo.RegisterCreatedObjectUndo(c, "Create Obi Cloth"); ObiCloth cloth = c.AddComponent <ObiCloth>(); ObiSolver solver = c.AddComponent <ObiSolver>(); ObiColliderGroup group = c.AddComponent <ObiColliderGroup>(); cloth.Solver = solver; solver.colliderGroup = group; }
static void CreateObiRope() { GameObject c = new GameObject("Obi Rope"); Undo.RegisterCreatedObjectUndo(c, "Create Obi Rope"); ObiRope rope = c.AddComponent <ObiRope>(); ObiCatmullRomCurve path = c.AddComponent <ObiCatmullRomCurve>(); ObiSolver solver = c.AddComponent <ObiSolver>(); ObiColliderGroup group = c.AddComponent <ObiColliderGroup>(); rope.Solver = solver; rope.Section = Resources.Load <ObiRopeSection>("DefaultRopeSection"); rope.ropePath = path; solver.colliderGroup = group; }
static void CreateObiClothWithSolver() { GameObject c = new GameObject("Obi Emitter"); Undo.RegisterCreatedObjectUndo(c, "Create Obi Emitter"); ObiEmitter em = c.AddComponent <ObiEmitter>(); c.AddComponent <ObiEmitterShapeDisk>(); c.AddComponent <ObiParticleRenderer>(); ObiSolver solver = c.AddComponent <ObiSolver>(); ObiColliderGroup group = c.AddComponent <ObiColliderGroup>(); em.Solver = solver; solver.colliderGroup = group; }
static void CreateObiClothWithSolver() { GameObject c = new GameObject("Obi Emitter"); Undo.RegisterCreatedObjectUndo(c, "Create Obi Emitter"); ObiEmitter em = c.AddComponent <ObiEmitter>(); c.AddComponent <ObiEmitterShapeDisk>(); GameObject p = new GameObject("Obi Particle Renderer"); Undo.RegisterCreatedObjectUndo(p, "Create Obi Particle Renderer"); ObiParticleRenderer pr = p.AddComponent <ObiParticleRenderer>(); p.transform.parent = c.transform; pr.Actor = em; ObiSolver solver = c.AddComponent <ObiSolver>(); ObiColliderGroup group = c.AddComponent <ObiColliderGroup>(); em.Solver = solver; solver.colliderGroup = group; }
public void OnEnable() { group = (ObiColliderGroup)target; }