public SocketMorphologyCallbacks(ComputeCraterGeometry computeCraterGeometry)
 {
     receivedDataFromPython = false;
     mComputeCraterGeometry = computeCraterGeometry;
     UnityEngine.Debug.Log ("SocketMorphologyCallbacks "+mComputeCraterGeometry);
     w = new float[5];
 }
Example #2
0
 // Crater crater;
 public GridObj(ComputeCraterGeometry ccG)
 {
     computeCraterGeometry = ccG;
     /*
     UnityEngine.Debug.Log ("GridObj");
     hasResult = false;
     currentRes = null;
     // listen for incomming python connections
     */
 }
Example #3
0
    public int initGrid(float [][] heightMap,ComputeCraterGeometry ccg)
    {
        SamplesY = heightMap.GetLength(0);
        SamplesX = heightMap[0].GetLength(0);
        mCCG = ccg;
        UnityEngine.Debug.Log("initGrid "+SamplesX+" "+SamplesY);

        // GetComponent<MeshFilter> ().mesh = mesh;
        //	MeshFilter meshFilter = (MeshFilter)plane.AddComponent(typeof(MeshFilter));
        //	meshFilter.mesh = mesh;
        //float Width = 10;
        //Samples = 100;
        float edgeX = Width / (SamplesX - 1);
        float edgeY = Height / (SamplesY - 1);
        // updateVertices = false;
        // Create the vertices and texture coords
         	vertices = new Vector3[SamplesX * SamplesY];
        uvs = new Vector2[SamplesX * SamplesY];
        // Fill in the data
        for (int j = 0, p = 0; j < SamplesY; j++) {
        string s = "";

            for (int i = 0; i < SamplesX; i++) {
                // Current vertex

                var center = new Vector3(i * edgeX-Width/2.0f,heightMap[j][i], j * edgeY-Height/2.0f);
                // s+= heightMap[j][i]+", ";
                // s += center.x+", ";
                // Height of this vertex (from heightmap)
                //	float h = SampleHeight(center.x, center.z);
                //	center.y = h;
                vertices[p] = center;
                // UV coords in [0,1] space
                uvs[p++] = new Vector2(i/(SamplesX - 1f),
                                       j/(SamplesY - 1f));
            }
            // UnityEngine.Debug.Log(s);
        }
        // this should be fixxed
        int quadCount = (SamplesX-1 ) * (SamplesY-2 );
        triangles = new int[3 * 2 * quadCount];
        UnityEngine.Debug.Log ("QUads: " + quadCount);
        for (int t = 0; t < quadCount; t++) {

            int i = t % (SamplesX - 1);
            int j = t / (SamplesX - 1);
            triangles[6 * t + 0] = i   + j *SamplesX; // CalculateIndex(i + 1, j);
            triangles[6 * t + 2] = i+1 + j *SamplesX;
            triangles[6 * t + 1] = i   + (1+j) *SamplesX;

            triangles[6 * t + 3] = i+1 + j *SamplesX;
            triangles[6 * t + 5] = i+1 + (j+1)*SamplesX;
            triangles[6 * t + 4] = i   + (j+1)*SamplesX;
        }
        // grid updated
        gridUpdated = true;
        return 0;
    }