ModelOverlay.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __MODELOVERLAY_H__
  21. #define __MODELOVERLAY_H__
  22. /*
  23. ===============================================================================
  24. Render model overlay for adding decals on top of dynamic models.
  25. ===============================================================================
  26. */
  27. const int MAX_OVERLAY_SURFACES = 16;
  28. typedef struct overlayVertex_s {
  29. int vertexNum;
  30. float st[2];
  31. } overlayVertex_t;
  32. typedef struct overlaySurface_s {
  33. int surfaceNum;
  34. int surfaceId;
  35. int numIndexes;
  36. glIndex_t * indexes;
  37. int numVerts;
  38. overlayVertex_t * verts;
  39. } overlaySurface_t;
  40. typedef struct overlayMaterial_s {
  41. const idMaterial * material;
  42. idList<overlaySurface_t *> surfaces;
  43. } overlayMaterial_t;
  44. class idRenderModelOverlay {
  45. public:
  46. idRenderModelOverlay();
  47. ~idRenderModelOverlay();
  48. static idRenderModelOverlay *Alloc( void );
  49. static void Free( idRenderModelOverlay *overlay );
  50. // Projects an overlay onto deformable geometry and can be added to
  51. // a render entity to allow decals on top of dynamic models.
  52. // This does not generate tangent vectors, so it can't be used with
  53. // light interaction shaders. Materials for overlays should always
  54. // be clamped, because the projected texcoords can run well off the
  55. // texture since no new clip vertexes are generated.
  56. void CreateOverlay( const idRenderModel *model, const idPlane localTextureAxis[2], const idMaterial *material );
  57. // Creates new model surfaces for baseModel, which should be a static instantiation of a dynamic model.
  58. void AddOverlaySurfacesToModel( idRenderModel *baseModel );
  59. // Removes overlay surfaces from the model.
  60. static void RemoveOverlaySurfacesFromModel( idRenderModel *baseModel );
  61. void ReadFromDemoFile( class idDemoFile *f );
  62. void WriteToDemoFile( class idDemoFile *f ) const;
  63. private:
  64. idList<overlayMaterial_t *> materials;
  65. void FreeSurface( overlaySurface_t *surface );
  66. };
  67. #endif /* !__MODELOVERLAY_H__ */