vxllayer.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. ** Command & Conquer Generals(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. /* $Header: /Commando/Code/Tools/max2w3d/vxllayer.h 3 10/28/97 6:08p Greg_h $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Commando Tools - W3D export *
  24. * *
  25. * $Archive:: /Commando/Code/Tools/max2w3d/vxllayer.h $*
  26. * *
  27. * $Author:: Greg_h $*
  28. * *
  29. * $Modtime:: 10/26/97 1:35p $*
  30. * *
  31. * $Revision:: 3 $*
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef VXLLAYER_H
  37. #define VXLLAYER_H
  38. #include <Max.h>
  39. #ifndef BITTYPE_H
  40. #include "bittype.h"
  41. #endif
  42. #ifndef NODELIST_H
  43. #include "nodelist.h"
  44. #endif
  45. const sint8 VOXEL_VISIBLE = 0; // voxels that are "outside" the object
  46. const sint8 VOXEL_SOLID = 1; // voxels that are part of the object
  47. const sint8 VOXEL_UNKNOWN = -1; // either inside or outside, don't know yet
  48. const int max_bitmap_width = 256;
  49. const int max_bitmap_height = 256;
  50. class VoxelLayerClass
  51. {
  52. public:
  53. VoxelLayerClass();
  54. VoxelLayerClass
  55. (
  56. INodeListClass & objectlist,
  57. TimeValue time,
  58. Matrix3 parenttm,
  59. Point3 offset,
  60. Point3 scale,
  61. float slicez,
  62. float sliceh,
  63. int bmwidth,
  64. int bmheight
  65. );
  66. ~VoxelLayerClass() {};
  67. BOOL Is_Visible( int x, int y )
  68. {
  69. if (x < 0 || x >= bitmap_width || y < 0 || y >= bitmap_height) {
  70. return TRUE;
  71. }
  72. if (Solid[x][y] == 0) {
  73. return TRUE;
  74. } else {
  75. return FALSE;
  76. }
  77. }
  78. BOOL Is_Solid( int x, int y )
  79. {
  80. if (x < 0 || x >= bitmap_width || y < 0 || y >= bitmap_height) {
  81. return FALSE;
  82. }
  83. if (Solid[x][y] == VOXEL_SOLID) {
  84. return TRUE;
  85. } else {
  86. return FALSE;
  87. }
  88. }
  89. unsigned int Get_Width(void) { return bitmap_width; }
  90. unsigned int Get_Height(void) { return bitmap_height; }
  91. protected:
  92. void Set_Visible ( int x, int y )
  93. {
  94. if (x >= 0 && x < bitmap_width && y >= 0 && y < bitmap_height && Solid[x][y] != VOXEL_SOLID )
  95. {
  96. Solid[x][y] = VOXEL_VISIBLE;
  97. }
  98. }
  99. void Add_Solid(int x,int y)
  100. {
  101. // check if the point is outside the bitmap:
  102. if (x >= 0 && x < bitmap_width && y >= 0 && y < bitmap_height) {
  103. Solid[x][y] = VOXEL_SOLID;
  104. }
  105. }
  106. // draw a line of voxels into the bitmap
  107. void Draw_Line(double x0,double y0,double x1,double y1);
  108. // draw the intersection between the triangle and the voxel plane
  109. void Intersect_Triangle(Point3 a,Point3 b,Point3 c,float z);
  110. // scan convert the polygon fragment in this voxel slab
  111. void Scan_Triangle(Point3 a,Point3 b,Point3 c);
  112. sint8 Solid[max_bitmap_width][max_bitmap_height];
  113. float SliceZ;
  114. float SliceH;
  115. float SliceZ0;
  116. float SliceZ1;
  117. int bitmap_width;
  118. int bitmap_height;
  119. };
  120. #endif /*VXLLAYER_H*/