draw_floor.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_DRAW_FLOOR_H
  9. #define IGL_DRAW_FLOOR_H
  10. #ifndef IGL_NO_OPENGL
  11. #include "igl_inline.h"
  12. namespace igl
  13. {
  14. // Draw a checkerboard floor aligned with current (X,Z) plane using OpenGL
  15. // calls. side=50 centered at (0,0):
  16. // (-25,-25)-->(-25,25)-->(25,25)-->(25,-25)
  17. //
  18. // Use glPushMatrix(), glScaled(), glTranslated() to arrange the floor.
  19. //
  20. // Inputs:
  21. // colorA float4 color
  22. // colorB float4 color
  23. //
  24. // Example:
  25. // // Draw a nice floor
  26. // glPushMatrix();
  27. // glCullFace(GL_BACK);
  28. // glEnable(GL_CULL_FACE);
  29. // glEnable(GL_LIGHTING);
  30. // glTranslated(0,-1,0);
  31. // if(project(Vector3d(0,0,0))(2) - project(Vector3d(0,1,0))(2) > -FLOAT_EPS)
  32. // {
  33. // draw_floor_outline();
  34. // }
  35. // draw_floor();
  36. // glPopMatrix();
  37. // glDisable(GL_CULL_FACE);
  38. //
  39. IGL_INLINE void draw_floor(
  40. const float * colorA,
  41. const float * colorB,
  42. const int GridSizeX=100,
  43. const int GridSizeY=100);
  44. // Wrapper with default colors
  45. IGL_INLINE void draw_floor();
  46. IGL_INLINE void draw_floor_outline(
  47. const float * colorA,
  48. const float * colorB,
  49. const int GridSizeX=100,
  50. const int GridSizeY=100);
  51. // Wrapper with default colors
  52. IGL_INLINE void draw_floor_outline();
  53. }
  54. #ifndef IGL_STATIC_LIBRARY
  55. # include "draw_floor.cpp"
  56. #endif
  57. #endif
  58. #endif