private void PullNode(NodeObject sphere, float factor, NodeObject parent)
        {
            Rigidbody rigid = sphere.GetComponent <Rigidbody>();

            if (rigid == null)
            {
                Debug.LogError("Sphere has no rigidbody, cannot pull it: " + sphere);
            }
            else
            {
                Vector3 move = (rightController.transform.position - sphere.transform.position) * factor;
                Debug.Log("Pulling node by " + move);
                rigid.velocity = rigid.velocity + move;
                if (factor > 0.1)
                {
                    foreach (NodeObject other in sphere.OtherNodes())
                    {
                        if (other != parent)
                        {
                            PullNode(other, factor / 2f, sphere);
                        }
                    }
                }
            }
        }
示例#2
0
            private int FindLabelIdByColor(Label[] labels, NodeObject nodeObject)
            {
                MeshRenderer renderer = nodeObject.GetComponent <MeshRenderer>();
                Color        color    = renderer.material.color;

                Debug.Log("Searching for label by color: " + color);
                foreach (Label label in labels)
                {
                    if (label.color.Equals(color))
                    {
                        Debug.Log("Found label: " + label);
                        return(label.labelId);
                    }
                }
                Debug.Log("Found no label matching color: " + color);
                return(-1);
            }