Exemplo n.º 1
0
        public override void Embody()
        {
            triVals = tris.GetTriData();

            connections = new List <int>();

            numConnections  = new int[count];
            connectionStart = new int[count];

            int maxConnections = 0;

            Vector3[] pos = verts.mesh.vertices;


            Vector3 me;
            Vector3 p1; Vector3 p2; Vector3 p3;
            int     id1; int id2; int id3;

            int totalIndicies = 0;

            for (int i = 0; i < count; i++)
            {
                me = pos[i];
                connectionStart[i] = totalIndicies;
                int connectionsForThisVert = 0;

                for (int j = 0; j < triVals.Length / 3; j++)
                {
                    id1 = triVals[j * 3 + 0];
                    id2 = triVals[j * 3 + 1];
                    id3 = triVals[j * 3 + 2];

                    p1 = pos[id1];
                    p2 = pos[id2];
                    p3 = pos[id3];

                    if (me.x == p1.x && me.y == p1.y && me.z == p1.z)
                    {
                        connections.Add(id2);
                        connections.Add(id3);
                        connectionsForThisVert += 1;
                    }

                    if (me.x == p2.x && me.y == p2.y && me.z == p2.z)
                    {
                        connections.Add(id3);
                        connections.Add(id1);
                        connectionsForThisVert += 1;
                    }

                    if (me.x == p3.x && me.y == p3.y && me.z == p3.z)
                    {
                        connections.Add(id1);
                        connections.Add(id2);
                        connectionsForThisVert += 1;
                    }
                }

                totalIndicies    += connectionsForThisVert;
                numConnections[i] = connectionsForThisVert;
            }

            float[] values = new float[count * structSize];



            for (int i = 0; i < count; i++)
            {
                if (numConnections[i] > maxConnections)
                {
                    maxConnections = numConnections[i];
                }

                // making our data into the debug section of our vert
                values[i * structSize + 14] = numConnections[i];
                values[i * structSize + 15] = connectionStart[i];
            }

            SetData(values);
        }
Exemplo n.º 2
0
        public override void Embody()
        {
            triVals        = tris.GetTriData();
            connections    = new int[count][][];
            numConnections = new int[count];
            int maxConnections = 0;

            for (int i = 0; i < connections.Length; i++)
            {
                connections[i] = new int[16][];
                for (int j = 0; j < connections[i].Length; j++)
                {
                    connections[i][j] = new int[3];
                }
            }


            for (int i = 0; i < triVals.Length / 3; i++)
            {
                int t1 = triVals[i * 3 + 0];
                int t2 = triVals[i * 3 + 1];
                int t3 = triVals[i * 3 + 2];

                AddConnection(t1, t2, t3);
                AddConnection(t2, t3, t1);
                AddConnection(t3, t1, t2);
            }

            Vector3[] pos = verts.mesh.vertices;

            for (int i = 0; i < count; i++)
            {
                for (int j = 0; j < count; j++)
                {
                    // means it is same vert
                    if (pos[i].x == pos[j].x && pos[i].y == pos[j].y && pos[i].z == pos[j].z)
                    {
                        for (int k = 0; k < 16; k++)
                        {
                            AddConnection(i, connections[j][k][0], connections[j][k][1]);
                        }
                    }
                }
            }

            float[] values = new float[count * structSize];



            for (int i = 0; i < count; i++)
            {
                if (numConnections[i] > maxConnections)
                {
                    maxConnections = numConnections[i];
                }

                for (int j = 0; j < numConnections[i]; j++)
                {
                    values[i * structSize + 20 + j * 3 + 0] = connections[i][j][0];
                    values[i * structSize + 20 + j * 3 + 1] = connections[i][j][1];
                    values[i * structSize + 20 + j * 3 + 2] = connections[i][j][2];
                }
            }

            print("MAX CONNECTION : " + maxConnections);

            SetData(values);
        }