Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void loadGround()
- {
- unsigned int groundToRenderSize = groundToRender.size();
- for(int g = 0; g < groundToRenderSize; g++)
- {
- // subChunkGroundSize
- double tex[4][2] = {{1, 0}, {1, 1}, {0, 1}, {0, 0}}; // {{0, 1}, {1, 1}, {0, 0}, {1, 0}};
- vector<string> name = split(groundToRender[g], " ");
- int chkXThousand = convertStrToInt(name[0]) * chunkGroundSize, chkYThousand = convertStrToInt(name[1]) * chunkGroundSize; // ex: 8000 15000
- vector<string> lines = getFileContent(groundFolder + groundToRender[g] + ".height");
- print(groundFolder + groundToRender[g] + ".height");
- groundLoaded[groundToRender[g]] = Gl_object("ground.jpg");
- unsigned int linesSize = lines.size() - 1;
- for(int i = 0; i < linesSize; i++)
- {
- vector<string> partsCurrentLine = split(lines[i], " ");
- vector<string> partsNextLine = split(lines[i + 1], " ");
- unsigned int partsCurrentLineSize = partsCurrentLine.size() - 1;
- for(int j = 0; j < partsCurrentLineSize; j++)
- {
- // if(j <= 10) continue; // TEST MEMORY
- string xMin = convertNbToStr(chkXThousand + j * subChunkGroundSize), xMax = convertNbToStr(chkXThousand + (j + 1) * subChunkGroundSize);
- int chkYThousandPluschunkGroundSize = chkYThousand + chunkGroundSize;
- string yMin = convertNbToStr(chkYThousandPluschunkGroundSize - i * subChunkGroundSize), yMax = convertNbToStr(chkYThousandPluschunkGroundSize - (i + 1) * subChunkGroundSize);
- string zA = partsCurrentLine[j], zB = partsCurrentLine[j + 1], zC = partsNextLine[j + 1], zD = partsNextLine[j];
- string vertex[4][3] = {{xMin, yMin, zA},
- {xMax, yMin, zB},
- {xMax, yMax, zC},
- {xMin, yMax, zD}};
- /*print(xMin + " " + yMin + " " + zA);
- print(xMax + " " + yMin + " " + zB);
- print(xMax + " " + yMax + " " + zC);
- print(xMin + " " + yMax + " " + zD);*/
- /*
- string vertex[4][3] = {{convertNbToStr(chkXThousand + j * 8), convertNbToStr(chkYThousand + chunkGroundSize - i * 8), partsCurrentLine[j]},
- {convertNbToStr(chkXThousand + (j + 1) * 8), convertNbToStr(chkYThousand + chunkGroundSize - i * 8), partsCurrentLine[j + 1]},
- {convertNbToStr(chkXThousand + j * 8), convertNbToStr(chkYThousand + chunkGroundSize - (i + 1) * 8), partsNextLine[j]},
- {convertNbToStr(chkXThousand + (j + 1) * 8), convertNbToStr(chkYThousand + chunkGroundSize - (i + 1) * 8), partsNextLine[j + 1]}};*/
- groundLoaded[groundToRender[g]].addPart(tex, vertex); // BREUH
- groundLoaded[groundToRender[g]].addPart(tex, vertex);
- groundLoaded[groundToRender[g]].addPart(tex, vertex);
- }
- }
- // BEN WORKING AREA
- /*vector<glm::vec3> testTmp;
- testTmp.push_back(glm::vec3(0, 0, 0));
- print(convertNbToStr(g) + " " + convertNbToStr(groundToRenderSize));
- groundLoaded[groundToRender[g]].initializeTranslations(testTmp);*/
- }
- }
- void Gl_object::addPart(double tex[4][2], string inVertex[4][3])
- {
- //print("start");
- double vertex[4][3];
- for(int x = 0; x < 4; x++)
- for(int y = 0; y < 3; y++)
- vertex[x][y] = convertStrToDouble(inVertex[x][y]);
- glm::vec3 vertices[] = {glm::vec3(vertex[0][0], vertex[0][1], vertex[0][2]),
- glm::vec3(vertex[1][0], vertex[1][1], vertex[1][2]),
- glm::vec3(vertex[2][0], vertex[2][1], vertex[2][2]),
- glm::vec3(vertex[3][0], vertex[3][1], vertex[3][2]),};
- glm::vec2 texCoord[] = {glm::vec2(tex[0][0], tex[0][1]), glm::vec2(tex[1][0], tex[1][1]), glm::vec2(tex[2][0], tex[2][1]), glm::vec2(tex[3][0], tex[3][1])};
- m_vertices.insert(m_vertices.end(), begin(vertices), end(vertices));
- m_texCoord.insert(m_texCoord.end(), begin(texCoord), end(texCoord));
- //for(int i = 0; i < 6; i++)
- // m_indices.push_back(i + partNumber * 6);
- m_indices.push_back(0 + partNumber * 4);
- m_indices.push_back(1 + partNumber * 4);
- m_indices.push_back(2 + partNumber * 4);
- m_indices.push_back(0 + partNumber * 4);
- m_indices.push_back(3 + partNumber * 4);
- m_indices.push_back(2 + partNumber * 4);
- //print(m_indices.size());
- partNumber++;
- //print("finished");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement