From 54f4da87923465a5387e2e854b58616647deb7af Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 15 Jul 2012 19:17:49 +0200 Subject: Fix in model loading; simple model viewer - fixed model loading code - added simple model viewer (model_test) in src/graphics/opengl/test - added system time stamp code - split the code in app/system modules to separate headers - added debug messages in model loading - minor fixes in OpenGL engine --- src/graphics/common/vertex.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/graphics/common/vertex.h') diff --git a/src/graphics/common/vertex.h b/src/graphics/common/vertex.h index c6375b9..0a74587 100644 --- a/src/graphics/common/vertex.h +++ b/src/graphics/common/vertex.h @@ -23,6 +23,8 @@ #include "math/vector.h" #include "math/point.h" +#include + namespace Gfx { /** @@ -46,6 +48,17 @@ struct Vertex Math::Vector aNormal = Math::Vector(), Math::Point aTexCoord = Math::Point()) : coord(aCoord), normal(aNormal), texCoord(aTexCoord) {} + + + //! Returns a string "(c: [...], n: [...], tc: [...])" + inline std::string ToString() const + { + std::stringstream s; + s.precision(3); + s << "(c: " << coord.ToString() << ", n: " << normal.ToString() + << ", tc: " << texCoord.ToString() << ")"; + return s.str(); + } }; /** @@ -72,6 +85,16 @@ struct VertexCol Gfx::Color aSpecular = Gfx::Color(), Math::Point aTexCoord = Math::Point()) : coord(aCoord), color(aColor), specular(aSpecular), texCoord(aTexCoord) {} + + //! Returns a string "(c: [...], col: [...], sp: [...], tc: [...])" + inline std::string ToString() const + { + std::stringstream s; + s.precision(3); + s << "(c: " << coord.ToString() << ", col: " << color.ToString() << ", sp: " + << specular.ToString() << ", tc: " << texCoord.ToString() << ")"; + return s.str(); + } }; @@ -95,6 +118,7 @@ struct VertexTex2 Math::Point aTexCoord2 = Math::Point()) : coord(aCoord), normal(aNormal), texCoord(aTexCoord), texCoord2(aTexCoord2) {} + //! Sets the fields from Gfx::Vertex with texCoord2 = (0,0) void FromVertex(const Gfx::Vertex &v) { coord = v.coord; @@ -102,6 +126,16 @@ struct VertexTex2 texCoord = v.texCoord; texCoord2 = Math::Point(); } + + //! Returns a string "(c: [...], n: [...], tc: [...], tc2: [...])" + inline std::string ToString() const + { + std::stringstream s; + s.precision(3); + s << "(c: " << coord.ToString() << ", n: " << normal.ToString() + << ", tc: " << texCoord.ToString() << ", tc2: " << texCoord2.ToString() << ")"; + return s.str(); + } }; }; // namespace Gfx -- cgit v1.2.3-1-g7c22