util.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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/util.h 26 3/14/02 4:21p Greg_h $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Commando Tools - W3D export *
  24. * *
  25. * $Archive:: /Commando/Code/Tools/max2w3d/util.h $*
  26. * *
  27. * $Author:: Greg_h $*
  28. * *
  29. * $Modtime:: 2/04/02 4:54p $*
  30. * *
  31. * $Revision:: 26 $*
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef UTIL_H
  37. #define UTIL_H
  38. #ifndef ALWAYS_H
  39. #include "always.h"
  40. #endif
  41. #include <Max.h>
  42. #include "skin.h"
  43. #include "nodelist.h"
  44. /*
  45. ** Gets rid of very small numbers in the matrix
  46. ** (sets them to zero).
  47. */
  48. Matrix3 Cleanup_Orthogonal_Matrix(Matrix3 & mat);
  49. float Compute_3x3_Determinant(const Matrix3 & tm);
  50. /*
  51. ** Naming utility functions
  52. */
  53. void Set_W3D_Name(char * set_name,const char * src);
  54. void Split_Node_Name(const char * name,char * set_base,char * set_exten,int * set_exten_index);
  55. bool Append_Lod_Character(char *meshname, int lod_level, INodeListClass *origin_list);
  56. /*
  57. ** File path utility functions
  58. */
  59. void Create_Full_Path(char *full_path, const char *cwd, const char *rel_path);
  60. void Create_Relative_Path(char *rel_path, const char *cwd, const char *full_path);
  61. bool Is_Full_Path(char * path);
  62. /*
  63. ** Check if this is some kind of triangle mesh inside of MAX. We will assume
  64. ** different default export behavior depending on whether the object is a
  65. ** triangle mesh or not.
  66. */
  67. bool Is_Max_Tri_Mesh(INode * node);
  68. /*
  69. ** Origin support.
  70. */
  71. bool Is_Origin(INode *node);
  72. bool Is_Base_Origin(INode *node);
  73. INode *Find_Origin(INode *node);
  74. bool Is_Damage_Root(INode *node);
  75. /*
  76. ** Lod-Level and Damage State settings for an INode
  77. */
  78. int Get_Lod_Level(INode *node);
  79. int Get_Damage_State(INode *node);
  80. /*
  81. ** Utility function to find a named node in a hierarchy.
  82. */
  83. INode *Find_Named_Node (char *nodename, INode *root);
  84. /*
  85. ** Macros
  86. */
  87. #define SAFE_DELETE(pobject) \
  88. if (pobject) { \
  89. delete pobject; \
  90. pobject = NULL; \
  91. } \
  92. #define SAFE_DELETE_ARRAY(pobject) \
  93. if (pobject) { \
  94. delete [] pobject; \
  95. pobject = NULL; \
  96. } \
  97. #endif