/opengles/src/Material.cpp

http://ftk.googlecode.com/ · C++ · 84 lines · 24 code · 20 blank · 40 comment · 0 complexity · ad27dbb5ddc68a62d694dcb9bb1f4a3d MD5 · raw file

  1. // ==========================================================================
  2. //
  3. // material.cpp Rendering Context Class for 3D Rendering Library
  4. //
  5. // Coloring and Material Related Operations
  6. //
  7. // --------------------------------------------------------------------------
  8. //
  9. // 08-07-2003 Hans-Martin Will initial version
  10. //
  11. // --------------------------------------------------------------------------
  12. //
  13. // Copyright (c) 2004, Hans-Martin Will. All rights reserved.
  14. //
  15. // Redistribution and use in source and binary forms, with or without
  16. // modification, are permitted provided that the following conditions are
  17. // met:
  18. //
  19. // * Redistributions of source code must retain the above copyright
  20. // notice, this list of conditions and the following disclaimer.
  21. // * Redistributions in binary form must reproduce the above copyright
  22. // notice, this list of conditions and the following disclaimer in the
  23. // documentation and/or other materials provided with the distribution.
  24. //
  25. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  29. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  30. // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  31. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  32. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  33. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  34. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  35. // THE POSSIBILITY OF SUCH DAMAGE.
  36. //
  37. // ==========================================================================
  38. #include "stdafx.h"
  39. #include "Material.h"
  40. using namespace EGL;
  41. // ==========================================================================
  42. // Material Class Members
  43. // ==========================================================================
  44. Material :: Material():
  45. m_AmbientColor(F(0.2f), F(0.2f), F(0.2f), F(1.0f)),
  46. m_DiffuseColor(F(0.8f), F(0.8f), F(0.8f), F(1.0f)),
  47. m_SpecularExponent(0)
  48. {
  49. }
  50. void Material :: SetAmbientColor(const FractionalColor & color) {
  51. m_AmbientColor = color;
  52. }
  53. void Material :: SetDiffuseColor(const FractionalColor & color) {
  54. m_DiffuseColor = color;
  55. }
  56. void Material :: SetSpecularColor(const FractionalColor & color) {
  57. m_SpecularColor = color;
  58. }
  59. void Material :: SetEmissiveColor(const FractionalColor & color) {
  60. m_EmissiveColor = color;
  61. }
  62. void Material :: SetSpecularExponent(EGL_Fixed exponent) {
  63. m_SpecularExponent = EGL_CLAMP(exponent, 0, EGL_FixedFromInt(128));
  64. }