diff --git a/engine/Camera.cpp b/engine/Camera.cpp index 31bcbd4..bccc753 100644 --- a/engine/Camera.cpp +++ b/engine/Camera.cpp @@ -58,10 +58,10 @@ std::vector> Camera::project(std::shared_ptr mes for (auto &clipped : clippedTriangles) { sf::Color color = clipped.color(); - sf::Color ambientColor = sf::Color((sf::Uint8) (color.r * (0.3 * std::abs(dot) + 0.7)), - (sf::Uint8) (color.g * (0.3 * std::abs(dot) + 0.7)), - (sf::Uint8) (color.b * (0.3 * std::abs(dot) + 0.7)), - (sf::Uint8) color.a); + sf::Color ambientColor = sf::Color(static_cast(color.r * (0.3 * std::abs(dot) + 0.7)), + static_cast(color.g * (0.3 * std::abs(dot) + 0.7)), + static_cast(color.b * (0.3 * std::abs(dot) + 0.7)), + static_cast(color.a)); // Finally its time to project our clipped colored drawTriangle from 3D -> 2D // and transform it's coordinate to screen space (in pixels): diff --git a/engine/Object.h b/engine/Object.h index 2a38649..7ad3d33 100644 --- a/engine/Object.h +++ b/engine/Object.h @@ -43,9 +43,9 @@ private: /* * Take into account when you rotate body, - * you change '_angle' only for this particular body, + * you change '_angle' & '_angleLeftUpLookAt' only for this particular body, * but not for attached objects! This way during rotation - * '_angle' stays the same for all attached objects. + * '_angle' & '_angleLeftUpLookAt' stays constant all attached objects. */ Vec3D _angle{0, 0, 0}; Vec3D _angleLeftUpLookAt{0, 0, 0}; diff --git a/engine/Screen.cpp b/engine/Screen.cpp index c6e52ec..2d94da4 100644 --- a/engine/Screen.cpp +++ b/engine/Screen.cpp @@ -51,9 +51,12 @@ void Screen::clear() { void Screen::drawTriangle(const Triangle &triangle) { sf::Vertex tris[3] = { - sf::Vertex(sf::Vector2f((float) triangle[0].x(), (float) triangle[0].y()), triangle.color()), - sf::Vertex(sf::Vector2f((float) triangle[1].x(), (float) triangle[1].y()), triangle.color()), - sf::Vertex(sf::Vector2f((float) triangle[2].x(), (float) triangle[2].y()), triangle.color()) + sf::Vertex(sf::Vector2f(static_cast(triangle[0].x()), static_cast(triangle[0].y())), + triangle.color()), + sf::Vertex(sf::Vector2f(static_cast(triangle[1].x()), static_cast(triangle[1].y())), + triangle.color()), + sf::Vertex(sf::Vector2f(static_cast(triangle[2].x()), static_cast(triangle[2].y())), + triangle.color()) }; _window->pushGLStates(); @@ -80,10 +83,10 @@ void Screen::setMouseCursorVisible(bool visible) { void Screen::drawTetragon(const Vec2D &p1, const Vec2D &p2, const Vec2D &p3, const Vec2D &p4, sf::Color color) { sf::ConvexShape polygon; polygon.setPointCount(4); - polygon.setPoint(0, sf::Vector2f((float) p1.x(), (float) p1.y())); - polygon.setPoint(1, sf::Vector2f((float) p2.x(), (float) p2.y())); - polygon.setPoint(2, sf::Vector2f((float) p3.x(), (float) p3.y())); - polygon.setPoint(3, sf::Vector2f((float) p4.x(), (float) p4.y())); + polygon.setPoint(0, sf::Vector2f(static_cast(p1.x()), static_cast(p1.y()))); + polygon.setPoint(1, sf::Vector2f(static_cast(p2.x()), static_cast(p2.y()))); + polygon.setPoint(2, sf::Vector2f(static_cast(p3.x()), static_cast(p3.y()))); + polygon.setPoint(3, sf::Vector2f(static_cast(p4.x()), static_cast(p4.y()))); polygon.setFillColor(color); _window->pushGLStates(); @@ -99,7 +102,7 @@ void Screen::drawText(const std::string &string, const Vec2D &position, int size text.setCharacterSize(size); text.setFillColor(color); text.setStyle(sf::Text::Italic); - text.setPosition((float) position.x(), (float) position.y()); + text.setPosition(static_cast(position.x()), static_cast(position.y())); text.setString(string); @@ -194,19 +197,19 @@ GLfloat *Screen::glMeshToGLfloatArray(std::shared_ptr mesh, const Vec3D &c dot[k] = MTriangle.norm().dot((Vec3D(MTriangle[k]) - cameraPosition).normalized()); sf::Color color = triangles[i].color(); - ambientColor[k] = sf::Color((sf::Uint8) (color.r * (0.3 * std::abs(dot[k]) + 0.7)), - (sf::Uint8) (color.g * (0.3 * std::abs(dot[k]) + 0.7)), - (sf::Uint8) (color.b * (0.3 * std::abs(dot[k]) + 0.7)), - (sf::Uint8) color.a); + ambientColor[k] = sf::Color(static_cast(color.r * (0.3 * std::abs(dot[k]) + 0.7)), + static_cast(color.g * (0.3 * std::abs(dot[k]) + 0.7)), + static_cast(color.b * (0.3 * std::abs(dot[k]) + 0.7)), + static_cast(color.a)); - geometry[stride + 7 * k + 0] = (GLfloat) MTriangle[k].x(); - geometry[stride + 7 * k + 1] = (GLfloat) MTriangle[k].y(); - geometry[stride + 7 * k + 2] = (GLfloat) MTriangle[k].z(); + geometry[stride + 7 * k + 0] = static_cast(MTriangle[k].x()); + geometry[stride + 7 * k + 1] = static_cast(MTriangle[k].y()); + geometry[stride + 7 * k + 2] = static_cast(MTriangle[k].z()); - geometry[stride + 7 * k + 3] = (GLfloat) ambientColor[k].r / 255.0f; - geometry[stride + 7 * k + 4] = (GLfloat) ambientColor[k].g / 255.0f; - geometry[stride + 7 * k + 5] = (GLfloat) ambientColor[k].b / 255.0f; - geometry[stride + 7 * k + 6] = (GLfloat) ambientColor[k].a / 255.0f; + geometry[stride + 7 * k + 3] = static_cast(ambientColor[k].r) / 255.0f; + geometry[stride + 7 * k + 4] = static_cast(ambientColor[k].g) / 255.0f; + geometry[stride + 7 * k + 5] = static_cast(ambientColor[k].b) / 255.0f; + geometry[stride + 7 * k + 6] = static_cast(ambientColor[k].a) / 255.0f; } } return geometry;