Пример #1
0
    void Start()
    {
        current     = this;
        mesh        = GetComponent <MeshFilter>().mesh;
        firstGround = false;

        Vector3 average = new Vector3();

        nodes = new Node[mesh.vertices.Length];
        for (int i = 0; i < mesh.vertices.Length; i++)
        {
            nodes[i] = new Node(this, mesh.vertices[i]);
            average += mesh.vertices[i];
        }
        average /= mesh.vertices.Length;

        HashSet <(int, int, float)> edges = new HashSet <(int, int, float)>();

        for (int ei = 0; ei < mesh.vertices.Length; ei++)
        {
            for (int si = 0; si < ei; si++)
            {
                edges.Add((si, ei, 1.0f));
            }
        }

        connections = new Connection[edges.Count];
        int edge_index = 0;

        foreach ((int, int, float)tp in edges)
        {
            connections[edge_index++] = new Connection(this, tp.Item1, tp.Item2, tp.Item3);
        }
    }
Пример #2
0
    public Node(WobblyPlane parent, Vector3 start, bool backbone = false)
    {
        this.backbone = backbone;
        this.parent   = parent;
        this.start    = location;
        this.location = start;

        speed = parent.gravity * 1.0f;
    }
Пример #3
0
    public Connection(WobblyPlane parent, int start, int end, float force)
    {
        this.parent = parent;
        this.start  = start;
        this.end    = end;
        this.force  = force;

        this.size = (parent.nodes[end].location - parent.nodes[start].location).magnitude;

        parent.nodes[start].connections += 1.0f;
        parent.nodes[end].connections   += 1.0f;

//    Debug.Log("Connection: " + start + " - " + end + ": " + size); //XXX
    }
Пример #4
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();
            WobblyPlane plane = (WobblyPlane)target;

            if (GUILayout.Button("Poke"))
            {
                WobblyPlane.current.RandomPoke();
            }

            if (GUILayout.Button("Drop"))
            {
                WobblyPlane.current.RemoveFloor();
            }
        }