public string DebugList() { if (_serial == null) { return(string.Empty); } System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("--- SPONGE INFO ---"); sb.Append("\n"); sb.Append("[MODE]"); sb.Append(Now_Mode); sb.Append("\n"); sb.Append("[value]"); float ave; for (int _id = 0; _id < Def_SensorCnt; _id++) { ave = 0; Sponge_Manage.SpongeInfo _info = _spongeManage.GetSpongeInfo(_id.ToString()); if (_info != null) { ave = _info.distValue_ave; } sb.Append(ave); sb.Append(","); } sb.Append("\n"); return(sb.ToString()); }
public Mesh SetZ(Sponge_Manage _m, int _id) { Mesh plotmesh = new Mesh(); Sponge_Manage.SpongeInfo _info = _m.GetSpongeInfo(_id.ToString()); if (_info == null) { return(plotmesh); } //境界値(下) //1点or2点の平均 //[0,0] PlotMesh_z[0, 0] = _info.MatrixTable_Plot[0, 0].z; //[1~plot_x-2,0] for (int i = 1; i < plot_x - 1; i++) { PlotMesh_z[i, 0] = (_info.MatrixTable_Plot[i - 1, 0].z + _info.MatrixTable_Plot[i, 0].z) / 2; } //[plot_x-1,0] PlotMesh_z[plot_x - 1, 0] = _info.MatrixTable_Plot[Sponge_Manage.Matrix_x - 1, 0].z; //境界値以外 //2点or4点の平均 for (int j = 1; j < plot_y - 1; j++) { //[0,j] PlotMesh_z[0, j] = (_info.MatrixTable_Plot[0, j - 1].z + _info.MatrixTable_Plot[0, j].z) / 2; //[1~plot_x-2,j] for (int i = 1; i < plot_x - 1; i++) { PlotMesh_z[i, j] = (_info.MatrixTable_Plot[i - 1, j - 1].z + _info.MatrixTable_Plot[i - 1, j].z + _info.MatrixTable_Plot[i, j - 1].z + _info.MatrixTable_Plot[i, j].z) / 4; } //[plot_x-1,j] PlotMesh_z[plot_x - 1, j] = (_info.MatrixTable_Plot[Sponge_Manage.Matrix_x - 1, j - 1].z + _info.MatrixTable_Plot[Sponge_Manage.Matrix_x - 1, j].z) / 2; } //境界値(上) //1点or2点の平均 //[0,plot_y-1] PlotMesh_z[0, plot_y - 1] = _info.MatrixTable_Plot[0, Sponge_Manage.Matrix_y - 1].z; //[1~cnt_x-2,plot_y-1] for (int i = 1; i < plot_x - 1; i++) { PlotMesh_z[i, plot_y - 1] = (_info.MatrixTable_Plot[i - 1, Sponge_Manage.Matrix_y - 1].z + _info.MatrixTable_Plot[i, Sponge_Manage.Matrix_y - 1].z) / 2; } //[cnt_x-1,plot_y-1] PlotMesh_z[plot_x - 1, plot_y - 1] = _info.MatrixTable_Plot[Sponge_Manage.Matrix_x - 1, Sponge_Manage.Matrix_y - 1].z; //計算した値をプロット用変数へ反映する int k = 0; float color = 0.0f; for (int i = 0; i < plot_y; i++) { for (int j = 0; j < plot_x; j++) { //頂点の指定 Unity上はz方向にセンサー値を与える VerticesTable[k].z = PlotMesh_z[j, i]; color = PlotMesh_z[j, i] / Sponge_Manage.PLOT_OFS / Sponge_Manage.PlaneSize_z_max; //端は多少丸める if (color > 0.95) { color = 1.0f; } if (color < 0.05) { color = 0.0f; } switch (_id) { case 0: ColorTable[k] = new Color(color, 0.0f, 0.0f); break; case 1: ColorTable[k] = new Color(0.0f, color, 0.0f); break; case 2: ColorTable[k] = new Color(0.0f, 0.0f, color); break; case 3: ColorTable[k] = new Color(0.0f, color, 0.0f); break; case 4: ColorTable[k] = new Color(0.0f, 0.0f, color); break; default: break; } k++; } } //頂点の指定 plotmesh.vertices = VerticesTable; //頂点インデックスの指定 plotmesh.triangles = TrianglesTable; plotmesh.colors = ColorTable; return(plotmesh); }