// Use this for initialization
 void Start()
 {
     crater = ComputeCraterGeometry.crater;
     mesh = new Mesh();
     grid.initGrid (128, 128);
     grid.updateGrid (mesh);
     GetComponent<MeshFilter> ().mesh = mesh;
     UnityEngine.Debug.Log ("Miua :" + verticesBuffer.count + " == " + mesh.vertices.Length);
     verticesBuffer.SetData(this.getVertices ());
     //mesh.
     //UnityEngine.Debug.Log ("Mesh updated: " );
 }
    // Update is called once per frame
    void Update()
    {
        crater = ComputeCraterGeometry.crater;
        // check for mouse key
        if (Input.GetKey (KeyCode.Mouse0)) {
            float x = -0.08f*Input.GetAxis ("Mouse X");
            float y = -0.08f*Input.GetAxis ("Mouse Y");
            UnityEngine.Debug.LogFormat("{0} {1}",x,y);
            // this.transform.Translate(new Vector3(x,0,y));
            crater.x += x*512;
            crater.y += y*512;

            // 	dtm_model.compare(this);
        }
        if (Input.GetKey (KeyCode.X)) {
            crater.r += 0.003f;
        //	UnityEngine.Debug.Log("X++");
        }
        if (Input.GetKey (KeyCode.Z)) {
            crater.r -= 0.003f;
        }
        if (Input.GetKey (KeyCode.C)) {
            crater.z += 0.003f;
        //	UnityEngine.Debug.Log("Z++");
        }
        if (Input.GetKey (KeyCode.V)) {
            crater.z -= 0.003f;
        }

        if (Input.GetKey (KeyCode.S)) {
            // start iterating
            crater.startSearch();
            // runningProfiling = true;
            //crater.r += 0.01f;
            // UnityEngine.Debug.Log("X++");
        }
    }
    public void updateCrater(Crater crater)
    {
        UnityEngine.Debug.Log (crater.x + " " + crater.y);
        imgCrater.setText(genTex);
        gridGenerated.updateVertices (verticesBuffer);
        // imgCrater.setVert(genTex);

        if (mP2 != null) {
            // Debug.Log ("OnGUI ");
             SharedMemoryUtil.convertToFloatArray(crater.x,crater.y,mP1,mP2,mG,ref arr);
            UnityEngine.Debug.Log ("S = "+arr[1]+ " " + arr[2]);
            craterParamsBuffer.SetData(arr);
            /*// OnGUI();
            if (genTex != null) {

                mGUI.DrawTexture(new Rect(0,0,1024,1024),genTex , ScaleMode.StretchToFill,false, 1.0F);
                // GUI.DrawTexture(new Rect(0,0,1024,1024),genTex , ScaleMode.StretchToFill,false, 1.0F);
            }*/
                /*
                float [] t;
            fixed float[21] pCrater;
            fixed (pCrater = craterPolinomio){

                craterParamsBuffer.SetData(pCrater);
            }
        */
                /*
                SetFloat("x",crater.x);
                SetFloat("y",crater.y);

            SetFloat ("p2_max", mP2.max);
            SetFloat ("p2_min", mP2.min);
            SetFloat ("p2_w0", mP2.w0);
            SetFloat ("p2_w1", mP2.w1);
            SetFloat ("p2_w2", mP2.w2);
            SetFloat ("p2_w3", mP2.w3);

            SetFloat ("p1_max", mP1.max);
            SetFloat ("p1_min", mP1.min);
            SetFloat ("p1_w0", mP1.w0);
            SetFloat ("p1_w1", mP1.w1);
            SetFloat ("p1_w2", mP1.w2);
            SetFloat ("p1_w3", mP1.w3);

            SetFloat ("g1_max", mG.max);
            SetFloat ("g1_min", mG.min);
            SetFloat ("g1_mean", mG.mean);
            SetFloat ("g1_sigma", mG.sigma);
            SetFloat ("g1_h", mG.h);
            SetFloat ("g1_hs", mG.hs);
        */
        }
        // SetFloat ("radious", crater.r);
        /*	SetFloat("z",crater.z);
            SetFloat ("radious", crater.r);
            if (crater.w != null) {
                SetFloat ("w0", crater.w [0]);
                SetFloat ("w1", crater.w [1]);
                SetFloat ("w2", crater.w [2]);
                SetFloat ("w3", crater.w [3]);
                SetFloat ("w4", crater.w [4]);
            }
            SetFloat ("tStart",1.8f);
            SetFloat ("tEnd", 1.8f);*/
    }
Exemplo n.º 4
0
 //Удаление кратора
 public void RemoveCrater(Crater crater)
 {
     listCrater.Remove(crater);
 }