void pin_rotate_ready()
        {
            //GameObject[] twoparticle = new GameObject[2];
            // Debug.Log("wang");
            ObiPinConstraints pins = this.GetComponent <ObiPinConstraints>();

            pins.RemoveFromSolver(null);
            ObiPinConstraintBatch batch = pins.GetFirstBatch() as ObiPinConstraintBatch;

            //attach more particle to pin
            kdtreesearch();
            for (int j = 0; j < 4; j++)
            {
                particleindexsphere[0][j] = particleindexsphere[0][4] - j - 1;
                particleindexsphere[1][j] = particleindexsphere[1][4] - j - 1;
            }
            for (int j = 5; j < 9; j++)
            {
                particleindexsphere[0][j] = particleindexsphere[0][4] + j - 4;
                particleindexsphere[1][j] = particleindexsphere[1][4] + j - 4;
            }
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    batch.AddConstraint(particleindexsphere[i][j], twoobject[i].GetComponent <ObiCollider>(), Vector3.zero, 1.0f);
                }
                twoobject[i].GetComponent <ObiCollider>().Phase = 1;
                twoobject[i].AddComponent <ObjectDragger>();
                //Debug.Log(twoobject[i].transform.position);
            }
            pins.AddToSolver(null);
        }
Beispiel #2
0
        /**
         * Updates pin constraint collider indices for a given solver.
         */
        private void UpdatePinConstraints(ObiSolver solver)
        {
            if (solver == null)
            {
                return;
            }

            // for all actors in the solver:
            foreach (ObiActor actor in solver.actors)
            {
                // See if they use pin contraints:
                ObiPinConstraints pinConstraints = actor.GetComponent <ObiPinConstraints>();
                if (pinConstraints != null)
                {
                    // for each constraint batch, update collider indices.
                    foreach (ObiPinConstraintBatch batch in pinConstraints.GetBatches())
                    {
                        batch.UpdateColliderIndices(this);
                    }

                    // push new data to the solver:
                    pinConstraints.PushDataToSolver();
                }
            }
        }
Beispiel #3
0
        public override void PushDataToSolver(ObiBatchedConstraints constraints)
        {
            if (constraints == null || constraints.Actor == null || !constraints.Actor.InSolver)
            {
                return;
            }

            ObiPinConstraints pc = (ObiPinConstraints)constraints;

            for (int i = 0; i < stiffnesses.Count; i++)
            {
                stiffnesses[i] = StiffnessToCompliance(pc.stiffness);
            }

            Oni.SetPinConstraints(batch, solverIndices, pinOffsets.ToArray(), restDarbouxVectors.ToArray(), solverColliders, stiffnesses.ToArray(), ConstraintCount);
        }
Beispiel #4
0
        protected override void OnRemoveFromSolver(object info)
        {
            ObiSolver solver = actor.solver;

            // Update following actors' indices:
            for (int i = actor.actorID + 1; i < solver.actors.Count; i++)
            {
                ObiPinConstraints pc = solver.actors[i].GetComponent <ObiPinConstraints>();
                if (pc != null)
                {
                    pc.UpdateIndicesOffset(pc.indicesOffset - pinOffsets.Count);
                }
            }

            ObiUtils.RemoveRange(ref solver.pinConstraints.pinIndices, indicesOffset * 2, pinOffsets.Count * 2);
            ObiUtils.RemoveRange(ref solver.pinConstraints.pinOffsets, indicesOffset, pinOffsets.Count);
            ObiUtils.RemoveRange(ref solver.pinConstraints.stiffnesses, indicesOffset, pinOffsets.Count);
        }
Beispiel #5
0
 public void OnEnable()
 {
     constraints = (ObiPinConstraints)target;
 }