private LowPolyMotion.xyz NewEndXYZ(LowPolyMotion.GridConfig gridConfig, int rect_i, int rect_j) { LowPolyMotion.xyz result = new LowPolyMotion.xyz(0, 0, rand.Next(LowPolyMotion.rangeZ.min, LowPolyMotion.rangeZ.max)); int edgeIndex = rand.Next(0, 4);// 0~3: 上下左右边 double bias = rand.NextDouble(); switch (edgeIndex) { case 0: result.x = (int)(gridConfig.getCrossCellWidth() * rect_i + gridConfig.getCrossCellWidth() * bias); result.y = gridConfig.getDirectionCellHeight() * rect_j; break; case 1: result.x = (int)(gridConfig.getCrossCellWidth() * rect_i + gridConfig.getCrossCellWidth() * bias); result.y = gridConfig.getDirectionCellHeight() * (rect_j + 1); break; case 2: result.x = gridConfig.getCrossCellWidth() * rect_i; result.y = (int)(gridConfig.getDirectionCellHeight() * rect_j + gridConfig.getDirectionCellHeight() * bias); break; default: result.x = gridConfig.getCrossCellWidth() * (rect_i + 1); result.y = (int)(gridConfig.getDirectionCellHeight() * rect_j + gridConfig.getDirectionCellHeight() * bias); break; } return(result); }
private void InitializeLowPolyConfig(LowPolyMotion.GridConfig gridConfig, int boardWidth, int boardHeight, int pointCount) { if (pointCount <= 1) { pointCount = 2; } // Initialize Grid gridConfig.initGridConfig(boardWidth, boardHeight, pointCount); // Initialize Rects LowPolyMotion.GridInfo gridInfo = gridConfig.getGridInfo(); gridInfo.c_x = grid.getCrossCellCount(); gridInfo.c_y = grid.getDirectionCellCount(); gridInfo.c_w = grid.getCrossCellWidth(); gridInfo.c_h = grid.getDirectionCellHeight(); rects = new LowPolyMotion.Rect[gridInfo.c_x, gridInfo.c_y]; for (int i = 0; i < gridInfo.c_x; i++) { for (int j = 0; j < gridInfo.c_y; j++) { rects[i, j] = new LowPolyMotion.Rect(); rects[i, j].xyz = new LowPolyMotion.xyz(gridInfo.c_w * i, gridInfo.c_h * j, 0); rects[i, j].w = gridInfo.c_w; rects[i, j].h = gridInfo.c_h; rects[i, j].T_Diagonal = rand.Next(0, 2); // [0,2) } } // Initialize Points points = new LowPolyMotion.MotionPoint[gridInfo.c_x, gridInfo.c_y]; InitializePoints(gridConfig, ref points); CalOutCenter(gridConfig, ref rects, points); // Initialize Light light = new LowPolyMotion.MotionPoint(rand.Next(LowPolyMotion.rangeN.min, LowPolyMotion.rangeN.max), 0, new LowPolyMotion.xyz(boardWidth / 2, boardHeight / 2, rand.Next(LowPolyMotion.rangeZ.min, LowPolyMotion.rangeZ.max)), NewEndXYZ(boardWidth, boardHeight, LowPolyMotion.rangeZ.light_min, LowPolyMotion.rangeZ.light_max)); // Color Rendering ColorRendering(gridConfig, ref rects, points); }