예제 #1
0
    virtual public void Register(BodyCenter body)
    {
        if (bodyList == null)
        {
            bodyList = new List <BodyCenter>();
        }
        if (connectionList == null)
        {
            connectionList = new List <ConnectionBarRT>();
        }
        bodyList.Add(body);
        body.Index = bodyList.Count - 1;

        foreach (var other in bodyList)
        {
            if (other != body)
            {
                foreach (var neighbour in body.neighbours)
                {
                    if (other == neighbour)
                    {
                        var connection = new ConnectionBarRT(other, body);
                        connectionList.Add(connection);
                    }
                }
            }
        }
    }
예제 #2
0
 public ConnectionBarRT(BodyCenter _body0, BodyCenter _body1, float _k = 1.0f)
 {
     this.body0 = _body0;
     this.body1 = _body1;
     this.k     = _k;
     restLength = (body0.transform.position - body1.transform.position).magnitude;
 }
예제 #3
0
 virtual public void Unregister(BodyCenter body)
 {
     // TODO : need to deal with the index
     // bodyList.Remove(body);
 }