public void StartProcess () { // TextureScale.Bilinear (screenshot, 90, 160); copy = Instantiate(screenshot); pixels = copy.GetPixels(); for(int i=0; i<pixels.Length; i++){ r_color_map[(i/screenshot.width), i%screenshot.width,0] = (int)(pixels[i].r*255); r_color_map[(i/screenshot.width), i%screenshot.width,1] =(int)(pixels[i].g*255); r_color_map[i/screenshot.width, i%screenshot.width,2] =(int)(pixels[i].b*255); float gray = pixels[i].grayscale; pixels[i] = new Color(1f-gray, 1f-gray, 1f-gray, pixels[i].a); } copy.SetPixels(pixels); copy.Apply(); copy = ChangeTextureContrast(copy, 0.999f); copy.Apply(); AnalyTexture(copy.GetPixels()); try{ SaveLoad.SaveColorMap(r_color_map); SaveLoad.SaveEdgeMap(r_edge_map); SaveLoad.SaveEdgeGroup(r_edge_group); }catch{}; Finished = true; MFS = GetComponent<MapFromScreenshot>(); if(MFS!=null && MFS!=null){ //try to move map infront camera(in map creating page) transform.position = new Vector3(-113f, -190f, -354f); transform.eulerAngles = new Vector3(-59f/360f, -26f/360f, -90f/360f); transform.localScale = new Vector3(0.01f, 0.01f, 0.01f); } // -------------------------------------for debug GUI --------------------------------------------------------- for(int i =0;i<pixels.Length; i++){ pixels[i] = Color.black; if(r_edge_map[i/copy.width, i%copy.width]==1) pixels[i] = Color.white; } foreach(List<int[]> group in r_edge_group){ float r_color = Random.Range(0f,1f); float r_color_g = Random.Range(0f,1f); float r_color_b = Random.Range(0f,1f); foreach(int[] point in group){ pixels[point[1]*copy.width + point[0]] = new Color(r_color, r_color_g, r_color_b); } } copy.SetPixels(pixels); copy.Apply(); show = false; //------------------------------------------------------------------------------------------------------------- }
public void StartProcess() { // TextureScale.Bilinear (screenshot, 90, 160); copy = Instantiate(screenshot); pixels = copy.GetPixels(); for (int i = 0; i < pixels.Length; i++) { r_color_map[(i / screenshot.width), i % screenshot.width, 0] = (int)(pixels[i].r * 255); r_color_map[(i / screenshot.width), i % screenshot.width, 1] = (int)(pixels[i].g * 255); r_color_map[i / screenshot.width, i % screenshot.width, 2] = (int)(pixels[i].b * 255); float gray = pixels[i].grayscale; pixels[i] = new Color(1f - gray, 1f - gray, 1f - gray, pixels[i].a); } copy.SetPixels(pixels); copy.Apply(); copy = ChangeTextureContrast(copy, 0.999f); copy.Apply(); AnalyTexture(copy.GetPixels()); try{ SaveLoad.SaveColorMap(r_color_map); SaveLoad.SaveEdgeMap(r_edge_map); SaveLoad.SaveEdgeGroup(r_edge_group); }catch {}; Finished = true; MFS = GetComponent <MapFromScreenshot>(); if (MFS != null && MFS != null) //try to move map infront camera(in map creating page) { transform.position = new Vector3(-113f, -190f, -354f); transform.eulerAngles = new Vector3(-59f / 360f, -26f / 360f, -90f / 360f); transform.localScale = new Vector3(0.01f, 0.01f, 0.01f); } // -------------------------------------for debug GUI --------------------------------------------------------- for (int i = 0; i < pixels.Length; i++) { pixels[i] = Color.black; if (r_edge_map[i / copy.width, i % copy.width] == 1) { pixels[i] = Color.white; } } foreach (List <int[]> group in r_edge_group) { float r_color = Random.Range(0f, 1f); float r_color_g = Random.Range(0f, 1f); float r_color_b = Random.Range(0f, 1f); foreach (int[] point in group) { pixels[point[1] * copy.width + point[0]] = new Color(r_color, r_color_g, r_color_b); } } copy.SetPixels(pixels); copy.Apply(); show = false; //------------------------------------------------------------------------------------------------------------- }
void Start(){ // StartProcess(); MFS = GetComponent<MapFromScreenshot>(); }
void Start() { // StartProcess(); MFS = GetComponent <MapFromScreenshot>(); }