cloud.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program 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. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #if 0 // TODO finish this some day...
  19. class CloudShadowClass : public VertexProcessorClass
  20. {
  21. public:
  22. CloudShadowClass(void);
  23. ~CloudShadowClass(void) {}
  24. // scene graph? transform into eye space
  25. void Set_Camera(const CameraClass & cam);
  26. // vertex processor interface
  27. virtual SRBOOL isActive(srVertexPipe&);
  28. virtual void process(srVertexPipe&);
  29. // fog volume interface
  30. float UOffset;
  31. float VOffset;
  32. Vector3 Center;
  33. Vector3 Scale;
  34. srMatrix4 modelview;
  35. protected:
  36. srColorSurfaceIFace *ShadowTexture;
  37. };
  38. CloudShadowClass::CloudShadowClass(void) :
  39. ShadowTexture(NULL),
  40. TextureWidth(0),
  41. TextureHeight(0),
  42. UOffset(0.0f),
  43. VOffset(0.0f),
  44. Center(0,0,0),
  45. Scale(75.0f,75.0f,1.0f)
  46. {
  47. ShadowTexture = srCore.getSurfaceIOManager()->importSurface( "clouds.tga" );
  48. TextureWidth = ShadowTexture->getWidth();
  49. TextureHeight = ShadowTexture->getHeight();
  50. }
  51. CloudShadowClass::~CloudShadowClass(void)
  52. {
  53. ShadowTexture->release();
  54. }
  55. void CloudShadowClass::Process_Push(srGERD * gerd)
  56. {
  57. // CloudShadows are applied in world space,
  58. srMatrix4 modelview;
  59. gerd.matrixMode(srGERD::MODELVIEW);
  60. gerd->getMatrix(modelView);
  61. modelview.invert();
  62. greg->pushVertexProcessor(*this);
  63. }
  64. void CloudShadowClass::Process_Pop(srGERD * gerd)
  65. {
  66. gerd->popVertexProcessor();
  67. }
  68. SRBOOL CloudShadowClass::isActive(srVertexPipe&)
  69. {
  70. return pipe.isChannelAvailable(CHANNEL_DIFFUSE);
  71. }
  72. void CloudShadowClass::process(srVertexPipe&)
  73. {
  74. // screen-mapped uv coordinates
  75. if (pipe.isChannelAvailable (CHANNEL_DIFFUSE))
  76. {
  77. int vnum = pipe.getVertexCount();
  78. srVector4 * loc = pipe.getEyeSpaceLocation(void);
  79. srVector4 * diffuse = pipe.getDiffuse(void);
  80. for (int vidx = 0; vidx < vnum; vidx++) {
  81. SRLONG x = (loc[vidx].x - Center.X) * TextureWidth / Scale.X;
  82. SRLONG y = (loc[vidx].y - Center.Y) * TextureHeight / Scale.Y;
  83. srARGB pixel = ShadowTexture->getPixel(x,y);
  84. diffuse[vidx].r = pixel.getRed();
  85. diffuse[vidx].g = pixel.getGreen();
  86. diffuse[vidx].b = pixel.getBlue();
  87. }
  88. }
  89. }
  90. #endif