Esempio n. 1
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         RaycastHit hit;
         Ray        ray  = cam.ScreenPointToRay(Input.mousePosition);
         bool       flag = Physics.Raycast(ray, out hit);
         Debug.Log(hit.transform);
         if (flag && hit.transform.gameObject.tag == "MarchingCube")
         {
             Vector3 p = new Vector3(-hit.point.x + 0.5f, hit.point.y + 0.5f, hit.point.z + 0.5f);
             bs.addVolume(p);
             // レイに当たったオブジェクトに何かをする
         }
     }
     if (Input.GetMouseButtonDown(1))
     {
         RaycastHit hit;
         Ray        ray  = cam.ScreenPointToRay(Input.mousePosition);
         bool       flag = Physics.Raycast(ray, out hit);
         Debug.Log(hit.transform);
         if (flag && hit.transform.gameObject.tag == "MarchingCube")
         {
             Vector3 p = hit.point + new Vector3(0.5f, 0.5f, 0.5f);
             bs.addVolume(p);
             // レイに当たったオブジェクトに何かをする
         }
     }
 }
Esempio n. 2
0
    void Initialize()
    {
        bs         = this.GetComponent <BakingShader>();
        segmentNum = bs.segmentNum;
        vertexMax  = segmentNum * segmentNum * segmentNum;

        Debug.Log("VertexMax " + vertexMax);

        // 1Cubeの大きさをsegmentNumで分割してレンダリング時の大きさを決める
        renderScale = 1f / segmentNum;

        bs.addVolume(new Vector3(0.5f, 0.8f, 0.5f));
        CreateMesh();

        // シェーダーで使うMarchingCubes用の定数配列の初期化
        mcDefines = new MarchingCubesDefines();
    }