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.
 
 
 
 
 
 

128 lines
3.4 KiB

  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2012, assimp team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the assimp team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the assimp team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. #if (!defined AV_BACKGROUND_H_INCLUDED)
  35. #define AV_BACKGROUND_H_INCLUDED
  36. class CBackgroundPainter
  37. {
  38. CBackgroundPainter()
  39. :
  40. clrColor(D3DCOLOR_ARGB(0xFF,100,100,100)),
  41. pcTexture(NULL),
  42. piSkyBoxEffect(NULL),
  43. eMode(SIMPLE_COLOR)
  44. {}
  45. public:
  46. // Supported background draw modi
  47. enum MODE {SIMPLE_COLOR, TEXTURE_2D, TEXTURE_CUBE};
  48. // Singleton accessors
  49. static CBackgroundPainter s_cInstance;
  50. inline static CBackgroundPainter& Instance ()
  51. {
  52. return s_cInstance;
  53. }
  54. // set the current background color
  55. // (this removes any textures loaded)
  56. void SetColor (D3DCOLOR p_clrNew);
  57. // Setup a cubemap/a 2d texture as background
  58. void SetCubeMapBG (const char* p_szPath);
  59. void SetTextureBG (const char* p_szPath);
  60. // Called by the render loop
  61. void OnPreRender();
  62. void OnPostRender();
  63. // Release any native resources associated with the instance
  64. void ReleaseNativeResource();
  65. // Recreate any native resources associated with the instance
  66. void RecreateNativeResource();
  67. // Rotate the skybox
  68. void RotateSB(const aiMatrix4x4* pm);
  69. // Reset the state of the skybox
  70. void ResetSB();
  71. inline MODE GetMode() const
  72. {
  73. return this->eMode;
  74. }
  75. inline IDirect3DBaseTexture9* GetTexture()
  76. {
  77. return this->pcTexture;
  78. }
  79. inline ID3DXBaseEffect* GetEffect()
  80. {
  81. return this->piSkyBoxEffect;
  82. }
  83. private:
  84. void RemoveSBDeps();
  85. // current background color
  86. D3DCOLOR clrColor;
  87. // current background texture
  88. IDirect3DBaseTexture9* pcTexture;
  89. ID3DXEffect* piSkyBoxEffect;
  90. // current background mode
  91. MODE eMode;
  92. // path to the texture
  93. std::string szPath;
  94. // transformation matrix for the skybox
  95. aiMatrix4x4 mMatrix;
  96. };
  97. #endif // !! AV_BACKGROUND_H_INCLUDED