//obtiene un color real de la paleta public Color GetColorPalette(VoxelPalette colorPalette) { switch (colorPalette) { case VoxelPalette.empty: return(new Color(0, 0, 0, 0)); break; case VoxelPalette.red: return(new Color(1, 0, 0, 1)); break; case VoxelPalette.green: return(new Color(0, 1, 0, 1)); break; case VoxelPalette.blue: return(new Color(0, 0, 1, 1)); break; case VoxelPalette.white: return(new Color(1, 1, 1, 1)); break; case VoxelPalette.black: return(new Color(0, 0, 0, 1)); break; default: return(new Color(1, 1, 1, 1)); break; } }
public void ReadPropertiesfromFile() { /* modificando harcoded * for(int i = 0; i< 16; i++) * { * for(int j = 0; j< 16; j++) * { * Transform vox = GetVoxel(i,0,j); * vox.GetComponent<MeshRenderer>().material.color = GetColorPalette( VoxelPalette.black) ; * SetVoxel( vox, i, 0 ,j ); * * vox = GetVoxel(i,1,j); * vox.GetComponent<MeshRenderer>().material.color = GetColorPalette( VoxelPalette.green) ; * SetVoxel( vox, i, 1 ,j ); * * * GetVoxel(8,2,8).GetComponent<MeshRenderer>().material.color = GetColorPalette( VoxelPalette.red) ; * * * } * } * */ TextAsset texto = Resources.Load <TextAsset>("mapa"); string[] lineas = texto.text.Split('\n'); for (int i = 0; i < lineas.Length; i++) { //dicidir cada linea e interpretar la coordenada string[] coord = lineas[i].Split(','); int x = System.Int32.Parse(coord[0]); int y = System.Int32.Parse(coord[1]); int z = System.Int32.Parse(coord[2]); VoxelPalette vcolor = (VoxelPalette)System.Int32.Parse(coord[3]); GetVoxel(x, y, z).GetComponent <MeshRenderer>().material.color = GetColorPalette(vcolor); } }