vxl.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. /* $Header: /Commando/Code/Tools/max2w3d/vxl.h 4 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/vxl.h $*
  26. * *
  27. * $Author:: Greg_h $*
  28. * *
  29. * $Modtime:: 10/26/97 1:35p $*
  30. * *
  31. * $Revision:: 4 $*
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef VXL_H
  37. #define VXL_H
  38. #ifndef ALWAYS_H
  39. #include "always.h"
  40. #endif
  41. #include <Max.h>
  42. #ifndef NODELIST_H
  43. #include "nodelist.h"
  44. #endif
  45. #ifndef VXLLAYER_H
  46. #include "vxllayer.h"
  47. #endif
  48. #ifndef PROGRESS_H
  49. #include "progress.h"
  50. #endif
  51. /*
  52. This class is used to compute approximate physical properties of a polygon
  53. mesh or meshes. Some of these properties are listed below:
  54. - Moment of Inertia Tensor (with density factored out)
  55. - Center of Mass
  56. - Volume
  57. It is a cannibalized version of the code from the voxel plugin.
  58. */
  59. class VoxelClass
  60. {
  61. public:
  62. VoxelClass(
  63. INodeListClass & meshlist,
  64. int resolution,
  65. Matrix3 parenttm,
  66. TimeValue time,
  67. Progress_Meter_Class & meter
  68. );
  69. ~VoxelClass(void);
  70. int Get_Width() { return XDim; }
  71. int Get_Height() { return YDim; }
  72. int Num_Layers() { return ZDim; }
  73. uint8 Is_Solid(int i,int j,int k);
  74. void Compute_Physical_Properties(double Volume[1],double CM[3],double I[9]);
  75. private:
  76. int XDim;
  77. int YDim;
  78. int ZDim;
  79. double BlockXDim;
  80. double BlockYDim;
  81. double BlockZDim;
  82. unsigned char * VisData;
  83. float Resolution; // resolution of the voxel grid
  84. TimeValue CurTime;
  85. Point3 Offset;
  86. Point3 Size;
  87. Point3 Scale; // three scale values to fit the meshes into the desired grid
  88. Point3 BoxCorner[8]; // World-Space corners of the bounding box of the voxel space
  89. Matrix3 ParentTM; // coordinate system of the parent of this object.
  90. void raw_set_vis(int i,int j,int k,uint8 val);
  91. uint8 raw_read_vis(int i,int j,int k);
  92. int voxel_touches_space(int i,int j,int k);
  93. void purge_interior(void);
  94. void Quantize_Meshes
  95. (
  96. INodeListClass & meshlist,
  97. Progress_Meter_Class & meter
  98. );
  99. // set one layer of the voxel object
  100. void Set_Layer
  101. (
  102. VoxelLayerClass & layer,
  103. uint32 z
  104. );
  105. // compute the bounding box
  106. void Compute_Bounding_Box(Point3 size,Point3 offset);
  107. // 3D visibility
  108. void Compute_Visiblity(Progress_Meter_Class & meter);
  109. // returns the position of the center of voxel(i,j,k)
  110. Point3 Voxel_Position(int i,int j,int k);
  111. };
  112. #endif /*VXL_H*/