TerrainEditing.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. #ifndef TERRAINEDITING_H
  13. #define TERRAINEDITING_H
  14. #include <Engine/Terrain/TerrainEditing.h>
  15. #define FLT_FINEBLUR 0
  16. #define FLT_SHARPEN 1
  17. #define FLT_EMBOSS 2
  18. #define FLT_EDGEDETECT 3
  19. #define FLT_COUNT 4
  20. enum ETerrainEdit {
  21. TE_NONE,
  22. // brush based altitude editing tools
  23. TE_BRUSH_ALTITUDE_START,
  24. TE_BRUSH_ALTITUDE_PAINT,
  25. TE_BRUSH_ALTITUDE_SMOOTH,
  26. TE_BRUSH_ALTITUDE_FILTER,
  27. TE_BRUSH_ALTITUDE_MINIMUM,
  28. TE_BRUSH_ALTITUDE_MAXIMUM,
  29. TE_BRUSH_ALTITUDE_FLATTEN,
  30. TE_BRUSH_ALTITUDE_POSTERIZE,
  31. TE_BRUSH_ALTITUDE_RND_NOISE,
  32. TE_BRUSH_ALTITUDE_CONTINOUS_NOISE,
  33. TE_BRUSH_ALTITUDE_END,
  34. // brush based layer texture editing tools
  35. TE_BRUSH_LAYER_START,
  36. TE_BRUSH_LAYER_PAINT,
  37. TE_BRUSH_LAYER_SMOOTH,
  38. TE_BRUSH_LAYER_FILTER,
  39. TE_BRUSH_LAYER_RND_NOISE,
  40. TE_BRUSH_LAYER_CONTINOUS_NOISE,
  41. TE_BRUSH_LAYER_END,
  42. // edge editing tools
  43. TE_BRUSH_EDGE_START,
  44. TE_BRUSH_EDGE_ERASE,
  45. TE_BRUSH_EDGE_END,
  46. // whole terrain altitude operations
  47. TE_ALTITUDE_START,
  48. TE_ALTITUDE_SMOOTH,
  49. TE_ALTITUDE_FILTER,
  50. TE_ALTITUDE_MINIMUM,
  51. TE_ALTITUDE_MAXIMUM,
  52. TE_ALTITUDE_FLATTEN,
  53. TE_ALTITUDE_POSTERIZE,
  54. TE_ALTITUDE_RND_NOISE,
  55. TE_ALTITUDE_CONTINOUS_NOISE,
  56. TE_ALTITUDE_END,
  57. // generate terrain
  58. TE_GENERATE_TERRAIN,
  59. // equalize heightmap
  60. TE_ALTITUDE_EQUALIZE,
  61. // tile painting
  62. TE_TILE_PAINT,
  63. // whole layer operations
  64. TE_LAYER_START,
  65. TE_LAYER_SMOOTH,
  66. TE_LAYER_FILTER,
  67. TE_LAYER_RND_NOISE,
  68. TE_LAYER_CONTINOUS_NOISE,
  69. TE_CLEAR_LAYER_MASK,
  70. TE_FILL_LAYER_MASK,
  71. TE_LAYER_END,
  72. };
  73. class CTerrainUndo {
  74. public:
  75. ULONG tu_ulEntityID;
  76. UWORD *tu_puwUndoBuffer;
  77. UWORD *tu_puwRedoBuffer;
  78. Rect tu_rcRect;
  79. BufferType tu_btUndoBufferType;
  80. INDEX tu_iUndoBufferData;
  81. // constructor
  82. CTerrainUndo();
  83. };
  84. class CTileInfo {
  85. public:
  86. INDEX ti_ix;
  87. INDEX ti_iy;
  88. BOOL ti_bSwapXY;
  89. BOOL ti_bFlipX;
  90. BOOL ti_bFlipY;
  91. CTileInfo();
  92. };
  93. extern CTextureData *_ptdContinousRandomNoise;
  94. extern CTextureData *_ptdDistributionRandomNoise;
  95. BOOL SetupContinousNoiseTexture( void);
  96. void FreeContinousNoiseTexture( void);
  97. BOOL SetupDistributionNoiseTexture( void);
  98. void FreeDistributionNoiseTexture( void);
  99. void RandomizeWhiteNoise(void);
  100. FLOAT *GenerateTerrain_FBMBuffer(PIX pixW, PIX pixH, INDEX ctOctaves, FLOAT fHighFrequencyStep,
  101. FLOAT fStepFactor, FLOAT fMaxAmplitude, FLOAT fAmplitudeDecreaser,
  102. BOOL bAddNegativeValues, BOOL bRandomOffest, FLOAT &fMin, FLOAT &fMax);
  103. void GenerateLayerDistribution(INDEX iForLayer, Rect rect);
  104. void GenerateLayerDistribution(INDEX iLayer);
  105. void OptimizeLayers(void);
  106. void RecalculateShadows(void);
  107. void SetHMPixel( UWORD pix, INDEX x, INDEX y);
  108. UWORD GetHMPixel(INDEX x, INDEX y);
  109. void EditTerrain(CTextureData *ptdBrush, FLOAT3D &vHitPoint, FLOAT fStrength, ETerrainEdit teTool);
  110. void UpdateLayerDistribution(void);
  111. void ApplyFilterOntoTerrain(void);
  112. void ApplySmoothOntoTerrain(void);
  113. void ApplyContinousNoiseOntoTerrain(void);
  114. void ApplyRndNoiseOntoTerrain(void);
  115. void ApplyGenerateTerrain(void);
  116. void ApplyEqualizeOntoTerrain(void);
  117. void ApplyMinimumOntoTerrain(void);
  118. void ApplyMaximumOntoTerrain(void);
  119. void ApplyFlattenOntoTerrain(void);
  120. void ApplyPosterizeOntoTerrain(void);
  121. void DiscardLayerDistribution(Rect rect);
  122. void ApplyTerrainUndo(CTerrainUndo *ptrud);
  123. void ApplyTerrainRedo(CTerrainUndo *ptrud);
  124. void DeleteTerrainUndo(CWorldEditorDoc* pDoc);
  125. void TerrainEditBegin(void);
  126. void TerrainEditEnd(void);
  127. void ObtainLayerTileInfo(CDynamicContainer<CTileInfo> *pdcTileInfo, CTextureData *ptdTexture, INDEX &ctTilesPerRaw);
  128. #endif // TERRAINEDITING_H