From ea5f50550ea2027043c9c3d0f5d998a1a1d336a5 Mon Sep 17 00:00:00 2001 From: Mateja Date: Fri, 19 Feb 2021 14:09:35 +0100 Subject: Improve variable names. --- src/main.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 94a8b30..f229003 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,22 +32,22 @@ int main() sf::Image image; image.loadFromFile("model/modelTexture.png"); - Bitmap map(image.getSize().x, image.getSize().y); + Bitmap modelTexture(image.getSize().x, image.getSize().y); const sf::Uint8* pp = image.getPixelsPtr(); for (int i = 0; i < image.getSize().x * image.getSize().y * 4; i += 4) { - map.pixels[i + 0] = (unsigned char)pp[i + 0]; - map.pixels[i + 1] = (unsigned char)pp[i + 1]; - map.pixels[i + 2] = (unsigned char)pp[i + 2]; - map.pixels[i + 3] = (unsigned char)pp[i + 3]; + modelTexture.pixels[i + 0] = (unsigned char)pp[i + 0]; + modelTexture.pixels[i + 1] = (unsigned char)pp[i + 1]; + modelTexture.pixels[i + 2] = (unsigned char)pp[i + 2]; + modelTexture.pixels[i + 3] = (unsigned char)pp[i + 3]; } std::chrono::high_resolution_clock::time_point time1 = std::chrono::high_resolution_clock::now(); - ObjModel vehicle("model/model.obj"); + ObjModel model("model/model.obj"); std::chrono::high_resolution_clock::time_point time2 = std::chrono::high_resolution_clock::now(); std::chrono::duration speed = std::chrono::duration_cast>(time2 - time1); std::cout << "Model loading time: " << speed.count() << "s\n"; - std::cout << "Vertice count: " << vehicle.vertices.size() << "\nNumber of normals: " << vehicle.normals.size() << "\nUV count: " << vehicle.uvcoo.size() << "\n"; - std::cout << "Number of faces: " << vehicle.faces.size() << "\n"; + std::cout << "Vertices count: " << model.vertices.size() << "\nNumber of normals: " << model.normals.size() << "\nUV count: " << model.uvcoo.size() << "\n"; + std::cout << "Number of faces: " << model.faces.size() << "\n"; while (window.isOpen()) { @@ -65,14 +65,14 @@ int main() Matrix4f project = Matrix4f::perspective(1.0f, 10000.0f, fov, width / height); Matrix4f end_matrix = project * move * rotate * scale; - ObjModel vehicle2 = vehicle.multiplyMatrix(end_matrix); - vehicle2.divideW(); - vehicle2.screenspace(width, height); + ObjModel projectedModel = model.multiplyMatrix(end_matrix); + projectedModel.divideW(); + projectedModel.screenspace(width, height); render.fill(255, 255, 255); render.resetZBuf(); - render.renderModel(vehicle2, map); + render.renderModel(projectedModel, modelTexture); texture.update((sf::Uint8*)render.pixels); window.draw(sprite); -- cgit v1.2.3