You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
5.5 KiB

5 years ago
  1. ///////////////////////////////////////////////////////////////////////////////////
  2. /// OpenGL Mathematics (glm.g-truc.net)
  3. ///
  4. /// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
  5. /// Permission is hereby granted, free of charge, to any person obtaining a copy
  6. /// of this software and associated documentation files (the "Software"), to deal
  7. /// in the Software without restriction, including without limitation the rights
  8. /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. /// copies of the Software, and to permit persons to whom the Software is
  10. /// furnished to do so, subject to the following conditions:
  11. ///
  12. /// The above copyright notice and this permission notice shall be included in
  13. /// all copies or substantial portions of the Software.
  14. ///
  15. /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. /// THE SOFTWARE.
  22. ///
  23. /// @ref virtrev_xstream
  24. /// @file glm/virtrev/xstream.hpp
  25. /// @date 2008-05-24 / 2008-05-26
  26. /// @author Mathieu Roumillac (matrem84.free.fr)
  27. ///
  28. /// @see core (dependence)
  29. /// @see gtc_matrix_access (dependence)
  30. ///
  31. /// @defgroup virtrev_xstream GLM_VIRTREV_xstream: xml like output
  32. /// @ingroup virtrev
  33. ///
  34. /// @brief Streaming vector and matrix in a xml way.
  35. ///
  36. /// Include <glm/virtrev/xstream.hpp> for this functionality.
  37. ///////////////////////////////////////////////////////////////////////////////////
  38. #ifndef GLM_VIRTREV_xstream
  39. #define GLM_VIRTREV_xstream GLM_VERSION
  40. #include "../glm.hpp"
  41. #include "../gtc/matrix_access.hpp"
  42. #include <iostream>
  43. #if(defined(GLM_MESSAGES) && !defined(glm_ext))
  44. # pragma message("GLM: GLM_VIRTREV_xstream extension included")
  45. #endif
  46. /*
  47. namespace glm{
  48. namespace detail
  49. {
  50. template<typename T>
  51. std::ostream & operator << (std::ostream & stream, glm::detail::tvec2<T> const & vec)
  52. {
  53. stream << "<glm_vec2 ";
  54. stream << "x=\"" << vec.x << "\" ";
  55. stream << "y=\"" << vec.y << "\" ";
  56. stream << "/>";
  57. return stream;
  58. }
  59. template<typename T>
  60. std::ostream & operator << (std::ostream & stream, glm::detail::tvec3<T> const & vec)
  61. {
  62. stream << "<glm_vec3 ";
  63. stream << "x=\"" << vec.x << "\" ";
  64. stream << "y=\"" << vec.y << "\" ";
  65. stream << "z=\"" << vec.z << "\" ";
  66. stream << "/>";
  67. return stream;
  68. }
  69. template<typename T>
  70. std::ostream & operator << (std::ostream & stream, glm::detail::tvec4<T> const & vec)
  71. {
  72. stream << "<glm_vec4 ";
  73. stream << "x=\"" << vec.x << "\" ";
  74. stream << "y=\"" << vec.y << "\" ";
  75. stream << "z=\"" << vec.z << "\" ";
  76. stream << "w=\"" << vec.w << "\" ";
  77. stream << "/>";
  78. return stream;
  79. }
  80. template<typename T>
  81. std::ostream & operator << (std::ostream & stream, glm::detail::tmat2x2<T> const & mat)
  82. {
  83. stream << "<glm_mat2>" << std::endl;
  84. stream << "<row ";
  85. stream << "x=\"" << glm::row(mat, 0)[0] << "\" ";
  86. stream << "y=\"" << glm::row(mat, 0)[1] << "\" ";
  87. stream << "/>" << std::endl;
  88. stream << "<row ";
  89. stream << "x=\"" << glm::row(mat, 1)[0] << "\" ";
  90. stream << "y=\"" << glm::row(mat, 1)[1] << "\" ";
  91. stream << "/>" << std::endl;
  92. stream << "</glm_mat2>";
  93. return stream;
  94. }
  95. template<typename T>
  96. std::ostream & operator << (std::ostream & stream, glm::detail::tmat3x3<T> const & mat)
  97. {
  98. stream << "<glm_mat3>" << std::endl;
  99. stream << "<row ";
  100. stream << "x=\"" << glm::row(mat, 0)[0] << "\" ";
  101. stream << "y=\"" << glm::row(mat, 0)[1] << "\" ";
  102. stream << "z=\"" << glm::row(mat, 0)[2] << "\" ";
  103. stream << "/>" << std::endl;
  104. stream << "<row ";
  105. stream << "x=\"" << glm::row(mat, 1)[0] << "\" ";
  106. stream << "y=\"" << glm::row(mat, 1)[1] << "\" ";
  107. stream << "z=\"" << glm::row(mat, 1)[2] << "\" ";
  108. stream << "/>" << std::endl;
  109. stream << "<row ";
  110. stream << "x=\"" << glm::row(mat, 2)[0] << "\" ";
  111. stream << "y=\"" << glm::row(mat, 2)[1] << "\" ";
  112. stream << "z=\"" << glm::row(mat, 2)[2] << "\" ";
  113. stream << "/>" << std::endl;
  114. stream << "</glm_mat3>";
  115. return stream;
  116. }
  117. template<typename T>
  118. std::ostream & operator << (std::ostream & stream, glm::detail::tmat4x4<T> const & mat)
  119. {
  120. stream << "<glm_mat4>" << std::endl;
  121. stream << "<row ";
  122. stream << "x=\"" << glm::row(mat, 0)[0] << "\" ";
  123. stream << "y=\"" << glm::row(mat, 0)[1] << "\" ";
  124. stream << "z=\"" << glm::row(mat, 0)[2] << "\" ";
  125. stream << "w=\"" << glm::row(mat, 0)[3] << "\" ";
  126. stream << "/>" << std::endl;
  127. stream << "<row ";
  128. stream << "x=\"" << glm::row(mat, 1)[0] << "\" ";
  129. stream << "y=\"" << glm::row(mat, 1)[1] << "\" ";
  130. stream << "z=\"" << glm::row(mat, 1)[2] << "\" ";
  131. stream << "w=\"" << glm::row(mat, 1)[3] << "\" ";
  132. stream << "/>" << std::endl;
  133. stream << "<row ";
  134. stream << "x=\"" << glm::row(mat, 2)[0] << "\" ";
  135. stream << "y=\"" << glm::row(mat, 2)[1] << "\" ";
  136. stream << "z=\"" << glm::row(mat, 2)[2] << "\" ";
  137. stream << "w=\"" << glm::row(mat, 2)[3] << "\" ";
  138. stream << "/>" << std::endl;
  139. stream << "<row ";
  140. stream << "x=\"" << glm::row(mat, 3)[0] << "\" ";
  141. stream << "y=\"" << glm::row(mat, 3)[1] << "\" ";
  142. stream << "z=\"" << glm::row(mat, 3)[2] << "\" ";
  143. stream << "w=\"" << glm::row(mat, 3)[3] << "\" ";
  144. stream << "/>" << std::endl;
  145. stream << "</glm_mat4>";
  146. return stream;
  147. }
  148. }//namespace detail
  149. }//namespace glm
  150. */
  151. #endif//GLM_VIRTREV_xstream