shdloader.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : WWShade *
  23. * *
  24. * $Archive:: /Commando/Code/wwshade/shdloader.cpp $*
  25. * *
  26. * Org Author:: Kenny Mitchell *
  27. * *
  28. * Author : Kenny Mitchell *
  29. * *
  30. * $Modtime:: 06/27/02 3:51p $*
  31. * *
  32. * $Revision:: 1 $*
  33. * *
  34. * 06/26/02 KM Abstracting shader system
  35. *---------------------------------------------------------------------------------------------*/
  36. #include "shdloader.h"
  37. #include "shdmesh.h"
  38. #include "mesh.h"
  39. ShdMeshLoaderClass _ShdMeshLoader;
  40. ShdMeshLegacyLoaderClass _ShdMeshLegacyLoader;
  41. /***********************************************************************************************
  42. * ShdMeshLoaderClass::Load -- reads in a shader mesh and creates a prototype for it *
  43. * *
  44. * INPUT: *
  45. * *
  46. * OUTPUT: *
  47. * *
  48. * WARNINGS: *
  49. * *
  50. * HISTORY: *
  51. * 5/21/02 KJM : Created. *
  52. *=============================================================================================*/
  53. PrototypeClass* ShdMeshLoaderClass::Load_W3D(ChunkLoadClass& cload)
  54. {
  55. ShdMeshClass* mesh=NEW_REF(ShdMeshClass, ());
  56. if (mesh==NULL)
  57. {
  58. return NULL;
  59. }
  60. if (mesh->Load_W3D(cload)!=WW3D_ERROR_OK)
  61. {
  62. // if the load failed, delete the mesh
  63. assert(mesh->Num_Refs() == 1);
  64. mesh->Release_Ref();
  65. return NULL;
  66. }
  67. // create the prototype and add it to the lists
  68. PrimitivePrototypeClass * newproto = new PrimitivePrototypeClass(mesh);
  69. mesh->Release_Ref();
  70. return newproto;
  71. }
  72. PrototypeClass * ShdMeshLegacyLoaderClass::Load_W3D(ChunkLoadClass & cload)
  73. {
  74. MeshClass * mesh = NEW_REF( MeshClass, () );
  75. if (mesh == NULL) {
  76. return NULL;
  77. }
  78. if (mesh->Load_W3D(cload) != WW3D_ERROR_OK) {
  79. // if the load failed, delete the mesh
  80. assert(mesh->Num_Refs() == 1);
  81. mesh->Release_Ref();
  82. return NULL;
  83. } else {
  84. ShdMeshClass* shdmesh=NEW_REF( ShdMeshClass, () );
  85. shdmesh->Init_From_Legacy_Mesh(mesh);
  86. mesh->Release_Ref();
  87. // create the prototype and add it to the lists
  88. PrimitivePrototypeClass * newproto = W3DNEW PrimitivePrototypeClass(shdmesh);
  89. shdmesh->Release_Ref();
  90. return newproto;
  91. }
  92. }