Esempio n. 1
0
    void SpawnVoid(int newVoidId)
    {
        qbitsBoundingMe           = new List <BoundingQbit_AllInfo>();
        foundBoundingQbitsCounter = 0;

        foreach (GameObject qbit in qbitsAll_obj)
        {
            if (foundBoundingQbitsCounter == 8)
            {
                break;
            }
            foundABoundingQbit = false;
            Vector2 thisQbitPosition = new Vector2(qbit.transform.position.x, qbit.transform.position.z);

            for (int t = 0; t < testVoidTriangles.Count; t++)
            {
                if (foundABoundingQbit == true)
                {
                    break;
                }
                for (int p = 0; p < 3; p++)
                {
                    if (thisQbitPosition == testVoidTriangles[t].sites[p].Coord)
                    {
                        bool         qbitAddedAlready   = false;
                        QbitMovement qbitMovementScript = qbit.GetComponent <QbitMovement>();
                        int          thisQbitId         = qbitMovementScript.self_id;
                        foreach (BoundingQbit_AllInfo qbitEntry in qbitsBoundingMe)
                        {
                            if (qbitEntry.id == thisQbitId)
                            {
                                qbitAddedAlready = true;
                                break;
                            }
                        }
                        if (qbitAddedAlready == false)
                        {
                            qbitsBoundingMe.Add(new BoundingQbit_AllInfo {
                                id = thisQbitId, transform = qbit.transform, qbitMovementScript = qbitMovementScript
                            });
                            foundABoundingQbit = true;
                            foundBoundingQbitsCounter++;
                            break;
                        }
                    }
                }
            }
        }

        // spawn and set self_voidAllInfo of the spawned GO
        GameObject goVoid = Instantiate(voidMeshPrefab, new Vector3(0, .01f, 0), Quaternion.identity);

        goVoid.transform.SetParent(voidContainer, true);
        goVoid.name = "void_" + newVoidId;
        VoidMesh voidMeshScript = goVoid.GetComponent <VoidMesh>();

        voidMeshScript.self_voidAllInfo = new Void_Cn {
            id = newVoidId, initialTrianglesFromDelaunay = testVoidTriangles, boundingQbits_allInfo = qbitsBoundingMe, area = testVoidArea, centroid = thisTestVoidCentroid
        };
    }
Esempio n. 2
0
    //________________________________________________________________________________________
    // positions and delaunay
    void GetDelaunayQbitsPositions()
    {
        // only do once on the first update():
        if (getAllQbits_obj == true)
        {
            // todo ONLY NEED TO REF ONCE?
            qbitsAll_obj    = GameObject.FindGameObjectsWithTag("qbit");
            getAllQbits_obj = false;
        }

        // always clear the old lists, or else they grow forever:
        delaunayQbitsAllInfo     = new List <DelaunayQbit_Cn>();
        delaunay_all_qbits_posXZ = new List <Vector2>();
        colors = new List <uint>();

        foreach (GameObject obj in qbitsAll_obj)
        {
            QbitMovement qbitMovement_script = obj.GetComponent <QbitMovement>();
            int          this_qtype          = qbitMovement_script.qtype;
            int          this_id             = qbitMovement_script.self_id;

            // so thus far, this if() is completely unnecessary but...keep it for now...
            if (this_qtype == 0 || this_qtype == 1)
            {
                colors.Add(0);

                if (this_qtype == 0)
                {
                    Vector3 centerPosition = qbitMovement_script.jittery_centerPosition;
                    posXZ = new Vector2(centerPosition.x, centerPosition.z);
                }
                else if (this_qtype == 1 && qbitMovement_script.brownian_moving == true)
                {
                    Vector3 centerPosition = qbitMovement_script.brownian_centerPosition;
                    posXZ = new Vector2(centerPosition.x, centerPosition.z);
                }
                else
                {
                    posXZ = new Vector2(obj.transform.position.x, obj.transform.position.z);
                }

                delaunayQbitsAllInfo.Add(new DelaunayQbit_Cn {
                    id = this_id, posXZ = posXZ
                });
                delaunay_all_qbits_posXZ.Add(posXZ);
            }
        }
    }