Reorganizing file structure.
Before Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 166 KiB After Width: | Height: | Size: 166 KiB |
Before Width: | Height: | Size: 344 KiB After Width: | Height: | Size: 344 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
4
main.cc
@ -37,8 +37,8 @@ void Application::init()
|
|||||||
// define where shaders and textures can be found:
|
// define where shaders and textures can be found:
|
||||||
ACGL::Base::Settings::the()->setResourcePath("../");
|
ACGL::Base::Settings::the()->setResourcePath("../");
|
||||||
ACGL::Base::Settings::the()->setShaderPath("Shader/");
|
ACGL::Base::Settings::the()->setShaderPath("Shader/");
|
||||||
ACGL::Base::Settings::the()->setTexturePath("Geometry/");
|
ACGL::Base::Settings::the()->setTexturePath("Levels/Textures/");
|
||||||
ACGL::Base::Settings::the()->setGeometryPath("Geometry/");
|
ACGL::Base::Settings::the()->setGeometryPath("Levels/Geometry/");
|
||||||
|
|
||||||
// construct VAO to give shader correct Attribute locations
|
// construct VAO to give shader correct Attribute locations
|
||||||
ACGL::OpenGL::SharedArrayBuffer ab = std::make_shared<ACGL::OpenGL::ArrayBuffer>();
|
ACGL::OpenGL::SharedArrayBuffer ab = std::make_shared<ACGL::OpenGL::ArrayBuffer>();
|
||||||
|
14
terrain.cc
@ -13,10 +13,10 @@ Terrain::~Terrain() {
|
|||||||
|
|
||||||
|
|
||||||
void Terrain::load() {
|
void Terrain::load() {
|
||||||
filePath = "../Levels/LevelTest/terrain/"; //TODO remove this, its only for testing
|
filePath = "../Levels/heightmapLvlTest.png"; //TODO remove this, its only for testing
|
||||||
|
|
||||||
std::vector<unsigned char> image; //the raw pixels
|
std::vector<unsigned char> image; //the raw pixels
|
||||||
unsigned error = lodepng::decode(image, heightmapWidth, heightmapHeight, filePath + "heightmap.png");
|
unsigned error = lodepng::decode(image, heightmapWidth, heightmapHeight, filePath);
|
||||||
if (error) {
|
if (error) {
|
||||||
std::cout << "decoder error " << error << ": " << lodepng_error_text(error) << std::endl;
|
std::cout << "decoder error " << error << ": " << lodepng_error_text(error) << std::endl;
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ void Terrain::makeTriangleMesh(){
|
|||||||
ab->defineAttribute("aTexCoord", GL_FLOAT, 2);
|
ab->defineAttribute("aTexCoord", GL_FLOAT, 2);
|
||||||
ab->defineAttribute("aNormal", GL_FLOAT, 3);
|
ab->defineAttribute("aNormal", GL_FLOAT, 3);
|
||||||
|
|
||||||
unsigned int rowNum=0, columnNum=0, dataCount=0, abNumFloats=8; //initializing:
|
unsigned int rowNum=0, columnNum=0, dataCount=0, floatsPerVertex=8; //initializing:
|
||||||
bool movingRight = true, isUp = true;
|
bool movingRight = true, isUp = true;
|
||||||
int numVertices = (this->heightmapHeight - 1) * (this->heightmapWidth * 2 + 1) + 1;
|
int numVertices = (this->heightmapHeight - 1) * (this->heightmapWidth * 2 + 1) + 1;
|
||||||
float* abData = new float[numVertices * floatsPerVertex];
|
float* abData = new float[numVertices * floatsPerVertex];
|
||||||
@ -56,9 +56,9 @@ void Terrain::makeTriangleMesh(){
|
|||||||
else if (movingRight) {
|
else if (movingRight) {
|
||||||
if (columnNum == this->heightmapWidth - 1) {
|
if (columnNum == this->heightmapWidth - 1) {
|
||||||
set_abData(abData, dataCount, rowNum, columnNum);
|
set_abData(abData, dataCount, rowNum, columnNum);
|
||||||
dataCount += abNumFloats;
|
dataCount += floatsPerVertex;
|
||||||
set_abData(abData, dataCount, rowNum, columnNum);
|
set_abData(abData, dataCount, rowNum, columnNum);
|
||||||
dataCount += abNumFloats;
|
dataCount += floatsPerVertex;
|
||||||
movingRight = false;
|
movingRight = false;
|
||||||
rowNum = rowNum + 1;
|
rowNum = rowNum + 1;
|
||||||
}
|
}
|
||||||
@ -71,9 +71,9 @@ void Terrain::makeTriangleMesh(){
|
|||||||
else {
|
else {
|
||||||
if (columnNum == 0){
|
if (columnNum == 0){
|
||||||
set_abData(abData, dataCount, rowNum, columnNum);
|
set_abData(abData, dataCount, rowNum, columnNum);
|
||||||
dataCount += abNumFloats;
|
dataCount += floatsPerVertex;
|
||||||
set_abData(abData, dataCount, rowNum, columnNum);
|
set_abData(abData, dataCount, rowNum, columnNum);
|
||||||
dataCount += abNumFloats;
|
dataCount += floatsPerVertex;
|
||||||
movingRight = true;
|
movingRight = true;
|
||||||
rowNum = rowNum + 1;
|
rowNum = rowNum + 1;
|
||||||
}
|
}
|
||||||
|