diff --git a/Core/Tools/CMakeLists.txt b/Core/Tools/CMakeLists.txt index cb47b91e401..381643f5731 100644 --- a/Core/Tools/CMakeLists.txt +++ b/Core/Tools/CMakeLists.txt @@ -8,4 +8,5 @@ endif() # Build less useful tool/test binaries. if(RTS_BUILD_CORE_EXTRAS) add_subdirectory(Compress) + add_subdirectory(WW3D) endif() diff --git a/Generals/Code/Tools/WW3D/CMakeLists.txt b/Core/Tools/WW3D/CMakeLists.txt similarity index 100% rename from Generals/Code/Tools/WW3D/CMakeLists.txt rename to Core/Tools/WW3D/CMakeLists.txt diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/AlphaModifier.cpp b/Core/Tools/WW3D/max2w3d/AlphaModifier.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/AlphaModifier.cpp rename to Core/Tools/WW3D/max2w3d/AlphaModifier.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/AlphaModifier.h b/Core/Tools/WW3D/max2w3d/AlphaModifier.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/AlphaModifier.h rename to Core/Tools/WW3D/max2w3d/AlphaModifier.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/AppData.cpp b/Core/Tools/WW3D/max2w3d/AppData.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/AppData.cpp rename to Core/Tools/WW3D/max2w3d/AppData.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/CMakeLists.txt b/Core/Tools/WW3D/max2w3d/CMakeLists.txt similarity index 88% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/CMakeLists.txt rename to Core/Tools/WW3D/max2w3d/CMakeLists.txt index 65242ec2fed..433365eb591 100644 --- a/GeneralsMD/Code/Tools/WW3D/max2w3d/CMakeLists.txt +++ b/Core/Tools/WW3D/max2w3d/CMakeLists.txt @@ -146,19 +146,19 @@ set(MAX2W3D_SRC "w3dutil.h" ) -add_library(z_max2w3d SHARED) -set_target_properties(z_max2w3d PROPERTIES OUTPUT_NAME max2w3d SUFFIX ".dle") +add_library(core_max2w3d SHARED) +set_target_properties(core_max2w3d PROPERTIES OUTPUT_NAME max2w3d SUFFIX ".dle") -target_include_directories(z_max2w3d PRIVATE +target_include_directories(core_max2w3d PRIVATE "../pluglib" ) -target_sources(z_max2w3d PRIVATE ${MAX2W3D_SRC}) +target_sources(core_max2w3d PRIVATE ${MAX2W3D_SRC}) # TODO: What does W3D_MAX4 do? Needs cmake option? -target_compile_definitions(z_max2w3d PRIVATE W3D_MAX4) +target_compile_definitions(core_max2w3d PRIVATE W3D_MAX4) -target_link_libraries(z_max2w3d PRIVATE +target_link_libraries(core_max2w3d PRIVATE Comctl32 # This is only linked to have its basetsd.h used instead of the vs6's basetsd.h # The headers typedef INT_PTR to different types, but maxsdk expects it @@ -166,11 +166,11 @@ target_link_libraries(z_max2w3d PRIVATE d3d8lib maxsdk winmm - z_pluglib + core_pluglib ) -set_target_properties(z_max2w3d PROPERTIES LINK_FLAGS "/DEF:max2w3d.def") +set_target_properties(core_max2w3d PROPERTIES LINK_FLAGS "/DEF:max2w3d.def") if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") - target_sources(z_max2w3d PRIVATE max2w3d.rc) + target_sources(core_max2w3d PRIVATE max2w3d.rc) endif() diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/ExportAll.cpp b/Core/Tools/WW3D/max2w3d/ExportAll.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/ExportAll.cpp rename to Core/Tools/WW3D/max2w3d/ExportAll.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/ExportAllDlg.cpp b/Core/Tools/WW3D/max2w3d/ExportAllDlg.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/ExportAllDlg.cpp rename to Core/Tools/WW3D/max2w3d/ExportAllDlg.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/ExportAllDlg.h b/Core/Tools/WW3D/max2w3d/ExportAllDlg.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/ExportAllDlg.h rename to Core/Tools/WW3D/max2w3d/ExportAllDlg.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/FormClass.cpp b/Core/Tools/WW3D/max2w3d/FormClass.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/FormClass.cpp rename to Core/Tools/WW3D/max2w3d/FormClass.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/FormClass.h b/Core/Tools/WW3D/max2w3d/FormClass.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/FormClass.h rename to Core/Tools/WW3D/max2w3d/FormClass.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtl.cpp b/Core/Tools/WW3D/max2w3d/GameMtl.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtl.cpp rename to Core/Tools/WW3D/max2w3d/GameMtl.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlDlg.cpp b/Core/Tools/WW3D/max2w3d/GameMtlDlg.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlDlg.cpp rename to Core/Tools/WW3D/max2w3d/GameMtlDlg.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlDlg.h b/Core/Tools/WW3D/max2w3d/GameMtlDlg.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlDlg.h rename to Core/Tools/WW3D/max2w3d/GameMtlDlg.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlForm.cpp b/Core/Tools/WW3D/max2w3d/GameMtlForm.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlForm.cpp rename to Core/Tools/WW3D/max2w3d/GameMtlForm.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlForm.h b/Core/Tools/WW3D/max2w3d/GameMtlForm.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlForm.h rename to Core/Tools/WW3D/max2w3d/GameMtlForm.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlPassDlg.cpp b/Core/Tools/WW3D/max2w3d/GameMtlPassDlg.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlPassDlg.cpp rename to Core/Tools/WW3D/max2w3d/GameMtlPassDlg.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlPassDlg.h b/Core/Tools/WW3D/max2w3d/GameMtlPassDlg.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlPassDlg.h rename to Core/Tools/WW3D/max2w3d/GameMtlPassDlg.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlShaderDlg.cpp b/Core/Tools/WW3D/max2w3d/GameMtlShaderDlg.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlShaderDlg.cpp rename to Core/Tools/WW3D/max2w3d/GameMtlShaderDlg.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlShaderDlg.h b/Core/Tools/WW3D/max2w3d/GameMtlShaderDlg.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlShaderDlg.h rename to Core/Tools/WW3D/max2w3d/GameMtlShaderDlg.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlTextureDlg.cpp b/Core/Tools/WW3D/max2w3d/GameMtlTextureDlg.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlTextureDlg.cpp rename to Core/Tools/WW3D/max2w3d/GameMtlTextureDlg.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlTextureDlg.h b/Core/Tools/WW3D/max2w3d/GameMtlTextureDlg.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlTextureDlg.h rename to Core/Tools/WW3D/max2w3d/GameMtlTextureDlg.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.cpp b/Core/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.cpp rename to Core/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.h b/Core/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.h rename to Core/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/InputDlg.cpp b/Core/Tools/WW3D/max2w3d/InputDlg.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/InputDlg.cpp rename to Core/Tools/WW3D/max2w3d/InputDlg.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/InputDlg.h b/Core/Tools/WW3D/max2w3d/InputDlg.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/InputDlg.h rename to Core/Tools/WW3D/max2w3d/InputDlg.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/LightGlareSave.cpp b/Core/Tools/WW3D/max2w3d/LightGlareSave.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/LightGlareSave.cpp rename to Core/Tools/WW3D/max2w3d/LightGlareSave.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/LightGlareSave.h b/Core/Tools/WW3D/max2w3d/LightGlareSave.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/LightGlareSave.h rename to Core/Tools/WW3D/max2w3d/LightGlareSave.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeform.cpp b/Core/Tools/WW3D/max2w3d/MeshDeform.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeform.cpp rename to Core/Tools/WW3D/max2w3d/MeshDeform.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeform.h b/Core/Tools/WW3D/max2w3d/MeshDeform.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeform.h rename to Core/Tools/WW3D/max2w3d/MeshDeform.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformData.cpp b/Core/Tools/WW3D/max2w3d/MeshDeformData.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformData.cpp rename to Core/Tools/WW3D/max2w3d/MeshDeformData.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformData.h b/Core/Tools/WW3D/max2w3d/MeshDeformData.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformData.h rename to Core/Tools/WW3D/max2w3d/MeshDeformData.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformDefs.h b/Core/Tools/WW3D/max2w3d/MeshDeformDefs.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformDefs.h rename to Core/Tools/WW3D/max2w3d/MeshDeformDefs.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformPanel.cpp b/Core/Tools/WW3D/max2w3d/MeshDeformPanel.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformPanel.cpp rename to Core/Tools/WW3D/max2w3d/MeshDeformPanel.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformPanel.h b/Core/Tools/WW3D/max2w3d/MeshDeformPanel.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformPanel.h rename to Core/Tools/WW3D/max2w3d/MeshDeformPanel.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformSave.cpp b/Core/Tools/WW3D/max2w3d/MeshDeformSave.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformSave.cpp rename to Core/Tools/WW3D/max2w3d/MeshDeformSave.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformSave.h b/Core/Tools/WW3D/max2w3d/MeshDeformSave.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformSave.h rename to Core/Tools/WW3D/max2w3d/MeshDeformSave.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformSaveDefs.h b/Core/Tools/WW3D/max2w3d/MeshDeformSaveDefs.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformSaveDefs.h rename to Core/Tools/WW3D/max2w3d/MeshDeformSaveDefs.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformSaveSet.cpp b/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformSaveSet.cpp rename to Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformSaveSet.h b/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformSaveSet.h rename to Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformSet.cpp b/Core/Tools/WW3D/max2w3d/MeshDeformSet.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformSet.cpp rename to Core/Tools/WW3D/max2w3d/MeshDeformSet.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformSet.h b/Core/Tools/WW3D/max2w3d/MeshDeformSet.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformSet.h rename to Core/Tools/WW3D/max2w3d/MeshDeformSet.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformUndo.cpp b/Core/Tools/WW3D/max2w3d/MeshDeformUndo.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformUndo.cpp rename to Core/Tools/WW3D/max2w3d/MeshDeformUndo.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformUndo.h b/Core/Tools/WW3D/max2w3d/MeshDeformUndo.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/MeshDeformUndo.h rename to Core/Tools/WW3D/max2w3d/MeshDeformUndo.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/PCToPS2Material.cpp b/Core/Tools/WW3D/max2w3d/PCToPS2Material.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/PCToPS2Material.cpp rename to Core/Tools/WW3D/max2w3d/PCToPS2Material.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/PS2GameMtl.cpp b/Core/Tools/WW3D/max2w3d/PS2GameMtl.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/PS2GameMtl.cpp rename to Core/Tools/WW3D/max2w3d/PS2GameMtl.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.cpp b/Core/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.cpp rename to Core/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.h b/Core/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.h rename to Core/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.h diff --git a/Generals/Code/Tools/WW3D/max2w3d/Res/DISK12.ICO b/Core/Tools/WW3D/max2w3d/Res/DISK12.ICO similarity index 100% rename from Generals/Code/Tools/WW3D/max2w3d/Res/DISK12.ICO rename to Core/Tools/WW3D/max2w3d/Res/DISK12.ICO diff --git a/Generals/Code/Tools/WW3D/max2w3d/Res/one.bmp b/Core/Tools/WW3D/max2w3d/Res/one.bmp similarity index 100% rename from Generals/Code/Tools/WW3D/max2w3d/Res/one.bmp rename to Core/Tools/WW3D/max2w3d/Res/one.bmp diff --git a/Generals/Code/Tools/WW3D/max2w3d/Res/orig.ico b/Core/Tools/WW3D/max2w3d/Res/orig.ico similarity index 100% rename from Generals/Code/Tools/WW3D/max2w3d/Res/orig.ico rename to Core/Tools/WW3D/max2w3d/Res/orig.ico diff --git a/Generals/Code/Tools/WW3D/max2w3d/Res/orig1.ico b/Core/Tools/WW3D/max2w3d/Res/orig1.ico similarity index 100% rename from Generals/Code/Tools/WW3D/max2w3d/Res/orig1.ico rename to Core/Tools/WW3D/max2w3d/Res/orig1.ico diff --git a/Generals/Code/Tools/WW3D/max2w3d/Res/two.bmp b/Core/Tools/WW3D/max2w3d/Res/two.bmp similarity index 100% rename from Generals/Code/Tools/WW3D/max2w3d/Res/two.bmp rename to Core/Tools/WW3D/max2w3d/Res/two.bmp diff --git a/Generals/Code/Tools/WW3D/max2w3d/Res/ww3d.bmp b/Core/Tools/WW3D/max2w3d/Res/ww3d.bmp similarity index 100% rename from Generals/Code/Tools/WW3D/max2w3d/Res/ww3d.bmp rename to Core/Tools/WW3D/max2w3d/Res/ww3d.bmp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/SceneSetup.cpp b/Core/Tools/WW3D/max2w3d/SceneSetup.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/SceneSetup.cpp rename to Core/Tools/WW3D/max2w3d/SceneSetup.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/SceneSetupDlg.cpp b/Core/Tools/WW3D/max2w3d/SceneSetupDlg.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/SceneSetupDlg.cpp rename to Core/Tools/WW3D/max2w3d/SceneSetupDlg.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/SceneSetupDlg.h b/Core/Tools/WW3D/max2w3d/SceneSetupDlg.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/SceneSetupDlg.h rename to Core/Tools/WW3D/max2w3d/SceneSetupDlg.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/SkinCopy.cpp b/Core/Tools/WW3D/max2w3d/SkinCopy.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/SkinCopy.cpp rename to Core/Tools/WW3D/max2w3d/SkinCopy.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/SnapPoints.cpp b/Core/Tools/WW3D/max2w3d/SnapPoints.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/SnapPoints.cpp rename to Core/Tools/WW3D/max2w3d/SnapPoints.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/SnapPoints.h b/Core/Tools/WW3D/max2w3d/SnapPoints.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/SnapPoints.h rename to Core/Tools/WW3D/max2w3d/SnapPoints.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/TARGA.CPP b/Core/Tools/WW3D/max2w3d/TARGA.CPP similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/TARGA.CPP rename to Core/Tools/WW3D/max2w3d/TARGA.CPP diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/TARGA.H b/Core/Tools/WW3D/max2w3d/TARGA.H similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/TARGA.H rename to Core/Tools/WW3D/max2w3d/TARGA.H diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/Utility.cpp b/Core/Tools/WW3D/max2w3d/Utility.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/Utility.cpp rename to Core/Tools/WW3D/max2w3d/Utility.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/aabtreebuilder.cpp b/Core/Tools/WW3D/max2w3d/aabtreebuilder.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/aabtreebuilder.cpp rename to Core/Tools/WW3D/max2w3d/aabtreebuilder.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/aabtreebuilder.h b/Core/Tools/WW3D/max2w3d/aabtreebuilder.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/aabtreebuilder.h rename to Core/Tools/WW3D/max2w3d/aabtreebuilder.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/animationcompressionsettings.cpp b/Core/Tools/WW3D/max2w3d/animationcompressionsettings.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/animationcompressionsettings.cpp rename to Core/Tools/WW3D/max2w3d/animationcompressionsettings.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/animationcompressionsettings.h b/Core/Tools/WW3D/max2w3d/animationcompressionsettings.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/animationcompressionsettings.h rename to Core/Tools/WW3D/max2w3d/animationcompressionsettings.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/bchannel.cpp b/Core/Tools/WW3D/max2w3d/bchannel.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/bchannel.cpp rename to Core/Tools/WW3D/max2w3d/bchannel.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/bchannel.h b/Core/Tools/WW3D/max2w3d/bchannel.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/bchannel.h rename to Core/Tools/WW3D/max2w3d/bchannel.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/boneicon.cpp b/Core/Tools/WW3D/max2w3d/boneicon.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/boneicon.cpp rename to Core/Tools/WW3D/max2w3d/boneicon.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/boneicon.h b/Core/Tools/WW3D/max2w3d/boneicon.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/boneicon.h rename to Core/Tools/WW3D/max2w3d/boneicon.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/bpick.cpp b/Core/Tools/WW3D/max2w3d/bpick.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/bpick.cpp rename to Core/Tools/WW3D/max2w3d/bpick.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/bpick.h b/Core/Tools/WW3D/max2w3d/bpick.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/bpick.h rename to Core/Tools/WW3D/max2w3d/bpick.h diff --git a/Generals/Code/Tools/WW3D/max2w3d/changes.txt b/Core/Tools/WW3D/max2w3d/changes.txt similarity index 100% rename from Generals/Code/Tools/WW3D/max2w3d/changes.txt rename to Core/Tools/WW3D/max2w3d/changes.txt diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/colboxsave.cpp b/Core/Tools/WW3D/max2w3d/colboxsave.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/colboxsave.cpp rename to Core/Tools/WW3D/max2w3d/colboxsave.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/colboxsave.h b/Core/Tools/WW3D/max2w3d/colboxsave.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/colboxsave.h rename to Core/Tools/WW3D/max2w3d/colboxsave.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/dazzlesave.cpp b/Core/Tools/WW3D/max2w3d/dazzlesave.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/dazzlesave.cpp rename to Core/Tools/WW3D/max2w3d/dazzlesave.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/dazzlesave.h b/Core/Tools/WW3D/max2w3d/dazzlesave.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/dazzlesave.h rename to Core/Tools/WW3D/max2w3d/dazzlesave.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/dllmain.cpp b/Core/Tools/WW3D/max2w3d/dllmain.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/dllmain.cpp rename to Core/Tools/WW3D/max2w3d/dllmain.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/dllmain.h b/Core/Tools/WW3D/max2w3d/dllmain.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/dllmain.h rename to Core/Tools/WW3D/max2w3d/dllmain.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/exportlog.cpp b/Core/Tools/WW3D/max2w3d/exportlog.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/exportlog.cpp rename to Core/Tools/WW3D/max2w3d/exportlog.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/exportlog.h b/Core/Tools/WW3D/max2w3d/exportlog.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/exportlog.h rename to Core/Tools/WW3D/max2w3d/exportlog.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/floaterdialog.cpp b/Core/Tools/WW3D/max2w3d/floaterdialog.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/floaterdialog.cpp rename to Core/Tools/WW3D/max2w3d/floaterdialog.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/floaterdialog.h b/Core/Tools/WW3D/max2w3d/floaterdialog.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/floaterdialog.h rename to Core/Tools/WW3D/max2w3d/floaterdialog.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/gamemaps.cpp b/Core/Tools/WW3D/max2w3d/gamemaps.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/gamemaps.cpp rename to Core/Tools/WW3D/max2w3d/gamemaps.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/gamemaps.h b/Core/Tools/WW3D/max2w3d/gamemaps.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/gamemaps.h rename to Core/Tools/WW3D/max2w3d/gamemaps.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/gamemtl.h b/Core/Tools/WW3D/max2w3d/gamemtl.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/gamemtl.h rename to Core/Tools/WW3D/max2w3d/gamemtl.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/genlodextensiondialog.cpp b/Core/Tools/WW3D/max2w3d/genlodextensiondialog.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/genlodextensiondialog.cpp rename to Core/Tools/WW3D/max2w3d/genlodextensiondialog.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/genlodextensiondialog.h b/Core/Tools/WW3D/max2w3d/genlodextensiondialog.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/genlodextensiondialog.h rename to Core/Tools/WW3D/max2w3d/genlodextensiondialog.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/genmtlnamesdialog.cpp b/Core/Tools/WW3D/max2w3d/genmtlnamesdialog.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/genmtlnamesdialog.cpp rename to Core/Tools/WW3D/max2w3d/genmtlnamesdialog.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/genmtlnamesdialog.h b/Core/Tools/WW3D/max2w3d/genmtlnamesdialog.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/genmtlnamesdialog.h rename to Core/Tools/WW3D/max2w3d/genmtlnamesdialog.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/gennamesdialog.cpp b/Core/Tools/WW3D/max2w3d/gennamesdialog.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/gennamesdialog.cpp rename to Core/Tools/WW3D/max2w3d/gennamesdialog.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/gennamesdialog.h b/Core/Tools/WW3D/max2w3d/gennamesdialog.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/gennamesdialog.h rename to Core/Tools/WW3D/max2w3d/gennamesdialog.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/geometryexportcontext.h b/Core/Tools/WW3D/max2w3d/geometryexportcontext.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/geometryexportcontext.h rename to Core/Tools/WW3D/max2w3d/geometryexportcontext.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/geometryexporttask.cpp b/Core/Tools/WW3D/max2w3d/geometryexporttask.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/geometryexporttask.cpp rename to Core/Tools/WW3D/max2w3d/geometryexporttask.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/geometryexporttask.h b/Core/Tools/WW3D/max2w3d/geometryexporttask.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/geometryexporttask.h rename to Core/Tools/WW3D/max2w3d/geometryexporttask.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/gmtldlg.cpp b/Core/Tools/WW3D/max2w3d/gmtldlg.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/gmtldlg.cpp rename to Core/Tools/WW3D/max2w3d/gmtldlg.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/gridsnapmodifier.cpp b/Core/Tools/WW3D/max2w3d/gridsnapmodifier.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/gridsnapmodifier.cpp rename to Core/Tools/WW3D/max2w3d/gridsnapmodifier.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/gridsnapmodifier.h b/Core/Tools/WW3D/max2w3d/gridsnapmodifier.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/gridsnapmodifier.h rename to Core/Tools/WW3D/max2w3d/gridsnapmodifier.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/hiersave.cpp b/Core/Tools/WW3D/max2w3d/hiersave.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/hiersave.cpp rename to Core/Tools/WW3D/max2w3d/hiersave.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/hiersave.h b/Core/Tools/WW3D/max2w3d/hiersave.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/hiersave.h rename to Core/Tools/WW3D/max2w3d/hiersave.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/hlodsave.cpp b/Core/Tools/WW3D/max2w3d/hlodsave.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/hlodsave.cpp rename to Core/Tools/WW3D/max2w3d/hlodsave.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/hlodsave.h b/Core/Tools/WW3D/max2w3d/hlodsave.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/hlodsave.h rename to Core/Tools/WW3D/max2w3d/hlodsave.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/logdlg.cpp b/Core/Tools/WW3D/max2w3d/logdlg.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/logdlg.cpp rename to Core/Tools/WW3D/max2w3d/logdlg.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/logdlg.h b/Core/Tools/WW3D/max2w3d/logdlg.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/logdlg.h rename to Core/Tools/WW3D/max2w3d/logdlg.h diff --git a/Generals/Code/Tools/WW3D/max2w3d/max2w3d.def b/Core/Tools/WW3D/max2w3d/max2w3d.def similarity index 100% rename from Generals/Code/Tools/WW3D/max2w3d/max2w3d.def rename to Core/Tools/WW3D/max2w3d/max2w3d.def diff --git a/Generals/Code/Tools/WW3D/max2w3d/max2w3d.rc b/Core/Tools/WW3D/max2w3d/max2w3d.rc similarity index 100% rename from Generals/Code/Tools/WW3D/max2w3d/max2w3d.rc rename to Core/Tools/WW3D/max2w3d/max2w3d.rc diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/maxworldinfo.cpp b/Core/Tools/WW3D/max2w3d/maxworldinfo.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/maxworldinfo.cpp rename to Core/Tools/WW3D/max2w3d/maxworldinfo.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/maxworldinfo.h b/Core/Tools/WW3D/max2w3d/maxworldinfo.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/maxworldinfo.h rename to Core/Tools/WW3D/max2w3d/maxworldinfo.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/meshbuild.cpp b/Core/Tools/WW3D/max2w3d/meshbuild.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/meshbuild.cpp rename to Core/Tools/WW3D/max2w3d/meshbuild.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/meshbuild.h b/Core/Tools/WW3D/max2w3d/meshbuild.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/meshbuild.h rename to Core/Tools/WW3D/max2w3d/meshbuild.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/meshcon.cpp b/Core/Tools/WW3D/max2w3d/meshcon.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/meshcon.cpp rename to Core/Tools/WW3D/max2w3d/meshcon.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/meshcon.h b/Core/Tools/WW3D/max2w3d/meshcon.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/meshcon.h rename to Core/Tools/WW3D/max2w3d/meshcon.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/meshsave.cpp b/Core/Tools/WW3D/max2w3d/meshsave.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/meshsave.cpp rename to Core/Tools/WW3D/max2w3d/meshsave.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/meshsave.h b/Core/Tools/WW3D/max2w3d/meshsave.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/meshsave.h rename to Core/Tools/WW3D/max2w3d/meshsave.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/motion.cpp b/Core/Tools/WW3D/max2w3d/motion.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/motion.cpp rename to Core/Tools/WW3D/max2w3d/motion.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/motion.h b/Core/Tools/WW3D/max2w3d/motion.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/motion.h rename to Core/Tools/WW3D/max2w3d/motion.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/namedsel.cpp b/Core/Tools/WW3D/max2w3d/namedsel.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/namedsel.cpp rename to Core/Tools/WW3D/max2w3d/namedsel.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/namedsel.h b/Core/Tools/WW3D/max2w3d/namedsel.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/namedsel.h rename to Core/Tools/WW3D/max2w3d/namedsel.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/nullsave.cpp b/Core/Tools/WW3D/max2w3d/nullsave.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/nullsave.cpp rename to Core/Tools/WW3D/max2w3d/nullsave.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/nullsave.h b/Core/Tools/WW3D/max2w3d/nullsave.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/nullsave.h rename to Core/Tools/WW3D/max2w3d/nullsave.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/presetexportoptionsdialog.cpp b/Core/Tools/WW3D/max2w3d/presetexportoptionsdialog.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/presetexportoptionsdialog.cpp rename to Core/Tools/WW3D/max2w3d/presetexportoptionsdialog.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/presetexportoptionsdialog.h b/Core/Tools/WW3D/max2w3d/presetexportoptionsdialog.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/presetexportoptionsdialog.h rename to Core/Tools/WW3D/max2w3d/presetexportoptionsdialog.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/rcmenu.cpp b/Core/Tools/WW3D/max2w3d/rcmenu.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/rcmenu.cpp rename to Core/Tools/WW3D/max2w3d/rcmenu.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/rcmenu.h b/Core/Tools/WW3D/max2w3d/rcmenu.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/rcmenu.h rename to Core/Tools/WW3D/max2w3d/rcmenu.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/resource.h b/Core/Tools/WW3D/max2w3d/resource.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/resource.h rename to Core/Tools/WW3D/max2w3d/resource.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/simpdib.cpp b/Core/Tools/WW3D/max2w3d/simpdib.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/simpdib.cpp rename to Core/Tools/WW3D/max2w3d/simpdib.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/simpdib.h b/Core/Tools/WW3D/max2w3d/simpdib.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/simpdib.h rename to Core/Tools/WW3D/max2w3d/simpdib.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/skin.cpp b/Core/Tools/WW3D/max2w3d/skin.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/skin.cpp rename to Core/Tools/WW3D/max2w3d/skin.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/skin.h b/Core/Tools/WW3D/max2w3d/skin.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/skin.h rename to Core/Tools/WW3D/max2w3d/skin.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/skindata.cpp b/Core/Tools/WW3D/max2w3d/skindata.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/skindata.cpp rename to Core/Tools/WW3D/max2w3d/skindata.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/skindata.h b/Core/Tools/WW3D/max2w3d/skindata.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/skindata.h rename to Core/Tools/WW3D/max2w3d/skindata.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/util.cpp b/Core/Tools/WW3D/max2w3d/util.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/util.cpp rename to Core/Tools/WW3D/max2w3d/util.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/util.h b/Core/Tools/WW3D/max2w3d/util.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/util.h rename to Core/Tools/WW3D/max2w3d/util.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/vchannel.cpp b/Core/Tools/WW3D/max2w3d/vchannel.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/vchannel.cpp rename to Core/Tools/WW3D/max2w3d/vchannel.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/vchannel.h b/Core/Tools/WW3D/max2w3d/vchannel.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/vchannel.h rename to Core/Tools/WW3D/max2w3d/vchannel.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/vxl.cpp b/Core/Tools/WW3D/max2w3d/vxl.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/vxl.cpp rename to Core/Tools/WW3D/max2w3d/vxl.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/vxl.h b/Core/Tools/WW3D/max2w3d/vxl.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/vxl.h rename to Core/Tools/WW3D/max2w3d/vxl.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/vxldbg.cpp b/Core/Tools/WW3D/max2w3d/vxldbg.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/vxldbg.cpp rename to Core/Tools/WW3D/max2w3d/vxldbg.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/vxldbg.h b/Core/Tools/WW3D/max2w3d/vxldbg.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/vxldbg.h rename to Core/Tools/WW3D/max2w3d/vxldbg.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/vxllayer.cpp b/Core/Tools/WW3D/max2w3d/vxllayer.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/vxllayer.cpp rename to Core/Tools/WW3D/max2w3d/vxllayer.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/vxllayer.h b/Core/Tools/WW3D/max2w3d/vxllayer.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/vxllayer.h rename to Core/Tools/WW3D/max2w3d/vxllayer.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/w3d_file.h b/Core/Tools/WW3D/max2w3d/w3d_file.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/w3d_file.h rename to Core/Tools/WW3D/max2w3d/w3d_file.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/w3d_obsolete.h b/Core/Tools/WW3D/max2w3d/w3d_obsolete.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/w3d_obsolete.h rename to Core/Tools/WW3D/max2w3d/w3d_obsolete.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/w3dappdata.cpp b/Core/Tools/WW3D/max2w3d/w3dappdata.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/w3dappdata.cpp rename to Core/Tools/WW3D/max2w3d/w3dappdata.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/w3dappdata.h b/Core/Tools/WW3D/max2w3d/w3dappdata.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/w3dappdata.h rename to Core/Tools/WW3D/max2w3d/w3dappdata.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/w3ddesc.cpp b/Core/Tools/WW3D/max2w3d/w3ddesc.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/w3ddesc.cpp rename to Core/Tools/WW3D/max2w3d/w3ddesc.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/w3ddesc.h b/Core/Tools/WW3D/max2w3d/w3ddesc.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/w3ddesc.h rename to Core/Tools/WW3D/max2w3d/w3ddesc.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/w3ddlg.cpp b/Core/Tools/WW3D/max2w3d/w3ddlg.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/w3ddlg.cpp rename to Core/Tools/WW3D/max2w3d/w3ddlg.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/w3ddlg.h b/Core/Tools/WW3D/max2w3d/w3ddlg.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/w3ddlg.h rename to Core/Tools/WW3D/max2w3d/w3ddlg.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/w3dexp.cpp b/Core/Tools/WW3D/max2w3d/w3dexp.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/w3dexp.cpp rename to Core/Tools/WW3D/max2w3d/w3dexp.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/w3dexp.h b/Core/Tools/WW3D/max2w3d/w3dexp.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/w3dexp.h rename to Core/Tools/WW3D/max2w3d/w3dexp.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/w3dmtl.cpp b/Core/Tools/WW3D/max2w3d/w3dmtl.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/w3dmtl.cpp rename to Core/Tools/WW3D/max2w3d/w3dmtl.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/w3dmtl.h b/Core/Tools/WW3D/max2w3d/w3dmtl.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/w3dmtl.h rename to Core/Tools/WW3D/max2w3d/w3dmtl.h diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/w3dutil.cpp b/Core/Tools/WW3D/max2w3d/w3dutil.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/w3dutil.cpp rename to Core/Tools/WW3D/max2w3d/w3dutil.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/w3dutil.h b/Core/Tools/WW3D/max2w3d/w3dutil.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/max2w3d/w3dutil.h rename to Core/Tools/WW3D/max2w3d/w3dutil.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/BITTYPE.H b/Core/Tools/WW3D/pluglib/BITTYPE.H similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/BITTYPE.H rename to Core/Tools/WW3D/pluglib/BITTYPE.H diff --git a/Generals/Code/Tools/WW3D/pluglib/CMakeLists.txt b/Core/Tools/WW3D/pluglib/CMakeLists.txt similarity index 80% rename from Generals/Code/Tools/WW3D/pluglib/CMakeLists.txt rename to Core/Tools/WW3D/pluglib/CMakeLists.txt index 11d7770c53d..9b286ad6598 100644 --- a/Generals/Code/Tools/WW3D/pluglib/CMakeLists.txt +++ b/Core/Tools/WW3D/pluglib/CMakeLists.txt @@ -53,9 +53,9 @@ set(PLUGLIB_SRC "WWmatrix3.h" ) -add_library(g_pluglib STATIC) -set_target_properties(g_pluglib PROPERTIES OUTPUT_NAME pluglib) +add_library(core_pluglib STATIC) +set_target_properties(core_pluglib PROPERTIES OUTPUT_NAME pluglib) -target_sources(g_pluglib PRIVATE ${PLUGLIB_SRC}) +target_sources(core_pluglib PRIVATE ${PLUGLIB_SRC}) -target_link_libraries(g_pluglib PRIVATE maxsdk) +target_link_libraries(core_pluglib PRIVATE maxsdk) diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/EULER.CPP b/Core/Tools/WW3D/pluglib/EULER.CPP similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/EULER.CPP rename to Core/Tools/WW3D/pluglib/EULER.CPP diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/EULER.H b/Core/Tools/WW3D/pluglib/EULER.H similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/EULER.H rename to Core/Tools/WW3D/pluglib/EULER.H diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/PROGRESS.H b/Core/Tools/WW3D/pluglib/PROGRESS.H similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/PROGRESS.H rename to Core/Tools/WW3D/pluglib/PROGRESS.H diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/Vector.CPP b/Core/Tools/WW3D/pluglib/Vector.CPP similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/Vector.CPP rename to Core/Tools/WW3D/pluglib/Vector.CPP diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/Vector.H b/Core/Tools/WW3D/pluglib/Vector.H similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/Vector.H rename to Core/Tools/WW3D/pluglib/Vector.H diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/WWmatrix3.cpp b/Core/Tools/WW3D/pluglib/WWmatrix3.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/WWmatrix3.cpp rename to Core/Tools/WW3D/pluglib/WWmatrix3.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/WWmatrix3.h b/Core/Tools/WW3D/pluglib/WWmatrix3.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/WWmatrix3.h rename to Core/Tools/WW3D/pluglib/WWmatrix3.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/aaplane.h b/Core/Tools/WW3D/pluglib/aaplane.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/aaplane.h rename to Core/Tools/WW3D/pluglib/aaplane.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/always.h b/Core/Tools/WW3D/pluglib/always.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/always.h rename to Core/Tools/WW3D/pluglib/always.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/bool.h b/Core/Tools/WW3D/pluglib/bool.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/bool.h rename to Core/Tools/WW3D/pluglib/bool.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/borlandc.h b/Core/Tools/WW3D/pluglib/borlandc.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/borlandc.h rename to Core/Tools/WW3D/pluglib/borlandc.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/chunkio.cpp b/Core/Tools/WW3D/pluglib/chunkio.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/chunkio.cpp rename to Core/Tools/WW3D/pluglib/chunkio.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/chunkio.h b/Core/Tools/WW3D/pluglib/chunkio.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/chunkio.h rename to Core/Tools/WW3D/pluglib/chunkio.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/errclass.h b/Core/Tools/WW3D/pluglib/errclass.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/errclass.h rename to Core/Tools/WW3D/pluglib/errclass.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/hashcalc.h b/Core/Tools/WW3D/pluglib/hashcalc.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/hashcalc.h rename to Core/Tools/WW3D/pluglib/hashcalc.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/hsv.cpp b/Core/Tools/WW3D/pluglib/hsv.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/hsv.cpp rename to Core/Tools/WW3D/pluglib/hsv.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/hsv.h b/Core/Tools/WW3D/pluglib/hsv.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/hsv.h rename to Core/Tools/WW3D/pluglib/hsv.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/iostruct.h b/Core/Tools/WW3D/pluglib/iostruct.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/iostruct.h rename to Core/Tools/WW3D/pluglib/iostruct.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/jshell.cpp b/Core/Tools/WW3D/pluglib/jshell.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/jshell.cpp rename to Core/Tools/WW3D/pluglib/jshell.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/matrix3d.cpp b/Core/Tools/WW3D/pluglib/matrix3d.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/matrix3d.cpp rename to Core/Tools/WW3D/pluglib/matrix3d.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/matrix3d.h b/Core/Tools/WW3D/pluglib/matrix3d.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/matrix3d.h rename to Core/Tools/WW3D/pluglib/matrix3d.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/matrix4.cpp b/Core/Tools/WW3D/pluglib/matrix4.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/matrix4.cpp rename to Core/Tools/WW3D/pluglib/matrix4.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/matrix4.h b/Core/Tools/WW3D/pluglib/matrix4.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/matrix4.h rename to Core/Tools/WW3D/pluglib/matrix4.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/nodefilt.cpp b/Core/Tools/WW3D/pluglib/nodefilt.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/nodefilt.cpp rename to Core/Tools/WW3D/pluglib/nodefilt.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/nodefilt.h b/Core/Tools/WW3D/pluglib/nodefilt.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/nodefilt.h rename to Core/Tools/WW3D/pluglib/nodefilt.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/nodelist.cpp b/Core/Tools/WW3D/pluglib/nodelist.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/nodelist.cpp rename to Core/Tools/WW3D/pluglib/nodelist.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/nodelist.h b/Core/Tools/WW3D/pluglib/nodelist.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/nodelist.h rename to Core/Tools/WW3D/pluglib/nodelist.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/noinit.h b/Core/Tools/WW3D/pluglib/noinit.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/noinit.h rename to Core/Tools/WW3D/pluglib/noinit.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/palette.cpp b/Core/Tools/WW3D/pluglib/palette.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/palette.cpp rename to Core/Tools/WW3D/pluglib/palette.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/palette.h b/Core/Tools/WW3D/pluglib/palette.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/palette.h rename to Core/Tools/WW3D/pluglib/palette.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/plane.h b/Core/Tools/WW3D/pluglib/plane.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/plane.h rename to Core/Tools/WW3D/pluglib/plane.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/rawfile.cpp b/Core/Tools/WW3D/pluglib/rawfile.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/rawfile.cpp rename to Core/Tools/WW3D/pluglib/rawfile.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/rawfile.h b/Core/Tools/WW3D/pluglib/rawfile.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/rawfile.h rename to Core/Tools/WW3D/pluglib/rawfile.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/realcrc.cpp b/Core/Tools/WW3D/pluglib/realcrc.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/realcrc.cpp rename to Core/Tools/WW3D/pluglib/realcrc.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/realcrc.h b/Core/Tools/WW3D/pluglib/realcrc.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/realcrc.h rename to Core/Tools/WW3D/pluglib/realcrc.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/rgb.cpp b/Core/Tools/WW3D/pluglib/rgb.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/rgb.cpp rename to Core/Tools/WW3D/pluglib/rgb.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/rgb.h b/Core/Tools/WW3D/pluglib/rgb.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/rgb.h rename to Core/Tools/WW3D/pluglib/rgb.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/uarray.h b/Core/Tools/WW3D/pluglib/uarray.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/uarray.h rename to Core/Tools/WW3D/pluglib/uarray.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/vector2.h b/Core/Tools/WW3D/pluglib/vector2.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/vector2.h rename to Core/Tools/WW3D/pluglib/vector2.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/vector3.h b/Core/Tools/WW3D/pluglib/vector3.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/vector3.h rename to Core/Tools/WW3D/pluglib/vector3.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/vector3i.h b/Core/Tools/WW3D/pluglib/vector3i.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/vector3i.h rename to Core/Tools/WW3D/pluglib/vector3i.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/vector4.h b/Core/Tools/WW3D/pluglib/vector4.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/vector4.h rename to Core/Tools/WW3D/pluglib/vector4.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/visualc.h b/Core/Tools/WW3D/pluglib/visualc.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/visualc.h rename to Core/Tools/WW3D/pluglib/visualc.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/w3d_file.h b/Core/Tools/WW3D/pluglib/w3d_file.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/w3d_file.h rename to Core/Tools/WW3D/pluglib/w3d_file.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/w3dquat.cpp b/Core/Tools/WW3D/pluglib/w3dquat.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/w3dquat.cpp rename to Core/Tools/WW3D/pluglib/w3dquat.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/w3dquat.h b/Core/Tools/WW3D/pluglib/w3dquat.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/w3dquat.h rename to Core/Tools/WW3D/pluglib/w3dquat.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/watcom.h b/Core/Tools/WW3D/pluglib/watcom.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/watcom.h rename to Core/Tools/WW3D/pluglib/watcom.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/win.h b/Core/Tools/WW3D/pluglib/win.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/win.h rename to Core/Tools/WW3D/pluglib/win.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/wwfile.h b/Core/Tools/WW3D/pluglib/wwfile.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/wwfile.h rename to Core/Tools/WW3D/pluglib/wwfile.h diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/wwmath.cpp b/Core/Tools/WW3D/pluglib/wwmath.cpp similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/wwmath.cpp rename to Core/Tools/WW3D/pluglib/wwmath.cpp diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/wwmath.h b/Core/Tools/WW3D/pluglib/wwmath.h similarity index 100% rename from GeneralsMD/Code/Tools/WW3D/pluglib/wwmath.h rename to Core/Tools/WW3D/pluglib/wwmath.h diff --git a/Generals/Code/Tools/CMakeLists.txt b/Generals/Code/Tools/CMakeLists.txt index 77983a2ec42..fa1a95c2248 100644 --- a/Generals/Code/Tools/CMakeLists.txt +++ b/Generals/Code/Tools/CMakeLists.txt @@ -24,5 +24,4 @@ if(RTS_BUILD_GENERALS_EXTRAS) add_subdirectory(timingTest) add_subdirectory(versionUpdate) add_subdirectory(wolSetup) - add_subdirectory(WW3D) endif() diff --git a/Generals/Code/Tools/WW3D/max2w3d/AlphaModifier.cpp b/Generals/Code/Tools/WW3D/max2w3d/AlphaModifier.cpp deleted file mode 100644 index e37c720efaa..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/AlphaModifier.cpp +++ /dev/null @@ -1,477 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project name : Buccaneer Bay * - * * - * File name : AlphaModifier.cpp * - * * - * Programmer : Mike Lytle * - * * - * Start date : 11/1/1999 * - * * - * Last update : 11/1/1999 * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "AlphaModifier.h" - -enum Alpha_Messages -{ - AM_NOTHING, - AM_UPDATE_DATA, - AM_INITIALIZE, - AM_BOX_CHECKED, -}; - -enum Dialog_Controls -{ - DL_EDIT_VALUE, - DL_FIND_CHECK_BOX, -}; - -void AlphaModifierClass::ModifyObject(TimeValue t, ModContext &mc, ObjectState *os, INode *node) -{ - if (!os->obj->IsSubClassOf(triObjectClassID)) - { - return; - } - - - // Get a mesh from input object - TriObject *object = (TriObject*)os->obj; - - Mesh *mesh = &object->mesh; - - assert(mesh); - - int numVert = mesh->getNumVerts(); - int i = 0; - float *vdata = NULL; - - // Get parameters from pblock - float sparam = 0.0f; - Interval valid = LocalValidity(t); - int pass = 1; - - pblock->GetValue(DL_EDIT_VALUE, t, sparam, valid); - - // If needed a control could be put into the dialog box to specify which - // pass to apply the alpha values to. At this time, it was decided to - // not implement this because of the complexity to the artist and the - // performance issues in game. - //pblock->GetValue(DL_EDIT_PASS, t, pass, valid); - - - // Start from 0. - pass -= 1; - assert(pass >= 0); - - // Use a channel for each pass. - vdata = mesh->vertexFloat(ALPHA_VERTEX_CHANNEL + pass); - - if (!vdata) - { - // Turn on the channel for vertex alpha support. - mesh->setVDataSupport(ALPHA_VERTEX_CHANNEL + pass); - vdata = mesh->vertexFloat(ALPHA_VERTEX_CHANNEL + pass); - - assert(vdata); - - for (i = 0; i < numVert; i++) - { - if (mesh->VertSel()[i]) - { - vdata[i] = 0.0f; - } - } - - } - - // Tracks the state of the FIND check box. - int box_checked = 0; - - - if (Message == AM_UPDATE_DATA) - { - // The user has updated the dialog box, so update the data. - assert(vdata); - - pblock->GetValue(DL_FIND_CHECK_BOX, t, box_checked, valid); - if (!box_checked) - { - for (i = 0; i < numVert; i++) - { - if (SelectedVertices[i]) - { - vdata[i] = sparam; - } - } - } - } - - if (Message == AM_BOX_CHECKED) - { - pblock->GetValue(DL_FIND_CHECK_BOX, t, box_checked, valid); - } - - - // The user is trying to find vertices with certain values. - if (box_checked) - { - assert(vdata); - // Find the vertices that have the user entered value. - for (i = 0; i < numVert; i++) - { - if (vdata[i] == sparam) - { - mesh->VertSel().Set(i); - SelectedVertices.Set(i); - } - else - { - mesh->VertSel().Clear(i); - SelectedVertices.Clear(i); - } - - } - - } - - if (Message == AM_INITIALIZE) - { - assert(vdata); - - SelectedVertices = mesh->VertSel(); - - for (i = 0; i < numVert; i++) - { - if (SelectedVertices[i]) - { - // Set the value in the dialog box to the value of the - // first selected vertex. - pblock->SetValue(DL_EDIT_VALUE, t, vdata[i]); - break; - } - } - - } - - - // Always select the vertices that have been saved by the modifier. - // This must be done because the mesh changes each time ModfiyObject is called. - for (i = 0; i < numVert; i++) - { - if (SelectedVertices[i]) - { - mesh->VertSel().Set(i); - } - else - { - mesh->VertSel().Clear(i); - } - - } - - // Display the vertices. - mesh->SetDispFlag(DISP_SELVERTS | DISP_VERTTICKS); - mesh->selLevel = MESH_VERTEX; - object->UpdateValidity(SELECT_CHAN_NUM, object->ChannelValidity (t, SELECT_CHAN_NUM)); - - // Clear messages. - Message = AM_NOTHING; -} - - - - -/*===========================================================================*\ - | NotifyInputChanged is called each time the input object is changed in some way - | We can find out how it was changed by checking partID and message -\*===========================================================================*/ - -void AlphaModifierClass::NotifyInputChanged(Interval changeInt, PartID partID, RefMessage message, ModContext *mc) -{ - if( (partID&PART_TOPO) || (partID&PART_GEOM) || (partID&PART_SELECT) ) - { - NotifyDependents(FOREVER, PART_OBJ, REFMSG_CHANGE); - } -} - - -/*===========================================================================*\ - | Class Descriptor OSM -\*===========================================================================*/ - -class AlphaClassDesc : public ClassDesc2 { - public: - int IsPublic() { return TRUE; } - void * Create( BOOL loading ) { return new AlphaModifierClass; } - const TCHAR * ClassName() { return Get_String(IDS_ALPHA_MODIFIER_CLASS); } - SClass_ID SuperClassID() { return OSM_CLASS_ID; } - Class_ID ClassID() { return ALPHA_MODIFIER_CLASSID; } - const TCHAR* Category() { return _T(""); } - - HINSTANCE HInstance() { return AppInstance; } - - // Hardwired name, used by MAX Script as unique identifier - const TCHAR* InternalName() { return _T("AlphaMod"); } -}; - -static AlphaClassDesc AlphaCD; -ClassDesc* Get_Alpha_Desc() {return &AlphaCD;} - -/*===========================================================================*\ - | Paramblock2 Descriptor -\*===========================================================================*/ -static ParamBlockDesc2 alpha_param_blk -( - //rollout - 0, _T("AlphaModifierParams"), 0, &AlphaCD, P_AUTO_CONSTRUCT + P_AUTO_UI, 0, - IDD_ALPHA_MODIFIER, IDS_PARAMETERS, 0, 0, NULL, - - // params - - DL_EDIT_VALUE, _T("Custom Data Value"), TYPE_FLOAT, P_ANIMATABLE, IDS_ALPHA_MODIFIER_CLASS, - p_default, 0.0f, - p_range, 0.0f, 100.0f, - p_ui, TYPE_SPINNER, EDITTYPE_FLOAT, IDC_ALPHA_EDIT, IDC_ALPHA_SPIN, 1.0f, - end, - - DL_FIND_CHECK_BOX, _T("1 Custom Data Value"), TYPE_BOOL, 0, IDS_ALPHA_MODIFIER_CLASS, - p_default, FALSE, - p_ui, TYPE_SINGLECHEKBOX, IDC_ALPHA_CHECKBOX, - p_enabled, TRUE, - end, - -/* - DL_EDIT_PASS, _T("2 Custom Data Value"), TYPE_INT, P_ANIMATABLE, IDS_ALPHA_MODIFIER_CLASS, - p_default, 1, - p_range, 1, 4, - p_ui, TYPE_SPINNER, EDITTYPE_INT, IDC_ALPHA_EDIT2, IDC_ALPHA_SPIN2, 1.0, - end, -*/ - - end -); - - -/*===========================================================================*\ - | Basic implementation of a dialog handler -\*===========================================================================*/ - -BOOL AlphaModDlgProc::DlgProc(TimeValue t, IParamMap2 *map, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - int id = LOWORD(wParam); - int code = HIWORD(wParam); - - switch (msg) - { - case WM_INITDIALOG: - AlphaModifier->Message = AM_INITIALIZE; - break; - case WM_DESTROY: - break; - case WM_COMMAND: - switch (code) - { - case EN_UPDATE: - break; - case EN_SETFOCUS: - break; - case EN_KILLFOCUS: - break; - case EN_CHANGE: - break; - } - if (id == IDC_ALPHA_EDIT) - { - AlphaModifier->Message = AM_UPDATE_DATA; - } - if (id == IDC_ALPHA_CHECKBOX) - { - AlphaModifier->Message = AM_BOX_CHECKED; - } - break; - - case WM_NOTIFY: - if (id == IDC_ALPHA_EDIT) - { - AlphaModifier->Message = AM_UPDATE_DATA; - } - break; - - default: - break; - - - } - return FALSE; -} - - -/*===========================================================================*\ - | Constructor - | Ask the ClassDesc2 to make the AUTO_CONSTRUCT paramblocks and wire them in -\*===========================================================================*/ - -AlphaModifierClass::AlphaModifierClass() -{ - AlphaCD.MakeAutoParamBlocks(this); - assert(pblock); - Message = 0; -} - - -/*===========================================================================*\ - | Invalidate our UI (or the recently changed parameter) -\*===========================================================================*/ - -void AlphaModifierClass::InvalidateUI() -{ - alpha_param_blk.InvalidateUI(pblock->LastNotifyParamID()); -} - - - -/*===========================================================================*\ - | Open and Close dialog UIs - | We ask the ClassDesc2 to handle Beginning and Ending EditParams for us -\*===========================================================================*/ - -void AlphaModifierClass::BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev ) -{ - - AlphaCD.BeginEditParams(ip, this, flags, prev); - - alpha_param_blk.SetUserDlgProc(new AlphaModDlgProc(this)); -} - -void AlphaModifierClass::EndEditParams( IObjParam *ip, ULONG flags,Animatable *next ) -{ - AlphaCD.EndEditParams(ip, this, flags, next); -} - - - -/*===========================================================================*\ - | Standard clone -\*===========================================================================*/ - - -RefTargetHandle AlphaModifierClass::Clone(RemapDir& remap) -{ - AlphaModifierClass* newmod = new AlphaModifierClass(); - newmod->ReplaceReference(0,pblock->Clone(remap)); - return(newmod); -} - - - - -/*===========================================================================*\ - | Subanim & References support -\*===========================================================================*/ - -Animatable* AlphaModifierClass::SubAnim(int i) -{ - switch (i) - { - case 0: return pblock; - default: return NULL; - } -} - -TSTR AlphaModifierClass::SubAnimName(int i) -{ - switch (i) - { - case 0: return Get_String(IDS_PARAMETERS); - default: return _T(""); - } -} - -RefTargetHandle AlphaModifierClass::GetReference(int i) -{ - switch (i) - { - case 0: return pblock; - default: - assert(TRUE); - return NULL; - } -} - -void AlphaModifierClass::SetReference(int i, RefTargetHandle rtarg) -{ - switch (i) - { - case 0: pblock = (IParamBlock2*)rtarg; break; - default: - assert(TRUE); - break; - } -} - -RefResult AlphaModifierClass::NotifyRefChanged -( - Interval changeInt, - RefTargetHandle hTarget, - PartID& partID, - RefMessage message -) -{ - switch (message) - { - case REFMSG_CHANGE: - { - alpha_param_blk.InvalidateUI(); - } - break; - } - return REF_SUCCEED; -} - - - - -/*===========================================================================*\ - | The validity of our parameters - | Start at FOREVER, and intersect with the validity of each item -\*===========================================================================*/ - -Interval AlphaModifierClass::GetValidity(TimeValue t) -{ - float f; - Interval valid = FOREVER; - pblock->GetValue(DL_EDIT_VALUE, t, f, valid); - return valid; -} - -Interval AlphaModifierClass::LocalValidity(TimeValue t) -{ - return GetValidity(t); -} - - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/AlphaModifier.h b/Generals/Code/Tools/WW3D/max2w3d/AlphaModifier.h deleted file mode 100644 index 732f5f539e5..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/AlphaModifier.h +++ /dev/null @@ -1,154 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project name : Buccaneer Bay * - * * - * File name : AlphaModifier.h * - * * - * Programmer : Mike Lytle * - * * - * Start date : 11/1/1999 * - * * - * Last update : 11/1/1999 * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef ALPHA_MODIFIER_H -#define ALPHA_MODIFIER_H - - -#include -#include "iparamm2.h" -#include "istdplug.h" -#include "meshadj.h" -#include "modstack.h" -#include "macrorec.h" -#include "resource.h" -#include "dllmain.h" - - -#define ALPHA_MODIFIER_CLASSID Class_ID(0x518970b3, 0x37d73373) - - -extern ClassDesc* Get_Alpha_Desc(); - -#define ALPHA_VERTEX_CHANNEL 10 - -class AlphaModifierClass : public Modifier -{ - public: - - // Global parameter block - IParamBlock2 *pblock; - - - //Constructor/Destructor - AlphaModifierClass(); - ~AlphaModifierClass() {} - void DeleteThis() { delete this;} - - - // Plugin identification - void GetClassName(TSTR& s) { s= TSTR(Get_String(IDS_ALPHA_MODIFIER_CLASS));} - virtual Class_ID ClassID() { return ALPHA_MODIFIER_CLASSID;} - TCHAR *GetObjectName() { return Get_String(IDS_ALPHA_MODIFIER_CLASS);} - - - // Defines the behavior for this modifier - // This is currently setup to be basic geometry - // modification of deformable objects - ChannelMask ChannelsUsed() {return PART_GEOM|PART_TOPO|PART_SELECT|PART_SUBSEL_TYPE;} - ChannelMask ChannelsChanged() {return PART_GEOM|PART_TOPO|PART_SELECT|PART_SUBSEL_TYPE;} - Class_ID InputType() { return triObjectClassID;} - BOOL ChangeTopology() {return FALSE;} - - - // Calculate the local validity from the parameters - Interval LocalValidity(TimeValue t); - Interval GetValidity(TimeValue t); - - - // Object modification and notification of change - void ModifyObject(TimeValue t, ModContext &mc, ObjectState *os, INode *node); - void NotifyInputChanged(Interval changeInt, PartID partID, RefMessage message, ModContext *mc); - - - // Reference support - int NumRefs() { return 1;} - RefTargetHandle GetReference(int i); - void SetReference(int i, RefTargetHandle rtarg); - RefTargetHandle Clone(RemapDir& remap = NoRemap()); - RefResult NotifyRefChanged( Interval changeInt,RefTargetHandle hTarget, PartID& partID, RefMessage message); - - // SubAnim support - int NumSubs() { return 0;} - Animatable* SubAnim(int i); - TSTR SubAnimName(int i); - - // Direct paramblock access - int NumParamBlocks() {return 1;} - IParamBlock2* GetParamBlock(int i) { return pblock;} - IParamBlock2* GetParamBlockByID(BlockID id) {return (pblock->ID() == id) ? pblock : NULL;} - int GetParamBlockIndex(int id) {return id;} - - // Does not use createmouse callbacks - CreateMouseCallBack* GetCreateMouseCallBack() {return NULL;} - - // Load and unload our UI - void BeginEditParams(IObjParam *ip, ULONG flags,Animatable *prev); - void EndEditParams(IObjParam *ip, ULONG flags,Animatable *next); - void InvalidateUI(); - - // Message saved from window messages. - int Message; - - // Selected vertices. - BitArray SelectedVertices; -}; - - -/*===========================================================================*\ - | Dialog Processor -\*===========================================================================*/ - -class AlphaModDlgProc : public ParamMap2UserDlgProc -{ - public: - AlphaModifierClass *AlphaModifier; - - AlphaModDlgProc() {} - AlphaModDlgProc(AlphaModifierClass *alpha_m) {AlphaModifier = alpha_m;} - - BOOL DlgProc(TimeValue t, IParamMap2 *map, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - void DeleteThis() {} - - void SetThing(ReferenceTarget *m) {AlphaModifier = (AlphaModifierClass*)m;} -}; - - -#endif //ALPHA_MODIFIER_H - - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/AppData.cpp b/Generals/Code/Tools/WW3D/max2w3d/AppData.cpp deleted file mode 100644 index 2a57dd814ce..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/AppData.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/AppData.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 9/26/00 4:24p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -/* -** AppData.cpp - Implementation of some Westwood -** extensions to the MAXScript language. -*/ - -#include // Main MAXScript header -#include // MAX* Wrapper objects -#include // MAX String class -#include // def_* functions to create static function headers - -#include "w3dutil.h" // W3DAppData*Struct accessor functions! -#include "w3ddesc.h" - - -/* -** Let MAXScript know we're implementing new built-in functions. -*/ -def_visible_primitive(copy_app_data, "wwCopyAppData"); -def_visible_primitive(set_origin_app_data, "wwSetOriginAppData"); -def_visible_primitive(get_hierarchy_file, "wwGetHierarchyFile"); - - -/* -** -** MAXScript Function: -** wwCopyAppData - Usage: wwCopyAppData to_node from_node -** -** Copies all AppData associated with from_node to to_node. -** This is needed for W3D flags such as Export Geometry -** and Export Transform to get passed on to their -** instances/copies/references. -*/ -Value * copy_app_data_cf (Value **arg_list, int count) -{ - // Verify the number and type of the arguments. - check_arg_count("wwCopyAppData", 2, count); - type_check(arg_list[0], MAXNode, "Target INode"); - type_check(arg_list[1], MAXNode, "Source INode"); - - // Get the INode pointers that were passed in. - INode *dest_node = arg_list[0]->to_node(); - INode *src_node = arg_list[1]->to_node(); - - /* - ** Copy W3DAppData0Struct - */ - W3DAppData0Struct *app_data_0 = GetW3DAppData0(src_node); - if (app_data_0 != NULL) { - - // App Data 0 is now obsolete, not fatal if we don't find one - W3DAppData0Struct *copy_data_0 = new W3DAppData0Struct; - if (copy_data_0 == NULL) - throw RuntimeError("Out of memory."); - - // Copy the app data and give it to the target node. - *copy_data_0 = *app_data_0; - dest_node->AddAppDataChunk(W3DUtilityClassID, UTILITY_CLASS_ID, W3D_APPDATA_0, - sizeof(W3DAppData0Struct), copy_data_0); - } - - /* - ** Copy W3DAppData1Struct - */ - W3DAppData1Struct *app_data_1 = GetW3DAppData1(src_node); - if (app_data_1 == NULL) - throw RuntimeError("Unable to retrieve W3DAppData1Struct from object: ", arg_list[1]); - - W3DAppData1Struct *copy_data_1 = new W3DAppData1Struct; - if (copy_data_1 == NULL) - throw RuntimeError("Out of memory."); - - // Copy the app data and give it to the target node. - *copy_data_1 = *app_data_1; - dest_node->AddAppDataChunk(W3DUtilityClassID, UTILITY_CLASS_ID, W3D_APPDATA_1, - sizeof(W3DAppData1Struct), copy_data_1); - - - /* - ** Copy W3DAppData2Struct - */ - W3DAppData2Struct *app_data_2 = GetW3DAppData2(src_node); - if (app_data_2 == NULL) - throw RuntimeError("Unable to retrieve W3DAppData1Struct from object: ", arg_list[1]); - - W3DAppData2Struct *copy_data_2 = new W3DAppData2Struct; - if (copy_data_2 == NULL) - throw RuntimeError("Out of memory."); - - // Copy the app data and give it to the target node. - *copy_data_2 = *app_data_2; - dest_node->AddAppDataChunk(W3DUtilityClassID, UTILITY_CLASS_ID, W3D_APPDATA_2, - sizeof(W3DAppData2Struct), copy_data_2); - - /* - ** Copy W3DDazzleAppDataStruct if one is present. - */ - W3DDazzleAppDataStruct *dazzle_app_data = GetW3DDazzleAppData(src_node); - if (dazzle_app_data != NULL) { - - W3DDazzleAppDataStruct *copy_dazzle_data = new W3DDazzleAppDataStruct; - if (copy_dazzle_data == NULL) - throw RuntimeError("Out of memory."); - - - // Copy the app data and give it to the target node. - *copy_dazzle_data = *dazzle_app_data; - dest_node->AddAppDataChunk(W3DUtilityClassID, UTILITY_CLASS_ID, W3D_DAZZLE_APPDATA, - sizeof(W3DDazzleAppDataStruct), copy_dazzle_data); - } - - return &ok; -} - - - -/* -** -** MAXScript Function: -** wwSetOriginAppData - Usage: wwSetOriginAppData origin_node -** -** Sets the AppData associated with the given node to values -** appropriate to an origin. (ie. turn off Export Geometry and -** Export Transform) -*/ -Value * set_origin_app_data_cf (Value **arg_list, int count) -{ - // Check the arguments that were passed to this function. - check_arg_count("wwSetOriginAppData", 1, count); - type_check(arg_list[0], MAXNode, "Origin INode"); - - // Get the INode that we were given. - INode *origin = arg_list[0]->to_node(); - - // Get the node's W3DAppData2Struct, and modify it accordingly. - W3DAppData2Struct *data = GetW3DAppData2(origin); - if (data == NULL) - throw RuntimeError("Unable to retrieve W3DAppData0Struct from object: ", arg_list[0]); - - // Turn off Export Geometry and Export Hierarchy. - data->Enable_Export_Geometry(false); - data->Enable_Export_Transform(false); - - return &ok; -} - -/* -** -** MAXScript Function: -** wwGetHierarchyFile - Usage: wwGetHierarchyFile() -** -** Returns the relative pathname of the file that will be loaded -** during W3D export to get the hierarchy tree. If no such file -** will be loaded, the return value is the MAXScript undefined. -** -*/ -Value * get_hierarchy_file_cf (Value **arg_list, int count) -{ - // Check that we weren't passed any arguments. - check_arg_count("wwGetHierarchyFile", 0, count); - - // Retrieve the export options from the scene. - W3dExportOptionsStruct *options = NULL; - AppDataChunk * appdata = MAXScript_interface->GetScenePointer()->GetAppDataChunk(W3D_EXPORTER_CLASS_ID,SCENE_EXPORT_CLASS_ID,0); - if (appdata) - options = (W3dExportOptionsStruct*)(appdata->data); - - // If we didn't get any options, return undefined. - if (!options) - return &undefined; - - // Return the relative path to the htree file if it's available. - // Otherwise, return the absolute path. - one_typed_value_local(String* htree_file); - if (options->RelativeHierarchyFilename[0] != 0) - vl.htree_file = new String(options->RelativeHierarchyFilename); - else if (options->HierarchyFilename[0] != 0) - vl.htree_file = new String(options->HierarchyFilename); - else - { - // Neither filename is available, return undefined. - pop_value_locals(); - return &undefined; - } - return_value(vl.htree_file); -} - - - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/CMakeLists.txt b/Generals/Code/Tools/WW3D/max2w3d/CMakeLists.txt deleted file mode 100644 index e8b27aa5e9a..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/CMakeLists.txt +++ /dev/null @@ -1,176 +0,0 @@ -set(MAX2W3D_SRC - "aabtreebuilder.cpp" - "aabtreebuilder.h" - "AlphaModifier.cpp" - "AlphaModifier.h" - "animationcompressionsettings.cpp" - "animationcompressionsettings.h" - "AppData.cpp" - "bchannel.cpp" - "bchannel.h" - "boneicon.cpp" - "boneicon.h" - "bpick.cpp" - "bpick.h" - "colboxsave.cpp" - "colboxsave.h" - "dazzlesave.cpp" - "dazzlesave.h" - "dllmain.cpp" - "dllmain.h" - "ExportAll.cpp" - "ExportAllDlg.cpp" - "ExportAllDlg.h" - "exportlog.cpp" - "exportlog.h" - "floaterdialog.cpp" - "floaterdialog.h" - "FormClass.cpp" - "FormClass.h" - "gamemaps.cpp" - "gamemaps.h" - "GameMtl.cpp" - "gamemtl.h" - "GameMtlDlg.cpp" - "GameMtlDlg.h" - "GameMtlForm.cpp" - "GameMtlForm.h" - "GameMtlPassDlg.cpp" - "GameMtlPassDlg.h" - "GameMtlShaderDlg.cpp" - "GameMtlShaderDlg.h" - "GameMtlTextureDlg.cpp" - "GameMtlTextureDlg.h" - "GameMtlVertexMaterialDlg.cpp" - "GameMtlVertexMaterialDlg.h" - "genlodextensiondialog.cpp" - "genlodextensiondialog.h" - "genmtlnamesdialog.cpp" - "genmtlnamesdialog.h" - "gennamesdialog.cpp" - "gennamesdialog.h" - "geometryexportcontext.h" - "geometryexporttask.cpp" - "geometryexporttask.h" - #"gmtldlg.cpp" - "gridsnapmodifier.cpp" - "gridsnapmodifier.h" - "hiersave.cpp" - "hiersave.h" - "hlodsave.cpp" - "hlodsave.h" - "InputDlg.cpp" - "InputDlg.h" - #"LightGlareSave.cpp" - #"LightGlareSave.h" - "logdlg.cpp" - "logdlg.h" - "max2w3d.def" - "maxworldinfo.cpp" - "maxworldinfo.h" - "meshbuild.cpp" - "meshbuild.h" - "meshcon.cpp" - "meshcon.h" - "MeshDeform.cpp" - "MeshDeform.h" - "MeshDeformData.cpp" - "MeshDeformData.h" - "MeshDeformDefs.h" - "MeshDeformPanel.cpp" - "MeshDeformPanel.h" - "MeshDeformSave.cpp" - "MeshDeformSave.h" - "MeshDeformSaveDefs.h" - "MeshDeformSaveSet.cpp" - "MeshDeformSaveSet.h" - "MeshDeformSet.cpp" - "MeshDeformSet.h" - "MeshDeformUndo.cpp" - "MeshDeformUndo.h" - "meshsave.cpp" - "meshsave.h" - "motion.cpp" - "motion.h" - "namedsel.cpp" - "namedsel.h" - "nullsave.cpp" - "nullsave.h" - "PCToPS2Material.cpp" - "presetexportoptionsdialog.cpp" - "presetexportoptionsdialog.h" - "PS2GameMtl.cpp" - "PS2GameMtlShaderDlg.cpp" - "PS2GameMtlShaderDlg.h" - "rcmenu.cpp" - "rcmenu.h" - "resource.h" - "SceneSetup.cpp" - "SceneSetupDlg.cpp" - "SceneSetupDlg.h" - "simpdib.cpp" - "simpdib.h" - "skin.cpp" - "skin.h" - "SkinCopy.cpp" - "skindata.cpp" - "skindata.h" - "SnapPoints.cpp" - "SnapPoints.h" - "TARGA.CPP" - "TARGA.H" - "util.cpp" - "util.h" - "Utility.cpp" - "vchannel.cpp" - "vchannel.h" - "vxl.cpp" - "vxl.h" - "vxldbg.cpp" - "vxldbg.h" - "vxllayer.cpp" - "vxllayer.h" - "w3d_file.h" - "w3d_obsolete.h" - "w3dappdata.cpp" - "w3dappdata.h" - "w3ddesc.cpp" - "w3ddesc.h" - "w3ddlg.cpp" - "w3ddlg.h" - "w3dexp.cpp" - "w3dexp.h" - "w3dmtl.cpp" - "w3dmtl.h" - "w3dutil.cpp" - "w3dutil.h" -) - -add_library(g_max2w3d SHARED) -set_target_properties(g_max2w3d PROPERTIES OUTPUT_NAME max2w3d SUFFIX ".dle") - -target_include_directories(g_max2w3d PRIVATE - "../pluglib" -) - -target_sources(g_max2w3d PRIVATE ${MAX2W3D_SRC}) - -# TODO: What does W3D_MAX4 do? Needs cmake option? -target_compile_definitions(g_max2w3d PRIVATE W3D_MAX4) - -target_link_libraries(g_max2w3d PRIVATE - Comctl32 - # This is only linked to have its basetsd.h used instead of the vs6's basetsd.h - # The headers typedef INT_PTR to different types, but maxsdk expects it - # typedef'ed to int, otherwise throws linker errors. - d3d8lib - g_pluglib - maxsdk - winmm -) - -set_target_properties(g_max2w3d PROPERTIES LINK_FLAGS "/DEF:max2w3d.def") - -if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") - target_sources(g_max2w3d PRIVATE max2w3d.rc) -endif() diff --git a/Generals/Code/Tools/WW3D/max2w3d/ExportAll.cpp b/Generals/Code/Tools/WW3D/max2w3d/ExportAll.cpp deleted file mode 100644 index be0c0a35135..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/ExportAll.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/ExportAll.cpp $* - * * - * $Author:: Andre_a $* - * * - * $Modtime:: 10/15/99 2:08p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * wwExportTreeSettings -- Returns the directory to export, and recursive flag. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -/* -** ExportAll.cpp - Implements wwExportTreeSettings, which presents the user with a dialog -** to allow them to choose which directory they want to export, and whether they want to -** export all subdirectories as well. These settings are then passed back so that a script -** can go through the directory (and maybe the subdirectories) and export all .max files -** it finds. -*/ - - -#include "ExportAllDlg.h" - -#undef STRICT -#include -#include -#include -#include - - -/* -** Let MAXScript know we're implementing new built-in functions. -*/ -def_visible_primitive(export_tree_settings, "wwExportTreeSettings"); - - -/*********************************************************************************************** - * export_tree_settings_cf - Returns the directory to export, and recursive flag. * - * * - * wwExportTreeSettings - Usage: wwExportTreeSettings #(, ) * - * * - * INPUT: A MaxScript array containing two values: * - * initial_path (string) - the initial export directory * - * recursive (bool) - the initial recursive setting * - * * - * OUTPUT: An array of the same format containing the values the user chose. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/4/1999 AJA : Created. * - *=============================================================================================*/ -Value * export_tree_settings_cf (Value **arg_list, int count) -{ - // We want an array as an argument - check_arg_count("wwExportAll", 1, count); - type_check(arg_list[0], Array, "Parameter array"); - - // Grab the two values out of the array. - // First value is a string whose value is the initial value for the directory. - // Second value is a bool, true for a recursive export. - ExportAllDlg dlg(MAXScript_interface); - Array *args = (Array*)(arg_list[0]); - char *temp = (args->get(1))->to_string(); - int len = strlen(temp); - if (len < MAX_PATH) - strcpy(dlg.m_Directory, temp); - else - { - strncpy(dlg.m_Directory, temp, MAX_PATH-1); - dlg.m_Directory[MAX_PATH-1] = 0; - } - dlg.m_Recursive = (args->get(2))->to_bool(); - - // Show the dialog to let the user change the settings. - if (dlg.DoModal() == IDCANCEL) - return &undefined; - - // Create the array we will return to MaxScript. - one_typed_value_local(Array *result); - vl.result = new Array(2); - vl.result->append(new String(dlg.m_Directory)); - if (dlg.m_Recursive) - vl.result->append(&true_value); - else - vl.result->append(&false_value); - - // Return the new values. - return_value(vl.result); -} \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/ExportAllDlg.cpp b/Generals/Code/Tools/WW3D/max2w3d/ExportAllDlg.cpp deleted file mode 100644 index 5c6d3dbcd42..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/ExportAllDlg.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/ExportAllDlg.cpp $* - * * - * $Author:: Andre_a $* - * * - * $Modtime:: 10/15/99 4:25p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - -// ExportAllDlg.cpp : implementation file -// - -#include "ExportAllDlg.h" -#include -#include -#include // SHBrowseForFolder - - -static BOOL CALLBACK _thunk_dialog_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - - -///////////////////////////////////////////////////////////////////////////// -// ExportAllDlg dialog - - -ExportAllDlg::ExportAllDlg (Interface *max_interface) -{ - m_Directory[0] = '\0'; - m_Recursive = TRUE; - m_hWnd = NULL; - assert(max_interface != NULL); - m_MaxInterface = max_interface; -} - - -///////////////////////////////////////////////////////////////////////////// -// ExportAllDlg Methods - -int ExportAllDlg::DoModal (void) -{ - // Put up the dialog box. - BOOL result = DialogBoxParam(AppInstance, MAKEINTRESOURCE(IDD_EXPORT_ALL), - m_MaxInterface->GetMAXHWnd(), (DLGPROC)_thunk_dialog_proc, - (LPARAM)this); - - // Return IDOK if the user accepted the new settings. - return (result == 1) ? IDOK : IDCANCEL; -} - -///////////////////////////////////////////////////////////////////////////// -// ExportAllDlg DialogProc - -BOOL CALLBACK _thunk_dialog_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - static ExportAllDlg *dialog = NULL; - - if (uMsg == WM_INITDIALOG) - { - dialog = (ExportAllDlg*)lParam; - dialog->m_hWnd = hWnd; - } - - if (dialog) - return dialog->DialogProc(hWnd, uMsg, wParam, lParam); - else - return 0; -} - -BOOL CALLBACK ExportAllDlg::DialogProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - int code = HIWORD(wParam); - - switch (uMsg) - { - - /******************************************************************* - * WM_INITDIALOG - * - * Initialize all of the custom controls for the dialog box - * - *******************************************************************/ - case WM_INITDIALOG: - - OnInitDialog(); - return TRUE; - - - /******************************************************************* - * WM_COMMAND - * - * - *******************************************************************/ - case WM_COMMAND: - - switch (LOWORD(wParam)) - { - case IDOK: - - if (OnOK() == FALSE) - return TRUE; - - SetCursor(LoadCursor(NULL, IDC_WAIT)); - EndDialog(m_hWnd, 1); - break; - - case IDCANCEL: - EndDialog(m_hWnd, 0); - break; - - case IDC_BROWSE: - OnBrowse(); - return FALSE; - - } - return TRUE; - - } - - return FALSE; -} - -///////////////////////////////////////////////////////////////////////////// -// ExportAllDlg message handlers - -void ExportAllDlg::OnInitDialog (void) -{ - CenterWindow(m_hWnd, m_MaxInterface->GetMAXHWnd()); - SetCursor(LoadCursor(NULL, IDC_ARROW)); - - // Set the check box state. - CheckDlgButton(m_hWnd, IDC_RECURSIVE, m_Recursive); - - // Set the default directory. - HWND edit = GetDlgItem(m_hWnd, IDC_DIRECTORY); - assert(edit != NULL); - SetWindowText(edit, m_Directory); -} - -void ExportAllDlg::OnBrowse() -{ - char folder_name[MAX_PATH]; - BROWSEINFO bi; - ZeroMemory(&bi, sizeof(bi)); - bi.hwndOwner = m_hWnd; - bi.pszDisplayName = folder_name; - bi.lpszTitle = "Select a folder for export..."; - bi.ulFlags = BIF_RETURNONLYFSDIRS; - - // Browse for a folder. - LPITEMIDLIST il = SHBrowseForFolder(&bi); - if (il) - { - // Get the path of the folder. - if (SHGetPathFromIDList(il, folder_name)) - { - HWND edit = GetDlgItem(m_hWnd, IDC_DIRECTORY); - assert(edit != NULL); - SetWindowText(edit, folder_name); - } - else - MessageBox(m_hWnd, "Error getting pathname with SHGetPathFromIDList()", - "Error", MB_OK | MB_ICONSTOP); - } -} - -BOOL ExportAllDlg::OnOK (void) -{ - // Get the directory chosen by the user. If none is entered, - // freak on the user. - char dir[_MAX_PATH]; - HWND edit = GetDlgItem(m_hWnd, IDC_DIRECTORY); - assert(edit != NULL); - if (GetWindowText(edit, dir, sizeof(dir)) == 0) - { - // The edit box is empty, that's not a valid choice. - MessageBox(m_hWnd, "You must choose a directory to export", - "Invalid Directory", MB_OK); - SetFocus(edit); - return FALSE; - } - - // TODO: Validate the directory as one that actually exists. - - // Store the values from the dialog in our class members. - strcpy(m_Directory, dir); - m_Recursive = (IsDlgButtonChecked(m_hWnd, IDC_RECURSIVE) == BST_CHECKED) ? TRUE : FALSE; - - return TRUE; -} - diff --git a/Generals/Code/Tools/WW3D/max2w3d/ExportAllDlg.h b/Generals/Code/Tools/WW3D/max2w3d/ExportAllDlg.h deleted file mode 100644 index c4fc8e1c352..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/ExportAllDlg.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/ExportAllDlg.h $* - * * - * $Author:: Andre_a $* - * * - * $Modtime:: 10/15/99 4:25p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef EXPORTALLDLG_H -#define EXPORTALLDLG_H - -#include "dllmain.h" -#include "resource.h" - - -class Interface; - -///////////////////////////////////////////////////////////////////////////// -// ExportAllDlg dialog - -class ExportAllDlg -{ -public: - - // Construction - ExportAllDlg (Interface *max_interface); - - // Methods - int DoModal (void); - - // DialogProc - BOOL CALLBACK DialogProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - - // Dialog data associated with GUI components. - char m_Directory[_MAX_PATH]; // edit box - BOOL m_Recursive; // check box - - // Dialog data - enum { IDD = IDD_EXPORT_ALL }; - HWND m_hWnd; - Interface *m_MaxInterface; - -protected: - - // Message Handlers - void OnInitDialog (void); - void OnBrowse (void); - BOOL OnOK (void); // TRUE if ok to close dialog -}; - - -#endif diff --git a/Generals/Code/Tools/WW3D/max2w3d/FormClass.cpp b/Generals/Code/Tools/WW3D/max2w3d/FormClass.cpp deleted file mode 100644 index ad1eec293c7..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/FormClass.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : FormClass * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/FormClass.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 11/09/98 3:02a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * FormClass::Create_Form -- Loads the dialog template and initializes * - * FormClass::fnFormProc -- windows proc which thunks into the virtual Dialog_Proc * - * FormClass::ExecuteDlgInit -- Initializes controls in the dialog template * - * FormClass::ExecuteDlgInit -- Initializes the controls in the dialog template * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "FormClass.h" -#include "dllmain.h" - -// hard-coded resource id which VC special cases for MFC... >:-) -#define RT_DLGINIT MAKEINTRESOURCE(240) - - -/*********************************************************************************************** - * FormClass::Create_Form -- Loads the dialog template and initializes * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/6/98 GTH : Created. * - *=============================================================================================*/ -HWND -FormClass::Create_Form -( - HWND parent_wnd, - UINT template_id -) -{ - // call PreCreateWindow to get prefered extended style - CREATESTRUCT cs = { 0 }; - cs.style = WS_CHILD; - - m_hWnd = ::CreateDialogParam( AppInstance, - MAKEINTRESOURCE (template_id), - parent_wnd, - fnFormProc, - (LPARAM)this); - - assert(m_hWnd); - - // Remove the caption from the dialog (if there was any) - ::SetWindowLong (m_hWnd, - GWL_STYLE, - ::GetWindowLong (m_hWnd, GWL_STYLE) & (~WS_CAPTION)); - - ::GetWindowRect (m_hWnd, &m_FormRect); - - ExecuteDlgInit(MAKEINTRESOURCE(template_id)); - - return m_hWnd; -} - - -/*********************************************************************************************** - * FormClass::fnFormProc -- windows proc which thunks into the virtual Dialog_Proc * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/6/98 GTH : Created. * - *=============================================================================================*/ -BOOL WINAPI -FormClass::fnFormProc -( - HWND dlg_wnd, - UINT message, - WPARAM wparam, - LPARAM lparam -) -{ - FormClass *pform = (FormClass *)::GetProp (dlg_wnd, "FORMCLASS"); - - if (message == WM_INITDIALOG) { - pform = (FormClass *)lparam; - ::SetProp (dlg_wnd, "FORMCLASS", (HANDLE)pform); - } else if (message == WM_DESTROY) { - ::RemoveProp (dlg_wnd, "FORMCLASS"); - } - - BOOL retval = FALSE; - if (pform) { - retval = pform->Dialog_Proc (dlg_wnd, message, wparam, lparam); - } - - return retval; -} - - -/*********************************************************************************************** - * FormClass::ExecuteDlgInit -- Initializes controls in the dialog template * - * * - * This code was lifted straight out of MFC. It does some "interesting" things like putting * - * strings into combo boxes which are typed in the resource editor. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/6/98 GTH : Created. * - *=============================================================================================*/ -BOOL FormClass::ExecuteDlgInit(LPCTSTR lpszResourceName) -{ - // find resource handle - LPVOID lpResource = NULL; - HGLOBAL hResource = NULL; - if (lpszResourceName != NULL) - { - HINSTANCE hInst = AppInstance; - HRSRC hDlgInit = ::FindResource(hInst, lpszResourceName, RT_DLGINIT); - if (hDlgInit != NULL) - { - // load it - hResource = LoadResource(hInst, hDlgInit); - if (hResource == NULL) - return FALSE; - // lock it - lpResource = LockResource(hResource); - assert(lpResource != NULL); - } - } - - // execute it - BOOL bResult = ExecuteDlgInit(lpResource); - - // cleanup - if (lpResource != NULL && hResource != NULL) - { - UnlockResource(hResource); - FreeResource(hResource); - } - return bResult; -} - - -/*********************************************************************************************** - * FormClass::ExecuteDlgInit -- Initializes the controls in the dialog template * - * * - * As the above ExecuteDlgInit function, this was lifted from MFC... * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/6/98 GTH : Created. * - *=============================================================================================*/ -BOOL FormClass::ExecuteDlgInit(LPVOID lpResource) -{ - BOOL bSuccess = TRUE; - if (lpResource != NULL) - { - UNALIGNED WORD* lpnRes = (WORD*)lpResource; - while (bSuccess && *lpnRes != 0) - { - WORD nIDC = *lpnRes++; - WORD nMsg = *lpnRes++; - DWORD dwLen = *((UNALIGNED DWORD*&)lpnRes)++; - - // In Win32 the WM_ messages have changed. They have - // to be translated from the 32-bit values to 16-bit - // values here. - #define WIN16_LB_ADDSTRING 0x0401 - #define WIN16_CB_ADDSTRING 0x0403 - - if (nMsg == WIN16_LB_ADDSTRING) - nMsg = LB_ADDSTRING; - else if (nMsg == WIN16_CB_ADDSTRING) - nMsg = CB_ADDSTRING; - - // check for invalid/unknown message types - assert(nMsg == LB_ADDSTRING || nMsg == CB_ADDSTRING); - - if (nMsg == LB_ADDSTRING || nMsg == CB_ADDSTRING) - { - // List/Combobox returns -1 for error - if (::SendDlgItemMessageA(m_hWnd, nIDC, nMsg, 0, (LONG)lpnRes) == -1) - bSuccess = FALSE; - } - - // skip past data - lpnRes = (WORD*)((LPBYTE)lpnRes + (UINT)dwLen); - } - } - - return bSuccess; -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/FormClass.h b/Generals/Code/Tools/WW3D/max2w3d/FormClass.h deleted file mode 100644 index 77de5b10f41..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/FormClass.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : max2w3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/FormClass.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 11/13/98 9:34a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef __FORMCLASS_H -#define __FORMCLASS_H - -#include - - -class FormClass : public ParamDlg -{ - public: - FormClass (void) - : m_hWnd (NULL) {} - ~FormClass (void) {} - - HWND Create_Form (HWND parent_wnd, UINT template_id); - void Show (bool show_flag = true) { ::ShowWindow (m_hWnd, show_flag ? SW_SHOW : SW_HIDE); } - virtual BOOL Dialog_Proc (HWND dlg_wnd, UINT message, WPARAM wparam, LPARAM lparam) = 0; - HWND Get_Hwnd(void) { return m_hWnd; } - virtual void Invalidate(void) { InvalidateRect(m_hWnd,NULL,0); } - - protected: - - BOOL ExecuteDlgInit(LPVOID lpResource); - BOOL ExecuteDlgInit(LPCTSTR lpszResourceName); - - static BOOL WINAPI fnFormProc (HWND dlg_wnd, UINT message, WPARAM wparam, LPARAM lparam); - - HWND m_hWnd; - RECT m_FormRect; -}; - -#endif //__FORMCLASS_H diff --git a/Generals/Code/Tools/WW3D/max2w3d/GameMtl.cpp b/Generals/Code/Tools/WW3D/max2w3d/GameMtl.cpp deleted file mode 100644 index 4463cc7b0b5..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/GameMtl.cpp +++ /dev/null @@ -1,3301 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/GameMtl.cpp 52 8/10/01 2:18p Ian_l $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : GAMEMTL.CPP * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 06/26/97 * - * * - * Last Update : 10/26/1999997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * GameMtl::GameMtl -- constructor * - * GameMtl::~GameMtl -- destructor * - * GameMtl::ClassID -- returns the max ClassID of the material plugin * - * GameMtl::SuperClassID -- returns the super class ID * - * GameMtl::GetClassName -- returns the name of this plugin clas * - * GameMtl::NumSubs -- returns the number of sub animations * - * GameMtl::SubAnimName -- returns the name of the i'th sub animation * - * GameMtl::SubAnim -- returns the i'th sub-anim * - * GameMtl::Clone -- clones this material * - * GameMtl::NotifyRefChanged -- NotifyRefChanged handler * - * GameMtl::SetReference -- set the i'th reference * - * GameMtl::GetReference -- returnst the i'th reference * - * GameMtl::NumSubTexmaps -- returns the number of texture maps in this material * - * GameMtl::SetSubTexmap -- set the i'th texture map * - * GameMtl::GetSubTexmap -- returns the i'th texture map * - * GameMtl::CreateParamDlg -- creates the material editor dialog box * - * GameMtl::Notify_Changed -- someone has changed this material * - * GameMtl::Reset -- reset this material to default settings * - * GameMtl::Update -- time has changed * - * GameMtl::Validity -- return the validity of the material at time t * - * GameMtl::Requirements -- what requirements does this material have? * - * GameMtl::Load -- loading from a MAX file * - * GameMtl::Save -- Saving into a MAX file * - * GameMtl::Shade -- evaluate the material for the renderer. * - * GameMtl::ps2_shade -- Emulate the PS2 shader. * - * GameMtl::Compute_PC_Shader_From_PS2_Shader -- Determine if a PC shader can be created. * - * GameMtl::Compute_PS2_Shader_From_PC_Shader -- Change a W3D material to a PS2 W3D material.* - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "gamemtl.h" -#include -#include -#include -#include "GameMtlDlg.h" -#include "dllmain.h" -#include "resource.h" -#include "util.h" -#include "meshsave.h" -#include "gamemaps.h" - - -/***************************************************************** -* -* GameMtl Class Descriptor -* -*****************************************************************/ -Class_ID GameMaterialClassID(GAMEMTL_ID_PARTA, GAMEMTL_ID_PARTB); - -class GameMaterialClassDesc:public ClassDesc { - -public: - int IsPublic() { return 1; } - void * Create(BOOL loading) { return new GameMtl(loading); } - const TCHAR * ClassName() { return Get_String(IDS_GAMEMTL); } - SClass_ID SuperClassID() { return MATERIAL_CLASS_ID; } - Class_ID ClassID() { return GameMaterialClassID; } - const TCHAR* Category() { return _T(""); } -}; - -static GameMaterialClassDesc _GameMaterialCD; - -ClassDesc * Get_Game_Material_Desc() { return &_GameMaterialCD; } - - -/****************************************************************************** -* -* PostLoadCallback for GameMtl -* -******************************************************************************/ -class GameMtlPostLoad : public PostLoadCallback -{ -public: - GameMtl *m; - - GameMtlPostLoad(GameMtl *b) { m=b; IsOld = false;} - void proc(ILoad *iload); - - /* - ** Data from the previous version of GameMtl - */ - bool IsOld; - ULONG Attributes; - Color Diffuse; - Color Specular; - Color AmbientCoeff; - Color DiffuseCoeff; - Color SpecularCoeff; - Color EmissiveCoeff; - float FogCoeff; - int DCTFrames; - int DITFrames; - int SCTFrames; - int SITFrames; - float DCTFrameRate; - float DITFrameRate; - float SCTFrameRate; - float SITFrameRate; - int DCTMappingType; - int DITMappingType; - int SCTMappingType; - int SITMappingType; - float Opacity; - float Translucency; - float Shininess; -}; - - - -/****************************************************************************** -* -* GameMtl -* -* Notes: -* Prior to Nov, 1998 I was storing everything about the material in custom -* chunks. As part of the upgrade to surrender 1.4x, I'm going to use -* a parameter block for each pass (combination of shader and vertex material) -* -******************************************************************************/ -#define MTL_HDR_CHUNK 0x4000 - -/* -** Custom Chunk IDs -*/ -#define GAMEMTL_FLAGS_CHUNK 0x0000 -#define GAMEMTL_GAMEFLAGS_CHUNK 0x0001 // OBSOLETE! -#define GAMEMTL_COLORS_CHUNK 0x0002 // OBSOLETE! - -#define GAMEMTL_TEXTURE_FRAMES_CHUNK 0x0003 -#define GAMEMTL_ENVMAP_FRAMES_CHUNK 0x0004 -#define GAMEMTL_DCT_FRAMES_CHUNK GAMEMTL_TEXTURE_FRAMES_CHUNK -#define GAMEMTL_DIT_FRAMES_CHUNK GAMEMTL_ENVMAP_FRAMES_CHUNK -#define GAMEMTL_SCT_FRAMES_CHUNK 0x0005 -#define GAMEMTL_SIT_FRAMES_CHUNK 0x0006 - -#define GAMEMTL_DCT_FRAME_RATE_CHUNK 0x0010 -#define GAMEMTL_DIT_FRAME_RATE_CHUNK 0x0011 -#define GAMEMTL_SCT_FRAME_RATE_CHUNK 0x0012 -#define GAMEMTL_SIT_FRAME_RATE_CHUNK 0x0013 - -#define GAMEMTL_DCT_MAPPING_CHUNK 0x0020 -#define GAMEMTL_DIT_MAPPING_CHUNK 0x0021 -#define GAMEMTL_SCT_MAPPING_CHUNK 0x0022 -#define GAMEMTL_SIT_MAPPING_CHUNK 0x0023 - -#define GAMEMTL_ATTRIBUTES_CHUNK 0x0030 -#define GAMEMTL_DIFFUSE_COLOR_CHUNK 0x0031 -#define GAMEMTL_SPECULAR_COLOR_CHUNK 0x0032 - -#define GAMEMTL_AMBIENT_COEFF_CHUNK 0x0040 -#define GAMEMTL_DIFFUSE_COEFF_CHUNK 0x0041 -#define GAMEMTL_SPECULAR_COEFF_CHUNK 0x0042 -#define GAMEMTL_EMISSIVE_COEFF_CHUNK 0x0043 - -#define GAMEMTL_OPACITY_CHUNK 0x0050 -#define GAMEMTL_TRANSLUCENCY_CHUNK 0x0051 -#define GAMEMTL_SHININESS_CHUNK 0x0052 -#define GAMEMTL_FOG_CHUNK 0x0053 - -#define GAMEMTL_PASS0_CUR_PAGE 0x0060 -#define GAMEMTL_PASS1_CUR_PAGE 0x0061 -#define GAMEMTL_PASS2_CUR_PAGE 0x0062 -#define GAMEMTL_PASS3_CUR_PAGE 0x0064 - -#define GAMEMTL_PASS0_STAGE0_MAPPER_ARGS 0x0070 -#define GAMEMTL_PASS1_STAGE0_MAPPER_ARGS 0x0071 -#define GAMEMTL_PASS2_STAGE0_MAPPER_ARGS 0x0072 -#define GAMEMTL_PASS3_STAGE0_MAPPER_ARGS 0x0073 - -#define GAMEMTL_SURFACE_TYPE_CHUNK 0x0080 - -#define GAMEMTL_SORT_LEVEL_CHUNK 0x0090 - -#define GAMEMTL_PASS0_STAGE1_MAPPER_ARGS 0x0100 -#define GAMEMTL_PASS1_STAGE1_MAPPER_ARGS 0x0101 -#define GAMEMTL_PASS2_STAGE1_MAPPER_ARGS 0x0102 -#define GAMEMTL_PASS3_STAGE1_MAPPER_ARGS 0x0103 - - -/* -** Main Parameter Block Definition -*/ -static ParamBlockDescID MainParameterBlockDesc[] = -{ - { TYPE_INT, NULL, FALSE, 0 }, // Pass Count -}; - - -/* -** ID numbers for parameter block entries. As of version 4 of the -** parameter block definitions, these enums should be used directly -** in the pblock defs to avoid accidental ID mismatches. -** -** Note: You should DO NOTHING TO CHANGE THE VALUES OF THE ENUM -** (except adding at the end of course). Following these constraints -** will preserve backwards compatibility with all pblock versions. -** -** Since this enum is now just a series of ID numbers, we must -** manually keep the PASS_PARAMBLOCK_LENGTH up to date. Believe it -** or not, but this is less error-prone than the previous way of -** doing things. -** -** (gth) Aug 6, 2000 -** IMPORTANT -PLEASE READ- -** The following enums are basically the index into the array of -** ParamBlockDescID's that we are using. It is critical that this -** enumeration does not skip indexes and that the value for each -** symbol in this list matches the position in the param block -** for that variable. This enumeration is does not define the -** id for the new variable, only its position in the array. -** -** When you add a new variable to the parameter block, you should -** find an id for it higher than any existing id (look through the -** rest of the entries in the parameter block). That id will not -** usually be able to be the same as its array index due to the -** evolution of this structure. The id I'm referring to is the -** number in the 4th element of each of the ParamBlockDescIDs. -** -** If you remove an entry from our array of ParamBlockDescIDs you -** will need to update all of the PB_xxx enumeration below so that -** they match their position in the array again. -*/ - -enum -{ - PB_AMBIENT = 0, - PB_DIFFUSE = 1, - PB_SPECULAR = 2, - PB_EMISSIVE = 3, - PB_SHININESS = 4, - PB_OPACITY = 5, - PB_TRANSLUCENCY = 6, - PB_COPY_SPECULAR_TO_DIFFUSE = 7, - PB_STAGE0_MAPPING_TYPE = 8, - PB_PSX_TRANSLUCENCY = 9, - PB_PSX_LIGHTING = 10, - - PB_DEPTH_COMPARE = 11, - PB_DEPTH_MASK = 12, - PB_COLOR_MASK = 13, // obsolete (ignored) - PB_DEST_BLEND = 14, - PB_FOG_FUNC = 15, // obsolete (ignored) - PB_PRI_GRADIENT = 16, - PB_SEC_GRADIENT = 17, - PB_SRC_BLEND = 18, - PB_DETAIL_COLOR_FUNC = 19, - PB_DETAIL_ALPHA_FUNC = 20, - - PB_STAGE0_TEXTURE_ENABLE = 21, - PB_STAGE0_TEXTURE_PUBLISH = 22, - PB_STAGE0_TEXTURE_RESIZE = 23, // obsolete (ignored) - PB_STAGE0_TEXTURE_NO_MIPMAP = 24, // obsolete (ignored) - PB_STAGE0_TEXTURE_CLAMP_U = 25, - PB_STAGE0_TEXTURE_CLAMP_V = 26, - PB_STAGE0_TEXTURE_HINT = 27, - PB_STAGE0_TEXTURE_DISPLAY = 28, - PB_STAGE0_TEXTURE_FRAME_RATE = 29, - PB_STAGE0_TEXTURE_FRAME_COUNT = 30, - PB_STAGE0_TEXTURE_ANIM_TYPE = 31, - - PB_STAGE1_TEXTURE_ENABLE = 32, - PB_STAGE1_TEXTURE_PUBLISH = 33, - PB_STAGE1_TEXTURE_RESIZE = 34, // obsolete (ignored) - PB_STAGE1_TEXTURE_NO_MIPMAP = 35, // obsolete (ignored) - PB_STAGE1_TEXTURE_CLAMP_U = 36, - PB_STAGE1_TEXTURE_CLAMP_V = 37, - PB_STAGE1_TEXTURE_HINT = 38, - PB_STAGE1_TEXTURE_DISPLAY = 39, - PB_STAGE1_TEXTURE_FRAME_RATE = 40, - PB_STAGE1_TEXTURE_FRAME_COUNT = 41, - PB_STAGE1_TEXTURE_ANIM_TYPE = 42, - - PB_STAGE0_TEXTURE_ALPHA_BITMAP = 43, - PB_STAGE1_TEXTURE_ALPHA_BITMAP = 44, - - PB_ALPHA_TEST = 45, - - PB_SHADER_PRESET = 46, // obsolete (ignored) - - // For the Playstation 2. - PB_PS2_SHADER_PARAM_A = 47, - PB_PS2_SHADER_PARAM_B = 48, - PB_PS2_SHADER_PARAM_C = 49, - PB_PS2_SHADER_PARAM_D = 50, - - // UV Channel selection - PB_STAGE0_MAP_CHANNEL = 51, - PB_STAGE1_MAP_CHANNEL = 52, - - PB_STAGE1_MAPPING_TYPE = 53, // (gth) this can't be 55, it is used as an array index // = 55, // yes, 55 - - // textures can now disable LOD - PB_STAGE0_TEXTURE_NO_LOD = 54, - PB_STAGE1_TEXTURE_NO_LOD = 55, -}; - - -/* -** Per-Pass Parameter Block Definition -*/ - -// Version 0 (old version) -static ParamBlockDescID PassParameterBlockDescVer0[] = -{ - { TYPE_POINT3, NULL, TRUE, 0 }, // Ambient - { TYPE_POINT3, NULL, TRUE, 1 }, // Diffuse - { TYPE_POINT3, NULL, TRUE, 2 }, // Specular - { TYPE_POINT3, NULL, TRUE, 3 }, // Emissive - { TYPE_FLOAT, NULL, TRUE, 4 }, // Shininess - { TYPE_FLOAT, NULL, TRUE, 5 }, // Opacity - { TYPE_FLOAT, NULL, TRUE, 6 }, // Translucency - { TYPE_INT, NULL, FALSE, 7 }, // Mapping Type - { TYPE_INT, NULL, FALSE, 8 }, // PSX Translucency Type - { TYPE_BOOL, NULL, FALSE, 9 }, // PSX Lighting Flag - - { TYPE_INT, NULL, FALSE, 10}, // Depth Compare - { TYPE_INT, NULL, FALSE, 11}, // Depth Mask - { TYPE_INT, NULL, FALSE, 12}, // Color Mask - { TYPE_INT, NULL, FALSE, 13}, // Dest Blend - { TYPE_INT, NULL, FALSE, 14}, // FogFunc - { TYPE_INT, NULL, FALSE, 15}, // PriGradient - { TYPE_INT, NULL, FALSE, 16}, // SecGradient - { TYPE_INT, NULL, FALSE, 17}, // SrcBlend - { TYPE_INT, NULL, FALSE, 18}, // DetailColorFunc - { TYPE_INT, NULL, FALSE, 19}, // DetailAlphaFunc - { TYPE_INT, NULL, FALSE, 20}, // DitherMask - { TYPE_INT, NULL, FALSE, 21}, // Shade Model - - { TYPE_BOOL, NULL, FALSE, 22}, // Stage0 Texture Enable - { TYPE_BOOL, NULL, FALSE, 23}, // Stage0 Texture Publish - { TYPE_BOOL, NULL, FALSE, 24}, // Stage0 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 25}, // Stage0 Frame Rate - { TYPE_INT, NULL, FALSE, 26}, // Stage0 Frame Count - { TYPE_INT, NULL, FALSE, 27}, // Stage0 Animation Type - - { TYPE_BOOL, NULL, FALSE, 28}, // Stage1 Texture Enable - { TYPE_BOOL, NULL, FALSE, 29}, // Stage1 Texture Publish - { TYPE_BOOL, NULL, FALSE, 30}, // Stage1 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 31}, // Stage1 Frame Rate - { TYPE_INT, NULL, FALSE, 32}, // Stage1 Frame Count - { TYPE_INT, NULL, FALSE, 33}, // Stage1 Animation Type - -}; - -// Version 1 -static ParamBlockDescID PassParameterBlockDescVer1[] = -{ - { TYPE_POINT3, NULL, TRUE, 0 }, // Ambient - { TYPE_POINT3, NULL, TRUE, 1 }, // Diffuse - { TYPE_POINT3, NULL, TRUE, 2 }, // Specular - { TYPE_POINT3, NULL, TRUE, 3 }, // Emissive - { TYPE_FLOAT, NULL, TRUE, 4 }, // Shininess - { TYPE_FLOAT, NULL, TRUE, 5 }, // Opacity - { TYPE_FLOAT, NULL, TRUE, 6 }, // Translucency - { TYPE_BOOL, NULL, FALSE, 34}, // Copy specular to diffuse (new to version 1) - { TYPE_INT, NULL, FALSE, 7 }, // Mapping Type - { TYPE_INT, NULL, FALSE, 8 }, // PSX Translucency Type - { TYPE_BOOL, NULL, FALSE, 9 }, // PSX Lighting Flag - - { TYPE_INT, NULL, FALSE, 10}, // Depth Compare - { TYPE_INT, NULL, FALSE, 11}, // Depth Mask - { TYPE_INT, NULL, FALSE, 12}, // Color Mask (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 13}, // Dest Blend - { TYPE_INT, NULL, FALSE, 14}, // FogFunc (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 15}, // PriGradient - { TYPE_INT, NULL, FALSE, 16}, // SecGradient - { TYPE_INT, NULL, FALSE, 17}, // SrcBlend - { TYPE_INT, NULL, FALSE, 18}, // DetailColorFunc - { TYPE_INT, NULL, FALSE, 19}, // DetailAlphaFunc - - { TYPE_BOOL, NULL, FALSE, 22}, // Stage0 Texture Enable - { TYPE_BOOL, NULL, FALSE, 23}, // Stage0 Texture Publish - { TYPE_BOOL, NULL, FALSE, 35}, // Stage0 Texture Resize (new to version 1) - { TYPE_BOOL, NULL, FALSE, 36}, // Stage0 Texture No Mipmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 37}, // Stage0 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 38}, // Stage0 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 39}, // Stage0 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 24}, // Stage0 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 25}, // Stage0 Frame Rate - { TYPE_INT, NULL, FALSE, 26}, // Stage0 Frame Count - { TYPE_INT, NULL, FALSE, 27}, // Stage0 Animation Type - - { TYPE_BOOL, NULL, FALSE, 28}, // Stage1 Texture Enable - { TYPE_BOOL, NULL, FALSE, 29}, // Stage1 Texture Publish - { TYPE_BOOL, NULL, FALSE, 40}, // Stage1 Texture Resize (new to version 1) - { TYPE_BOOL, NULL, FALSE, 41}, // Stage1 Texture No Mipmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 42}, // Stage1 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 43}, // Stage1 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 44}, // Stage1 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 30}, // Stage1 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 31}, // Stage1 Frame Rate - { TYPE_INT, NULL, FALSE, 32}, // Stage1 Frame Count - { TYPE_INT, NULL, FALSE, 33}, // Stage1 Animation Type - - { TYPE_BOOL, NULL, FALSE, 45}, // Stage0 Texture Alpha Bitmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 46}, // Stage1 Texture Alpha Bitmap (new to version 1) - - { TYPE_BOOL, NULL, FALSE, 47}, // Alpha Test (new to version 1) - { TYPE_INT, NULL, FALSE, 48}, // Shader preset (new to version 1) (now obsolete and ignored) -}; - -// Version 2 (old version) -static ParamBlockDescID PassParameterBlockDescVer2[] = -{ - { TYPE_POINT3, NULL, TRUE, 0 }, // Ambient - { TYPE_POINT3, NULL, TRUE, 1 }, // Diffuse - { TYPE_POINT3, NULL, TRUE, 2 }, // Specular - { TYPE_POINT3, NULL, TRUE, 3 }, // Emissive - { TYPE_FLOAT, NULL, TRUE, 4 }, // Shininess - { TYPE_FLOAT, NULL, TRUE, 5 }, // Opacity - { TYPE_FLOAT, NULL, TRUE, 6 }, // Translucency - { TYPE_BOOL, NULL, FALSE, 34}, // Copy specular to diffuse (new to version 1) - { TYPE_INT, NULL, FALSE, 7 }, // Mapping Type - { TYPE_INT, NULL, FALSE, 8 }, // PSX Translucency Type - { TYPE_BOOL, NULL, FALSE, 9 }, // PSX Lighting Flag - - { TYPE_INT, NULL, FALSE, 10}, // Depth Compare - { TYPE_INT, NULL, FALSE, 11}, // Depth Mask - { TYPE_INT, NULL, FALSE, 12}, // Color Mask (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 13}, // Dest Blend - { TYPE_INT, NULL, FALSE, 14}, // FogFunc (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 15}, // PriGradient - { TYPE_INT, NULL, FALSE, 16}, // SecGradient - { TYPE_INT, NULL, FALSE, 17}, // SrcBlend - { TYPE_INT, NULL, FALSE, 18}, // DetailColorFunc - { TYPE_INT, NULL, FALSE, 19}, // DetailAlphaFunc - - { TYPE_BOOL, NULL, FALSE, 22}, // Stage0 Texture Enable - { TYPE_BOOL, NULL, FALSE, 23}, // Stage0 Texture Publish - { TYPE_BOOL, NULL, FALSE, 35}, // Stage0 Texture Resize (new to version 1) - { TYPE_BOOL, NULL, FALSE, 36}, // Stage0 Texture No Mipmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 37}, // Stage0 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 38}, // Stage0 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 39}, // Stage0 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 24}, // Stage0 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 25}, // Stage0 Frame Rate - { TYPE_INT, NULL, FALSE, 26}, // Stage0 Frame Count - { TYPE_INT, NULL, FALSE, 27}, // Stage0 Animation Type - - { TYPE_BOOL, NULL, FALSE, 28}, // Stage1 Texture Enable - { TYPE_BOOL, NULL, FALSE, 29}, // Stage1 Texture Publish - { TYPE_BOOL, NULL, FALSE, 40}, // Stage1 Texture Resize (new to version 1) - { TYPE_BOOL, NULL, FALSE, 41}, // Stage1 Texture No Mipmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 42}, // Stage1 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 43}, // Stage1 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 44}, // Stage1 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 30}, // Stage1 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 31}, // Stage1 Frame Rate - { TYPE_INT, NULL, FALSE, 32}, // Stage1 Frame Count - { TYPE_INT, NULL, FALSE, 33}, // Stage1 Animation Type - - { TYPE_BOOL, NULL, FALSE, 45}, // Stage0 Texture Alpha Bitmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 46}, // Stage1 Texture Alpha Bitmap (new to version 1) - - { TYPE_BOOL, NULL, FALSE, 47}, // Alpha Test (new to version 1) - { TYPE_INT, NULL, FALSE, 48}, // Shader preset (new to version 1) (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 49}, // PS2 Shader Param A - { TYPE_INT, NULL, FALSE, 50}, // PS2 Shader Param B - { TYPE_INT, NULL, FALSE, 51}, // PS2 Shader Param C - { TYPE_INT, NULL, FALSE, 52}, // PS2 Shader Param D -}; - -// Version 3 (old version) -static ParamBlockDescID PassParameterBlockDescVer3[] = -{ - { TYPE_POINT3, NULL, TRUE, 0 }, // Ambient - { TYPE_POINT3, NULL, TRUE, 1 }, // Diffuse - { TYPE_POINT3, NULL, TRUE, 2 }, // Specular - { TYPE_POINT3, NULL, TRUE, 3 }, // Emissive - { TYPE_FLOAT, NULL, TRUE, 4 }, // Shininess - { TYPE_FLOAT, NULL, TRUE, 5 }, // Opacity - { TYPE_FLOAT, NULL, TRUE, 6 }, // Translucency - { TYPE_BOOL, NULL, FALSE, 34}, // Copy specular to diffuse (new to version 1) - { TYPE_INT, NULL, FALSE, 7 }, // Mapping Type - { TYPE_INT, NULL, FALSE, 8 }, // PSX Translucency Type - { TYPE_BOOL, NULL, FALSE, 9 }, // PSX Lighting Flag - - { TYPE_INT, NULL, FALSE, 10}, // Depth Compare - { TYPE_INT, NULL, FALSE, 11}, // Depth Mask - { TYPE_INT, NULL, FALSE, 12}, // Color Mask (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 13}, // Dest Blend - { TYPE_INT, NULL, FALSE, 14}, // FogFunc (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 15}, // PriGradient - { TYPE_INT, NULL, FALSE, 16}, // SecGradient - { TYPE_INT, NULL, FALSE, 17}, // SrcBlend - { TYPE_INT, NULL, FALSE, 18}, // DetailColorFunc - { TYPE_INT, NULL, FALSE, 19}, // DetailAlphaFunc - - { TYPE_BOOL, NULL, FALSE, 22}, // Stage0 Texture Enable - { TYPE_BOOL, NULL, FALSE, 23}, // Stage0 Texture Publish - { TYPE_BOOL, NULL, FALSE, 35}, // Stage0 Texture Resize (new to version 1) - { TYPE_BOOL, NULL, FALSE, 36}, // Stage0 Texture No Mipmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 37}, // Stage0 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 38}, // Stage0 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 39}, // Stage0 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 24}, // Stage0 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 25}, // Stage0 Frame Rate - { TYPE_INT, NULL, FALSE, 26}, // Stage0 Frame Count - { TYPE_INT, NULL, FALSE, 27}, // Stage0 Animation Type - - { TYPE_BOOL, NULL, FALSE, 28}, // Stage1 Texture Enable - { TYPE_BOOL, NULL, FALSE, 29}, // Stage1 Texture Publish - { TYPE_BOOL, NULL, FALSE, 40}, // Stage1 Texture Resize (new to version 1) - { TYPE_BOOL, NULL, FALSE, 41}, // Stage1 Texture No Mipmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 42}, // Stage1 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 43}, // Stage1 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 44}, // Stage1 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 30}, // Stage1 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 31}, // Stage1 Frame Rate - { TYPE_INT, NULL, FALSE, 32}, // Stage1 Frame Count - { TYPE_INT, NULL, FALSE, 33}, // Stage1 Animation Type - - { TYPE_BOOL, NULL, FALSE, 45}, // Stage0 Texture Alpha Bitmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 46}, // Stage1 Texture Alpha Bitmap (new to version 1) - - { TYPE_BOOL, NULL, FALSE, 47}, // Alpha Test (new to version 1) - { TYPE_INT, NULL, FALSE, 48}, // Shader preset (new to version 1) (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 49}, // PS2 Shader Param A - { TYPE_INT, NULL, FALSE, 50}, // PS2 Shader Param B - { TYPE_INT, NULL, FALSE, 51}, // PS2 Shader Param C - { TYPE_INT, NULL, FALSE, 52}, // PS2 Shader Param D - - { TYPE_INT, NULL, FALSE, 53}, // Stage0 UV Channel - { TYPE_INT, NULL, FALSE, 54}, // Stage1 UV Channel -}; - - -// Version 4 (old version) -static ParamBlockDescID PassParameterBlockDescVer4[] = -{ - { TYPE_POINT3, NULL, TRUE, 0 }, // Ambient - { TYPE_POINT3, NULL, TRUE, 1 }, // Diffuse - { TYPE_POINT3, NULL, TRUE, 2 }, // Specular - { TYPE_POINT3, NULL, TRUE, 3 }, // Emissive - { TYPE_FLOAT, NULL, TRUE, 4 }, // Shininess - { TYPE_FLOAT, NULL, TRUE, 5 }, // Opacity - { TYPE_FLOAT, NULL, TRUE, 6 }, // Translucency - { TYPE_BOOL, NULL, FALSE, 34}, // Copy specular to diffuse (new to version 1) - { TYPE_INT, NULL, FALSE, 7 }, // Stage0 Mapping Type - { TYPE_INT, NULL, FALSE, 8 }, // PSX Translucency Type - { TYPE_BOOL, NULL, FALSE, 9 }, // PSX Lighting Flag - - { TYPE_INT, NULL, FALSE, 10}, // Depth Compare - { TYPE_INT, NULL, FALSE, 11}, // Depth Mask - { TYPE_INT, NULL, FALSE, 12}, // Color Mask (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 13}, // Dest Blend - { TYPE_INT, NULL, FALSE, 14}, // FogFunc (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 15}, // PriGradient - { TYPE_INT, NULL, FALSE, 16}, // SecGradient - { TYPE_INT, NULL, FALSE, 17}, // SrcBlend - { TYPE_INT, NULL, FALSE, 18}, // DetailColorFunc - { TYPE_INT, NULL, FALSE, 19}, // DetailAlphaFunc - - { TYPE_BOOL, NULL, FALSE, 22}, // Stage0 Texture Enable - { TYPE_BOOL, NULL, FALSE, 23}, // Stage0 Texture Publish - { TYPE_BOOL, NULL, FALSE, 35}, // Stage0 Texture Resize (new to version 1) - { TYPE_BOOL, NULL, FALSE, 36}, // Stage0 Texture No Mipmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 37}, // Stage0 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 38}, // Stage0 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 39}, // Stage0 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 24}, // Stage0 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 25}, // Stage0 Frame Rate - { TYPE_INT, NULL, FALSE, 26}, // Stage0 Frame Count - { TYPE_INT, NULL, FALSE, 27}, // Stage0 Animation Type - - { TYPE_BOOL, NULL, FALSE, 28}, // Stage1 Texture Enable - { TYPE_BOOL, NULL, FALSE, 29}, // Stage1 Texture Publish - { TYPE_BOOL, NULL, FALSE, 40}, // Stage1 Texture Resize (new to version 1) - { TYPE_BOOL, NULL, FALSE, 41}, // Stage1 Texture No Mipmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 42}, // Stage1 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 43}, // Stage1 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 44}, // Stage1 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 30}, // Stage1 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 31}, // Stage1 Frame Rate - { TYPE_INT, NULL, FALSE, 32}, // Stage1 Frame Count - { TYPE_INT, NULL, FALSE, 33}, // Stage1 Animation Type - - { TYPE_BOOL, NULL, FALSE, 45}, // Stage0 Texture Alpha Bitmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 46}, // Stage1 Texture Alpha Bitmap (new to version 1) - - { TYPE_BOOL, NULL, FALSE, 47}, // Alpha Test (new to version 1) - { TYPE_INT, NULL, FALSE, 48}, // Shader preset (new to version 1) (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 49}, // PS2 Shader Param A - { TYPE_INT, NULL, FALSE, 50}, // PS2 Shader Param B - { TYPE_INT, NULL, FALSE, 51}, // PS2 Shader Param C - { TYPE_INT, NULL, FALSE, 52}, // PS2 Shader Param D - - { TYPE_INT, NULL, FALSE, 53}, // Stage0 UV Channel - { TYPE_INT, NULL, FALSE, 54}, // Stage1 UV Channel - - { TYPE_INT, NULL, FALSE, 9998}, // foo - { TYPE_INT, NULL, FALSE, 9999}, // bar - - { TYPE_INT, NULL, FALSE, 55}, // Stage1 Mapping Type (new to version 4) -}; - - -// Version 5 (current version) -static ParamBlockDescID PassParameterBlockDescVer5[] = -{ - { TYPE_POINT3, NULL, TRUE, 0 }, // Ambient - { TYPE_POINT3, NULL, TRUE, 1 }, // Diffuse - { TYPE_POINT3, NULL, TRUE, 2 }, // Specular - { TYPE_POINT3, NULL, TRUE, 3 }, // Emissive - { TYPE_FLOAT, NULL, TRUE, 4 }, // Shininess - { TYPE_FLOAT, NULL, TRUE, 5 }, // Opacity - { TYPE_FLOAT, NULL, TRUE, 6 }, // Translucency - { TYPE_BOOL, NULL, FALSE, 34}, // Copy specular to diffuse (new to version 1) - { TYPE_INT, NULL, FALSE, 7 }, // Stage0 Mapping Type - { TYPE_INT, NULL, FALSE, 8 }, // PSX Translucency Type - { TYPE_BOOL, NULL, FALSE, 9 }, // PSX Lighting Flag - - { TYPE_INT, NULL, FALSE, 10}, // Depth Compare - { TYPE_INT, NULL, FALSE, 11}, // Depth Mask - { TYPE_INT, NULL, FALSE, 12}, // Color Mask (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 13}, // Dest Blend - { TYPE_INT, NULL, FALSE, 14}, // FogFunc (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 15}, // PriGradient - { TYPE_INT, NULL, FALSE, 16}, // SecGradient - { TYPE_INT, NULL, FALSE, 17}, // SrcBlend - { TYPE_INT, NULL, FALSE, 18}, // DetailColorFunc - { TYPE_INT, NULL, FALSE, 19}, // DetailAlphaFunc - - { TYPE_BOOL, NULL, FALSE, 22}, // Stage0 Texture Enable - { TYPE_BOOL, NULL, FALSE, 23}, // Stage0 Texture Publish - { TYPE_BOOL, NULL, FALSE, 35}, // Stage0 Texture Resize (new to version 1) OBSOLETE! - { TYPE_BOOL, NULL, FALSE, 36}, // Stage0 Texture No Mipmap (new to version 1) OBSOLETE! - { TYPE_BOOL, NULL, FALSE, 37}, // Stage0 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 38}, // Stage0 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 39}, // Stage0 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 24}, // Stage0 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 25}, // Stage0 Frame Rate - { TYPE_INT, NULL, FALSE, 26}, // Stage0 Frame Count - { TYPE_INT, NULL, FALSE, 27}, // Stage0 Animation Type - - { TYPE_BOOL, NULL, FALSE, 28}, // Stage1 Texture Enable - { TYPE_BOOL, NULL, FALSE, 29}, // Stage1 Texture Publish - { TYPE_BOOL, NULL, FALSE, 40}, // Stage1 Texture Resize (new to version 1) OBSOLETE! - { TYPE_BOOL, NULL, FALSE, 41}, // Stage1 Texture No Mipmap (new to version 1) OBSOLETE! - { TYPE_BOOL, NULL, FALSE, 42}, // Stage1 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 43}, // Stage1 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 44}, // Stage1 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 30}, // Stage1 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 31}, // Stage1 Frame Rate - { TYPE_INT, NULL, FALSE, 32}, // Stage1 Frame Count - { TYPE_INT, NULL, FALSE, 33}, // Stage1 Animation Type - - { TYPE_BOOL, NULL, FALSE, 45}, // Stage0 Texture Alpha Bitmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 46}, // Stage1 Texture Alpha Bitmap (new to version 1) - - { TYPE_BOOL, NULL, FALSE, 47}, // Alpha Test (new to version 1) - { TYPE_INT, NULL, FALSE, 48}, // Shader preset (new to version 1) (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 49}, // PS2 Shader Param A - { TYPE_INT, NULL, FALSE, 50}, // PS2 Shader Param B - { TYPE_INT, NULL, FALSE, 51}, // PS2 Shader Param C - { TYPE_INT, NULL, FALSE, 52}, // PS2 Shader Param D - - { TYPE_INT, NULL, FALSE, 53}, // Stage0 UV Channel - { TYPE_INT, NULL, FALSE, 54}, // Stage1 UV Channel - - { TYPE_INT, NULL, FALSE, 55 }, // Stage1 Mapping Type (new to version 4) - - { TYPE_BOOL, NULL, FALSE, 56 }, // Stage0 no texture reduction (new to version 5) - { TYPE_BOOL, NULL, FALSE, 57 }, // Stage0 no texture reduction (new to version 5) -}; - -// Array of old pass parameter block versions (for backwards compatibility) -const int NUM_OLDVERSIONS = 5; -static ParamVersionDesc PassParameterBlockVersions[] = { - ParamVersionDesc(PassParameterBlockDescVer0, 34, 0), - ParamVersionDesc(PassParameterBlockDescVer1, 47, 1), - ParamVersionDesc(PassParameterBlockDescVer2, 51, 2), - ParamVersionDesc(PassParameterBlockDescVer3, 53, 3), - ParamVersionDesc(PassParameterBlockDescVer4, 56, 4) -}; - - -// Current pass parameter block version -const int CURRENT_VERSION = 5; -static ParamVersionDesc CurrentPassParameterBlockVersion( - PassParameterBlockDescVer5, - sizeof(PassParameterBlockDescVer5) / sizeof(ParamBlockDescID), - CURRENT_VERSION); - - -const int DISPLACEMENT_INDEX = (W3dMaterialClass::MAX_PASSES * W3dMaterialClass::MAX_STAGES); - -Color scale(const Color& a, const Color& b) -{ - return Color(a.r * b.r, a.g * b.g, a.b * b.b); -} - -/*********************************************************************************************** - * GameMtl::GameMtl -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -GameMtl::GameMtl(BOOL loading) -{ - MaterialDialog = NULL; - SurfaceType = SURFACE_TYPE_DEFAULT; - SortLevel = SORT_LEVEL_NONE; - - Ivalid.SetEmpty(); - RollScroll = 0; - Flags = 0; - Flags |= GAMEMTL_PASSCOUNT_ROLLUP_OPEN; - Set_Flag(GAMEMTL_CONVERTED_TO_NOLOD,true); - - DisplacementMap = NULL; - DisplacementAmt = 0.0F; - - Maps = NULL; - MainParameterBlock = NULL; - for (int pass=0; passReplaceReference(REF_MAIN,remap.CloneRef(MainParameterBlock)); - - // Clone the displacment map's settings - mnew->ReplaceReference (REF_TEXTURE + DISPLACEMENT_INDEX, DisplacementMap); - mnew->DisplacementAmt = DisplacementAmt; - - // Maintain the shader type. - mnew->Set_Shader_Type(ShaderType); - - // replace each pass's parameter block and the textures - for (int pass=0; pass < W3dMaterialClass::MAX_PASSES; pass++) { - - IParamBlock * pblock = NULL; - if (PassParameterBlock[pass]) { - pblock = (IParamBlock *)remap.CloneRef(PassParameterBlock[pass]); - } - mnew->ReplaceReference(pass_ref_index(pass), pblock); - mnew->PassParameterBlock[pass] = pblock; - - for (int stage=0; stage < W3dMaterialClass::MAX_STAGES; stage++) { - if (Texture[pass][stage]) { - mnew->ReplaceReference(texture_ref_index(pass,stage),Texture[pass][stage]->Clone()); - } else { - mnew->ReplaceReference(texture_ref_index(pass,stage),NULL); - } - - // Copy mapper arg strings and lengths - if (MapperArgLen[pass][stage] > 0) { - char *temp = new char[MapperArgLen[pass][stage] + 1]; - assert(strlen(MapperArg[pass][stage]) <= MapperArgLen[pass][stage]); - strcpy(temp, MapperArg[pass][stage]); - mnew->MapperArg[pass][stage] = temp; - mnew->MapperArgLen[pass][stage] = MapperArgLen[pass][stage]; - } - } - - } - - mnew->Ivalid = Ivalid; - return mnew; -} - - -/*********************************************************************************************** - * GameMtl::NotifyRefChanged -- NotifyRefChanged handler * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -RefResult GameMtl::NotifyRefChanged -( - Interval changeInt, - RefTargetHandle hTarget, - PartID & partID, - RefMessage message -) -{ - switch (message) { - case REFMSG_CHANGE: - { - Ivalid.SetEmpty(); // if any refs changed, clear the validity - if (MaterialDialog && (MaterialDialog->TheMtl == this)) { - MaterialDialog->Invalidate(); // if the dialog is up, refresh it - } - break; - } - case REFMSG_GET_PARAM_DIM: - { - GetParamDim *gpd = (GetParamDim*)partID; - gpd->dim = defaultDim; - return REF_STOP; - } - - case REFMSG_GET_PARAM_NAME: - { - GetParamName *gpn = (GetParamName*)partID; - bool pass_parameter = false; - for(int pass = 0; pass < Get_Pass_Count(); pass++) { - if(hTarget == (RefTargetHandle)PassParameterBlock[pass]) pass_parameter = true; - } - - if (pass_parameter) { - switch (gpn->index) - { - case PB_AMBIENT: gpn->name = _T("Ambient"); break; - case PB_DIFFUSE: gpn->name = _T("Diffuse"); break; - case PB_SPECULAR: gpn->name = _T("Specular"); break; - case PB_EMISSIVE: gpn->name = _T("Emissive"); break; - case PB_SHININESS: gpn->name = _T("Shininess"); break; - case PB_OPACITY: gpn->name = _T("Opacity"); break; - case PB_TRANSLUCENCY: gpn->name = _T("Translucency"); break; - default: gpn->name = _T(""); break; - } - } - return REF_STOP; - } - } - return(REF_SUCCEED); -} - - -/*********************************************************************************************** - * GameMtl::SetReference -- set the i'th reference * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtl::SetReference(int i, RefTargetHandle rtarg) -{ - assert(i < REF_COUNT); - - if (i == REF_MAPS) { - Maps = (GameMapsClass *)rtarg; - return; - } - - if (i == REF_MAIN) { - MainParameterBlock = (IParamBlock*)rtarg; - return; - } - - if ((i >= REF_PASS_PARAMETERS) && (i < REF_PASS_PARAMETERS + W3dMaterialClass::MAX_PASSES)) { - PassParameterBlock[i - REF_PASS_PARAMETERS] = (IParamBlock*)rtarg; - return; - } - - if ((i >= REF_TEXTURE) && (i < REF_TEXTURE + 9)) { - if (i == REF_TEXTURE + DISPLACEMENT_INDEX) { - DisplacementMap = (Texmap *)rtarg; - } else { - int offset = i - REF_TEXTURE; - int pass = offset / 2; - int stage = offset % 2; - Texture[pass][stage] = (Texmap *)rtarg; - } - return; - } -} - - -/*********************************************************************************************** - * GameMtl::GetReference -- returnst the i'th reference * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -RefTargetHandle GameMtl::GetReference(int i) -{ - if (i == REF_MAPS) { - return Maps; - } - if (i == REF_MAIN) { - return MainParameterBlock; - } - if ((i >= REF_PASS_PARAMETERS) && (i < REF_PASS_PARAMETERS + W3dMaterialClass::MAX_PASSES)) { - return PassParameterBlock[i - REF_PASS_PARAMETERS]; - } - if ((i >= REF_TEXTURE) && (i < REF_TEXTURE + 9)) { - if (i == REF_TEXTURE + DISPLACEMENT_INDEX) { - return DisplacementMap; - } else { - int offset = i - REF_TEXTURE; - int pass = offset / 2; - int stage = offset % 2; - return Texture[pass][stage]; - } - } - - return NULL; -} - - -/*********************************************************************************************** - * GameMtl::NumSubTexmaps -- returns the number of texture maps in this material * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -int GameMtl::NumSubTexmaps(void) -{ - return (W3dMaterialClass::MAX_PASSES * W3dMaterialClass::MAX_STAGES) + 1; -} - - -/*********************************************************************************************** - * GameMtl::Get_Displacement_Map_Index -- returns the Sub-texmap index for the displacement map. - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 7/01/99 PDS : Created. * - *=============================================================================================*/ -int GameMtl::Get_Displacement_Map_Index(void) const -{ - return DISPLACEMENT_INDEX; -} - - -/*********************************************************************************************** - * GameMtl::SetSubTexmap -- set the i'th texture map * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtl::SetSubTexmap(int i, Texmap * m) -{ - ReplaceReference(REF_TEXTURE + i, m); - - int pass,stage; - texmap_index_to_pass_stage(i,&pass,&stage); - if (Texture[pass][stage] != NULL) { - UVGen * uvgen = Texture[pass][stage]->GetTheUVGen(); - if (uvgen != NULL) { - uvgen->SetMapChannel(Get_Map_Channel(pass,stage)); - } - } - - NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE); -} - - -/*********************************************************************************************** - * GameMtl::GetSubTexmap -- returns the i'th texture map * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -Texmap * GameMtl::GetSubTexmap(int i) -{ - if (i == DISPLACEMENT_INDEX) { - return DisplacementMap; - } - - int pass; - int stage; - texmap_index_to_pass_stage(i,&pass,&stage); - return Texture[pass][stage]; -} - - -/*********************************************************************************************** - * GameMtl::CreateParamDlg -- creates the material editor dialog box * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -ParamDlg * GameMtl::CreateParamDlg(HWND hwnd_mtl_edit, IMtlParams *imp) -{ - GameMtlDlg *dlg = new GameMtlDlg(hwnd_mtl_edit, imp, this); - SetParamDlg(dlg); - return dlg; -} - - -/*********************************************************************************************** - * GameMtl::Notify_Changed -- someone has changed this material * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtl::Notify_Changed(void) -{ - NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE); - if (MaterialDialog != NULL) { - MaterialDialog->Update_Display(); - } -} - - -/*********************************************************************************************** - * GameMtl::Reset -- reset this material to default settings * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtl::Reset() -{ - DebugPrint("GameMtl::Reset()\n"); - - ReplaceReference(REF_MAIN,CreateParameterBlock(MainParameterBlockDesc,1,CURRENT_VERSION)); - - for (int pass = 0; pass < W3dMaterialClass::MAX_PASSES; pass++) { - - // Install a parameter block for each pass - IParamBlock * pblock = CreateParameterBlock( PassParameterBlockDescVer5, - sizeof(PassParameterBlockDescVer5)/sizeof(ParamBlockDescID), - CURRENT_VERSION); - - ReplaceReference(pass_ref_index(pass), pblock); - - for (int stage = 0;stage < W3dMaterialClass::MAX_STAGES; stage++) { - ReplaceReference(texture_ref_index(pass,stage), NULL); - - Set_Texture_Enable(pass,stage,false); - Set_Texture_Publish(pass,stage,false); - Set_Texture_Resize(pass,stage,false); - Set_Texture_No_Mipmap(pass,stage,false); - Set_Texture_Clamp_U(pass,stage,false); - Set_Texture_Clamp_V(pass,stage,false); - Set_Texture_No_LOD(pass,stage,false); - Set_Texture_Alpha_Bitmap(pass,stage,false); - Set_Texture_Hint(pass,stage,W3DTEXTURE_HINT_BASE); - Set_Texture_Display(pass,stage,false); - Set_Texture_Frame_Rate(pass,stage,15.0f); - Set_Texture_Frame_Count(pass,stage,1); - Set_Texture_Anim_Type(pass,stage,W3DTEXTURE_ANIM_LOOP); - Set_Map_Channel(pass,stage,1); - - if (MapperArg[pass][stage]) { - delete [] (MapperArg[pass][stage]); - MapperArg[pass][stage] = NULL; - MapperArgLen[pass][stage] = 0; - } - } - - Set_Sort_Level(SORT_LEVEL_NONE); - - Set_Ambient(pass,0,(pass == 0 ? Color(1.0,1.0,1.0) : Color(0,0,0))); - Set_Diffuse(pass,0,(pass == 0 ? Color(1.0,1.0,1.0) : Color(0,0,0))); - Set_Specular(pass,0,Color(0,0,0)); - Set_Emissive(pass,0,Color(0,0,0)); - Set_Shininess(pass,0,0.0f); - Set_Opacity(pass,0,1.0f); - Set_Translucency(pass,0,0.0f); - Set_Copy_Specular_To_Diffuse(pass,false); - Set_Mapping_Type(pass,0,W3DMAPPING_UV); - Set_Mapping_Type(pass,1,W3DMAPPING_UV); - Set_PSX_Translucency(pass,GAMEMTL_PSX_TRANS_NONE); - Set_PSX_Lighting(pass,true); - - Set_Depth_Compare(pass,W3DSHADER_DEPTHCOMPARE_DEFAULT); - Set_Depth_Mask(pass,W3DSHADER_DEPTHMASK_DEFAULT); - Set_Alpha_Test(pass,W3DSHADER_ALPHATEST_DEFAULT); - Set_Dest_Blend(pass,W3DSHADER_DESTBLENDFUNC_DEFAULT); - Set_Pri_Gradient(pass,W3DSHADER_PRIGRADIENT_DEFAULT); - Set_Sec_Gradient(pass,W3DSHADER_SECGRADIENT_DEFAULT); - Set_Src_Blend(pass,W3DSHADER_SRCBLENDFUNC_DEFAULT); - Set_Detail_Color_Func(pass,W3DSHADER_DETAILCOLORFUNC_DEFAULT); - Set_Detail_Alpha_Func(pass,W3DSHADER_DETAILCOLORFUNC_DEFAULT); - - // Playstation 2 default for opaque. - Set_PS2_Shader_Param_A(pass, PSS_SRC); - Set_PS2_Shader_Param_B(pass, PSS_ZERO); - Set_PS2_Shader_Param_C(pass, PSS_ONE); - Set_PS2_Shader_Param_D(pass, PSS_ZERO); - } - - Ivalid.SetEmpty(); - Set_Pass_Count(1); // set default value for the main param block -} - - -/*********************************************************************************************** - * GameMtl::Update -- time has changed * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtl::Update(TimeValue t, Interval &ivalid) -{ - // This function is called by the system prior to rendering - // Its purpose is to let you pre-calculate anything you can to - // speed up the subsequent 'Shade' calls. - Ivalid = FOREVER; - ivalid &= Ivalid; -} - - -/*********************************************************************************************** - * GameMtl::Validity -- return the validity of the material at time t * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -Interval GameMtl::Validity(TimeValue t) -{ - return FOREVER; -} - - -/*********************************************************************************************** - * GameMtl::Requirements -- what requirements does this material have? * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -ULONG GameMtl::Requirements(int subMtlNum) -{ - ULONG req = 0; - - for (int pass = 0; pass < W3dMaterialClass::MAX_PASSES; pass++) { - for (int stage = 0; stage < W3dMaterialClass::MAX_STAGES; stage++) { - if (Texture[pass][stage]) { - req |= Texture[pass][stage]->Requirements(subMtlNum); - } - } - } - - req |= MTLREQ_BGCOL; - req |= MTLREQ_NOATMOS; - - #ifdef WANT_DISPLACEMENT_MAPS - req |= MTLREQ_DISPLACEMAP; - #endif //WANT_DISPLACEMENT_MAPS - - return req; -} - - -/*********************************************************************************************** - * GameMtl::Load -- loading from a MAX file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -IOResult GameMtl::Load(ILoad *iload) -{ - ULONG nb; - int id; - int passindex = 0; - int len = 0; - unsigned char tmp8; - unsigned short tmp16; - char * tmpstring = NULL; - float tmpfloat; - IOResult res; - - GameMtlPostLoad * lc = new GameMtlPostLoad(this); - iload->RegisterPostLoadCallback(lc); - - // Register automatic translation callbacks for the pass parameter blocks - for (int i = 0; i < W3dMaterialClass::MAX_PASSES; i++) { - iload->RegisterPostLoadCallback( - new ParamBlockPLCB(PassParameterBlockVersions, NUM_OLDVERSIONS, - &CurrentPassParameterBlockVersion, this, REF_PASS_PARAMETERS + i) - ); - } - - while (IO_OK==(res=iload->OpenChunk())) { - - switch (id = iload->CurChunkID()) { - - case MTL_HDR_CHUNK: - res = MtlBase::Load(iload); - Ivalid.SetEmpty(); - break; - - case GAMEMTL_FLAGS_CHUNK: - res = iload->Read(&Flags,sizeof(Flags), &nb); - break; - - case GAMEMTL_SURFACE_TYPE_CHUNK: - res = iload->Read(&SurfaceType,sizeof(SurfaceType),&nb); - break; - - case GAMEMTL_SORT_LEVEL_CHUNK: - res = iload->Read(&SortLevel,sizeof(SortLevel),&nb); - break; - - case GAMEMTL_PASS0_CUR_PAGE: - case GAMEMTL_PASS1_CUR_PAGE: - case GAMEMTL_PASS2_CUR_PAGE: - case GAMEMTL_PASS3_CUR_PAGE: - res = iload->Read(&tmp8,sizeof(tmp8),&nb); - CurPage[id - GAMEMTL_PASS0_CUR_PAGE] = tmp8; - break; - - case GAMEMTL_PASS0_STAGE0_MAPPER_ARGS: - case GAMEMTL_PASS1_STAGE0_MAPPER_ARGS: - case GAMEMTL_PASS2_STAGE0_MAPPER_ARGS: - case GAMEMTL_PASS3_STAGE0_MAPPER_ARGS: - len = iload->CurChunkLength(); - passindex = id - GAMEMTL_PASS0_STAGE0_MAPPER_ARGS; - tmpstring = Get_Mapping_Arg_Buffer(passindex, 0, len); - res = iload->Read(tmpstring, len, &nb); - break; - - case GAMEMTL_PASS0_STAGE1_MAPPER_ARGS: - case GAMEMTL_PASS1_STAGE1_MAPPER_ARGS: - case GAMEMTL_PASS2_STAGE1_MAPPER_ARGS: - case GAMEMTL_PASS3_STAGE1_MAPPER_ARGS: - len = iload->CurChunkLength(); - passindex = id - GAMEMTL_PASS0_STAGE1_MAPPER_ARGS; - tmpstring = Get_Mapping_Arg_Buffer(passindex, 1, len); - res = iload->Read(tmpstring, len, &nb); - break; - - /* - ** All chunks below here are for the obsolete material plugin... - */ - case GAMEMTL_GAMEFLAGS_CHUNK: - break; - - case GAMEMTL_ATTRIBUTES_CHUNK: - res = iload->Read(&lc->Attributes,sizeof(lc->Attributes),&nb); - lc->IsOld = true; - break; - - case GAMEMTL_COLORS_CHUNK: - res = iload->Read(&lc->Diffuse,sizeof(lc->Diffuse),&nb); - lc->IsOld = true; - break; - - case GAMEMTL_DCT_FRAMES_CHUNK: - res = iload->Read(&tmp16,sizeof(unsigned short),&nb); - lc->DCTFrames = tmp16; - lc->IsOld = true; - break; - - case GAMEMTL_DCT_FRAME_RATE_CHUNK: - res = iload->Read(&tmpfloat,sizeof(float),&nb); - lc->DCTFrameRate = tmpfloat; - lc->IsOld = true; - break; - - case GAMEMTL_DIT_FRAMES_CHUNK: - res = iload->Read(&tmp16,sizeof(unsigned short),&nb); - lc->DITFrames = tmp16; - lc->IsOld = true; - break; - - case GAMEMTL_DIT_FRAME_RATE_CHUNK: - res = iload->Read(&tmpfloat,sizeof(float),&nb); - lc->DITFrameRate = tmpfloat; - lc->IsOld = true; - break; - - case GAMEMTL_SCT_FRAMES_CHUNK: - res = iload->Read(&tmp16,sizeof(unsigned short),&nb); - lc->SCTFrames = tmp16; - lc->IsOld = true; - break; - - case GAMEMTL_SCT_FRAME_RATE_CHUNK: - res = iload->Read(&tmpfloat,sizeof(float),&nb); - lc->SCTFrameRate = tmpfloat; - lc->IsOld = true; - break; - - case GAMEMTL_SIT_FRAMES_CHUNK: - res = iload->Read(&tmp16,sizeof(unsigned short),&nb); - lc->SITFrames = tmp16; - lc->IsOld = true; - break; - - case GAMEMTL_SIT_FRAME_RATE_CHUNK: - res = iload->Read(&tmpfloat,sizeof(float),&nb); - lc->SITFrameRate = tmpfloat; - lc->IsOld = true; - break; - - case GAMEMTL_DCT_MAPPING_CHUNK: - res = iload->Read(&tmp8,sizeof(unsigned char),&nb); - lc->DCTMappingType = tmp8; - lc->IsOld = true; - break; - - case GAMEMTL_DIT_MAPPING_CHUNK: - res = iload->Read(&tmp8,sizeof(unsigned char),&nb); - lc->DITMappingType = tmp8; - lc->IsOld = true; - break; - - case GAMEMTL_SCT_MAPPING_CHUNK: - res = iload->Read(&tmp8,sizeof(unsigned char),&nb); - lc->SCTMappingType = tmp8; - lc->IsOld = true; - break; - - case GAMEMTL_SIT_MAPPING_CHUNK: - res = iload->Read(&tmp8,sizeof(unsigned char),&nb); - lc->SITMappingType = tmp8; - lc->IsOld = true; - break; - - case GAMEMTL_DIFFUSE_COLOR_CHUNK: - res = iload->Read(&lc->Diffuse,sizeof(lc->Diffuse),&nb); - lc->IsOld = true; - break; - - case GAMEMTL_SPECULAR_COLOR_CHUNK: - res = iload->Read(&lc->Specular,sizeof(lc->Specular),&nb); - lc->IsOld = true; - break; - - case GAMEMTL_AMBIENT_COEFF_CHUNK: - res = iload->Read(&lc->AmbientCoeff,sizeof(lc->AmbientCoeff),&nb); - lc->IsOld = true; - break; - - case GAMEMTL_DIFFUSE_COEFF_CHUNK: - res = iload->Read(&lc->DiffuseCoeff,sizeof(lc->DiffuseCoeff),&nb); - lc->IsOld = true; - break; - - case GAMEMTL_SPECULAR_COEFF_CHUNK: - res = iload->Read(&lc->SpecularCoeff,sizeof(lc->SpecularCoeff),&nb); - lc->IsOld = true; - break; - - case GAMEMTL_EMISSIVE_COEFF_CHUNK: - res = iload->Read(&lc->EmissiveCoeff,sizeof(lc->EmissiveCoeff),&nb); - lc->IsOld = true; - break; - - case GAMEMTL_OPACITY_CHUNK: - res = iload->Read(&lc->Opacity,sizeof(lc->Opacity),&nb); - lc->IsOld = true; - break; - - case GAMEMTL_TRANSLUCENCY_CHUNK: - res = iload->Read(&lc->Translucency,sizeof(lc->Translucency),&nb); - lc->IsOld = true; - break; - - case GAMEMTL_SHININESS_CHUNK: - res = iload->Read(&lc->Shininess,sizeof(lc->Shininess),&nb); - lc->IsOld = true; - break; - - case GAMEMTL_FOG_CHUNK: - res = iload->Read(&lc->FogCoeff,sizeof(lc->FogCoeff),&nb); - lc->IsOld = true; - break; - - default: - break; - } - - iload->CloseChunk(); - if (res!=IO_OK) { - return res; - } - } - - return IO_OK; -} - - -/*********************************************************************************************** - * GameMtl::Save -- Saving into a MAX file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -IOResult GameMtl::Save(ISave *isave) -{ - IOResult res; - ULONG nb; - - /* - ** Save the base class stuff - */ - isave->BeginChunk(MTL_HDR_CHUNK); - res = MtlBase::Save(isave); - if (res!=IO_OK) - return res; - isave->EndChunk(); - - /* - ** Save the flags - */ - isave->BeginChunk(GAMEMTL_FLAGS_CHUNK); - isave->Write(&Flags,sizeof(Flags),&nb); - isave->EndChunk(); - - /* - ** Save the "cur-pages" - */ - uint8 tmp8; - int pass; - for (pass=0; pass < W3dMaterialClass::MAX_PASSES; pass++) { - isave->BeginChunk(GAMEMTL_PASS0_CUR_PAGE + pass); - tmp8 = CurPage[pass]; - isave->Write(&tmp8,sizeof(tmp8),&nb); - isave->EndChunk(); - } - - /* - ** Save any Mapper Args - */ - for (pass=0; pass < W3dMaterialClass::MAX_PASSES; pass++) { - char *buffer = Get_Mapping_Arg_Buffer(pass, 0); - if (buffer) { - isave->BeginChunk(GAMEMTL_PASS0_STAGE0_MAPPER_ARGS + pass); - isave->Write(buffer, strlen(buffer) + 1, &nb); - isave->EndChunk(); - } - buffer = Get_Mapping_Arg_Buffer(pass, 1); - if (buffer) { - isave->BeginChunk(GAMEMTL_PASS0_STAGE1_MAPPER_ARGS + pass); - isave->Write(buffer, strlen(buffer) + 1, &nb); - isave->EndChunk(); - } - } - - /* - ** Save the surface type - */ - isave->BeginChunk(GAMEMTL_SURFACE_TYPE_CHUNK); - isave->Write(&SurfaceType,sizeof(SurfaceType),&nb); - isave->EndChunk(); - - /* - ** Save the sort level - */ - isave->BeginChunk(GAMEMTL_SORT_LEVEL_CHUNK); - isave->Write(&SortLevel,sizeof(SortLevel),&nb); - isave->EndChunk(); - - return IO_OK; -} - - -/*********************************************************************************************** - * GameMtl::Shade -- evaluate the material for the renderer. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * This function could use a little work. It doesn't always produce correct results. * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtl::Shade(ShadeContext& sc) -{ - if (ShaderType == STE_PS2_SHADER) { - ps2_shade(sc); - return; - } - - if (gbufID) sc.SetGBufferID(gbufID); - - /* - ** Shadowing, return black - */ - if (sc.mode==SCMODE_SHADOW) { - sc.out.t = Color(0,0,0); - return; - } - - /* - ** Render each pass, initialize dest with the current background - */ - Color back_c; - Color back_t; - - Color dest; - Color src; - float alpha; - - sc.GetBGColor(back_c,back_t, FALSE); - dest = back_c; - - for (int pass=0; pass < Get_Pass_Count(); pass++) { - - /* - ** Computing the Primary and Secondary Gradients - */ - Color ambient = sc.ambientLight; - Color diffuse(0,0,0); - Color specular(0,0,0); - - for(int light_index = 0; light_index < sc.nLights; light_index++) { - - Color light_color; - Point3 light_dir; - float dot_nl; - float diffuse_coef; - - LightDesc * light = sc.Light(light_index); - if(light->Illuminate(sc, sc.Normal(), light_color, light_dir, dot_nl, diffuse_coef)) { - - //ambient += light_color; - if (dot_nl > 0.0f) diffuse += dot_nl * light_color; - - float c = DotProd(light_dir, sc.ReflectVector()); - if(c > 0.f) { - specular += (float)pow(c, Get_Shininess(pass, sc.CurTime())) * light_color; - } - } - } - - ambient = ambient * Get_Ambient(pass,sc.CurTime()); - diffuse = diffuse * Get_Diffuse(pass,sc.CurTime()); - specular = specular * Get_Specular(pass,sc.CurTime()); - - Color pri_gradient = ambient + diffuse + Get_Emissive(pass,sc.CurTime()); - if (pri_gradient.r > 1.0f) pri_gradient.r = 1.0f; - if (pri_gradient.g > 1.0f) pri_gradient.g = 1.0f; - if (pri_gradient.b > 1.0f) pri_gradient.b = 1.0f; - - Color sec_gradient = specular * Get_Specular(pass,sc.CurTime()); - - /* - ** Sampling the Texture(s) - */ - AColor texel(1,1,1,1); - if (Get_Texture_Enable(pass,0) && Texture[pass][0]) { -// if (Get_Mapping_Type(pass) == GAMEMTL_MAPPING_UV) { - texel = Texture[pass][0]->EvalColor(sc); -// } - } - - if (Get_Texture_Enable(pass,1) && Texture[pass][1]) { - AColor detail_texel = Texture[pass][1]->EvalColor(sc); - switch (Get_Detail_Color_Func(pass)) - { - case W3DSHADER_DETAILCOLORFUNC_DISABLE: - break; - case W3DSHADER_DETAILCOLORFUNC_DETAIL: - texel = detail_texel; - break; - case W3DSHADER_DETAILCOLORFUNC_SCALE: - texel.r = detail_texel.r * texel.r; - texel.g = detail_texel.g * texel.g; - texel.b = detail_texel.b * texel.b; - break; - case W3DSHADER_DETAILCOLORFUNC_INVSCALE: - texel.r = texel.r + (1.0f - texel.r) * detail_texel.r; - texel.g = texel.g + (1.0f - texel.g) * detail_texel.g; - texel.b = texel.b + (1.0f - texel.b) * detail_texel.b; - break; - case W3DSHADER_DETAILCOLORFUNC_ADD: - texel.r = detail_texel.r + texel.r; - texel.g = detail_texel.g + texel.g; - texel.b = detail_texel.b + texel.b; - break; - case W3DSHADER_DETAILCOLORFUNC_SUB: - texel.r = texel.r - detail_texel.r; - texel.g = texel.g - detail_texel.g; - texel.b = texel.b - detail_texel.b; - break; - case W3DSHADER_DETAILCOLORFUNC_SUBR: - texel.r = detail_texel.r - texel.r; - texel.g = detail_texel.g - texel.g; - texel.b = detail_texel.b - texel.b; - break; - case W3DSHADER_DETAILCOLORFUNC_BLEND: - texel.r = (texel.a * texel.r) + ((1.0f - texel.a)*detail_texel.r); - texel.g = (texel.a * texel.g) + ((1.0f - texel.a)*detail_texel.g); - texel.b = (texel.a * texel.b) + ((1.0f - texel.a)*detail_texel.b); - break; - case W3DSHADER_DETAILCOLORFUNC_DETAILBLEND: - texel.r = (detail_texel.a * texel.r) + ((1.0f - detail_texel.a)*detail_texel.r); - texel.g = (detail_texel.a * texel.g) + ((1.0f - detail_texel.a)*detail_texel.g); - texel.b = (detail_texel.a * texel.b) + ((1.0f - detail_texel.a)*detail_texel.b); - break; - } - switch (Get_Detail_Alpha_Func(pass)) - { - case W3DSHADER_DETAILALPHAFUNC_DISABLE: - break; - case W3DSHADER_DETAILALPHAFUNC_DETAIL: - texel.a = detail_texel.a; - break; - case W3DSHADER_DETAILALPHAFUNC_SCALE: - texel.a = texel.a * detail_texel.a; - break; - case W3DSHADER_DETAILALPHAFUNC_INVSCALE: - texel.a = texel.a + (1.0f - texel.a) * detail_texel.a; - break; - } - } - - /* - ** Shader parameters define combination... - */ - src.r = texel.r; - src.g = texel.g; - src.b = texel.b; - alpha = texel.a * Get_Opacity(pass,sc.CurTime()); - - switch (Get_Pri_Gradient(pass)) - { - case W3DSHADER_PRIGRADIENT_DISABLE: break; - case W3DSHADER_PRIGRADIENT_MODULATE: src = src * pri_gradient; break; - case W3DSHADER_PRIGRADIENT_ADD: src = src + pri_gradient; break; - } - - switch (Get_Sec_Gradient(pass)) - { - case W3DSHADER_SECGRADIENT_DISABLE: break; - case W3DSHADER_SECGRADIENT_ENABLE: src = src + sec_gradient; break; - } - - if (src.r > 1.0f) src.r = 1.0f; - if (src.g > 1.0f) src.g = 1.0f; - if (src.b > 1.0f) src.b = 1.0f; - - if (src.r < 0.0f) src.r = 0.0f; - if (src.g < 0.0f) src.g = 0.0f; - if (src.b < 0.0f) src.b = 0.0f; - - Color dest_blend; - switch (Get_Dest_Blend(pass)) - { - case W3DSHADER_DESTBLENDFUNC_ZERO: dest_blend = Color(0,0,0); break; - case W3DSHADER_DESTBLENDFUNC_ONE: dest_blend = Color(1,1,1); break; - case W3DSHADER_DESTBLENDFUNC_SRC_COLOR: dest_blend = src; break; - case W3DSHADER_DESTBLENDFUNC_ONE_MINUS_SRC_COLOR: dest_blend = Color(1.0f-src.r,1.0f-src.g, 1.0f-src.b); break; - case W3DSHADER_DESTBLENDFUNC_SRC_ALPHA: dest_blend = Color(alpha,alpha,alpha); break; - case W3DSHADER_DESTBLENDFUNC_ONE_MINUS_SRC_ALPHA: dest_blend = Color(1.0f-alpha,1.0f-alpha,1.0f-alpha); break; - case W3DSHADER_DESTBLENDFUNC_SRC_COLOR_PREFOG: dest_blend = src; break; - } - - Color src_blend; - switch (Get_Src_Blend(pass)) - { - case W3DSHADER_SRCBLENDFUNC_ZERO: src_blend = Color(0,0,0); break; - case W3DSHADER_SRCBLENDFUNC_ONE: src_blend = Color(1,1,1); break; - case W3DSHADER_SRCBLENDFUNC_SRC_ALPHA: src_blend = Color(alpha,alpha,alpha); break; - case W3DSHADER_SRCBLENDFUNC_ONE_MINUS_SRC_ALPHA: src_blend = Color(1.0f-alpha,1.0f-alpha,1.0f-alpha); break; - } - - src = scale(src_blend,src) + scale(dest_blend,dest); - - /* - ** Dest becomes Src and we repeat! - */ - dest = src; - - } - - sc.out.t = Color(0.0f, 0.0f, 0.0f); - sc.out.c = dest; - -} - - -/*********************************************************************************************** - * GameMtl::ps2_shade -- Emulate the PS2 shader. * - * * - * * - * * - * * - * HISTORY: * - * 10/12/1999MLL: Created. * - *=============================================================================================*/ -void GameMtl::ps2_shade(ShadeContext& sc) -{ - if (gbufID) sc.SetGBufferID(gbufID); - - /* - ** Shadowing, return black - */ - if (sc.mode == SCMODE_SHADOW) { - sc.out.t = Color(0,0,0); - return; - } - - /* - ** Render each pass, initialize dest with the current background - */ - - // Background transparency. ??? - Color back_t; - Color back_c; - - AColor dest; - AColor src(1,1,1,1); - - sc.GetBGColor(back_c, back_t, FALSE); - - dest.r = back_c.r; - dest.g = back_c.g; - dest.b = back_c.b; - dest.a = 0.0f; - - for (int pass=0; pass < Get_Pass_Count(); pass++) { - - // Compute the gradients. - Color ambient = sc.ambientLight; - Color diffuse(0,0,0); - Color specular(0,0,0); - - for (int light_index = 0; light_index < sc.nLights; light_index++) { - - Color light_color; - Point3 light_dir; - float dot_nl; - float diffuse_coef; - - LightDesc * light = sc.Light(light_index); - - assert(light); - if(light->Illuminate(sc, sc.Normal(), light_color, light_dir, dot_nl, diffuse_coef)) { - - if (dot_nl > 0.0f) diffuse += dot_nl * light_color; - - float c = DotProd(light_dir, sc.ReflectVector()); - if (c > 0.f) { - specular += (float)pow(c, Get_Shininess(pass, sc.CurTime())) * light_color; - } - } - } - - ambient = ambient * Get_Ambient(pass,sc.CurTime()); - diffuse = diffuse * Get_Diffuse(pass,sc.CurTime()); - specular = specular * Get_Specular(pass,sc.CurTime()); - - Color gradient = ambient + diffuse + Get_Emissive(pass,sc.CurTime()); - AColor pri_gradient; - pri_gradient.r = gradient.r; - pri_gradient.g = gradient.g; - pri_gradient.b = gradient.b; - pri_gradient.a = 1.0f; - if (pri_gradient.r > 1.0f) pri_gradient.r = 1.0f; - if (pri_gradient.g > 1.0f) pri_gradient.g = 1.0f; - if (pri_gradient.b > 1.0f) pri_gradient.b = 1.0f; - - /* - ** Sampling the Texture(s) - */ - if (Get_Texture_Enable(pass,0) && Texture[pass][0]) { - src = Texture[pass][0]->EvalColor(sc); - } - - - /* - ** Shader parameters define combination... - */ - src.a *= Get_Opacity(pass,sc.CurTime()); - - switch (Get_Pri_Gradient(pass)) - { - case PSS_PRIGRADIENT_MODULATE: - src = src * pri_gradient; - break; - case PSS_PRIGRADIENT_HIGHLIGHT: - src = src * pri_gradient; - src += back_t; // ??? - break; - case PSS_PRIGRADIENT_HIGHLIGHT2: - src = src * pri_gradient; - src += back_t; // ??? - break; - } - - if (src.r > 1.0f) src.r = 1.0f; - if (src.g > 1.0f) src.g = 1.0f; - if (src.b > 1.0f) src.b = 1.0f; - if (src.b > 1.0f) src.a = 1.0f; - - if (src.r < 0.0f) src.r = 0.0f; - if (src.g < 0.0f) src.g = 0.0f; - if (src.b < 0.0f) src.b = 0.0f; - if (src.a < 0.0f) src.a = 0.0f; - - AColor param_a; - AColor param_b; - AColor param_c; - AColor param_d; - int a_value = Get_PS2_Shader_Param_A(pass); - int b_value = Get_PS2_Shader_Param_B(pass); - int c_value = Get_PS2_Shader_Param_C(pass); - int d_value = Get_PS2_Shader_Param_D(pass); - - switch (a_value) - { - case PSS_SRC: - param_a = src; - break; - case PSS_DEST: - param_a = dest; - break; - case PSS_ZERO: - param_a = AColor(0, 0, 0, 0); - break; - } - - switch (b_value) - { - case PSS_SRC: - param_b = src; - break; - case PSS_DEST: - param_b = dest; - break; - case PSS_ZERO: - param_b = AColor(0, 0, 0, 0); - break; - } - - switch (c_value) - { - case PSS_SRC_ALPHA: - param_c = AColor(src.a, src.a, src.a, src.a); - break; - case PSS_DEST_ALPHA: - param_c = back_t; // ??? - break; - case PSS_ONE: - param_c = AColor(1, 1, 1, 1); - break; - } - - switch (d_value) - { - case PSS_SRC: - param_d = src; - break; - case PSS_DEST: - param_d = dest; - break; - case PSS_ZERO: - param_d = AColor(0, 0, 0); - break; - } - - src = scale((param_a - param_b), param_c) + param_d; - - if (src.r > 1.0f) src.r = 1.0f; - if (src.g > 1.0f) src.g = 1.0f; - if (src.b > 1.0f) src.b = 1.0f; - if (src.b > 1.0f) src.a = 1.0f; - - if (src.r < 0.0f) src.r = 0.0f; - if (src.g < 0.0f) src.g = 0.0f; - if (src.b < 0.0f) src.b = 0.0f; - if (src.a < 0.0f) src.a = 0.0f; - - /* - ** Dest becomes Src and we repeat! - */ - dest = src; - } - - sc.out.t = Color(0.0f, 0.0f, 0.0f); - sc.out.c.r = dest.r; - sc.out.c.g = dest.g; - sc.out.c.b = dest.b; - - -} - -// PS2 equation paramaters. -// They are set to primes to avoid multiple equation solutions. -enum Shader_Translation { - ST_ZERO, - ST_ONE, - ST_SRC = 7, - ST_DEST = 31, - ST_SRC_ALPHA = 101, - ST_DEST_ALPHA = 2999, -}; - -/*********************************************************************************************** - * GameMtl::Compute_PC_Shader_From_PS2_Shader -- Determine if a PC shader can be created. * - * * - * * - * * - * * - * HISTORY: * - * 10/13/1999MLL: Created. * - *=============================================================================================*/ -int GameMtl::Compute_PC_Shader_From_PS2_Shader(int pass) -{ - int param_value[4]; - - // These match the PC equation paramaters. - static const int src_blend[4] = { - ST_ZERO, - ST_ONE, - ST_SRC_ALPHA, - 1 - ST_SRC_ALPHA - }; - static const int dest_blend[6] = { - ST_ZERO, - ST_ONE, - ST_SRC, - 1 - ST_SRC, - ST_SRC_ALPHA, - 1 - ST_SRC_ALPHA - }; - - int i = 0; - int j = 0; - int equation_value = 0; - - // Get the PS2 shader values. - param_value[0] = Get_PS2_Shader_Param_A(pass); - param_value[1] = Get_PS2_Shader_Param_B(pass); - param_value[2] = Get_PS2_Shader_Param_D(pass); - param_value[3] = Get_PS2_Shader_Param_C(pass); - - // Convert them to the enumeration. - for (i = 0; i < 3; i++) { - switch(param_value[i]) - { - case PSS_SRC: - param_value[i] = ST_SRC; - break; - case PSS_DEST: - param_value[i] = ST_DEST; - break; - case PSS_ZERO: - param_value[i] = ST_ZERO; - break; - } - } - - // The alpha paramater. - switch(param_value[3]) - { - case PSS_SRC_ALPHA: - param_value[3] = ST_SRC_ALPHA; - break; - case PSS_DEST_ALPHA: - param_value[3] = ST_DEST_ALPHA; - break; - case PSS_ONE: - param_value[3] = ST_ONE; - break; - } - - // Calculate the PS2 shader. - equation_value = ((param_value[0] - param_value[1]) * param_value[3]) + param_value[2]; - - for (i = 0; i < 4; i++) { - for (j = 0; j < 6; j++) { - // Calculate the PC shader. If equal, we have found a conversion. - if (((src_blend[i] * ST_SRC) + (dest_blend[j] * ST_DEST)) == equation_value) { - break; - } - } - - if (j != 6) { - break; - } - } - - if ((j == 6) && (i == 4)) { - // Set the W3D shader to opaque. - Set_Dest_Blend(pass, W3DSHADER_DESTBLENDFUNC_ZERO); - Set_Src_Blend(pass, W3DSHADER_SRCBLENDFUNC_ONE); - - // No matches. - return (FALSE); - } - - // Set the PC shader to an equivalant of the PS2 shader. - switch (dest_blend[j]) - { - case ST_ZERO: - Set_Dest_Blend(pass, W3DSHADER_DESTBLENDFUNC_ZERO); - break; - case ST_ONE: - Set_Dest_Blend(pass, W3DSHADER_DESTBLENDFUNC_ONE); - break; - case ST_SRC: - Set_Dest_Blend(pass, W3DSHADER_DESTBLENDFUNC_SRC_COLOR); - break; - case (1 - ST_SRC): - Set_Dest_Blend(pass, W3DSHADER_DESTBLENDFUNC_ONE_MINUS_SRC_COLOR); - break; - case ST_SRC_ALPHA: - Set_Dest_Blend(pass, W3DSHADER_DESTBLENDFUNC_SRC_ALPHA); - break; - case (1 - ST_SRC_ALPHA): - Set_Dest_Blend(pass, W3DSHADER_DESTBLENDFUNC_ONE_MINUS_SRC_ALPHA); - break; - } - - switch (src_blend[i]) - { - case ST_ZERO: - Set_Src_Blend(pass, W3DSHADER_SRCBLENDFUNC_ZERO); - break; - case ST_ONE: - Set_Src_Blend(pass, W3DSHADER_SRCBLENDFUNC_ONE); - break; - case ST_SRC_ALPHA: - Set_Src_Blend(pass, W3DSHADER_SRCBLENDFUNC_SRC_ALPHA); - break; - case (1 - ST_SRC_ALPHA): - Set_Src_Blend(pass, W3DSHADER_SRCBLENDFUNC_ONE_MINUS_SRC_ALPHA); - break; - } - - // A match was made. - return (TRUE); -} - - -/*********************************************************************************************** - * GameMtl::Compute_PS2_Shader_From_PC_Shader -- Change a W3D material to a PS2 W3D material. * -W3DSHADER_PRIGRADIENT_ * * - * * - * * - * * - * HISTORY: * - * 10/26/1999MLL: Created. * - *=============================================================================================*/ -int GameMtl::Compute_PS2_Shader_From_PC_Shader(int pass) -{ - - // These match the PC equation paramaters. - static const int a_blend[3] = { - ST_ZERO, - ST_SRC, - ST_DEST, - }; - - static const int b_blend[3] = { - ST_ZERO, - ST_SRC, - ST_DEST, - }; - - static const int d_blend[3] = { - ST_ZERO, - ST_SRC, - ST_DEST, - }; - - static const int c_blend[6] = { - ST_ONE, - ST_SRC_ALPHA, - ST_DEST_ALPHA, - }; - - int i = 0; - int j = 0; - int k = 0; - int l = 0; - int equation_value = 0; - int param_value[2]; - - // Get the PC shader values. - param_value[0] = Get_Src_Blend(pass); - param_value[1] = Get_Dest_Blend(pass); - - switch (param_value[0]) - { - case W3DSHADER_SRCBLENDFUNC_ZERO: - param_value[0] = ST_ZERO; - break; - case W3DSHADER_SRCBLENDFUNC_ONE: - param_value[0] = ST_ONE; - break; - case W3DSHADER_SRCBLENDFUNC_SRC_ALPHA: - param_value[0] = ST_SRC_ALPHA; - break; - case W3DSHADER_SRCBLENDFUNC_ONE_MINUS_SRC_ALPHA: - param_value[0] = 1 - ST_SRC_ALPHA; - break; - } - - // Convert them to the enumeration. - switch (param_value[1]) - { - case W3DSHADER_DESTBLENDFUNC_ZERO: - param_value[1] = ST_ZERO; - break; - case W3DSHADER_DESTBLENDFUNC_ONE: - param_value[1] = ST_ONE; - break; - case W3DSHADER_DESTBLENDFUNC_SRC_COLOR: - param_value[1] = ST_SRC; - break; - case W3DSHADER_DESTBLENDFUNC_ONE_MINUS_SRC_COLOR: - param_value[1] = 1 - ST_SRC; - break; - case W3DSHADER_DESTBLENDFUNC_SRC_ALPHA: - param_value[1] = ST_SRC_ALPHA; - break; - case W3DSHADER_DESTBLENDFUNC_ONE_MINUS_SRC_ALPHA: - param_value[1] = 1 - ST_SRC_ALPHA; - break; - case W3DSHADER_DESTBLENDFUNC_SRC_COLOR_PREFOG: - assert(true); - break; - } - - - // Calculate the PC shader. - equation_value = param_value[0] * ST_SRC + param_value[1] * ST_DEST; - - // Set the shader to be a PS2 Shader. - ShaderType = STE_PS2_SHADER; - - // Find a match for the depth compare test. - switch (Get_Depth_Compare(pass)) - { - case W3DSHADER_DEPTHCOMPARE_PASS_NEVER: - Set_Depth_Compare(pass, PSS_DEPTHCOMPARE_PASS_NEVER); - break; - case W3DSHADER_DEPTHCOMPARE_PASS_LESS: - Set_Depth_Compare(pass, PSS_DEPTHCOMPARE_PASS_LESS); - break; - case W3DSHADER_DEPTHCOMPARE_PASS_LEQUAL: - Set_Depth_Compare(pass, PSS_DEPTHCOMPARE_PASS_LEQUAL); - break; - case W3DSHADER_DEPTHCOMPARE_PASS_ALWAYS: - Set_Depth_Compare(pass, PSS_DEPTHCOMPARE_PASS_ALWAYS); - break; - default: - Set_Depth_Compare(pass, PSS_DEPTHCOMPARE_PASS_LEQUAL); - break; - } - - // Only 1 gradient matches between the PC and PS2. - switch (Get_Pri_Gradient(pass)) - { - case W3DSHADER_PRIGRADIENT_MODULATE: - Set_Pri_Gradient(pass, PSS_PRIGRADIENT_MODULATE); - break; - default: - Set_Pri_Gradient(pass, PSS_PRIGRADIENT_MODULATE); - break; - } - - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { - for (k = 0; k < 3; k++) { - for (l = 0; l < 3; l++) { - // Calculate the PS2 shader. If equal, we have found a conversion. - if (equation_value == ((a_blend[i] - b_blend[j]) * c_blend[k]) + d_blend[l]) { - goto finished; - } - } - } - } - } - - // Set the PS2 W3D shader to opaque. - Set_PS2_Shader_Param_A(pass, PSS_SRC); - Set_PS2_Shader_Param_B(pass, PSS_ZERO); - Set_PS2_Shader_Param_C(pass, PSS_ONE); - Set_PS2_Shader_Param_D(pass, PSS_ZERO); - Set_Depth_Mask(pass,W3DSHADER_DEPTHMASK_DEFAULT); - - // No matches. - return (FALSE); - -finished: - // Set the PS2 shader to an equivalant of the PC shader. - switch (a_blend[i]) - { - case ST_ZERO: - Set_PS2_Shader_Param_A(pass, PSS_ZERO); - break; - case ST_SRC: - Set_PS2_Shader_Param_A(pass, PSS_SRC); - break; - case ST_DEST: - Set_PS2_Shader_Param_A(pass, PSS_DEST); - break; - } - - switch (b_blend[j]) - { - case ST_ZERO: - Set_PS2_Shader_Param_B(pass, PSS_ZERO); - break; - case ST_SRC: - Set_PS2_Shader_Param_B(pass, PSS_SRC); - break; - case ST_DEST: - Set_PS2_Shader_Param_B(pass, PSS_DEST); - break; - } - - - switch (d_blend[l]) - { - case ST_ZERO: - Set_PS2_Shader_Param_D(pass, PSS_ZERO); - break; - case ST_SRC: - Set_PS2_Shader_Param_D(pass, PSS_SRC); - break; - case ST_DEST: - Set_PS2_Shader_Param_D(pass, PSS_DEST); - break; - } - - switch (c_blend[k]) - { - case ST_ONE: - Set_PS2_Shader_Param_C(pass, PSS_ONE); - break; - case ST_SRC_ALPHA: - Set_PS2_Shader_Param_C(pass, PSS_SRC_ALPHA); - break; - case ST_DEST_ALPHA: - Set_PS2_Shader_Param_C(pass, PSS_DEST_ALPHA); - break; - } - - // A match was made. - return (TRUE); -} - -void GameMtl::Set_Pass_Count(int passcount) -{ - assert(MainParameterBlock); - MainParameterBlock->SetValue(0, TimeValue(0), passcount); -} - -int GameMtl::Get_Pass_Count(void) -{ - assert(MainParameterBlock); - int pcount; - MainParameterBlock->GetValue(0, TimeValue(0), pcount, FOREVER); - return pcount; -} - - -Color GameMtl::Get_Ambient(int pass,TimeValue t) -{ - Color val; - PassParameterBlock[pass]->GetValue(PB_AMBIENT,t,val,FOREVER); - return val; -} -Color GameMtl::Get_Diffuse(int pass,TimeValue t) -{ - Color val; - PassParameterBlock[pass]->GetValue(PB_DIFFUSE,t,val,FOREVER); - return val; -} -Color GameMtl::Get_Specular(int pass,TimeValue t) -{ - Color val; - PassParameterBlock[pass]->GetValue(PB_SPECULAR,t,val,FOREVER); - return val; -} -Color GameMtl::Get_Emissive(int pass,TimeValue t) -{ - Color val; - PassParameterBlock[pass]->GetValue(PB_EMISSIVE,t,val,FOREVER); - return val; -} -float GameMtl::Get_Shininess(int pass,TimeValue t) -{ - float val; - PassParameterBlock[pass]->GetValue(PB_SHININESS,t,val,FOREVER); - return val; -} -float GameMtl::Get_Opacity(int pass,TimeValue t) -{ - float val; - PassParameterBlock[pass]->GetValue(PB_OPACITY,t,val,FOREVER); - return val; -} -float GameMtl::Get_Translucency(int pass,TimeValue t) -{ - float val; - PassParameterBlock[pass]->GetValue(PB_TRANSLUCENCY,t,val,FOREVER); - return val; -} -int GameMtl::Get_Copy_Specular_To_Diffuse(int pass) -{ - int val; - PassParameterBlock[pass]->GetValue(PB_COPY_SPECULAR_TO_DIFFUSE,0,val,FOREVER); - return val; -} -int GameMtl::Get_Mapping_Type(int pass, int stage) -{ - int val = -1; - if (stage == 0) - PassParameterBlock[pass]->GetValue(PB_STAGE0_MAPPING_TYPE,0,val,FOREVER); - else if (stage == 1) - PassParameterBlock[pass]->GetValue(PB_STAGE1_MAPPING_TYPE,0,val,FOREVER); - return val; -} -int GameMtl::Get_PSX_Translucency(int pass) -{ - int val; - PassParameterBlock[pass]->GetValue(PB_PSX_TRANSLUCENCY,0,val,FOREVER); - return val; -} -int GameMtl::Get_PSX_Lighting(int pass) -{ - int val; - PassParameterBlock[pass]->GetValue(PB_PSX_LIGHTING,0,val,FOREVER); - return val; -} -int GameMtl::Get_Depth_Compare(int pass) -{ - int val; - PassParameterBlock[pass]->GetValue(PB_DEPTH_COMPARE,0,val,FOREVER); - return val; -} -int GameMtl::Get_Depth_Mask(int pass) -{ - int val; - PassParameterBlock[pass]->GetValue(PB_DEPTH_MASK,0,val,FOREVER); - return val; -} -int GameMtl::Get_Alpha_Test(int pass) -{ - int val; - PassParameterBlock[pass]->GetValue(PB_ALPHA_TEST,0,val,FOREVER); - return val; -} -int GameMtl::Get_Dest_Blend(int pass) -{ - int val; - PassParameterBlock[pass]->GetValue(PB_DEST_BLEND,0,val,FOREVER); - return val; -} -int GameMtl::Get_Pri_Gradient(int pass) -{ - int val; - PassParameterBlock[pass]->GetValue(PB_PRI_GRADIENT,0,val,FOREVER); - return val; -} -int GameMtl::Get_Sec_Gradient(int pass) -{ - int val; - PassParameterBlock[pass]->GetValue(PB_SEC_GRADIENT,0,val,FOREVER); - return val; -} -int GameMtl::Get_Src_Blend(int pass) -{ - int val; - PassParameterBlock[pass]->GetValue(PB_SRC_BLEND,0,val,FOREVER); - return val; -} -int GameMtl::Get_Detail_Color_Func(int pass) -{ - int val; - PassParameterBlock[pass]->GetValue(PB_DETAIL_COLOR_FUNC,0,val,FOREVER); - return val; -} -int GameMtl::Get_Detail_Alpha_Func(int pass) -{ - int val; - PassParameterBlock[pass]->GetValue(PB_DETAIL_ALPHA_FUNC,0,val,FOREVER); - return val; -} -int GameMtl::Get_Texture_Enable(int pass,int stage) -{ - int val; - if (stage == 0) { - PassParameterBlock[pass]->GetValue(PB_STAGE0_TEXTURE_ENABLE,0,val,FOREVER); - } else { - PassParameterBlock[pass]->GetValue(PB_STAGE1_TEXTURE_ENABLE,0,val,FOREVER); - } - return val; -} -int GameMtl::Get_Texture_Publish(int pass,int stage) -{ - int val; - if (stage == 0) { - PassParameterBlock[pass]->GetValue(PB_STAGE0_TEXTURE_PUBLISH,0,val,FOREVER); - } else { - PassParameterBlock[pass]->GetValue(PB_STAGE1_TEXTURE_PUBLISH,0,val,FOREVER); - } - return val; -} -int GameMtl::Get_Texture_Resize(int pass,int stage) -{ - int val; - if (stage == 0) { - PassParameterBlock[pass]->GetValue(PB_STAGE0_TEXTURE_RESIZE,0,val,FOREVER); - } else { - PassParameterBlock[pass]->GetValue(PB_STAGE1_TEXTURE_RESIZE,0,val,FOREVER); - } - return val; -} -int GameMtl::Get_Texture_No_Mipmap(int pass,int stage) -{ - int val; - if (stage == 0) { - PassParameterBlock[pass]->GetValue(PB_STAGE0_TEXTURE_NO_MIPMAP,0,val,FOREVER); - } else { - PassParameterBlock[pass]->GetValue(PB_STAGE1_TEXTURE_NO_MIPMAP,0,val,FOREVER); - } - return val; -} -int GameMtl::Get_Texture_Clamp_U(int pass,int stage) -{ - int val; - if (stage == 0) { - PassParameterBlock[pass]->GetValue(PB_STAGE0_TEXTURE_CLAMP_U,0,val,FOREVER); - } else { - PassParameterBlock[pass]->GetValue(PB_STAGE1_TEXTURE_CLAMP_U,0,val,FOREVER); - } - return val; -} -int GameMtl::Get_Texture_Clamp_V(int pass,int stage) -{ - int val; - if (stage == 0) { - PassParameterBlock[pass]->GetValue(PB_STAGE0_TEXTURE_CLAMP_V,0,val,FOREVER); - } else { - PassParameterBlock[pass]->GetValue(PB_STAGE1_TEXTURE_CLAMP_V,0,val,FOREVER); - } - return val; -} -int GameMtl::Get_Texture_No_LOD(int pass,int stage) -{ - int val; - if (stage == 0) { - PassParameterBlock[pass]->GetValue(PB_STAGE0_TEXTURE_NO_LOD,0,val,FOREVER); - } else { - PassParameterBlock[pass]->GetValue(PB_STAGE1_TEXTURE_NO_LOD,0,val,FOREVER); - } - return val; -} -int GameMtl::Get_Texture_Alpha_Bitmap(int pass,int stage) -{ - int val; - if (stage == 0) { - PassParameterBlock[pass]->GetValue(PB_STAGE0_TEXTURE_ALPHA_BITMAP,0,val,FOREVER); - } else { - PassParameterBlock[pass]->GetValue(PB_STAGE1_TEXTURE_ALPHA_BITMAP,0,val,FOREVER); - } - return val; -} -int GameMtl::Get_Texture_Hint(int pass,int stage) -{ - int val; - if (stage == 0) { - PassParameterBlock[pass]->GetValue(PB_STAGE0_TEXTURE_HINT,0,val,FOREVER); - } else { - PassParameterBlock[pass]->GetValue(PB_STAGE1_TEXTURE_HINT,0,val,FOREVER); - } - return val; -} -int GameMtl::Get_Texture_Display(int pass,int stage) -{ - int val; - if (stage == 0) { - PassParameterBlock[pass]->GetValue(PB_STAGE0_TEXTURE_DISPLAY,0,val,FOREVER); - } else { - PassParameterBlock[pass]->GetValue(PB_STAGE1_TEXTURE_DISPLAY,0,val,FOREVER); - } - return val; -} -float GameMtl::Get_Texture_Frame_Rate(int pass,int stage) -{ - float val; - if (stage == 0) { - PassParameterBlock[pass]->GetValue(PB_STAGE0_TEXTURE_FRAME_RATE,0,val,FOREVER); - } else { - PassParameterBlock[pass]->GetValue(PB_STAGE1_TEXTURE_FRAME_RATE,0,val,FOREVER); - } - return val; -} -int GameMtl::Get_Texture_Frame_Count(int pass,int stage) -{ - int val; - if (stage == 0) { - PassParameterBlock[pass]->GetValue(PB_STAGE0_TEXTURE_FRAME_COUNT,0,val,FOREVER); - } else { - PassParameterBlock[pass]->GetValue(PB_STAGE1_TEXTURE_FRAME_COUNT,0,val,FOREVER); - } - return val; -} -int GameMtl::Get_Texture_Anim_Type(int pass,int stage) -{ - int val; - if (stage == 0) { - PassParameterBlock[pass]->GetValue(PB_STAGE0_TEXTURE_ANIM_TYPE,0,val,FOREVER); - } else { - PassParameterBlock[pass]->GetValue(PB_STAGE1_TEXTURE_ANIM_TYPE,0,val,FOREVER); - } - return val; -} -Texmap * GameMtl::Get_Texture(int pass,int stage) -{ - return GetSubTexmap(pass_stage_to_texmap_index(pass,stage)); -} - -int GameMtl::Get_PS2_Shader_Param_A(int pass) -{ - int val; - PassParameterBlock[pass]->GetValue(PB_PS2_SHADER_PARAM_A,0,val,FOREVER); - return val; -} - -int GameMtl::Get_PS2_Shader_Param_B(int pass) -{ - int val; - PassParameterBlock[pass]->GetValue(PB_PS2_SHADER_PARAM_B,0,val,FOREVER); - return val; -} - -int GameMtl::Get_PS2_Shader_Param_C(int pass) -{ - int val; - PassParameterBlock[pass]->GetValue(PB_PS2_SHADER_PARAM_C,0,val,FOREVER); - return val; -} - -int GameMtl::Get_PS2_Shader_Param_D(int pass) -{ - int val; - PassParameterBlock[pass]->GetValue(PB_PS2_SHADER_PARAM_D,0,val,FOREVER); - return val; -} - -int GameMtl::Get_Map_Channel(int pass,int stage) -{ - int val; - if (stage == 0) { - PassParameterBlock[pass]->GetValue(PB_STAGE0_MAP_CHANNEL,0,val,FOREVER); - } else { - PassParameterBlock[pass]->GetValue(PB_STAGE1_MAP_CHANNEL,0,val,FOREVER); - } - return val; -} - - -void GameMtl::Set_Ambient(int pass,TimeValue t,Color val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_AMBIENT, t, val); -} -void GameMtl::Set_Diffuse(int pass,TimeValue t,Color val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_DIFFUSE, t, val); -} -void GameMtl::Set_Specular(int pass,TimeValue t,Color val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_SPECULAR, t, val); -} -void GameMtl::Set_Emissive(int pass,TimeValue t,Color val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_EMISSIVE, t, val); -} -void GameMtl::Set_Shininess(int pass,TimeValue t,float val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_SHININESS, t, val); -} -void GameMtl::Set_Opacity(int pass,TimeValue t,float val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_OPACITY, t, val); -} -void GameMtl::Set_Translucency(int pass,TimeValue t,float val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_TRANSLUCENCY, t, val); -} -void GameMtl::Set_Copy_Specular_To_Diffuse(int pass,bool val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_COPY_SPECULAR_TO_DIFFUSE, 0, val); -} -void GameMtl::Set_Mapping_Type(int pass,int stage,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - if (stage == 0) - PassParameterBlock[pass]->SetValue(PB_STAGE0_MAPPING_TYPE, 0, val); - else if (stage == 1) - PassParameterBlock[pass]->SetValue(PB_STAGE1_MAPPING_TYPE, 0, val); -} -void GameMtl::Set_PSX_Translucency(int pass,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_PSX_TRANSLUCENCY, 0, val); -} -void GameMtl::Set_PSX_Lighting(int pass,bool val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_PSX_LIGHTING, 0, val); -} -void GameMtl::Set_Depth_Compare(int pass,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_DEPTH_COMPARE, 0, val); -} -void GameMtl::Set_Depth_Mask(int pass,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_DEPTH_MASK, 0, val); -} -void GameMtl::Set_Alpha_Test(int pass,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_ALPHA_TEST, 0, val); -} -void GameMtl::Set_Dest_Blend(int pass,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_DEST_BLEND, 0, val); -} -void GameMtl::Set_Pri_Gradient(int pass,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_PRI_GRADIENT, 0, val); -} -void GameMtl::Set_Sec_Gradient(int pass,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_SEC_GRADIENT, 0, val); -} -void GameMtl::Set_Src_Blend(int pass,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_SRC_BLEND, 0, val); -} -void GameMtl::Set_Detail_Color_Func(int pass,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_DETAIL_COLOR_FUNC, 0, val); -} -void GameMtl::Set_Detail_Alpha_Func(int pass,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_DETAIL_ALPHA_FUNC, 0, val); -} -void GameMtl::Set_Texture_Enable(int pass,int stage,bool val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - if (stage == 0) { - PassParameterBlock[pass]->SetValue(PB_STAGE0_TEXTURE_ENABLE, 0, val); - } else { - PassParameterBlock[pass]->SetValue(PB_STAGE1_TEXTURE_ENABLE, 0, val); - } -} -void GameMtl::Set_Texture_Publish(int pass,int stage,bool val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - if (stage == 0) { - PassParameterBlock[pass]->SetValue(PB_STAGE0_TEXTURE_PUBLISH, 0, val); - } else { - PassParameterBlock[pass]->SetValue(PB_STAGE1_TEXTURE_PUBLISH, 0, val); - } -} -void GameMtl::Set_Texture_Resize(int pass,int stage,bool val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - if (stage == 0) { - PassParameterBlock[pass]->SetValue(PB_STAGE0_TEXTURE_RESIZE, 0, val); - } else { - PassParameterBlock[pass]->SetValue(PB_STAGE1_TEXTURE_RESIZE, 0, val); - } -} -void GameMtl::Set_Texture_No_Mipmap(int pass,int stage,bool val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - if (stage == 0) { - PassParameterBlock[pass]->SetValue(PB_STAGE0_TEXTURE_NO_MIPMAP, 0, val); - } else { - PassParameterBlock[pass]->SetValue(PB_STAGE1_TEXTURE_NO_MIPMAP, 0, val); - } -} -void GameMtl::Set_Texture_Clamp_U(int pass,int stage,bool val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - if (stage == 0) { - PassParameterBlock[pass]->SetValue(PB_STAGE0_TEXTURE_CLAMP_U, 0, val); - } else { - PassParameterBlock[pass]->SetValue(PB_STAGE1_TEXTURE_CLAMP_U, 0, val); - } -} -void GameMtl::Set_Texture_Clamp_V(int pass,int stage,bool val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - if (stage == 0) { - PassParameterBlock[pass]->SetValue(PB_STAGE0_TEXTURE_CLAMP_V, 0, val); - } else { - PassParameterBlock[pass]->SetValue(PB_STAGE1_TEXTURE_CLAMP_V, 0, val); - } -} -void GameMtl::Set_Texture_No_LOD(int pass,int stage,bool val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - if (stage == 0) { - PassParameterBlock[pass]->SetValue(PB_STAGE0_TEXTURE_NO_LOD, 0, val); - } else { - PassParameterBlock[pass]->SetValue(PB_STAGE1_TEXTURE_NO_LOD, 0, val); - } -} -void GameMtl::Set_Texture_Alpha_Bitmap(int pass,int stage,bool val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - if (stage == 0) { - PassParameterBlock[pass]->SetValue(PB_STAGE0_TEXTURE_ALPHA_BITMAP, 0, val); - } else { - PassParameterBlock[pass]->SetValue(PB_STAGE1_TEXTURE_ALPHA_BITMAP, 0, val); - } -} -void GameMtl::Set_Texture_Hint(int pass,int stage,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - if (stage == 0) { - PassParameterBlock[pass]->SetValue(PB_STAGE0_TEXTURE_HINT, 0, val); - } else { - PassParameterBlock[pass]->SetValue(PB_STAGE1_TEXTURE_HINT, 0, val); - } -} -void GameMtl::Set_Texture_Display(int pass,int stage,bool val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - - // clear all tex display flags - for (int pi = 0; piSetValue(PB_STAGE0_TEXTURE_DISPLAY, 0, false); - PassParameterBlock[pi]->SetValue(PB_STAGE1_TEXTURE_DISPLAY, 0, false); - } - - // set the one we want - if (val == true) { - - if (stage == 0) { - PassParameterBlock[pass]->SetValue(PB_STAGE0_TEXTURE_DISPLAY, 0, val); - } else { - PassParameterBlock[pass]->SetValue(PB_STAGE1_TEXTURE_DISPLAY, 0, val); - } - SetMtlFlag( MTL_TEX_DISPLAY_ENABLED, TRUE ); - SetActiveTexmap(Texture[pass][stage]); - NotifyDependents(FOREVER,PART_ALL,REFMSG_CHANGE); - - } else { - - SetMtlFlag( MTL_TEX_DISPLAY_ENABLED, FALSE ); - SetActiveTexmap(NULL); - NotifyDependents(FOREVER,PART_ALL,REFMSG_CHANGE); - - } - - // tell dialog to refresh... - if (MaterialDialog) { - MaterialDialog->ReloadDialog(); - } - - if (IsMultiMtl()) { - - // Loop through all sub materials of the multi-material. - for (unsigned mi = 0; mi < NumSubMtls(); mi++) { - - // Only change those that are W3D materials. - if (GetSubMtl(mi)->ClassID() == GameMaterialClassID) { - int pass; - - for (pass = 0; pass < ((GameMtl*)(GetSubMtl(mi)))->Get_Pass_Count(); pass++) { - - if (((GameMtl*)(GetSubMtl(mi)))->Get_Texture_Enable(pass, stage)) { - (GetSubMtl(mi))->SetMtlFlag(MTL_TEX_DISPLAY_ENABLED, TRUE); - } - } - } - } - } -} - -void GameMtl::Set_Texture_Frame_Rate(int pass,int stage,float val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - if (stage == 0) { - PassParameterBlock[pass]->SetValue(PB_STAGE0_TEXTURE_FRAME_RATE, 0, val); - } else { - PassParameterBlock[pass]->SetValue(PB_STAGE1_TEXTURE_FRAME_RATE, 0, val); - } -} -void GameMtl::Set_Texture_Frame_Count(int pass,int stage,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - if (stage == 0) { - PassParameterBlock[pass]->SetValue(PB_STAGE0_TEXTURE_FRAME_COUNT, 0, val); - } else { - PassParameterBlock[pass]->SetValue(PB_STAGE1_TEXTURE_FRAME_COUNT, 0, val); - } -} -void GameMtl::Set_Texture_Anim_Type(int pass,int stage,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - if (stage == 0) { - PassParameterBlock[pass]->SetValue(PB_STAGE0_TEXTURE_ANIM_TYPE, 0, val); - } else { - PassParameterBlock[pass]->SetValue(PB_STAGE1_TEXTURE_ANIM_TYPE, 0, val); - } -} - -void GameMtl::Set_Texture(int pass,int stage,Texmap * tex) -{ - SetSubTexmap(pass_stage_to_texmap_index(pass,stage),tex); -} - -void GameMtl::Set_PS2_Shader_Param_A(int pass,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_PS2_SHADER_PARAM_A, 0, val); -} - -void GameMtl::Set_PS2_Shader_Param_B(int pass,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_PS2_SHADER_PARAM_B, 0, val); -} - -void GameMtl::Set_PS2_Shader_Param_C(int pass,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_PS2_SHADER_PARAM_C, 0, val); -} - -void GameMtl::Set_PS2_Shader_Param_D(int pass,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - PassParameterBlock[pass]->SetValue(PB_PS2_SHADER_PARAM_D, 0, val); -} - -void GameMtl::Set_Map_Channel(int pass,int stage,int val) -{ - assert((pass >=0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert(PassParameterBlock[pass]); - if (stage == 0) { - PassParameterBlock[pass]->SetValue(PB_STAGE0_MAP_CHANNEL, 0, val); - } else { - PassParameterBlock[pass]->SetValue(PB_STAGE1_MAP_CHANNEL, 0, val); - } - - if (Texture[pass][stage] != NULL) { - UVGen * uvgen = Texture[pass][stage]->GetTheUVGen(); - if (uvgen != NULL) { - uvgen->SetMapChannel(val); - } - } - - NotifyDependents(FOREVER,PART_ALL,REFMSG_CHANGE); -} - - -// This returns the mapping args string buffer for that pass (and stage) after -// assuring that it can contain a string of length 'len' (if len is 0 no -// resizing will be performed).. -char * GameMtl::Get_Mapping_Arg_Buffer(int pass, int stage, unsigned int len) -{ - assert(pass >= 0); - assert(pass < W3dMaterialClass::MAX_PASSES); - assert(stage >= 0); - assert(stage < W3dMaterialClass::MAX_STAGES); - - if (MapperArgLen[pass][stage] < len) { - MapperArgLen[pass][stage] = len + 10; // New length - char *temp = new char[MapperArgLen[pass][stage] + 1]; - if (MapperArg[pass][stage]) { - assert(strlen(MapperArg[pass][stage]) <= MapperArgLen[pass][stage]); - strcpy(temp, MapperArg[pass][stage]); - delete [] (MapperArg[pass][stage]); - MapperArg[pass][stage] = NULL; - } - - MapperArg[pass][stage] = temp; - } - - return MapperArg[pass][stage]; -} - -int GameMtl::pass_stage_to_texmap_index(int pass,int stage) -{ - assert((pass >= 0) && (pass < W3dMaterialClass::MAX_PASSES)); - assert((stage >= 0) && (stage < W3dMaterialClass::MAX_STAGES)); - return pass * W3dMaterialClass::MAX_STAGES + stage; -} - -void GameMtl::texmap_index_to_pass_stage(int index,int * set_pass,int * set_stage) -{ - *set_pass = index / W3dMaterialClass::MAX_STAGES; - *set_stage = index % W3dMaterialClass::MAX_STAGES; -} - -float GameMtl::EvalDisplacement(ShadeContext& sc) -{ - float displacement = 0.0F; - if (DisplacementMap != NULL) { - displacement = DisplacementMap->EvalMono(sc); - displacement = displacement * DisplacementAmt; - } - return displacement; -} - -Interval GameMtl::DisplacementValidity(TimeValue t) -{ - return FOREVER; -} - -void GameMtlPostLoad::proc(ILoad *iload) -{ - if (IsOld) { - - m->Reset(); - m->Set_Pass_Count(1); - m->Set_Ambient(0,0,AmbientCoeff); - m->Set_Diffuse(0,0,Diffuse * DiffuseCoeff); - m->Set_Specular(0,0,Specular * SpecularCoeff); - m->Set_Emissive(0,0,EmissiveCoeff); - m->Set_Opacity(0,0,Opacity); - m->Set_Translucency(0,0,Translucency); - m->Set_Shininess(0,0,Shininess); - m->Set_Mapping_Type(0,0,DCTMappingType); - - Texmap * tex = (*(m->Maps))[ID_DI].Map; - - if ((tex) && (tex->ClassID() == Class_ID(BMTEX_CLASS_ID,0))) { - m->Set_Texture(0,0,tex); - m->Set_Texture_Enable(0,0,true); - m->Set_Texture_Frame_Rate(0,0,DCTFrameRate); - m->Set_Texture_Frame_Count(0,0,DCTFrames); - - if (m->TestMtlFlag(MTL_TEX_DISPLAY_ENABLED)) { - m->Set_Texture_Display(0,0,true); - } - } - - m->ReplaceReference(GameMtl::REF_MAPS,NULL); - } - - // older material formats did not save the map channel and will default to zero, - // we need to change the map channel to one in this case. - for (int pass = 0; pass < W3dMaterialClass::MAX_PASSES; pass++) { - for (int stage = 0; stage < W3dMaterialClass::MAX_STAGES; stage++) { - if ((m->Get_Map_Channel(pass,stage) < 1) || (m->Get_Map_Channel(pass,stage) > 99)) { - m->Set_Map_Channel(pass,stage,1); - } - } - } - - // Now that I've removed the UI for the RESIZE and NO_MIPMAP options in the texture - // pane, we initialize the No_LOD setting to the existing NO_MIPMAP setting - // NOTE: I created a new flag for gamemtl which gets set when this conversion takes - // place for the first time. - if (m->Get_Flag(GAMEMTL_CONVERTED_TO_NOLOD) == false) { - for (int pass = 0; pass < W3dMaterialClass::MAX_PASSES; pass++) { - for (int stage = 0; stage < W3dMaterialClass::MAX_STAGES; stage++) { - bool no_lod = m->Get_Texture_No_Mipmap(pass,stage) != 0; - m->Set_Texture_No_LOD(pass,stage,no_lod); - } - } - m->Set_Flag(GAMEMTL_CONVERTED_TO_NOLOD,true); - } - - delete this; -} - diff --git a/Generals/Code/Tools/WW3D/max2w3d/GameMtlDlg.cpp b/Generals/Code/Tools/WW3D/max2w3d/GameMtlDlg.cpp deleted file mode 100644 index c9dc5c24447..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/GameMtlDlg.cpp +++ /dev/null @@ -1,685 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/GameMtlDlg.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 12/07/00 5:52p $* - * * - * $Revision:: 12 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include -#include -#include -#include - -#include "GameMtlDlg.h" -#include "gamemtl.h" -#include "GameMtlPassDlg.h" -#include "dllmain.h" -#include "resource.h" -#include "w3d_file.h" - -static BOOL CALLBACK DisplacementMapDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara,LPARAM lParam); -static BOOL CALLBACK SurfaceTypePanelDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara,LPARAM lParam); -static BOOL CALLBACK PassCountPanelDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara,LPARAM lParam); -static BOOL CALLBACK PassCountDialogDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,LPARAM lParam); - -static int _Pass_Index_To_Flag[] = -{ - GAMEMTL_PASS0_ROLLUP_OPEN, - GAMEMTL_PASS1_ROLLUP_OPEN, - GAMEMTL_PASS2_ROLLUP_OPEN, - GAMEMTL_PASS3_ROLLUP_OPEN, -}; - -/*********************************************************************************************** - * GameMtlDlg::GameMtlDlg -- constructor * - * * - * INPUT: * - * hwMtlEdit - windows handle of the MAX material editor * - * imp - Interface object for MAX materials and textures * - * m - pointer to a GameMtl to be edited * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -GameMtlDlg::GameMtlDlg(HWND hwMtlEdit, IMtlParams *imp, GameMtl *m) -{ - HwndEdit = hwMtlEdit; - HwndPassCount = NULL; - HwndSurfaceType = NULL; - HwndDisplacementMap = NULL; - HpalOld = NULL; - - for (int i=0; iRestorePalette(hdc, HpalOld); - ReleaseDC(HwndPassCount,hdc); - } - - #ifdef WANT_DISPLACEMENT_MAPS - TheMtl->Set_Flag(GAMEMTL_DISPLACEMENT_ROLLUP_OPEN,IParams->IsRollupPanelOpen(HwndDisplacementMap)); - #endif //WANT_DISPLACEMENT_MAPS - - TheMtl->Set_Flag(GAMEMTL_SURFACE_ROLLUP_OPEN,IParams->IsRollupPanelOpen(HwndSurfaceType)); - TheMtl->Set_Flag(GAMEMTL_PASSCOUNT_ROLLUP_OPEN,IParams->IsRollupPanelOpen(HwndPassCount)); - TheMtl->RollScroll = IParams->GetRollupScrollPos(); - - IParams->UnRegisterDlgWnd(HwndSurfaceType); - IParams->DeleteRollupPage(HwndSurfaceType); - HwndSurfaceType = NULL; - - #ifdef WANT_DISPLACEMENT_MAPS - IParams->UnRegisterDlgWnd(HwndDisplacementMap); - IParams->DeleteRollupPage(HwndDisplacementMap); - HwndDisplacementMap = NULL; - #endif //#ifdef WANT_DISPLACEMENT_MAPS - - IParams->UnRegisterDlgWnd(HwndPassCount); - IParams->DeleteRollupPage(HwndPassCount); - HwndPassCount = NULL; - - for (int i=0; iSetParamDlg(NULL); -} - - -/*********************************************************************************************** - * GameMtlDlg::ClassID -- Returns the ClassID of GameMtl * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -Class_ID GameMtlDlg::ClassID() -{ - return GameMaterialClassID; -} - -/*********************************************************************************************** - * GameMtlDlg::SetThing -- Sets the material to be edited * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -void GameMtlDlg::SetThing(ReferenceTarget *m) -{ - assert (m); - assert (m->SuperClassID()==MATERIAL_CLASS_ID); - assert ((m->ClassID()==GameMaterialClassID) || (m->ClassID()==PS2GameMaterialClassID)); - assert (TheMtl); - - int pass; - - // destroy our old pass dialogs - for (pass=0; passGet_Pass_Count();pass++) { - delete PassDialog[pass]; - PassDialog[pass] = NULL; - } - - // install the new material - TheMtl->SetParamDlg(NULL); - TheMtl = (GameMtl *)m; - TheMtl->SetParamDlg(this); - - // build a new set of pass dialogs - for (pass=0; passGet_Pass_Count(); pass++) { - PassDialog[pass] = new GameMtlPassDlg(HwndEdit, IParams, TheMtl, pass); - } - - // refresh the contents of the dialogs - ReloadDialog(); -} - -/*********************************************************************************************** - * GameMtlDlg::SetTime -- Sets the time value, updates the material and the dialog * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -void GameMtlDlg::SetTime(TimeValue t) -{ - if (t!=CurTime) { - CurTime = t; -// TheMtl->Update(IParams->GetTime(),Valid); - ReloadDialog(); - } -} - -/*********************************************************************************************** - * GameMtlDlg::ReloadDialog -- Updates the values in all of the dialog's controls * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -void GameMtlDlg::ReloadDialog() -{ - /* - ** Init the pass count panel - */ - assert(TheMtl && HwndPassCount && HwndSurfaceType); - - /* - ** Init the surface count panel - */ - ::SendMessage (HwndSurfaceType, WM_USER+101, 0, 0L); - - #ifdef WANT_DISPLACEMENT_MAPS - ::SendMessage (HwndDisplacementMap, WM_USER+101, 0, 0L); - #endif //WANT_DISPLACEMENT_MAPS - - /* - ** Init the pass count panel - */ - char a[10]; - sprintf(a, "%d", TheMtl->Get_Pass_Count()); - SetWindowText(GetDlgItem(HwndPassCount, IDC_GAMEMTL_PASSCOUNT_STATIC), a); - - /* - ** Init each pass panel - */ - for(int i = 0; i < TheMtl->Get_Pass_Count(); i++) - { - PassDialog[i]->ReloadDialog(); - } -} - -/*********************************************************************************************** - * GameMtlDlg::ActivateDlg -- Activates and deactivates the dialog * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -void GameMtlDlg::ActivateDlg(BOOL onoff) -{ - for(int i = 0; i < TheMtl->Get_Pass_Count(); i++) - { - assert(PassDialog[i]); - PassDialog[i]->ActivateDlg(onoff); - } -} - -/*********************************************************************************************** - * GameMtlDlg::Invalidate -- causes the dialog to be redrawn * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -void GameMtlDlg::Invalidate() -{ - InvalidateRect(HwndSurfaceType,NULL,0); - - #ifdef WANT_DISPLACEMENT_MAPS - InvalidateRect(HwndDisplacementMap,NULL,0); - #endif //WANT_DISPLACEMENT_MAPS - - InvalidateRect(HwndPassCount,NULL,0); -} - -BOOL GameMtlDlg::DisplacementMapProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - - case WM_INITDIALOG: - //SetupIntSpinner(hDlg, IDC_AMOUNT_SPIN, IDC_AMOUNT_EDIT, -999, 999, 0); - /* no break */ - - case WM_USER + 101: - { - SetDlgItemInt (hDlg, IDC_AMOUNT_EDIT, TheMtl->Get_Displacement_Amount () * 100, TRUE); - SetupIntSpinner(hDlg, IDC_AMOUNT_SPIN, IDC_AMOUNT_EDIT, -999, 999, TheMtl->Get_Displacement_Amount () * 100); - - Texmap *map = TheMtl->Get_Displacement_Map (); - if (map != NULL) { - SetDlgItemText (hDlg, IDC_TEXTURE_BUTTON, map->GetFullName ()); - } - } - break; - - case CC_SPINNER_CHANGE: - { - ISpinnerControl *control = (ISpinnerControl *)lParam; - TheMtl->Set_Displacement_Amount (((float)control->GetIVal ()) / 100.0F); - } - break; - - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDC_TEXTURE_BUTTON: - if(HIWORD(wParam) == BN_CLICKED) - { - PostMessage(HwndEdit, WM_TEXMAP_BUTTON, TheMtl->Get_Displacement_Map_Index (), (LPARAM)TheMtl); - } - } - break; - } - - return FALSE; -} - -BOOL GameMtlDlg::SurfaceTypeProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - - case WM_INITDIALOG: - { - // - // Fill the combobox with the names of the different surface types - // - for (int index = 0; index < SURFACE_TYPE_MAX; index ++) { - ::SendDlgItemMessage ( hDlg, - IDC_SURFACE_TYPE_COMBO, - CB_ADDSTRING, - 0, - (LPARAM)SURFACE_TYPE_STRINGS[index]); - } - - // - // Limit the range of the static sort level spinner to 0 - MAX_SORT_LEVEL. - // - int sort_level = TheMtl->Get_Sort_Level(); - SetupIntSpinner(hDlg, IDC_SORT_LEVEL_SPIN, IDC_SORT_LEVEL, 0, MAX_SORT_LEVEL, sort_level); - - // Check the checkbox if sort_level is not SORT_LEVEL_NONE. - ::SendDlgItemMessage(hDlg, IDC_ENABLE_SORT_LEVEL, BM_SETCHECK, - sort_level == SORT_LEVEL_NONE ? BST_UNCHECKED : BST_CHECKED, 0); - } - - case WM_USER + 101: - { - // - // Select the current surface type - // - ::SendDlgItemMessage ( hDlg, - IDC_SURFACE_TYPE_COMBO, - CB_SETCURSEL, - (WPARAM)TheMtl->Get_Surface_Type (), - - 0L); - - // - // Set the correct sort level - // - int sort_level = TheMtl->Get_Sort_Level(); - ISpinnerControl *spinner = GetISpinner(::GetDlgItem(hDlg, IDC_SORT_LEVEL_SPIN)); - assert(spinner); - spinner->SetValue(sort_level, FALSE); - ::SendDlgItemMessage(hDlg, IDC_ENABLE_SORT_LEVEL, BM_SETCHECK, - sort_level == SORT_LEVEL_NONE ? BST_UNCHECKED : BST_CHECKED, 0); - break; - } - - case WM_COMMAND: - { - switch(LOWORD(wParam)) - { - case IDC_SURFACE_TYPE_COMBO: - if(HIWORD(wParam) == CBN_SELCHANGE) - { - unsigned int type = ::SendDlgItemMessage (hDlg, IDC_SURFACE_TYPE_COMBO, CB_GETCURSEL, 0, 0L); - TheMtl->Set_Surface_Type (type); - } - break; - - case IDC_ENABLE_SORT_LEVEL: - if (HIWORD(wParam) == BN_CLICKED) - { - // If the 'enable' checkbox was unchecked, set the sort level to NONE. - int state = ::IsDlgButtonChecked(hDlg, IDC_ENABLE_SORT_LEVEL); - ISpinnerControl *spinner = GetISpinner(::GetDlgItem(hDlg, IDC_SORT_LEVEL_SPIN)); - assert(spinner); - if (state == BST_UNCHECKED) - { - spinner->SetValue(SORT_LEVEL_NONE, FALSE); - TheMtl->Set_Sort_Level(SORT_LEVEL_NONE); - } - else if (state == BST_CHECKED) - { - // Sort level was enabled, so set it's level to 1 if it was NONE before. - if (spinner->GetIVal() == SORT_LEVEL_NONE) - { - spinner->SetValue(1, FALSE); - TheMtl->Set_Sort_Level(1); - } - } - } - } - break; - } - - case CC_SPINNER_CHANGE: - { - ISpinnerControl *spinner = (ISpinnerControl*)lParam; - switch(LOWORD(wParam)) - { - case IDC_SORT_LEVEL_SPIN: - // Check the 'enabled' checkbox if sort level != SORT_LEVEL_NONE, uncheck it otherwise. - ::SendDlgItemMessage(hDlg, IDC_ENABLE_SORT_LEVEL, BM_SETCHECK, - spinner->GetIVal() == SORT_LEVEL_NONE ? BST_UNCHECKED : BST_CHECKED, 0); - TheMtl->Set_Sort_Level(spinner->GetIVal()); - break; - } - break; - } - } - - return FALSE; -} - - -BOOL GameMtlDlg::PassCountProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG: - break; - - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDC_SETPASSCOUNT: - if(HIWORD(wParam) == BN_CLICKED) - { - Set_Pass_Count_Dialog(); - } - } - break; - } - - return FALSE; -} - -static BOOL CALLBACK DisplacementMapDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,LPARAM lParam) -{ - GameMtlDlg * theDlg; - if (msg == WM_INITDIALOG) { - theDlg = (GameMtlDlg*)lParam; - theDlg->HwndDisplacementMap = hwndDlg; - SetWindowLong(hwndDlg, GWL_USERDATA,lParam); - } else { - if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) { - return FALSE; - } - } - - theDlg->IsActive = 1; - BOOL res = theDlg->DisplacementMapProc(hwndDlg,msg,wParam,lParam); - theDlg->IsActive = 0; - - return res; -} - -static BOOL CALLBACK SurfaceTypePanelDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,LPARAM lParam) -{ - GameMtlDlg * theDlg; - if (msg == WM_INITDIALOG) { - theDlg = (GameMtlDlg*)lParam; - theDlg->HwndSurfaceType = hwndDlg; - SetWindowLong(hwndDlg, GWL_USERDATA,lParam); - } else { - if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) { - return FALSE; - } - } - - theDlg->IsActive = 1; - BOOL res = theDlg->SurfaceTypeProc(hwndDlg,msg,wParam,lParam); - theDlg->IsActive = 0; - - return res; -} - -static BOOL CALLBACK PassCountPanelDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,LPARAM lParam) -{ - GameMtlDlg * theDlg; - if (msg == WM_INITDIALOG) { - theDlg = (GameMtlDlg*)lParam; - theDlg->HwndPassCount = hwndDlg; - SetWindowLong(hwndDlg, GWL_USERDATA,lParam); - } else { - if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) { - return FALSE; - } - } - - theDlg->IsActive = 1; - BOOL res = theDlg->PassCountProc(hwndDlg,msg,wParam,lParam); - theDlg->IsActive = 0; - - return res; -} - -void GameMtlDlg::Set_Pass_Count_Dialog(void) -{ - int res = DialogBoxParam( - AppInstance, - MAKEINTRESOURCE(IDD_GAMEMTL_PASS_COUNT_DIALOG), - HwndPassCount, - PassCountDialogDlgProc, - (LPARAM)TheMtl->Get_Pass_Count()); - - if (res>=0) - { - if (res<=0) res = 1; - if (res>4) res = 4; - - char a[10]; - sprintf(a, "%d", res); - - SetWindowText(GetDlgItem(HwndPassCount, IDC_GAMEMTL_PASSCOUNT_STATIC), a); - - if(TheMtl->Get_Pass_Count() != res) - { - for(int i = 0; i < TheMtl->Get_Pass_Count(); i++) - { - delete PassDialog[i]; - PassDialog[i] = NULL; - } - - TheMtl->Set_Pass_Count(res); - - for(i = 0; i < TheMtl->Get_Pass_Count(); i++) - { - PassDialog[i] = new GameMtlPassDlg(HwndEdit, IParams, TheMtl, i); - } - - ReloadDialog(); - } - } -} - -static BOOL CALLBACK PassCountDialogDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,LPARAM lParam) -{ - switch (msg) - { - case WM_INITDIALOG: - { - ISpinnerControl *spin = SetupIntSpinner( - hwndDlg,IDC_PASSCOUNT_SPIN, IDC_PASSCOUNT_EDIT, - 1,4,(int)lParam); - ReleaseISpinner(spin); - CenterWindow(hwndDlg,GetParent(hwndDlg)); - break; - } - - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDOK: - { - ISpinnerControl *spin = GetISpinner(GetDlgItem(hwndDlg,IDC_PASSCOUNT_SPIN)); - EndDialog(hwndDlg,spin->GetIVal()); - ReleaseISpinner(spin); - break; - } - - case IDCANCEL: - EndDialog(hwndDlg,-1); - break; - } - break; - - default: - return FALSE; - } - return TRUE; -} - - -/*********************************************************************************************** - * GameMtlDlg::Build_Dialog -- Adds the dialog to the material editor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -void GameMtlDlg::Build_Dialog() -{ - if ((TheMtl->Flags&(GAMEMTL_ROLLUP_FLAGS))==0) { - TheMtl->Set_Flag(GAMEMTL_PASS0_ROLLUP_OPEN,TRUE); - } - - HwndSurfaceType = IParams->AddRollupPage( - AppInstance, - MAKEINTRESOURCE(IDD_GAMEMTL_SURFACE_TYPE), - SurfaceTypePanelDlgProc, - Get_String(IDS_SURFACE_TYPE), - (LPARAM)this, - TheMtl->Get_Flag(GAMEMTL_SURFACE_ROLLUP_OPEN) ? 0:APPENDROLL_CLOSED - ); - - #ifdef WANT_DISPLACEMENT_MAPS - HwndDisplacementMap = IParams->AddRollupPage( - AppInstance, - MAKEINTRESOURCE(IDD_GAMEMTL_DISPLACEMENT_MAP), - DisplacementMapDlgProc, - Get_String(IDS_DISPLACEMENT_MAP), - (LPARAM)this, - TheMtl->Get_Flag(GAMEMTL_DISPLACEMENT_ROLLUP_OPEN) ? 0:APPENDROLL_CLOSED - ); - #endif //WANT_DISPLACEMENT_MAPS - - HwndPassCount = IParams->AddRollupPage( - AppInstance, - MAKEINTRESOURCE(IDD_GAMEMTL_PASS_COUNT), - PassCountPanelDlgProc, - Get_String(IDS_PASS_COUNT), - (LPARAM)this, - TheMtl->Get_Flag(GAMEMTL_PASSCOUNT_ROLLUP_OPEN) ? 0:APPENDROLL_CLOSED - ); - - for (int i=0; iGet_Pass_Count(); i++) { - PassDialog[i] = new GameMtlPassDlg(HwndEdit, IParams, TheMtl, i); - } - - IParams->SetRollupScrollPos(TheMtl->RollScroll); - - ReloadDialog(); -} - - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/GameMtlDlg.h b/Generals/Code/Tools/WW3D/max2w3d/GameMtlDlg.h deleted file mode 100644 index e11efb6ae16..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/GameMtlDlg.h +++ /dev/null @@ -1,119 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/GameMtlDlg.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 6/30/99 7:10p $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - - -#ifndef GAMEMTLDLG_H -#define GAMEMTLDLG_H - -class GameMtl; -class GameMtlPassDlg; - - -//////////////////////////////////////////////////////////////////////// -// GameMtlDlg -// -// Dialog box interface in the material editor for GameMtl -// This is basically a cannibalized version of the Standard -// Max material's dialog. -// -//////////////////////////////////////////////////////////////////////// -class GameMtlDlg: public ParamDlg -{ - -public: - - //////////////////////////////////////////////////////////////////////// - // Methods - //////////////////////////////////////////////////////////////////////// - GameMtlDlg(HWND hwMtlEdit, IMtlParams *imp, GameMtl *m); - ~GameMtlDlg(); - - // From ParamDlg: - Class_ID ClassID(void); - void SetThing(ReferenceTarget *m); - ReferenceTarget* GetThing(void) { return (ReferenceTarget*)TheMtl; } - void DeleteThis() { delete this; } - void SetTime(TimeValue t); - void ReloadDialog(void); - void ActivateDlg(BOOL onOff); - - void Invalidate(void); - void Update_Display(void) { IParams->MtlChanged(); } - -protected: - - void Build_Dialog(void); - - BOOL DisplacementMapProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); - BOOL SurfaceTypeProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); - BOOL PassCountProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); - void Set_Pass_Count_Dialog(void); - - enum { MAX_PASSES = 4 }; - - //////////////////////////////////////////////////////////////////////// - // Windows handles - //////////////////////////////////////////////////////////////////////// - HWND HwndEdit; // window handle of the materials editor dialog - HWND HwndPassCount; // Rollup pass count panel - HWND HwndSurfaceType; // Rollup surface type panel - HWND HwndDisplacementMap; - HPALETTE HpalOld; - - GameMtlPassDlg * PassDialog[MAX_PASSES]; - - //////////////////////////////////////////////////////////////////////// - // Material dialog interface - //////////////////////////////////////////////////////////////////////// - IMtlParams * IParams; // interface to the material editor - GameMtl * TheMtl; // current mtl being edited. - - //////////////////////////////////////////////////////////////////////// - // Member variables - //////////////////////////////////////////////////////////////////////// - TimeValue CurTime; - int IsActive; - - friend BOOL CALLBACK DisplacementMapDlgProc(HWND, UINT, WPARAM,LPARAM); - friend BOOL CALLBACK SurfaceTypePanelDlgProc(HWND, UINT, WPARAM,LPARAM); - friend BOOL CALLBACK PassCountPanelDlgProc(HWND, UINT, WPARAM,LPARAM); - friend class GameMtl; -}; - - -#endif \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/GameMtlForm.cpp b/Generals/Code/Tools/WW3D/max2w3d/GameMtlForm.cpp deleted file mode 100644 index 463f209352c..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/GameMtlForm.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/GameMtlForm.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 11/23/98 6:21p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * GameMtlFormClass::GameMtlFormClass -- constructor * - * GameMtlFormClass::SetThing -- Set the material being edited by this form * - * GameMtlFormClass::GetThing -- get the material being edited by this form * - * GameMtlFormClass::DeleteThis -- delete myself * - * GameMtlFormClass::ClassID -- returns the classID of the object being edited * - * GameMtlFormClass::SetTime -- set the current time * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "GameMtlForm.h" -#include "gamemtl.h" - - -/*********************************************************************************************** - * GameMtlFormClass::GameMtlFormClass -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -GameMtlFormClass::GameMtlFormClass -( - IMtlParams * imtl_params, - GameMtl * mtl, - int pass -) -{ - IParams = imtl_params; - TheMtl = mtl; - PassIndex = pass; -} - - -/*********************************************************************************************** - * GameMtlFormClass::SetThing -- Set the material being edited by this form * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlFormClass::SetThing(ReferenceTarget * target) -{ - assert (target->SuperClassID()==MATERIAL_CLASS_ID); - assert (target->ClassID()==GameMaterialClassID); - - TheMtl = (GameMtl *)target; -} - - -/*********************************************************************************************** - * GameMtlFormClass::GetThing -- get the material being edited by this form * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -ReferenceTarget * GameMtlFormClass::GetThing(void) -{ - return (ReferenceTarget*)TheMtl; -} - - -/*********************************************************************************************** - * GameMtlFormClass::DeleteThis -- delete myself * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlFormClass::DeleteThis(void) -{ - delete this; -} - - -/*********************************************************************************************** - * GameMtlFormClass::ClassID -- returns the classID of the object being edited * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -Class_ID GameMtlFormClass::ClassID() -{ - return GameMaterialClassID; -} - - -/*********************************************************************************************** - * GameMtlFormClass::SetTime -- set the current time * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlFormClass::SetTime(TimeValue t) -{ - // child dialog classes don't have to support - // the SetTime function. -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/GameMtlForm.h b/Generals/Code/Tools/WW3D/max2w3d/GameMtlForm.h deleted file mode 100644 index 18884ad75d2..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/GameMtlForm.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/GameMtlForm.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 11/13/98 10:26a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - -#ifndef GAMEMTLFORM_H -#define GAMEMTLFORM_H - -#include "FormClass.h" - -class GameMtl; - -class GameMtlFormClass : public FormClass -{ -public: - GameMtlFormClass(IMtlParams * imtl_params,GameMtl * mtl,int pass); - - void SetThing(ReferenceTarget *m); - ReferenceTarget* GetThing(void); - void DeleteThis(void); - Class_ID ClassID(void); - void SetTime(TimeValue t); - -protected: - - IMtlParams * IParams; // interface to the material editor - GameMtl * TheMtl; // current mtl being edited. - int PassIndex; // material pass that this form edits -}; - -#endif diff --git a/Generals/Code/Tools/WW3D/max2w3d/GameMtlPassDlg.cpp b/Generals/Code/Tools/WW3D/max2w3d/GameMtlPassDlg.cpp deleted file mode 100644 index b178f6a2d95..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/GameMtlPassDlg.cpp +++ /dev/null @@ -1,393 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Bay/Tools/max2w3d/GameMtlPassDlg.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 10/22/99 9:54a $* - * * - * $Revision:: 9 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * PassDlgProc -- dialog proc which thunks into a GameMtlPassDlg * - * GameMtlPassDlg::GameMtlPassDlg -- constructor * - * GameMtlPassDlg::~GameMtlPassDlg -- destructor * - * GameMtlPassDlg::DialogProc -- windows message handler * - * GameMtlPassDlg::Invalidate -- invalidate the dialog * - * GameMtlPassDlg::ReloadDialog -- update the contents of all of the controls * - * GameMtlPassDlg::ClassID -- returns classID of the object being edited * - * GameMtlPassDlg::SetThing -- set the material being edited * - * GameMtlPassDlg::ActivateDlg -- activate or deactivate the dialog * - * GameMtlPassDlg::SetTime -- set the current time * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "GameMtlPassDlg.h" -#include "dllmain.h" -#include "resource.h" -#include "gamemtl.h" -#include "GameMtlDlg.h" -#include "GameMtlShaderDlg.h" -#include "PS2GameMtlShaderDlg.h" -#include "GameMtlTextureDlg.h" -#include "GameMtlVertexMaterialDlg.h" -#include "w3d_file.h" - - -static int _Pass_Index_To_Flag[] = -{ - GAMEMTL_PASS0_ROLLUP_OPEN, - GAMEMTL_PASS1_ROLLUP_OPEN, - GAMEMTL_PASS2_ROLLUP_OPEN, - GAMEMTL_PASS3_ROLLUP_OPEN, -}; - - -/*********************************************************************************************** - * PassDlgProc -- dialog proc which thunks into a GameMtlPassDlg * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -static BOOL CALLBACK PassDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - GameMtlPassDlg *theDlg; - - if (msg==WM_INITDIALOG) { - theDlg = (GameMtlPassDlg*)lParam; - theDlg->HwndPanel = hwndDlg; - SetWindowLong(hwndDlg, GWL_USERDATA,lParam); - } else { - if ((theDlg = (GameMtlPassDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) { - return FALSE; - } - } - - return theDlg->DialogProc(hwndDlg,msg,wParam,lParam); -} - - -/*********************************************************************************************** - * GameMtlPassDlg::GameMtlPassDlg -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -GameMtlPassDlg::GameMtlPassDlg(HWND hwMtlEdit, IMtlParams *imp, GameMtl *m,int pass) -{ - HwndEdit = hwMtlEdit; - TheMtl = m; - IParams = imp; - PassIndex = pass; - - char title[200]; - sprintf(title, "Pass %d", pass + 1); - - HwndPanel = IParams->AddRollupPage( - AppInstance, - MAKEINTRESOURCE(IDD_GAMEMTL_PASS), - PassDlgProc, - title, - (LPARAM)this, - TheMtl->Get_Flag(_Pass_Index_To_Flag[PassIndex]) ? 0 : APPENDROLL_CLOSED - ); -} - - -/*********************************************************************************************** - * GameMtlPassDlg::~GameMtlPassDlg -- destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -GameMtlPassDlg::~GameMtlPassDlg() -{ - TheMtl->Set_Flag(_Pass_Index_To_Flag[PassIndex],IParams->IsRollupPanelOpen(HwndPanel)); - IParams->DeleteRollupPage(HwndPanel); - SetWindowLong(HwndPanel, GWL_USERDATA, NULL); -} - - -/*********************************************************************************************** - * GameMtlPassDlg::DialogProc -- windows message handler * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -BOOL GameMtlPassDlg::DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - int i=0; - int id = LOWORD(wParam); - int code = HIWORD(wParam); - - switch (message) { - - case WM_INITDIALOG: - { - Page[0] = new GameMtlVertexMaterialDlg(HwndPanel,IParams,TheMtl,PassIndex); - if (TheMtl->Get_Shader_Type() == GameMtl::STE_PC_SHADER) { - Page[1] = new GameMtlShaderDlg(HwndPanel,IParams,TheMtl,PassIndex); - } else { - // The PS2 shader is different. - Page[1] = new PS2GameMtlShaderDlg(HwndPanel,IParams,TheMtl,PassIndex); - } - - Page[2] = new GameMtlTextureDlg(HwndPanel,IParams,TheMtl,PassIndex); - - for (i=0; iGet_Hwnd(); - - // set the tab names - char name[64]; - ::GetWindowText(hwnd,name,sizeof(name)); - TC_ITEM tcitem = { TCIF_TEXT,0,0,name,0 }; - TabCtrl_InsertItem(GetDlgItem(HwndPanel,IDC_GAMEMTL_TAB),i,&tcitem); - } - - // Get the display rectangle of the tab control - RECT rect; - ::GetWindowRect(GetDlgItem(HwndPanel,IDC_GAMEMTL_TAB),&rect); - TabCtrl_AdjustRect(GetDlgItem(HwndPanel,IDC_GAMEMTL_TAB),FALSE, &rect); - - // Convert the display rectangle from screen to client coords - ScreenToClient(HwndPanel,(POINT *)(&rect)); - ScreenToClient(HwndPanel, ((LPPOINT)&rect) + 1); - - for (i=0; iGet_Hwnd(); - - // Loop through all the tabs in the property sheet - // Get a pointer to this tab - SetWindowPos( hwnd, - NULL, - rect.left, rect.top, - rect.right - rect.left, rect.bottom - rect.top, - SWP_NOZORDER); - } - - CurPage = 0; - TabCtrl_SetCurSel(GetDlgItem(HwndPanel,IDC_GAMEMTL_TAB),CurPage); - Page[CurPage]->Show(); - - break; - } - - case WM_PAINT: - { - if (!Valid) { - Valid = TRUE; - ReloadDialog(); - } - return FALSE; - } - - case WM_NOTIFY: - { - NMHDR * header = (NMHDR *)lParam; - - switch(header->code) { - case TCN_SELCHANGE: - { - int sel = TabCtrl_GetCurSel(GetDlgItem(HwndPanel,IDC_GAMEMTL_TAB)); - Page[sel]->Show(); - - for (int i=0; i < PAGE_COUNT; i++) { - if (i != sel) Page[i]->Show(false); - } - CurPage = sel; - TheMtl->Set_Current_Page(PassIndex,CurPage); - } - }; - break; - } - } - return FALSE; -} - - -/*********************************************************************************************** - * GameMtlPassDlg::Invalidate -- invalidate the dialog * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlPassDlg::Invalidate() -{ - Valid = FALSE; - InvalidateRect(HwndPanel,NULL,0); -} - - -/*********************************************************************************************** - * GameMtlPassDlg::ReloadDialog -- update the contents of all of the controls * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlPassDlg::ReloadDialog() -{ - int i; - - DebugPrint("GameMtlPassDlg::ReloadDialog\n"); - Interval v; - TheMtl->Update(IParams->GetTime(),v); - - for (i=0; iReloadDialog(); - } - - CurPage = TheMtl->Get_Current_Page(PassIndex); - TabCtrl_SetCurSel(GetDlgItem(HwndPanel,IDC_GAMEMTL_TAB),CurPage); - Page[CurPage]->Show(); - for (i=0; i < PAGE_COUNT; i++) { - if (i != CurPage) Page[i]->Show(false); - } -} - - -/*********************************************************************************************** - * GameMtlPassDlg::ClassID -- returns classID of the object being edited * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -Class_ID GameMtlPassDlg::ClassID() -{ - return GameMaterialClassID; -} - - -/*********************************************************************************************** - * GameMtlPassDlg::SetThing -- set the material being edited * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlPassDlg::SetThing(ReferenceTarget* target) -{ - // Note, parent will "reload" when our "thing" changes :-) - assert (target->SuperClassID()==MATERIAL_CLASS_ID); - assert (target->ClassID()==GameMaterialClassID); - - TheMtl = (GameMtl *)target; - - for (int i=0; iSetThing(target); - } -} - - -/*********************************************************************************************** - * GameMtlPassDlg::ActivateDlg -- activate or deactivate the dialog * - * * - * some of the custom max controls need to be activated and deactivated * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlPassDlg::ActivateDlg(BOOL onoff) -{ - for (int i=0; iActivateDlg(onoff); - } -} - - -/*********************************************************************************************** - * GameMtlPassDlg::SetTime -- set the current time * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlPassDlg::SetTime(TimeValue t) -{ - // parent dialog class keeps track of the validty and we - // don't have to do anything in this function (it will never - // be called in fact) -} - diff --git a/Generals/Code/Tools/WW3D/max2w3d/GameMtlPassDlg.h b/Generals/Code/Tools/WW3D/max2w3d/GameMtlPassDlg.h deleted file mode 100644 index 5dd8a2aa731..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/GameMtlPassDlg.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/GameMtlPassDlg.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 11/17/98 1:32p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - - -#ifndef GAMEMTLPASSDLG_H -#define GAMEMTLPASSDLG_H - -#include - -class GameMtl; -class GameMtlFormClass; - -/* -** The GameMtlPassDlg will contain a Tab Control which switches between -** editing the VertexMaterial parameters, the Shader parameters and the -** Texture parameters. -*/ -class GameMtlPassDlg: public ParamDlg -{ -public: - - GameMtlPassDlg(HWND hwMtlEdit, IMtlParams *imp, GameMtl *m,int pass); - ~GameMtlPassDlg(); - - BOOL DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); - - void Invalidate(); - void UpdateMtlDisplay() { IParams->MtlChanged(); } - - void ReloadDialog(); - Class_ID ClassID(); - void SetThing(ReferenceTarget* target); - ReferenceTarget * GetThing() { return (ReferenceTarget *)TheMtl; } - void DeleteThis() { delete this; } - void SetTime(TimeValue t); - void ActivateDlg(BOOL onOff); - - enum { PAGE_COUNT = 3 }; - - //////////////////////////////////////////////////////////////////////// - // Material dialog interface - //////////////////////////////////////////////////////////////////////// - IMtlParams * IParams; // interface to the material editor - GameMtl * TheMtl; // current mtl being edited. - - //////////////////////////////////////////////////////////////////////// - // Windows handles - //////////////////////////////////////////////////////////////////////// - HWND HwndEdit; // window handle of the materials editor dialog - HWND HwndPanel; // Rollup parameters panel - - //////////////////////////////////////////////////////////////////////// - // Variables - //////////////////////////////////////////////////////////////////////// - int PassIndex; - int CurPage; - BOOL Valid; - - GameMtlFormClass* Page[PAGE_COUNT]; -}; - -#endif \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/GameMtlShaderDlg.cpp b/Generals/Code/Tools/WW3D/max2w3d/GameMtlShaderDlg.cpp deleted file mode 100644 index c9859f4cff5..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/GameMtlShaderDlg.cpp +++ /dev/null @@ -1,397 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/GameMtlShaderDlg.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 2/26/99 7:23p $* - * * - * $Revision:: 13 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * GameMtlShaderDlg::GameMtlShaderDlg -- constructor * - * GameMtlShaderDlg::~GameMtlShaderDlg -- destructor * - * GameMtlShaderDlg::Dialog_Proc -- windows message handler * - * GameMtlShaderDlg::ReloadDialog -- reload the contents of all of the controls * - * GameMtlShaderDlg::ActivateDlg -- activate/deactivate the dialog * - * GameMtlShaderDlg::Apply_Preset -- apply a preset shader setting * - * GameMtlShaderDlg::Set_Preset -- determine preset shader setting from game material * - * GameMtlShaderDlg::CompareShaderToBlendPreset -- compare preset to game material shader * - * GameMtlShaderDlg::Set_Advanced_Defaults -- set advanced settings to defaults * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "GameMtlShaderDlg.h" -#include "GameMtlDlg.h" -#include "gamemtl.h" -#include "resource.h" - -/* -** Shader Blend Setting Presets -*/ - -// Note: the array has NUM_SHADER_BLEND_PRESETS + 1 entries (due to the 'Custom' entry). - -#define NUM_SHADER_BLEND_PRESETS 8 - -static char * _ShaderBlendSettingPresetNames[NUM_SHADER_BLEND_PRESETS + 1] = -{ - "Opaque", - "Add", - "Multiply", - "Multiply and Add", - "Screen", - "Alpha Blend", - "Alpha Test", - "Alpha Test and Blend", - "------ Custom -----" -}; -struct ShaderBlendSettingPreset -{ - int SrcBlend; - int DestBlend; - bool DepthMask; - bool AlphaTest; -}; -static const ShaderBlendSettingPreset ShaderBlendSettingPresets[NUM_SHADER_BLEND_PRESETS] = { - {W3DSHADER_SRCBLENDFUNC_ONE, W3DSHADER_DESTBLENDFUNC_ZERO, true, false}, // Opaque - {W3DSHADER_SRCBLENDFUNC_ONE, W3DSHADER_DESTBLENDFUNC_ONE, false, false}, // Add - {W3DSHADER_SRCBLENDFUNC_ZERO, W3DSHADER_DESTBLENDFUNC_SRC_COLOR, false, false}, // Multiply - {W3DSHADER_SRCBLENDFUNC_ONE, W3DSHADER_DESTBLENDFUNC_SRC_COLOR, false, false}, // Multiply and Add - {W3DSHADER_SRCBLENDFUNC_ONE, W3DSHADER_DESTBLENDFUNC_ONE_MINUS_SRC_COLOR, false, false}, // Screen - {W3DSHADER_SRCBLENDFUNC_SRC_ALPHA, W3DSHADER_DESTBLENDFUNC_ONE_MINUS_SRC_ALPHA, false, false}, // Alpha Blend - {W3DSHADER_SRCBLENDFUNC_ONE, W3DSHADER_DESTBLENDFUNC_ZERO, true, true}, // Alpha Test - {W3DSHADER_SRCBLENDFUNC_SRC_ALPHA, W3DSHADER_DESTBLENDFUNC_ONE_MINUS_SRC_ALPHA, true, true} // Alpha Test and Blend -}; - - -/*********************************************************************************************** - * GameMtlShaderDlg::GameMtlShaderDlg -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -GameMtlShaderDlg::GameMtlShaderDlg -( - HWND parent, - IMtlParams * imp, - GameMtl * mtl, - int pass -) : - GameMtlFormClass(imp,mtl,pass) -{ - Create_Form(parent,IDD_GAMEMTL_SHADER); -} - - -/*********************************************************************************************** - * GameMtlShaderDlg::~GameMtlShaderDlg -- destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -GameMtlShaderDlg::~GameMtlShaderDlg() -{ -} - - -/*********************************************************************************************** - * GameMtlShaderDlg::Dialog_Proc -- windows message handler * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -BOOL GameMtlShaderDlg::Dialog_Proc (HWND dlg_wnd, UINT message, WPARAM wparam, LPARAM lparam) -{ - int cursel; - int i; - int id = LOWORD(wparam); - int code = HIWORD(wparam); - - switch (message) - { - - case WM_INITDIALOG: - for(i = 0; i <= NUM_SHADER_BLEND_PRESETS; i++) { - SendDlgItemMessage(dlg_wnd,IDC_PRESET_COMBO,CB_ADDSTRING,0,(LONG)_ShaderBlendSettingPresetNames[i]); - } - SendDlgItemMessage(dlg_wnd,IDC_PRESET_COMBO,CB_SETCURSEL,0,0); - break; - - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - { - IParams->RollupMouseMessage(dlg_wnd,message,wparam,lparam); - } - return FALSE; - - case WM_COMMAND: - { - if (code == CBN_SELCHANGE) { - - switch (id) - { - case IDC_DEPTHCOMPARE_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_DEPTHCOMPARE_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Depth_Compare(PassIndex,cursel); - break; - case IDC_DESTBLEND_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_DESTBLEND_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Dest_Blend(PassIndex,cursel); - TheMtl->Notify_Changed(); - Set_Preset(); - break; - case IDC_PRIGRADIENT_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_PRIGRADIENT_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Pri_Gradient(PassIndex,cursel); - TheMtl->Notify_Changed(); - break; - case IDC_SECGRADIENT_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_SECGRADIENT_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Sec_Gradient(PassIndex,cursel); - TheMtl->Notify_Changed(); - break; - case IDC_SRCBLEND_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_SRCBLEND_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Src_Blend(PassIndex,cursel); - TheMtl->Notify_Changed(); - Set_Preset(); - break; - case IDC_DETAILCOLOR_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_DETAILCOLOR_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Detail_Color_Func(PassIndex,cursel); - TheMtl->Notify_Changed(); - break; - case IDC_DETAILALPHA_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_DETAILALPHA_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Detail_Alpha_Func(PassIndex,cursel); - TheMtl->Notify_Changed(); - break; - case IDC_PRESET_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_PRESET_COMBO,CB_GETCURSEL,0,0); - Apply_Preset(cursel); - break; - } - - } else { - - switch(id) { - - case IDC_DEPTHMASK_CHECK: - if (SendDlgItemMessage(dlg_wnd,IDC_DEPTHMASK_CHECK,BM_GETCHECK,0,0)) { - TheMtl->Set_Depth_Mask(PassIndex,W3DSHADER_DEPTHMASK_WRITE_ENABLE); - } else { - TheMtl->Set_Depth_Mask(PassIndex,W3DSHADER_DEPTHMASK_WRITE_DISABLE); - } - Set_Preset(); - break; - - case IDC_ALPHATEST_CHECK: - if (SendDlgItemMessage(dlg_wnd,IDC_ALPHATEST_CHECK,BM_GETCHECK,0,0)) { - TheMtl->Set_Alpha_Test(PassIndex,W3DSHADER_ALPHATEST_ENABLE); - } else { - TheMtl->Set_Alpha_Test(PassIndex,W3DSHADER_ALPHATEST_DISABLE); - } - Set_Preset(); - break; - - case IDC_SHADER_DEFAULTS_BUTTON: - Set_Advanced_Defaults(); - break; - } - } - } - } - - return FALSE; -} - - -/*********************************************************************************************** - * GameMtlShaderDlg::ReloadDialog -- reload the contents of all of the controls * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlShaderDlg::ReloadDialog(void) -{ - DebugPrint("GameMtlShaderDlg::ReloadDialog\n"); - SendDlgItemMessage(m_hWnd, IDC_DESTBLEND_COMBO, CB_SETCURSEL, TheMtl->Get_Dest_Blend(PassIndex), 0 ); - SendDlgItemMessage(m_hWnd, IDC_SRCBLEND_COMBO, CB_SETCURSEL, TheMtl->Get_Src_Blend(PassIndex), 0 ); - SendDlgItemMessage(m_hWnd, IDC_PRIGRADIENT_COMBO, CB_SETCURSEL, TheMtl->Get_Pri_Gradient(PassIndex), 0 ); - SendDlgItemMessage(m_hWnd, IDC_SECGRADIENT_COMBO, CB_SETCURSEL, TheMtl->Get_Sec_Gradient(PassIndex), 0 ); - SendDlgItemMessage(m_hWnd, IDC_DEPTHCOMPARE_COMBO, CB_SETCURSEL, TheMtl->Get_Depth_Compare(PassIndex), 0 ); - SendDlgItemMessage(m_hWnd, IDC_DETAILCOLOR_COMBO, CB_SETCURSEL, TheMtl->Get_Detail_Color_Func(PassIndex), 0 ); - SendDlgItemMessage(m_hWnd, IDC_DETAILALPHA_COMBO, CB_SETCURSEL, TheMtl->Get_Detail_Alpha_Func(PassIndex), 0 ); - Set_Preset(); - - SetCheckBox(m_hWnd,IDC_DEPTHMASK_CHECK, TheMtl->Get_Depth_Mask(PassIndex)); - SetCheckBox(m_hWnd,IDC_ALPHATEST_CHECK, TheMtl->Get_Alpha_Test(PassIndex)); -} - - -/*********************************************************************************************** - * GameMtlShaderDlg::ActivateDlg -- activate/deactivate the dialog * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlShaderDlg::ActivateDlg(BOOL onoff) -{ - // shader has no color swatches which need to be activated... -} - - -/*********************************************************************************************** - * GameMtlShaderDlg::Apply_Preset -- apply a preset shader setting * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlShaderDlg::Apply_Preset(int preset_index) -{ - if (preset_index < 0 || preset_index >= NUM_SHADER_BLEND_PRESETS) return; - - const ShaderBlendSettingPreset &preset = ShaderBlendSettingPresets[preset_index]; - - TheMtl->Set_Src_Blend(PassIndex, preset.SrcBlend); - - TheMtl->Set_Dest_Blend(PassIndex, preset.DestBlend); - - int depth_mask = preset.DepthMask ? W3DSHADER_DEPTHMASK_WRITE_ENABLE : W3DSHADER_DEPTHMASK_WRITE_DISABLE; - TheMtl->Set_Depth_Mask(PassIndex, depth_mask); - - int alpha_test = preset.AlphaTest ? W3DSHADER_ALPHATEST_ENABLE : W3DSHADER_ALPHATEST_DISABLE; - TheMtl->Set_Alpha_Test(PassIndex, alpha_test); - - TheMtl->Notify_Changed(); - ReloadDialog(); -} - - -/*********************************************************************************************** - * GameMtlShaderDlg::Set_Preset -- determine preset shader setting from game material * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/26/99 NH : Created. * - *=============================================================================================*/ -void GameMtlShaderDlg::Set_Preset(void) -{ - for (int i = 0; i < NUM_SHADER_BLEND_PRESETS; i++) { - if (CompareShaderToBlendPreset(ShaderBlendSettingPresets[i])) break; - } - SendDlgItemMessage(m_hWnd, IDC_PRESET_COMBO, CB_SETCURSEL, i, 0); -} - - -/*********************************************************************************************** - * GameMtlShaderDlg::CompareShaderToBlendPreset -- compare preset to game material shader * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/26/99 NH : Created. * - *=============================================================================================*/ -bool GameMtlShaderDlg::CompareShaderToBlendPreset(const ShaderBlendSettingPreset &blend_preset) -{ - if (TheMtl->Get_Src_Blend(PassIndex) != blend_preset.SrcBlend) return false; - if (TheMtl->Get_Dest_Blend(PassIndex) != blend_preset.DestBlend) return false; - bool depthmask = TheMtl->Get_Depth_Mask(PassIndex) != W3DSHADER_DEPTHMASK_WRITE_DISABLE; - if (depthmask != blend_preset.DepthMask) return false; - bool alphatest = TheMtl->Get_Alpha_Test(PassIndex) != W3DSHADER_ALPHATEST_DISABLE; - if (alphatest != blend_preset.AlphaTest) return false; - return true; -} - - -/*********************************************************************************************** - * GameMtlShaderDlg::Set_Advanced_Defaults -- set advanced settings to defaults * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/26/99 NH : Created. * - *=============================================================================================*/ -void GameMtlShaderDlg::Set_Advanced_Defaults(void) -{ - TheMtl->Set_Pri_Gradient(PassIndex, W3DSHADER_PRIGRADIENT_DEFAULT); - TheMtl->Set_Sec_Gradient(PassIndex, W3DSHADER_SECGRADIENT_DEFAULT); - TheMtl->Set_Depth_Compare(PassIndex, W3DSHADER_DEPTHCOMPARE_DEFAULT); - TheMtl->Set_Detail_Color_Func(PassIndex, W3DSHADER_DETAILCOLORFUNC_DEFAULT); - TheMtl->Set_Detail_Alpha_Func(PassIndex, W3DSHADER_DETAILALPHAFUNC_DEFAULT); - - TheMtl->Notify_Changed(); - ReloadDialog(); -} \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/GameMtlShaderDlg.h b/Generals/Code/Tools/WW3D/max2w3d/GameMtlShaderDlg.h deleted file mode 100644 index 77b51300c86..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/GameMtlShaderDlg.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/GameMtlShaderDlg.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 2/26/99 7:00p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - -#ifndef GAMEMTLSHADERDLG_H -#define GAMEMTLSHADERDLG_H - -#include -#include "GameMtlForm.h" - - -class GameMtl; -struct ShaderBlendSettingPreset; - -class GameMtlShaderDlg : public GameMtlFormClass -{ - -public: - - GameMtlShaderDlg(HWND parent, IMtlParams * imp, GameMtl * m, int pass); - ~GameMtlShaderDlg(); - - virtual BOOL Dialog_Proc (HWND dlg_wnd, UINT message, WPARAM wparam, LPARAM lparam); - - void ActivateDlg(BOOL onOff); - void ReloadDialog(void); - -private: - - void Apply_Preset(int preset_index); - void Set_Preset(void); - bool CompareShaderToBlendPreset(const ShaderBlendSettingPreset &blend_preset); - void Set_Advanced_Defaults(void); -}; - -#endif \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/GameMtlTextureDlg.cpp b/Generals/Code/Tools/WW3D/max2w3d/GameMtlTextureDlg.cpp deleted file mode 100644 index f6dd31be76b..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/GameMtlTextureDlg.cpp +++ /dev/null @@ -1,667 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/GameMtlTextureDlg.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 8/14/00 1:47p $* - * * - * $Revision:: 15 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * GameMtlTextureDlg::GameMtlTextureDlg -- constructor * - * GameMtlTextureDlg::~GameMtlTextureDlg -- destructor * - * GameMtlTextureDlg::Dialog_Proc -- windows message handler * - * GameMtlTextureDlg::ReloadDialog -- reload the contents of all of the controls in this dia * - * GameMtlTextureDlg::ActivateDlg -- activate/deactivate this dialog * - * GameMtlTextureDlg::Enable_Stage -- enable or disable a texture stage * - * GameMtlTextureDlg::Update_Texture_Buttons -- update the texture buttons text * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - - - -#include "GameMtlTextureDlg.h" -#include "gamemtl.h" -#include "dllmain.h" -#include "resource.h" -#include -#include -#include - - -/*********************************************************************************************** - * GameMtlTextureDlg::GameMtlTextureDlg -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -GameMtlTextureDlg::GameMtlTextureDlg -( - HWND parent, - IMtlParams * imp, - GameMtl * mtl, - int pass -) : - GameMtlFormClass(imp,mtl,pass) -{ - Stage0FramesSpin = NULL; - Stage1FramesSpin = NULL; - Stage0RateSpin = NULL; - Stage1RateSpin = NULL; - - Stage0PublishButton = NULL; - Stage1PublishButton = NULL; - Stage0ClampUButton = NULL; - Stage1ClampUButton = NULL; - Stage0ClampVButton = NULL; - Stage1ClampVButton = NULL; - Stage0NoLODButton = NULL; - Stage1NoLODButton = NULL; - Stage0AlphaBitmapButton = NULL; - Stage1AlphaBitmapButton = NULL; - Stage0DisplayButton = NULL; - Stage1DisplayButton = NULL; - - if (mtl->Get_Shader_Type() == GameMtl::STE_PC_SHADER) { - Create_Form(parent,IDD_GAMEMTL_TEXTURES); - } else { - // Use the PS2 dialog. It is the same but it disables some functions that aren't - // supported yet. - Create_Form(parent,IDD_GAMEMTL_PS2_TEXTURES); - } -} - - -/*********************************************************************************************** - * GameMtlTextureDlg::~GameMtlTextureDlg -- destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -GameMtlTextureDlg::~GameMtlTextureDlg() -{ - assert(Stage0FramesSpin && Stage1FramesSpin && Stage0RateSpin && Stage1RateSpin); - ReleaseISpinner(Stage0FramesSpin); - ReleaseISpinner(Stage1FramesSpin); - ReleaseISpinner(Stage0RateSpin); - ReleaseISpinner(Stage1RateSpin); - - ReleaseICustButton(Stage0PublishButton); - ReleaseICustButton(Stage1PublishButton); - ReleaseICustButton(Stage0ClampUButton); - ReleaseICustButton(Stage1ClampUButton); - ReleaseICustButton(Stage0ClampVButton); - ReleaseICustButton(Stage1ClampVButton); - ReleaseICustButton(Stage0NoLODButton); - ReleaseICustButton(Stage1NoLODButton); - ReleaseICustButton(Stage0AlphaBitmapButton); - ReleaseICustButton(Stage1AlphaBitmapButton); - ReleaseICustButton(Stage0DisplayButton); - ReleaseICustButton(Stage1DisplayButton); -} - - -/*********************************************************************************************** - * GameMtlTextureDlg::Dialog_Proc -- windows message handler * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - * 10/6/1999 MLL: Turned off the display button when the texture is turned off. * - *=============================================================================================*/ -BOOL GameMtlTextureDlg::Dialog_Proc (HWND dlg_wnd, UINT message, WPARAM wparam, LPARAM lparam) -{ - int cursel; - int id = LOWORD(wparam); - int code = HIWORD(wparam); - - switch (message) - { - case WM_INITDIALOG: - { - Stage0FramesSpin = SetupIntSpinner( dlg_wnd, - IDC_STAGE0_FRAMES_SPIN, - IDC_STAGE0_FRAMES_EDIT, - 1,999, - TheMtl->Get_Texture_Frame_Count(PassIndex,0) ); - - Stage0RateSpin = SetupFloatSpinner( dlg_wnd, - IDC_STAGE0_RATE_SPIN, - IDC_STAGE0_RATE_EDIT, - 0.0f,60.0f, - TheMtl->Get_Texture_Frame_Rate(PassIndex,0), - 1.0f ); - - Stage1FramesSpin = SetupIntSpinner( dlg_wnd, - IDC_STAGE1_FRAMES_SPIN, - IDC_STAGE1_FRAMES_EDIT, - 1,999, - TheMtl->Get_Texture_Frame_Count(PassIndex,1) ); - - Stage1RateSpin = SetupFloatSpinner( dlg_wnd, - IDC_STAGE1_RATE_SPIN, - IDC_STAGE1_RATE_EDIT, - 0.0f,60.0f, - TheMtl->Get_Texture_Frame_Rate(PassIndex,1), - 1.0f ); - - Stage0PublishButton = GetICustButton(GetDlgItem(dlg_wnd, IDC_STAGE0_PUBLISH_BUTTON)); - Stage0PublishButton->SetType(CBT_CHECK); - Stage0PublishButton->SetHighlightColor(GREEN_WASH); - Stage0PublishButton->SetCheck(TheMtl->Get_Texture_Publish(PassIndex,0)); - Stage0PublishButton->SetText(Get_String(IDS_PUBLISH)); - - Stage1PublishButton = GetICustButton(GetDlgItem(dlg_wnd, IDC_STAGE1_PUBLISH_BUTTON)); - Stage1PublishButton->SetType(CBT_CHECK); - Stage1PublishButton->SetHighlightColor(GREEN_WASH); - Stage1PublishButton->SetCheck(TheMtl->Get_Texture_Publish(PassIndex,1)); - Stage1PublishButton->SetText(Get_String(IDS_PUBLISH)); - - Stage0ClampUButton = GetICustButton(GetDlgItem(dlg_wnd, IDC_STAGE0_CLAMP_U_BUTTON)); - Stage0ClampUButton->SetType(CBT_CHECK); - Stage0ClampUButton->SetHighlightColor(GREEN_WASH); - Stage0ClampUButton->SetCheck(TheMtl->Get_Texture_Clamp_U(PassIndex,0)); - Stage0ClampUButton->SetText(Get_String(IDS_CLAMP_U)); - - Stage1ClampUButton = GetICustButton(GetDlgItem(dlg_wnd, IDC_STAGE1_CLAMP_U_BUTTON)); - Stage1ClampUButton->SetType(CBT_CHECK); - Stage1ClampUButton->SetHighlightColor(GREEN_WASH); - Stage1ClampUButton->SetCheck(TheMtl->Get_Texture_Clamp_U(PassIndex,1)); - Stage1ClampUButton->SetText(Get_String(IDS_CLAMP_U)); - - Stage0ClampVButton = GetICustButton(GetDlgItem(dlg_wnd, IDC_STAGE0_CLAMP_V_BUTTON)); - Stage0ClampVButton->SetType(CBT_CHECK); - Stage0ClampVButton->SetHighlightColor(GREEN_WASH); - Stage0ClampVButton->SetCheck(TheMtl->Get_Texture_Clamp_V(PassIndex,0)); - Stage0ClampVButton->SetText(Get_String(IDS_CLAMP_V)); - - Stage1ClampVButton = GetICustButton(GetDlgItem(dlg_wnd, IDC_STAGE1_CLAMP_V_BUTTON)); - Stage1ClampVButton->SetType(CBT_CHECK); - Stage1ClampVButton->SetHighlightColor(GREEN_WASH); - Stage1ClampVButton->SetCheck(TheMtl->Get_Texture_Clamp_V(PassIndex,1)); - Stage1ClampVButton->SetText(Get_String(IDS_CLAMP_V)); - - Stage0NoLODButton = GetICustButton(GetDlgItem(dlg_wnd, IDC_STAGE0_NOLOD_BUTTON)); - Stage0NoLODButton->SetType(CBT_CHECK); - Stage0NoLODButton->SetHighlightColor(GREEN_WASH); - Stage0NoLODButton->SetCheck(TheMtl->Get_Texture_No_LOD(PassIndex,0)); - Stage0NoLODButton->SetText(Get_String(IDS_NO_LOD)); - - Stage1NoLODButton = GetICustButton(GetDlgItem(dlg_wnd, IDC_STAGE1_NOLOD_BUTTON)); - Stage1NoLODButton->SetType(CBT_CHECK); - Stage1NoLODButton->SetHighlightColor(GREEN_WASH); - Stage1NoLODButton->SetCheck(TheMtl->Get_Texture_No_LOD(PassIndex,0)); - Stage1NoLODButton->SetText(Get_String(IDS_NO_LOD)); - - Stage0AlphaBitmapButton = GetICustButton(GetDlgItem(dlg_wnd, IDC_STAGE0_ALPHA_BITMAP_BUTTON)); - Stage0AlphaBitmapButton->SetType(CBT_CHECK); - Stage0AlphaBitmapButton->SetHighlightColor(GREEN_WASH); - Stage0AlphaBitmapButton->SetCheck(TheMtl->Get_Texture_Alpha_Bitmap(PassIndex,0)); - Stage0AlphaBitmapButton->SetText(Get_String(IDS_ALPHA_BITMAP)); - - Stage1AlphaBitmapButton = GetICustButton(GetDlgItem(dlg_wnd, IDC_STAGE1_ALPHA_BITMAP_BUTTON)); - Stage1AlphaBitmapButton->SetType(CBT_CHECK); - Stage1AlphaBitmapButton->SetHighlightColor(GREEN_WASH); - Stage1AlphaBitmapButton->SetCheck(TheMtl->Get_Texture_Alpha_Bitmap(PassIndex,1)); - Stage1AlphaBitmapButton->SetText(Get_String(IDS_ALPHA_BITMAP)); - - Stage0DisplayButton = GetICustButton(GetDlgItem(dlg_wnd, IDC_STAGE0_DISPLAY_BUTTON)); - Stage0DisplayButton->SetType(CBT_CHECK); - Stage0DisplayButton->SetHighlightColor(GREEN_WASH); - Stage0DisplayButton->SetCheck(TheMtl->Get_Texture_Display(PassIndex,0)); - Stage0DisplayButton->SetText(Get_String(IDS_DISPLAY)); - - Stage1DisplayButton = GetICustButton(GetDlgItem(dlg_wnd, IDC_STAGE1_DISPLAY_BUTTON)); - Stage1DisplayButton->SetType(CBT_CHECK); - Stage1DisplayButton->SetHighlightColor(GREEN_WASH); - Stage1DisplayButton->SetCheck(TheMtl->Get_Texture_Display(PassIndex,1)); - Stage1DisplayButton->SetText(Get_String(IDS_DISPLAY)); - break; - } - - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - { - IParams->RollupMouseMessage(dlg_wnd,message,wparam,lparam); - return FALSE; - } - - case CC_SPINNER_CHANGE: - { - TheMtl->Set_Texture_Frame_Count( PassIndex, 0, - Stage0FramesSpin->GetIVal()); - - TheMtl->Set_Texture_Frame_Rate( PassIndex, 0, - Stage0RateSpin->GetFVal()); - - TheMtl->Set_Texture_Frame_Count( PassIndex, 1, - Stage1FramesSpin->GetIVal()); - - TheMtl->Set_Texture_Frame_Rate( PassIndex, 1, - Stage1RateSpin->GetFVal()); - break; - } - - case CC_SPINNER_BUTTONUP: - { - TheMtl->Notify_Changed(); - break; - } - - case WM_COMMAND: - { - switch (id) - { - case IDC_STAGE0_BUTTON: - { - BitmapInfo bmi; - BitmapTex * texture; - - if (TheManager->SelectFileInput(&bmi, m_hWnd)) { - texture = NewDefaultBitmapTex(); - if (texture) { - - BOOL disp = TheMtl->Get_Texture_Display(PassIndex,0); - if (disp) { - TheMtl->Set_Texture_Display(PassIndex,0,FALSE); - } - - texture->SetMapName((char *)bmi.Name()); - int texmap_index = TheMtl->pass_stage_to_texmap_index(PassIndex,0); - TheMtl->SetSubTexmap(texmap_index,texture); - Update_Texture_Buttons(); - TheMtl->Notify_Changed(); - - if (disp) { - TheMtl->Set_Texture_Display(PassIndex,0,TRUE); - TheMtl->Notify_Changed(); - } - } - } - break; - } - case IDC_STAGE1_BUTTON: - { - BitmapInfo bmi; - BitmapTex * texture; - - if (TheManager->SelectFileInput(&bmi, m_hWnd)) { - texture = NewDefaultBitmapTex(); - if (texture) { - - BOOL disp = TheMtl->Get_Texture_Display(PassIndex,1); - if (disp) { - TheMtl->Set_Texture_Display(PassIndex,1,FALSE); - } - - texture->SetMapName((char *)bmi.Name()); - int texmap_index = TheMtl->pass_stage_to_texmap_index(PassIndex,1); - TheMtl->SetSubTexmap(texmap_index,texture); - Update_Texture_Buttons(); - TheMtl->Notify_Changed(); - - if (disp) { - TheMtl->Set_Texture_Display(PassIndex,1,TRUE); - TheMtl->Notify_Changed(); - } - } - } - break; - } - case IDC_STAGE0_ENABLE: - { - int checkbox = GetCheckBox(dlg_wnd,IDC_STAGE0_ENABLE); - Enable_Stage(0,(checkbox == TRUE ? true : false) ); - - // If the texture stage is turned off, turn off the Display button so that it won't - // show up in the viewport. - if (checkbox == FALSE) { - - TheMtl->Set_Texture_Display(PassIndex, 0, FALSE); - TheMtl->Notify_Changed(); - } - break; - } - case IDC_STAGE1_ENABLE: - { - int checkbox = GetCheckBox(dlg_wnd,IDC_STAGE1_ENABLE); - - Enable_Stage(1,(checkbox == TRUE ? true : false) ); - - // If the texture stage is turned off, turn off the Display button so that it won't - // show up in the viewport. - if (checkbox == FALSE) { - - TheMtl->Set_Texture_Display(PassIndex, 1, FALSE); - TheMtl->Notify_Changed(); - } - break; - } - case IDC_STAGE0_PUBLISH_BUTTON: - { - TheMtl->Set_Texture_Publish(PassIndex,0,(Stage0PublishButton->IsChecked() ? TRUE : FALSE)); - break; - } - case IDC_STAGE1_PUBLISH_BUTTON: - { - TheMtl->Set_Texture_Publish(PassIndex,1,(Stage1PublishButton->IsChecked() ? TRUE : FALSE)); - break; - } - - case IDC_STAGE0_CLAMP_U_BUTTON: - { - TheMtl->Set_Texture_Clamp_U(PassIndex,0,(Stage0ClampUButton->IsChecked() ? TRUE : FALSE)); - break; - } - case IDC_STAGE1_CLAMP_U_BUTTON: - { - TheMtl->Set_Texture_Clamp_U(PassIndex,1,(Stage1ClampUButton->IsChecked() ? TRUE : FALSE)); - break; - } - case IDC_STAGE0_CLAMP_V_BUTTON: - { - TheMtl->Set_Texture_Clamp_V(PassIndex,0,(Stage0ClampVButton->IsChecked() ? TRUE : FALSE)); - break; - } - case IDC_STAGE1_CLAMP_V_BUTTON: - { - TheMtl->Set_Texture_Clamp_V(PassIndex,1,(Stage1ClampVButton->IsChecked() ? TRUE : FALSE)); - break; - } - case IDC_STAGE0_NOLOD_BUTTON: - { - TheMtl->Set_Texture_No_LOD(PassIndex,0,(Stage0NoLODButton->IsChecked() ? TRUE : FALSE)); - break; - } - case IDC_STAGE1_NOLOD_BUTTON: - { - TheMtl->Set_Texture_No_LOD(PassIndex,1,(Stage1NoLODButton->IsChecked() ? TRUE : FALSE)); - break; - } - case IDC_STAGE0_ALPHA_BITMAP_BUTTON: - { - TheMtl->Set_Texture_Alpha_Bitmap(PassIndex,0,(Stage0AlphaBitmapButton->IsChecked() ? TRUE : FALSE)); - break; - } - case IDC_STAGE1_ALPHA_BITMAP_BUTTON: - { - TheMtl->Set_Texture_Alpha_Bitmap(PassIndex,1,(Stage0AlphaBitmapButton->IsChecked() ? TRUE : FALSE)); - break; - } - case IDC_STAGE0_DISPLAY_BUTTON: - { - TheMtl->Set_Texture_Display(PassIndex,0,(Stage0DisplayButton->IsChecked() ? TRUE : FALSE)); - TheMtl->Notify_Changed(); - break; - } - case IDC_STAGE1_DISPLAY_BUTTON: - { - TheMtl->Set_Texture_Display(PassIndex,1,(Stage1DisplayButton->IsChecked() ? TRUE : FALSE)); - TheMtl->Notify_Changed(); - break; - } - case IDC_STAGE0_ANIM_COMBO: - { - if (code == CBN_SELCHANGE) { - cursel = SendDlgItemMessage(dlg_wnd,IDC_STAGE0_ANIM_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Texture_Anim_Type(PassIndex,0,cursel); - } - break; - } - case IDC_STAGE1_ANIM_COMBO: - { - if (code == CBN_SELCHANGE) { - cursel = SendDlgItemMessage(dlg_wnd,IDC_STAGE1_ANIM_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Texture_Anim_Type(PassIndex,1,cursel); - } - break; - } - case IDC_STAGE0_HINT_COMBO: - { - if (code == CBN_SELCHANGE) { - cursel = SendDlgItemMessage(dlg_wnd,IDC_STAGE0_HINT_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Texture_Hint(PassIndex,0,cursel); - } - break; - } - case IDC_STAGE1_HINT_COMBO: - { - if (code == CBN_SELCHANGE) { - cursel = SendDlgItemMessage(dlg_wnd,IDC_STAGE1_HINT_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Texture_Hint(PassIndex,1,cursel); - } - break; - } - - } - break; - } - } - - return FALSE; -} - - -/*********************************************************************************************** - * GameMtlTextureDlg::ReloadDialog -- reload the contents of all of the controls in this dialo * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlTextureDlg::ReloadDialog(void) -{ - DebugPrint("GameMtlTextureDlg::ReloadDialog\n"); - assert(Stage0FramesSpin && Stage1FramesSpin && Stage0RateSpin && Stage1RateSpin); - Stage0FramesSpin->SetValue(TheMtl->Get_Texture_Frame_Count(PassIndex,0),FALSE); - Stage1FramesSpin->SetValue(TheMtl->Get_Texture_Frame_Count(PassIndex,1),FALSE); - Stage0RateSpin->SetValue(TheMtl->Get_Texture_Frame_Rate(PassIndex,0),FALSE); - Stage1RateSpin->SetValue(TheMtl->Get_Texture_Frame_Rate(PassIndex,1),FALSE); - - SendDlgItemMessage( m_hWnd, - IDC_STAGE0_ANIM_COMBO, - CB_SETCURSEL, - TheMtl->Get_Texture_Anim_Type(PassIndex,0), 0 ); - - SendDlgItemMessage( m_hWnd, - IDC_STAGE1_ANIM_COMBO, - CB_SETCURSEL, - TheMtl->Get_Texture_Anim_Type(PassIndex,1), 0 ); - - SendDlgItemMessage( m_hWnd, - IDC_STAGE0_HINT_COMBO, - CB_SETCURSEL, - TheMtl->Get_Texture_Hint(PassIndex,0), 0 ); - - SendDlgItemMessage( m_hWnd, - IDC_STAGE1_HINT_COMBO, - CB_SETCURSEL, - TheMtl->Get_Texture_Hint(PassIndex,1), 0 ); - - SetCheckBox(m_hWnd,IDC_STAGE0_ENABLE, TheMtl->Get_Texture_Enable(PassIndex,0)); - SetCheckBox(m_hWnd,IDC_STAGE1_ENABLE, TheMtl->Get_Texture_Enable(PassIndex,1)); - - Stage0PublishButton->SetCheck(TheMtl->Get_Texture_Publish(PassIndex,0)); - Stage1PublishButton->SetCheck(TheMtl->Get_Texture_Publish(PassIndex,1)); - Stage0ClampUButton->SetCheck(TheMtl->Get_Texture_Clamp_U(PassIndex,0)); - Stage1ClampUButton->SetCheck(TheMtl->Get_Texture_Clamp_U(PassIndex,1)); - Stage0ClampVButton->SetCheck(TheMtl->Get_Texture_Clamp_V(PassIndex,0)); - Stage1ClampVButton->SetCheck(TheMtl->Get_Texture_Clamp_V(PassIndex,1)); - Stage0NoLODButton->SetCheck(TheMtl->Get_Texture_No_LOD(PassIndex,0)); - Stage1NoLODButton->SetCheck(TheMtl->Get_Texture_No_LOD(PassIndex,1)); - Stage0AlphaBitmapButton->SetCheck(TheMtl->Get_Texture_Alpha_Bitmap(PassIndex,0)); - Stage1AlphaBitmapButton->SetCheck(TheMtl->Get_Texture_Alpha_Bitmap(PassIndex,1)); - Stage0DisplayButton->SetCheck(TheMtl->Get_Texture_Display(PassIndex,0)); - Stage1DisplayButton->SetCheck(TheMtl->Get_Texture_Display(PassIndex,1)); - - Update_Texture_Buttons(); - - Enable_Stage(0,TheMtl->Get_Texture_Enable(PassIndex,0)); - Enable_Stage(1,TheMtl->Get_Texture_Enable(PassIndex,1)); -} - - -/*********************************************************************************************** - * GameMtlTextureDlg::ActivateDlg -- activate/deactivate this dialog * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlTextureDlg::ActivateDlg(BOOL onOff) -{ - // no color swatches to activate. -} - - -/*********************************************************************************************** - * GameMtlTextureDlg::Enable_Stage -- enable or disable a texture stage * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlTextureDlg::Enable_Stage(int stage,BOOL onoff) -{ - assert((stage >= 0) && (stage < W3dMaterialClass::MAX_STAGES)); - TheMtl->Set_Texture_Enable(PassIndex,stage,(onoff == TRUE ? true : false)); - - if (stage == 0) { - - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_BUTTON),onoff); - - // Turn these off if it is a playstation 2 shader. - // These aren't supported yet. - if (TheMtl->Get_Shader_Type() == GameMtl::STE_PC_SHADER) { - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_RATE_SPIN), onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_RATE_EDIT), onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_FRAMES_SPIN), onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_FRAMES_EDIT), onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_ANIM_COMBO), onoff); - } else { - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_RATE_SPIN), FALSE); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_RATE_EDIT), FALSE); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_FRAMES_SPIN), FALSE); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_FRAMES_EDIT), FALSE); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_ANIM_COMBO), FALSE); - } - - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_PUBLISH_BUTTON),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_CLAMP_U_BUTTON),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_CLAMP_V_BUTTON),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_NOLOD_BUTTON),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_ALPHA_BITMAP_BUTTON),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_DISPLAY_BUTTON),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE0_HINT_COMBO),onoff); - - } else { - - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE1_BUTTON),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE1_RATE_SPIN),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE1_RATE_EDIT),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE1_FRAMES_SPIN),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE1_FRAMES_EDIT),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE1_PUBLISH_BUTTON),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE1_CLAMP_U_BUTTON),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE1_CLAMP_V_BUTTON),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE1_NOLOD_BUTTON),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE1_ALPHA_BITMAP_BUTTON),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE1_DISPLAY_BUTTON),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE1_ANIM_COMBO),onoff); - EnableWindow(GetDlgItem(m_hWnd,IDC_STAGE1_HINT_COMBO),onoff); - - } -} - - -/*********************************************************************************************** - * GameMtlTextureDlg::Update_Texture_Buttons -- update the texture buttons text * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlTextureDlg::Update_Texture_Buttons(void) -{ - Texmap * texmap; - texmap = TheMtl->Get_Texture(PassIndex,0); - TSTR filename; - - if (texmap) { - SplitPathFile(texmap->GetFullName(),NULL,&filename); - SetDlgItemText(m_hWnd, IDC_STAGE0_BUTTON,filename); - } else { - SetDlgItemText(m_hWnd, IDC_STAGE0_BUTTON,Get_String(IDS_NONE)); - } - - texmap = TheMtl->Get_Texture(PassIndex,1); - if (texmap) { - SplitPathFile(texmap->GetFullName(),NULL,&filename); - SetDlgItemText(m_hWnd, IDC_STAGE1_BUTTON,filename); - } else { - SetDlgItemText(m_hWnd, IDC_STAGE1_BUTTON,Get_String(IDS_NONE)); - } -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/GameMtlTextureDlg.h b/Generals/Code/Tools/WW3D/max2w3d/GameMtlTextureDlg.h deleted file mode 100644 index 42cea835088..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/GameMtlTextureDlg.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/GameMtlTextureDlg.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 8/14/00 1:47p $* - * * - * $Revision:: 8 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - - -#ifndef GAMEMTLTEXTUREDLG_H -#define GAMEMTLTEXTUREDLG_H - -#include -#include "GameMtlForm.h" - -class GameMtl; - -class GameMtlTextureDlg : public GameMtlFormClass -{ - -public: - - GameMtlTextureDlg(HWND parent, IMtlParams * imp, GameMtl * m, int pass); - ~GameMtlTextureDlg(void); - - virtual BOOL Dialog_Proc (HWND dlg_wnd, UINT message, WPARAM wparam, LPARAM lparam); - void ActivateDlg(BOOL onOff); - void ReloadDialog(void); - -private: - - void Enable_Stage(int stage,BOOL onoff); - void Update_Texture_Buttons(void); - - ISpinnerControl * Stage0FramesSpin; - ISpinnerControl * Stage1FramesSpin; - - ISpinnerControl * Stage0RateSpin; - ISpinnerControl * Stage1RateSpin; - - ICustButton * Stage0PublishButton; - ICustButton * Stage1PublishButton; - ICustButton * Stage0ClampUButton; - ICustButton * Stage1ClampUButton; - ICustButton * Stage0ClampVButton; - ICustButton * Stage1ClampVButton; - ICustButton * Stage0NoLODButton; - ICustButton * Stage1NoLODButton; - ICustButton * Stage0AlphaBitmapButton; - ICustButton * Stage1AlphaBitmapButton; - ICustButton * Stage0DisplayButton; - ICustButton * Stage1DisplayButton; -}; - - - - -#endif - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.cpp b/Generals/Code/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.cpp deleted file mode 100644 index 020173cf2fb..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/GameMtlVertexMaterialDlg.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 7/10/00 3:37p $* - * * - * $Revision:: 12 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * GameMtlVertexMaterialDlg::GameMtlVertexMaterialDlg -- constructor * - * GameMtlVertexMaterialDlg::~GameMtlVertexMaterialDlg -- destructor * - * GameMtlVertexMaterialDlg::Dialog_Proc -- windows message handler * - * GameMtlVertexMaterialDlg::ReloadDialog -- reload the contents of the controls * - * GameMtlVertexMaterialDlg::ActivateDlg -- activate / deactivate this dialog * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "GameMtlVertexMaterialDlg.h" -#include "gamemtl.h" -#include "dllmain.h" -#include "resource.h" - - -/*********************************************************************************************** - * GameMtlVertexMaterialDlg::GameMtlVertexMaterialDlg -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -GameMtlVertexMaterialDlg::GameMtlVertexMaterialDlg -( - HWND parent, - IMtlParams * imp, - GameMtl * mtl, - int pass -) : - GameMtlFormClass(imp,mtl,pass) -{ - AmbientSwatch = NULL; - DiffuseSwatch = NULL; - SpecularSwatch = NULL; - EmissiveSwatch = NULL; - - OpacitySpin = NULL; - TranslucencySpin = NULL; - ShininessSpin = NULL; - - for (int i=0; iGet_Ambient(PassIndex,IParams->GetTime()),Get_String(IDS_AMBIENT_COLOR)); - DiffuseSwatch = GetIColorSwatch(GetDlgItem(dlg_wnd, IDC_DIFFUSE_COLOR),TheMtl->Get_Diffuse(PassIndex,IParams->GetTime()),Get_String(IDS_DIFFUSE_COLOR)); - SpecularSwatch = GetIColorSwatch(GetDlgItem(dlg_wnd, IDC_SPECULAR_COLOR),TheMtl->Get_Specular(PassIndex,IParams->GetTime()),Get_String(IDS_SPECULAR_COLOR)); - EmissiveSwatch = GetIColorSwatch(GetDlgItem(dlg_wnd, IDC_EMISSIVE_COLOR),TheMtl->Get_Emissive(PassIndex,IParams->GetTime()),Get_String(IDS_EMISSIVE_COLOR)); - - OpacitySpin = SetupFloatSpinner(dlg_wnd,IDC_OPACITY_SPIN,IDC_OPACITY_EDIT,0.0f,1.0f,TheMtl->Get_Opacity(PassIndex,IParams->GetTime()),0.01f); - TranslucencySpin = SetupFloatSpinner(dlg_wnd,IDC_TRANSLUCENCY_SPIN,IDC_TRANSULCENCY_EDIT,0.0f,1.0f,TheMtl->Get_Translucency(PassIndex,IParams->GetTime()),0.01f); - ShininessSpin = SetupFloatSpinner(dlg_wnd,IDC_SHININESS_SPIN,IDC_SHININESS_EDIT,1.0f,1000.0f,TheMtl->Get_Shininess(PassIndex,IParams->GetTime()),1.0f); - UVChannelSpin[0] = SetupIntSpinner(dlg_wnd,IDC_STAGE0UVCHAN_SPIN,IDC_STAGE0UVCHAN_EDIT,1,99,1); - UVChannelSpin[1] = SetupIntSpinner(dlg_wnd,IDC_STAGE1UVCHAN_SPIN,IDC_STAGE1UVCHAN_EDIT,1,99,1); - break; - } - - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - { - IParams->RollupMouseMessage(dlg_wnd,message,wparam,lparam); - return FALSE; - } - - case WM_COMMAND: - { - switch (id) - { - case IDC_COPY_SPECULAR_DIFFUSE: - TheMtl->Set_Copy_Specular_To_Diffuse(PassIndex,GetCheckBox(dlg_wnd, IDC_COPY_SPECULAR_DIFFUSE) == TRUE); - break; - - case IDC_MAPPING0_COMBO: - if (code == CBN_SELCHANGE) { - val = SendDlgItemMessage(dlg_wnd,IDC_MAPPING0_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Mapping_Type(PassIndex,0,val); - } - break; - - case IDC_MAPPING1_COMBO: - if (code == CBN_SELCHANGE) { - val = SendDlgItemMessage(dlg_wnd,IDC_MAPPING1_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Mapping_Type(PassIndex,1,val); - } - break; - - case IDC_MAPPING0_ARGS_EDIT: - switch (code) { - case EN_SETFOCUS: - DisableAccelerators(); - break; - case EN_KILLFOCUS: - EnableAccelerators(); - break; - case EN_CHANGE: - int len = GetWindowTextLength(GetDlgItem(dlg_wnd, IDC_MAPPING0_ARGS_EDIT)); - char *buffer = TheMtl->Get_Mapping_Arg_Buffer(PassIndex, 0, len); - GetWindowText(GetDlgItem(dlg_wnd, IDC_MAPPING0_ARGS_EDIT), buffer, len + 1); - break; - } - break; - - case IDC_MAPPING1_ARGS_EDIT: - switch (code) { - case EN_SETFOCUS: - DisableAccelerators(); - break; - case EN_KILLFOCUS: - EnableAccelerators(); - break; - case EN_CHANGE: - int len = GetWindowTextLength(GetDlgItem(dlg_wnd, IDC_MAPPING1_ARGS_EDIT)); - char *buffer = TheMtl->Get_Mapping_Arg_Buffer(PassIndex, 1, len); - GetWindowText(GetDlgItem(dlg_wnd, IDC_MAPPING1_ARGS_EDIT), buffer, len + 1); - break; - } - break; - - case IDC_NO_TRANS: - TheMtl->Set_PSX_Translucency(PassIndex,GAMEMTL_PSX_TRANS_NONE); - break; - - case IDC_100_TRANS: - TheMtl->Set_PSX_Translucency(PassIndex,GAMEMTL_PSX_TRANS_100); - break; - - case IDC_50_TRANS: - TheMtl->Set_PSX_Translucency(PassIndex,GAMEMTL_PSX_TRANS_50); - break; - - case IDC_25_TRANS: - TheMtl->Set_PSX_Translucency(PassIndex,GAMEMTL_PSX_TRANS_25); - break; - - case IDC_MINUS_100_TRANS: - TheMtl->Set_PSX_Translucency(PassIndex,GAMEMTL_PSX_TRANS_MINUS_100); - break; - - case IDC_NO_RT_LIGHTING: - TheMtl->Set_PSX_Lighting(PassIndex,!GetCheckBox(dlg_wnd, IDC_NO_RT_LIGHTING)); - break; - } - break; - } - - case CC_COLOR_CHANGE: - { - // just update all of the colors - TheMtl->Set_Ambient(PassIndex,IParams->GetTime(),AmbientSwatch->GetColor()); - TheMtl->Set_Diffuse(PassIndex,IParams->GetTime(),DiffuseSwatch->GetColor()); - TheMtl->Set_Specular(PassIndex,IParams->GetTime(),SpecularSwatch->GetColor()); - TheMtl->Set_Emissive(PassIndex,IParams->GetTime(),EmissiveSwatch->GetColor()); - TheMtl->Notify_Changed(); - break; - } - - case CC_SPINNER_CHANGE: - { - TheMtl->Set_Shininess(PassIndex,IParams->GetTime(),ShininessSpin->GetFVal()); - TheMtl->Set_Opacity(PassIndex,IParams->GetTime(),OpacitySpin->GetFVal()); - TheMtl->Set_Translucency(PassIndex,IParams->GetTime(),TranslucencySpin->GetFVal()); - for (int i=0; iSet_Map_Channel(PassIndex,i,UVChannelSpin[i]->GetIVal()); - } - break; - } - - case CC_SPINNER_BUTTONUP: - { - TheMtl->Notify_Changed(); - break; - } - - } - return FALSE; -} - - -/*********************************************************************************************** - * GameMtlVertexMaterialDlg::ReloadDialog -- reload the contents of the controls * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlVertexMaterialDlg::ReloadDialog(void) -{ - // Vertex Material Controls - DebugPrint("GameMtlVertexMaterialDlg::ReloadDialog\n"); - assert(AmbientSwatch && DiffuseSwatch && SpecularSwatch && EmissiveSwatch); - assert(ShininessSpin && OpacitySpin && TranslucencySpin); - - AmbientSwatch->InitColor(TheMtl->Get_Ambient(PassIndex,IParams->GetTime())); - DiffuseSwatch->InitColor(TheMtl->Get_Diffuse(PassIndex,IParams->GetTime())); - SpecularSwatch->InitColor(TheMtl->Get_Specular(PassIndex,IParams->GetTime())); - EmissiveSwatch->InitColor(TheMtl->Get_Emissive(PassIndex,IParams->GetTime())); - - ShininessSpin->SetValue(TheMtl->Get_Shininess(PassIndex,IParams->GetTime()),FALSE); - OpacitySpin->SetValue(TheMtl->Get_Opacity(PassIndex,IParams->GetTime()),FALSE); - TranslucencySpin->SetValue(TheMtl->Get_Translucency(PassIndex,IParams->GetTime()),FALSE); - for (int i=0; iSetValue(TheMtl->Get_Map_Channel(PassIndex,i),FALSE); - } - - SetCheckBox(m_hWnd,IDC_COPY_SPECULAR_DIFFUSE, TheMtl->Get_Copy_Specular_To_Diffuse(PassIndex)); - - SendDlgItemMessage( m_hWnd, - IDC_MAPPING0_COMBO, - CB_SETCURSEL, - TheMtl->Get_Mapping_Type(PassIndex, 0), - 0 ); - - SendDlgItemMessage( m_hWnd, - IDC_MAPPING1_COMBO, - CB_SETCURSEL, - TheMtl->Get_Mapping_Type(PassIndex, 1), - 0 ); - - // PSX Controls - SetCheckBox(m_hWnd,IDC_NO_RT_LIGHTING, !TheMtl->Get_PSX_Lighting(PassIndex)); - SetCheckBox(m_hWnd,IDC_NO_TRANS, false); - SetCheckBox(m_hWnd,IDC_100_TRANS, false); - SetCheckBox(m_hWnd,IDC_50_TRANS, false); - SetCheckBox(m_hWnd,IDC_25_TRANS, false); - SetCheckBox(m_hWnd,IDC_MINUS_100_TRANS, false); - - switch (TheMtl->Get_PSX_Translucency(PassIndex)) { - case 0: - SetCheckBox(m_hWnd,IDC_NO_TRANS,true); - break; - case GAMEMTL_PSX_TRANS_100: - SetCheckBox(m_hWnd,IDC_100_TRANS,true); - break; - case GAMEMTL_PSX_TRANS_50: - SetCheckBox(m_hWnd,IDC_50_TRANS,true); - break; - case GAMEMTL_PSX_TRANS_25: - SetCheckBox(m_hWnd,IDC_25_TRANS,true); - break; - case GAMEMTL_PSX_TRANS_MINUS_100: - SetCheckBox(m_hWnd,IDC_MINUS_100_TRANS,true); - break; - } - - // Reload contents of mapper args edit box: - char *buffer = TheMtl->Get_Mapping_Arg_Buffer(PassIndex, 0); - SetWindowText(GetDlgItem(m_hWnd, IDC_MAPPING0_ARGS_EDIT), buffer); - buffer = TheMtl->Get_Mapping_Arg_Buffer(PassIndex, 1); - SetWindowText(GetDlgItem(m_hWnd, IDC_MAPPING1_ARGS_EDIT), buffer); -} - - -/*********************************************************************************************** - * GameMtlVertexMaterialDlg::ActivateDlg -- activate / deactivate this dialog * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/98 GTH : Created. * - *=============================================================================================*/ -void GameMtlVertexMaterialDlg::ActivateDlg(BOOL onoff) -{ - if (AmbientSwatch) { - AmbientSwatch->Activate(onoff); - } - if (DiffuseSwatch) { - DiffuseSwatch->Activate(onoff); - } - if (SpecularSwatch) { - SpecularSwatch->Activate(onoff); - } - if (EmissiveSwatch) { - EmissiveSwatch->Activate(onoff); - } -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.h b/Generals/Code/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.h deleted file mode 100644 index 3c9fefc4423..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/GameMtlVertexMaterialDlg.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 5/30/00 12:08p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - -#ifndef GAMEMTLVERTEXMATERIALDLG_H -#define GAMEMTLVERTEXMATERIALDLG_H - -#include -#include "GameMtlForm.h" - -class GameMtl; - -class GameMtlVertexMaterialDlg : public GameMtlFormClass -{ - -public: - - GameMtlVertexMaterialDlg(HWND parent, IMtlParams * imp, GameMtl * m, int pass); - ~GameMtlVertexMaterialDlg(); - - virtual BOOL Dialog_Proc (HWND dlg_wnd, UINT message, WPARAM wparam, LPARAM lparam); - - void ActivateDlg(BOOL onoff); - void ReloadDialog(void); - -private: - - enum { MAX_STAGES = 2 }; - - IColorSwatch * AmbientSwatch; - IColorSwatch * DiffuseSwatch; - IColorSwatch * SpecularSwatch; - IColorSwatch * EmissiveSwatch; - - ISpinnerControl * OpacitySpin; - ISpinnerControl * TranslucencySpin; - ISpinnerControl * ShininessSpin; - ISpinnerControl * UVChannelSpin[MAX_STAGES]; -}; - - -#endif \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/InputDlg.cpp b/Generals/Code/Tools/WW3D/max2w3d/InputDlg.cpp deleted file mode 100644 index 22cea6d20f5..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/InputDlg.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/InputDlg.cpp $* - * * - * $Author:: Andre_a $* - * * - * $Modtime:: 5/08/00 1:58p $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - -// InputDlg.cpp : implementation file -// - -#include "InputDlg.h" -#include - - -static BOOL CALLBACK _thunk_dialog_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - - -///////////////////////////////////////////////////////////////////////////// -// InputDlg dialog - - -InputDlg::InputDlg (HWND hWndParent) -: m_hWndParent(hWndParent), - m_hWnd(NULL) -{ - // Set the strings to default values. - SetCaption("Input Value..."); - SetLabel("Please enter a value:"); - SetValue(NULL); -} - - -///////////////////////////////////////////////////////////////////////////// -// InputDlg Methods - -int InputDlg::DoModal (void) -{ - // Put up the dialog box. - BOOL result = DialogBoxParam(AppInstance, MAKEINTRESOURCE(IDD), - m_hWndParent, (DLGPROC)_thunk_dialog_proc, - (LPARAM)this); - - // Return IDOK if the user accepted the new settings. - return (result == 1) ? IDOK : IDCANCEL; -} - -void InputDlg::SetCaption (const char *caption) -{ - if (caption) - { - assert(strlen(caption) < sizeof(m_Caption)); - strcpy(m_Caption, caption); - } - else - m_Caption[0] = '\0'; -} - -void InputDlg::SetLabel (const char *label) -{ - if (label) - { - assert(strlen(label) < sizeof(m_Label)); - strcpy(m_Label, label); - } - else - m_Label[0] = '\0'; -} - -void InputDlg::SetValue (const char *value) -{ - if (value) - { - assert(strlen(value) < sizeof(m_Value)); - strcpy(m_Value, value); - } - else - m_Value[0] = '\0'; -} - - -///////////////////////////////////////////////////////////////////////////// -// InputDlg DialogProc - -BOOL CALLBACK _thunk_dialog_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - static InputDlg *dialog = NULL; - - if (uMsg == WM_INITDIALOG) - { - dialog = (InputDlg*)lParam; - dialog->m_hWnd = hWnd; - } - - if (dialog) - return dialog->DialogProc(hWnd, uMsg, wParam, lParam); - else - return 0; -} - -BOOL CALLBACK InputDlg::DialogProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - int code = HIWORD(wParam); - - switch (uMsg) - { - /******************************************************************* - * WM_INITDIALOG - * - * Initialize all of the custom controls for the dialog box - * - *******************************************************************/ - case WM_INITDIALOG: - - OnInitDialog(wParam, lParam); - return TRUE; - - - /******************************************************************* - * WM_COMMAND - * - * - *******************************************************************/ - case WM_COMMAND: - - switch (LOWORD(wParam)) - { - case IDOK: - if (!OnOK()) - return TRUE; - - SetCursor(LoadCursor(NULL, IDC_WAIT)); - EndDialog(m_hWnd, 1); - break; - - case IDCANCEL: - EndDialog(m_hWnd, 0); - break; - } - return TRUE; - } - - return FALSE; -} - -///////////////////////////////////////////////////////////////////////////// -// InputDlg message handlers - -LRESULT InputDlg::OnInitDialog (WPARAM wParam, LPARAM lParam) -{ - // Set the cursor to the normal arrow. - SetCursor(LoadCursor(NULL, IDC_ARROW)); - - // Set the dialog box caption. - SetWindowText(m_hWnd, m_Caption); - - // Set the label text. - HWND hLabel = GetDlgItem(m_hWnd, IDC_LABEL); - assert(hLabel != NULL); - SetWindowText(hLabel, m_Label); - - // Set the default value. - HWND hEdit = GetDlgItem(m_hWnd, IDC_VALUE); - assert(hEdit != NULL); - SetWindowText(hEdit, m_Value); - - // Select all of the text in the edit box. - SendMessage(hEdit, EM_SETSEL, 0, -1); - - return 0; -} - -BOOL InputDlg::OnOK (void) -{ - // Update our copy of what the user typed. - HWND hEdit = GetDlgItem(m_hWnd, IDC_VALUE); - assert(hEdit != NULL); - GetWindowText(hEdit, m_Value, sizeof(m_Value)); - - // The dialog can be dismissed. - return TRUE; -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/InputDlg.h b/Generals/Code/Tools/WW3D/max2w3d/InputDlg.h deleted file mode 100644 index bbe02e2106e..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/InputDlg.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/InputDlg.h $* - * * - * $Author:: Andre_a $* - * * - * $Modtime:: 5/08/00 1:36p $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - -#ifndef INPUTDLG_H -#define INPUTDLG_H - -#include "dllmain.h" -#include "resource.h" - - -///////////////////////////////////////////////////////////////////////////// -// InputDlg dialog - a generic input box for MAXScript - -class InputDlg -{ - friend BOOL CALLBACK _thunk_dialog_proc (HWND, UINT, WPARAM, LPARAM); - -public: - - // Construction - InputDlg (HWND hWndParent=NULL); - - // Methods - int DoModal (void); // returns IDOK or IDCANCEL - - void SetCaption (const char *caption); - void SetLabel (const char *label); - void SetValue (const char *value); - - // DialogProc - BOOL CALLBACK DialogProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - - // Dialog data associated with GUI components. - char m_Value[1024]; // edit box - char m_Label[512]; // description label - char m_Caption[128]; // dialog caption - -protected: - - // Dialog data - enum { IDD = IDD_INPUT_DIALOG }; - HWND m_hWnd; - HWND m_hWndParent; - - // Message Handlers - LRESULT OnInitDialog (WPARAM wParam, LPARAM lParam); - BOOL OnOK (void); -}; - - -#endif diff --git a/Generals/Code/Tools/WW3D/max2w3d/LightGlareSave.cpp b/Generals/Code/Tools/WW3D/max2w3d/LightGlareSave.cpp deleted file mode 100644 index 945f44b852c..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/LightGlareSave.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/LightGlareSave.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 8/06/00 11:21a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "LightGlareSave.h" -#include "w3d_file.h" -#include "util.h" -#include "w3dappdata.h" -#include "errclass.h" - - -LightGlareSaveClass::LightGlareSaveClass -( - char * mesh_name, - char * container_name, - INode * inode, - Matrix3 & exportspace, - TimeValue curtime, - Progress_Meter_Class & meter -) -{ - ////////////////////////////////////////////////////////////////////// - // Init the glare info - ////////////////////////////////////////////////////////////////////// - memset(&GlareData,0,sizeof(GlareData)); - - ////////////////////////////////////////////////////////////////////// - // Get the position of the pivot point relative to the given - // export coordinate system. - ////////////////////////////////////////////////////////////////////// - - // Transform the mesh into the desired coordinate system - Matrix3 node_matrix = inode->GetObjectTM(curtime); - Matrix3 offset_matrix = node_matrix * Inverse(exportspace); - - GlareData.Position.X = offset_matrix.GetTrans().x; - GlareData.Position.Y = offset_matrix.GetTrans().y; - GlareData.Position.Z = offset_matrix.GetTrans().z; -} - - - -int LightGlareSaveClass::Write_To_File(ChunkSaveClass & csave) -{ - csave.Begin_Chunk(W3D_CHUNK_LIGHTGLARE); - csave.Begin_Chunk(W3D_CHUNK_LIGHTGLARE_INFO); - csave.Write(&GlareData,sizeof(GlareData)); - csave.End_Chunk(); - csave.End_Chunk(); - return 0; -} - - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/LightGlareSave.h b/Generals/Code/Tools/WW3D/max2w3d/LightGlareSave.h deleted file mode 100644 index a1752ca6ce1..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/LightGlareSave.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/LightGlareSave.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 8/05/00 10:27a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef LIGHTGLARESAVE_H -#define LIGHTGLARESAVE_H - -#include -#include "w3d_file.h" -#include "chunkio.h" -#include "PROGRESS.H" - - -/******************************************************************************************* -** -** LightGlareSaveClass - Create a Light Glare definition from a Max mesh. In the initial -** implementation, all I need to save is the point at the pivot of the mesh. -** -*******************************************************************************************/ -class LightGlareSaveClass -{ -public: - - enum { - EX_UNKNOWN = 0, // exception error codes - EX_CANCEL = 1 - }; - - LightGlareSaveClass( char * mesh_name, - char * container_name, - INode * inode, - Matrix3 & exportspace, - TimeValue curtime, - Progress_Meter_Class & meter); - - int Write_To_File(ChunkSaveClass & csave); - -private: - - W3dLightGlareStruct GlareData; - -}; - - - -#endif \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/MeshDeform.cpp b/Generals/Code/Tools/WW3D/max2w3d/MeshDeform.cpp deleted file mode 100644 index 0b30edadd3c..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/MeshDeform.cpp +++ /dev/null @@ -1,1446 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/MeshDeform.cpp 7 5/01/01 8:56p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : MeshDeform.cpp * - * * - * Programmer : Patrick Smith * - * * - * Start Date : 04/19/99 * - * * - * Last Update : - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "MeshDeform.h" -#include "MeshDeformData.h" -#include "MeshDeformPanel.h" -#include "MeshDeformUndo.h" -#include "dllmain.h" -#include "resource.h" -#include "util.h" - -#if defined W3D_MAX4 //defined as in the project (.dsp) -static GenSubObjType _SubObjectTypeVertex(1); -#endif - -/////////////////////////////////////////////////////////////////////////// -// -// MeshDeformClass Class ID -// -/////////////////////////////////////////////////////////////////////////// -Class_ID _MeshDeformClassID(0x51981f5b, 0x1db2bf3); - - -/////////////////////////////////////////////////////////////////////////// -// -// MeshDeformClassDesc -// -/////////////////////////////////////////////////////////////////////////// -class MeshDeformClassDesc : public ClassDesc -{ - public: - int IsPublic (void) { return 1; } - void * Create (BOOL loading) { return new MeshDeformClass (); } - const TCHAR * ClassName () { return _T("WWDeform"); } - SClass_ID SuperClassID () { return OSM_CLASS_ID; } - Class_ID ClassID () { return _MeshDeformClassID; } - const TCHAR* Category () { return _T("Westwood Modifiers"); } -}; - - -/////////////////////////////////////////////////////////////////////////// -// -// Static class desc instance -// -/////////////////////////////////////////////////////////////////////////// -#if 0 // (gth) MeshDeform is obsolete! making sure nobody uses it... -static MeshDeformClassDesc _MeshDeformCD; -ClassDesc * Get_Mesh_Deform_Desc (void) { return &_MeshDeformCD; } -#else -ClassDesc * Get_Mesh_Deform_Desc (void) { return NULL; } -#endif - - -/////////////////////////////////////////////////////////////////////////// -// -// ChannelsUsed -// -/////////////////////////////////////////////////////////////////////////// -ChannelMask -MeshDeformClass::ChannelsUsed (void) -{ - return GEOM_CHANNEL | SELECT_CHANNEL | SUBSEL_TYPE_CHANNEL | VERTCOLOR_CHANNEL; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// ChannelsChanged -// -/////////////////////////////////////////////////////////////////////////// -ChannelMask -MeshDeformClass::ChannelsChanged (void) -{ - return GEOM_CHANNEL | SELECT_CHANNEL | SUBSEL_TYPE_CHANNEL | VERTCOLOR_CHANNEL; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// ModifyObject -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::ModifyObject -( - TimeValue time, - ModContext & mod_context, - ObjectState * object_state, - INode * /*node*/ -) -{ - assert(object_state->obj->IsSubClassOf(triObjectClassID)); - - - MeshDeformModData *mod_data = NULL; - if (mod_context.localData == NULL) { - mod_data = new MeshDeformModData; - mod_context.localData = mod_data; - } else { - mod_data = static_cast (mod_context.localData); - } - - // Display the verts - TriObject *tri_obj = (TriObject *)object_state->obj; - tri_obj->mesh.SetDispFlag (DISP_SELVERTS | DISP_VERTTICKS); - - // Record the initial state of the mesh - bool lock_sets = false; - if (m_pPanel != NULL) { - lock_sets = (m_pPanel->Are_Sets_Tied () == TRUE); - } - mod_data->Record_Mesh_State (*tri_obj, m_DeformState, lock_sets); - - tri_obj->PointsWereChanged(); - - // Kind of a waste when there's no animation... - tri_obj->UpdateValidity (GEOM_CHAN_NUM, Interval (time, time + 1)); - tri_obj->UpdateValidity (SELECT_CHAN_NUM, Interval (time, time + 1)); - tri_obj->UpdateValidity (SUBSEL_TYPE_CHAN_NUM, Interval (time, time + 1)); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// InputType -// -/////////////////////////////////////////////////////////////////////////// -Class_ID -MeshDeformClass::InputType (void) -{ - return triObjectClassID; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// NotifyRefChanged -// -/////////////////////////////////////////////////////////////////////////// -RefResult -MeshDeformClass::NotifyRefChanged -( - Interval time, - RefTargetHandle htarget, - PartID &part_id, - RefMessage mesage -) -{ - return REF_SUCCEED; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// GetCreateMouseCallBack -// -/////////////////////////////////////////////////////////////////////////// -CreateMouseCallBack * -MeshDeformClass::GetCreateMouseCallBack (void) -{ - return NULL; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// BeginEditParams -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::BeginEditParams -( - IObjParam *max_interface, - ULONG flags, - Animatable *prev -) -{ - m_MaxInterface = max_interface; - Update_Set_Count (); - Set_Max_Deform_Sets (m_MaxSets); - - // Add our rollup to the command panel - m_hRollupWnd = m_MaxInterface->AddRollupPage (AppInstance, - MAKEINTRESOURCE (IDD_MESH_DEFORM_PANEL), - MeshDeformPanelClass::Message_Proc, - "Westwood Mesh Deform", - 0, - 0); - - // - // Update the UI - // - m_pPanel = MeshDeformPanelClass::Get_Object (m_hRollupWnd); - m_pPanel->Set_Deformer (this); - m_pPanel->Set_Max_Sets (m_MaxSets); - m_pPanel->Set_Current_Set (m_CurrentSet); - Set_Current_Set (m_CurrentSet, false); - - // - // Register the desired sub-object selection types. - // - const TCHAR * ptype[] = { "Vertices" }; -#if defined W3D_MAX4 //defined as in the project (.dsp) - max_interface->SetSubObjectLevel(1); -#else - //---This call is obsolete from max4. - max_interface->RegisterSubObjectTypes( ptype, 1); -#endif - - // - // Create the mode handlers - // - m_ModeSelect = new SelectModBoxCMode (this, max_interface); - m_ModeMove = new MoveModBoxCMode (this, max_interface); - m_ModeRotate = new RotateModBoxCMode (this, max_interface); - m_ModeUScale = new UScaleModBoxCMode (this, max_interface); - m_ModeNUScale = new NUScaleModBoxCMode (this, max_interface); - m_ModeSquash = new SquashModBoxCMode (this, max_interface); - - // - // Restore the selection level. - /// - max_interface->SetSubObjectLevel (1); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// EndEditParams -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::EndEditParams -( - IObjParam *max_interface, - ULONG flags, - Animatable *next -) -{ - // Remove our deform rollup - if (m_hRollupWnd != NULL) { - max_interface->DeleteRollupPage (m_hRollupWnd); - m_hRollupWnd = NULL; - } - - // - // Free the mode handlers - // - max_interface->DeleteMode (m_ModeMove); - max_interface->DeleteMode (m_ModeSelect); - max_interface->DeleteMode (m_ModeRotate); - max_interface->DeleteMode (m_ModeNUScale); - max_interface->DeleteMode (m_ModeUScale); - max_interface->DeleteMode (m_ModeSquash); - SAFE_DELETE (m_ModeMove); - SAFE_DELETE (m_ModeSelect); - SAFE_DELETE (m_ModeRotate); - SAFE_DELETE (m_ModeNUScale); - SAFE_DELETE (m_ModeUScale); - SAFE_DELETE (m_ModeSquash); - - // Release our hold on the max interface pointer - m_MaxInterface = NULL; - m_pPanel = NULL; - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// ActivateSubobjSel -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::ActivateSubobjSel -( - int level, - XFormModes &modes -) -{ - switch (level) - { - // Vertex manipulation - case 1: - modes = XFormModes (m_ModeMove, m_ModeRotate, m_ModeNUScale, m_ModeUScale, m_ModeSquash, m_ModeSelect); - break; - } - - /* - ** Notify our dependents that the subselection type, - ** and the display have changed - */ - NotifyDependents(FOREVER, PART_SUBSEL_TYPE|PART_DISPLAY, REFMSG_CHANGE); - - /* - ** Notify the pipeline that the selection level has changed. - */ - m_MaxInterface->PipeSelLevelChanged(); - - /* - ** Notify our dependents that the selection channel, - ** display attributes, and subselection type channels have changed - */ - NotifyDependents(FOREVER, VERTCOLOR_CHANNEL|SELECT_CHANNEL|DISP_ATTRIB_CHANNEL|SUBSEL_TYPE_CHANNEL, REFMSG_CHANGE); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// HitTest -// -/////////////////////////////////////////////////////////////////////////// -int -MeshDeformClass::HitTest -( - TimeValue time_value, - INode * node, - int type, - int crossing, - int flags, - IPoint2 * point, - ViewExp * viewport, - ModContext * mod_context -) -{ - // Initialize the HitRegion - HitRegion hit_rgn; - MakeHitRegion (hit_rgn, type, crossing, 4, point); - - Matrix3 transform = node->GetObjectTM (time_value); - Object * obj = node->EvalWorldState(time_value).obj; - TriObject * tri = (TriObject *)obj->ConvertToType(time_value, triObjectClassID); - - // - // Set up the graphics window to do the hit-test - // - GraphicsWindow *graphics_wnd = viewport->getGW (); - graphics_wnd->setHitRegion (&hit_rgn); - graphics_wnd->setTransform (transform); - - int saved_limits = graphics_wnd->getRndLimits (); - graphics_wnd->setRndLimits ((saved_limits | GW_PICK) & ~(GW_ILLUM | GW_BACKCULL)); - graphics_wnd->clearHitCode (); - - // - // Perform the hit test - // - SubObjHitList hitlist; - MeshDeformModData *mod_data = static_cast (mod_context->localData); - Mesh &mesh = tri->mesh;//mod_data->Peek_Mesh (); - int result = mesh.SubObjectHitTest (graphics_wnd, - graphics_wnd->getMaterial (), - &hit_rgn, - flags | SUBHIT_VERTS, - hitlist); - - // - // Record all of the hits - // - for (MeshSubHitRec *hit_record = hitlist.First (); - hit_record != NULL; - hit_record = hit_record->Next ()) { - - // rec->index is the index of vertex which was hit! - viewport->LogHit (node, mod_context, hit_record->dist, hit_record->index, NULL); - } - - // Cleanup - graphics_wnd->setRndLimits (saved_limits); - - // Return the integer result code - return result; -} - -/////////////////////////////////////////////////////////////////////////// -// -// HitTest -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::SelectSubComponent -( - HitRecord * hit_record, - BOOL selected, - BOOL all, - BOOL invert -) -{ - // Loop through all the hit records - for (; hit_record != NULL; hit_record = hit_record->Next ()) { - - // Peek at the vertex selection array for this hit record - MeshDeformModData *mod_data = static_cast (hit_record->modContext->localData); - Mesh *mesh = mod_data->Peek_Mesh (); - BitArray &array = (mesh->vertSel); - - if (all & invert) { - - /* - ** hitRec->hitInfo is the MeshSubHitRec::index that was stored in the - ** HitTest method through LogHit - */ - if (array[hit_record->hitInfo]) { - array.Clear (hit_record->hitInfo); - } else { - array.Set (hit_record->hitInfo, selected); - } - } else { - array.Set (hit_record->hitInfo, selected); - } - - if (!all) break; - } - - m_pPanel->Update_Vertex_Color (); - NotifyDependents (FOREVER, PART_SELECT, REFMSG_CHANGE); - m_bSetDirty = true; - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// GetSubObjectTMs -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::GetSubObjectTMs -( - SubObjAxisCallback *cb, - TimeValue t, - INode *node, - ModContext *mc -) -{ - int test = 0; - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// HitTest -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::GetSubObjectCenters -( - SubObjAxisCallback * callback, - TimeValue time_val, - INode * node, - ModContext * mod_context -) -{ - // Peek at the vertex selection array for this hit record - MeshDeformModData *mod_data = static_cast (mod_context->localData); - const Point3 *vertex_array = mod_data->Peek_Orig_Vertex_Array (); - Mesh *mesh = mod_data->Peek_Mesh (); - - BitArray sel_array = mesh->vertSel; - Matrix3 transform = node->GetObjectTM (time_val); - Box3 box; - - // Loop through all the selected verticies and create a bounding - // box which we can use to determine the selection center. - for (int index = 0; index < mesh->getNumVerts (); index++ ) { - if (sel_array[index]) { - box += mesh->getVert (index) * transform; - } - } - - // Pass the 'selection' center onto MAX - callback->Center (box.Center (), 0); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// ClearSelection -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::ClearSelection (int selLevel) -{ - ModContextList mod_context_list; - INodeTab nodes; - m_MaxInterface->GetModContexts (mod_context_list, nodes); - - for (int i = 0; i < mod_context_list.Count (); i++) { - - MeshDeformModData *mod_data = static_cast (mod_context_list[i]->localData); - - if (mod_data != NULL) { - mod_data->Peek_Mesh ()->vertSel.ClearAll (); - } - } - - /* - ** Get rid of the temporary copies of the INodes. - */ - nodes.DisposeTemporary (); - - /* - ** Tell our dependents that the selection set has changed - */ - NotifyDependents (FOREVER, PART_SELECT, REFMSG_CHANGE); - m_bSetDirty = true; - return ; -} - -static Point3 last_delta; -static Point3 last_scale; -static Matrix3 last_rot; - -/////////////////////////////////////////////////////////////////////////// -// -// Move -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::Move -( - TimeValue time_val, - Matrix3 & parent_tm, - Matrix3 & tm_axis, - Point3 & displacement, - BOOL local_origin -) -{ - if (m_pPanel->Is_Edit_Mode ()) { - - INodeTab nodes; - ModContextList mod_context_list; - m_MaxInterface->GetModContexts (mod_context_list, nodes); - - // Loop through all the modifier contexts - for (int index = 0; index < mod_context_list.Count (); index ++) { - - // Get the data we've cached for this modifier context - MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { - Mesh *mesh = mod_data->Peek_Mesh (); - const Point3 *vertex_array = mod_data->Peek_Orig_Vertex_Array (); - Point3 *opstart_array = mod_data->Peek_Vertex_OPStart_Array (); - - // Loop through all the selected verts - for (int vert = 0; vert < mesh->numVerts; vert ++) { - if (mesh->vertSel[vert]) { - - // Do the 'displacment' in axis-space - Point3 vert_ws = parent_tm * mesh->verts[vert]; - Point3 vert_as = Inverse (tm_axis) * vert_ws; - vert_as += displacement - last_delta; - - // Convert back to obj-space - vert_ws = tm_axis * vert_as; - mesh->verts[vert] = Inverse (parent_tm) * vert_ws; - - // Record the delta - //delta_array[vert] = mesh->verts[vert] - vertex_array[vert]; - } - } - - // - // Record these changes in the current set - // - mod_data->Update_Set (m_CurrentSet, VERT_POSITION); - } - } - - // Remember what our last displacement was because we - // want to perform our calculations relative to the current - // position. - last_delta = displacement; - - // Repaint the view - nodes.DisposeTemporary (); - NotifyDependents (FOREVER, PART_GEOM, REFMSG_CHANGE); - } - - m_OperationName = "Move"; - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Move -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::Scale -( - TimeValue time_val, - Matrix3 & parent_tm, - Matrix3 & tm_axis, - Point3 & value, - BOOL local_origin -) -{ - Point3 test = value - last_scale; - bool bok = (test.x != 0) && (test.y != 0) && (test.z != 0); - if (m_pPanel->Is_Edit_Mode () && bok) { - - INodeTab nodes; - ModContextList mod_context_list; - m_MaxInterface->GetModContexts (mod_context_list, nodes); - - // Loop through all the modifier contexts - for (int index = 0; index < mod_context_list.Count (); index ++) { - - // Get the data we've cached for this modifier context - MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { - Mesh *mesh = mod_data->Peek_Mesh (); - const Point3 *vertex_array = mod_data->Peek_Orig_Vertex_Array (); - Point3 *opstart_array = mod_data->Peek_Vertex_OPStart_Array (); - - // Loop through all the selected verts - for (int vert = 0; vert < mesh->numVerts; vert ++) { - if (mesh->vertSel[vert]) { - - // Do the 'scale' in axis-space - Point3 vert_ws = parent_tm * opstart_array[vert];//mesh->verts[vert]; - Point3 vert_as = Inverse (tm_axis) * vert_ws; - vert_as = ScaleMatrix (value) * vert_as; - - // Convert back to obj-space - vert_ws = tm_axis * vert_as; - mesh->verts[vert] = Inverse (parent_tm) * vert_ws; - - // Record the delta - //delta_array[vert] = mesh->verts[vert] - vertex_array[vert]; - } - } - - // - // Record these changes in the current set - // - mod_data->Update_Set (m_CurrentSet, VERT_POSITION); - } - } - - // Remember what our last displacement was because we - // want to perform our calculations relative to the current - // position. - //last_scale = value - Point3 (1,1,1); - //last_delta = displacement; - - // Repaint the view - nodes.DisposeTemporary (); - NotifyDependents (FOREVER, PART_GEOM, REFMSG_CHANGE); - } - - m_OperationName = "Scale"; - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Rotate -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::Rotate -( - TimeValue time_val, - Matrix3 & parent_tm, - Matrix3 & tm_axis, - Quat & rotation, - BOOL local_origin -) -{ - if (m_pPanel->Is_Edit_Mode ()) { - INodeTab nodes; - ModContextList mod_context_list; - m_MaxInterface->GetModContexts (mod_context_list, nodes); - - Matrix3 matrix_rot; - rotation.MakeMatrix (matrix_rot); - - Matrix3 rel_rot; - rel_rot = Inverse (last_rot) * matrix_rot; - - // Loop through all the modifier contexts - for (int index = 0; index < mod_context_list.Count (); index ++) { - - // Get the data we've cached for this modifier context - MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { - Mesh *mesh = mod_data->Peek_Mesh (); - const Point3 *vertex_array = mod_data->Peek_Orig_Vertex_Array (); - Point3 *opstart_array = mod_data->Peek_Vertex_OPStart_Array (); - - // Loop through all the selected verts - for (int vert = 0; vert < mesh->numVerts; vert ++) { - if (mesh->vertSel[vert]) { - - // Do the 'displacment' in axis-space - Point3 vert_ws = parent_tm * mesh->verts[vert]; - Point3 vert_as = Inverse (tm_axis) * vert_ws; - vert_as = (rel_rot * vert_as); - - // Convert back to obj-space - vert_ws = tm_axis * vert_as; - mesh->verts[vert] = Inverse (parent_tm) * vert_ws; - - // Record the delta - //delta_array[vert] = mesh->verts[vert] - vertex_array[vert]; - } - } - - // - // Record these changes in the current set - // - mod_data->Update_Set (m_CurrentSet, VERT_POSITION); - } - } - - // Remember what our last displacement was because we - // want to perform our calculations relative to the current - // position. - //last_delta = displacement; - last_rot = matrix_rot; - - // Repaint the view - nodes.DisposeTemporary (); - NotifyDependents (FOREVER, PART_GEOM, REFMSG_CHANGE); - - // Make sure our current 'set' knows what verts have changed - //Update_Current_Set (); - } - - m_OperationName = "Rotate"; - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// TransformStart -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::TransformStart (TimeValue time_val) -{ - if (m_MaxInterface != NULL) { - m_MaxInterface->LockAxisTripods (TRUE); - } - - // Reset our last-delta value - last_delta.x = 0; - last_delta.y = 0; - last_delta.z = 0; - last_rot.IdentityMatrix (); - last_scale.x = 0; - last_scale.y = 0; - last_scale.z = 0; - - INodeTab nodes; - ModContextList mod_context_list; - m_MaxInterface->GetModContexts (mod_context_list, nodes); - - // Begin the undo operation - theHold.Begin (); - - // Loop through all the modifier contexts - for (int index = 0; index < mod_context_list.Count (); index ++) { - - // Get the data we've cached for this modifier context - MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { - Mesh *mesh = mod_data->Peek_Mesh (); - Point3 *opstart_array = mod_data->Peek_Vertex_OPStart_Array (); - - // Copy the current state of the mesh - for (int vert = 0; vert < mesh->numVerts; vert ++) { - opstart_array[vert] = mesh->verts[vert]; - } - - // Add the 'position restore' object to the undo stack - theHold.Put (new VertexPositionRestoreClass (mesh, this, mod_data)); - } - } - - // Repaint the view - nodes.DisposeTemporary (); - NotifyDependents (FOREVER, PART_GEOM, REFMSG_CHANGE); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// TransformFinish -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::TransformFinish (TimeValue time_val) -{ - if (m_MaxInterface != NULL) { - m_MaxInterface->LockAxisTripods (FALSE); - } - - // Accept the undo operation - theHold.Accept (m_OperationName); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// TransformCancel -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::TransformCancel (TimeValue time_val) -{ - if (m_MaxInterface != NULL) { - m_MaxInterface->LockAxisTripods (FALSE); - } - - // Cancel the undo operation - theHold.Cancel (); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Set_Deform_State -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::Set_Deform_State (float state) -{ - if ((m_MaxInterface != NULL) && (state != m_DeformState)) { - m_DeformState = state; - NotifyDependents (FOREVER, PART_GEOM | PART_VERTCOLOR, REFMSG_CHANGE); - m_MaxInterface->RedrawViews (m_MaxInterface->GetTime ()); - if (m_pPanel != NULL) { - m_pPanel->Update_Vertex_Color (); - } - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Set_Vertex_Color -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::Set_Vertex_Color (const Point3 &color, bool button_up) -{ - if (m_MaxInterface != NULL) { - - INodeTab nodes; - ModContextList mod_context_list; - m_MaxInterface->GetModContexts (mod_context_list, nodes); - - bool save_undo = false; - if ((button_up == false) && (m_VertColorChanging == false)) { - theHold.Begin (); - m_VertColorChanging = true; - save_undo = true; - } - - // Loop through all the modifier contexts - for (int index = 0; index < mod_context_list.Count (); index ++) { - - // Get the data we've cached for this modifier context - MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { - Mesh *mesh = mod_data->Peek_Mesh (); - - // - // Record the original color in the undo stack - // - if (save_undo) { - theHold.Put (new VertexColorRestoreClass (mesh, this, mod_data)); - } - - // Only do this if the mesh is using vertex coloring - if (mesh->numCVerts >= mesh->numVerts) { - - // - // Loop through all the per-face verts - // - for (int face = 0; face < mesh->numFaces; face ++) { - for (int vert = 0; vert < 3; vert ++) { - - // - // If the vertex is selected, then change its color - // - if (mesh->vertSel[mesh->faces[face].v[vert]]) { - int color_index = mesh->vcFace[face].t[vert]; - mesh->vertCol[color_index] = color; - } - } - } - } - - // - // Record these changes in the current set - // - mod_data->Update_Set (m_CurrentSet, VERT_COLORS); - } - } - - if (button_up && m_VertColorChanging) { - theHold.Accept ("Vertex Color"); - } - - // Repaint the model - nodes.DisposeTemporary (); - NotifyDependents (FOREVER, PART_GEOM | PART_VERTCOLOR, REFMSG_CHANGE); - m_MaxInterface->RedrawViews (m_MaxInterface->GetTime ()); - } - - m_VertColorChanging = !button_up; - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Get_Vertex_Color -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::Get_Vertex_Color (Point3 &color) -{ - // Assume black - color.x = 0; - color.y = 0; - color.z = 0; - - if (m_MaxInterface != NULL) { - - INodeTab nodes; - ModContextList mod_context_list; - m_MaxInterface->GetModContexts (mod_context_list, nodes); - - // - // Loop through all the modifier contexts - // - int sel_count = 0; - for (int index = 0; index < mod_context_list.Count (); index ++) { - - // - // Get the data we've cached for this modifier context - // - MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { - Mesh *mesh = mod_data->Peek_Mesh (); - - // Only do this if the mesh is using vertex coloring - if (mesh->numCVerts >= mesh->numVerts) { - - // - // Loop through all the per-face verts - // - for (int face = 0; face < mesh->numFaces; face ++) { - for (int vert = 0; vert < 3; vert ++) { - - // - // If this vert is selected, then add its color to the total - // - if (mesh->vertSel[mesh->faces[face].v[vert]]) { - int color_index = mesh->vcFace[face].t[vert]; - Point3 vert_color = mesh->vertCol[color_index]; - color += vert_color; - sel_count ++; - } - } - } - } - } - } - - // - // Normalize the selected color - // - if (sel_count > 0) { - color = color / sel_count; - } - - nodes.DisposeTemporary (); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Update_UI -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::Update_UI (MeshDeformModData *mod_data) -{ - assert (mod_data != NULL); - - if (m_pPanel != NULL) { - Update_Set_Count (); - - m_CurrentSet = mod_data->Get_Current_Set (); - int keyframe = mod_data->Peek_Set (m_CurrentSet).Get_Current_Key_Frame (); - Set_Deform_State ((float(keyframe + 1) + 0.5F) / 10.0F); - - m_pPanel->Update_Vertex_Color (); - m_pPanel->Set_Max_Sets (m_MaxSets); - m_pPanel->Set_Current_Set (m_CurrentSet); - m_pPanel->Set_Current_State (m_DeformState); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Auto_Apply -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::Auto_Apply (bool auto_apply) -{ - if (m_MaxInterface != NULL) { - - // Get a list of contexts that we are part of. - INodeTab nodes; - ModContextList mod_context_list; - m_MaxInterface->GetModContexts (mod_context_list, nodes); - - // Loop through all the modifier contexts - for (int index = 0; index < mod_context_list.Count (); index ++) { - - // - // Let the mod context know what it's auto apply state is - // - MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { - mod_data->Auto_Apply (auto_apply); - } - } - - // Cleanup - nodes.DisposeTemporary (); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Set_Max_Deform_Sets -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::Set_Max_Deform_Sets (int max) -{ - // - // Make sure the current set doesn't exceed the total sets - // - if (m_CurrentSet >= max) { - Set_Current_Set (max - 1, true); - } - - m_MaxSets = max; - if (m_MaxInterface != NULL) { - - // Get a list of contexts that we are part of. - INodeTab nodes; - ModContextList mod_context_list; - m_MaxInterface->GetModContexts (mod_context_list, nodes); - - // Loop through all the modifier contexts - for (int index = 0; index < mod_context_list.Count (); index ++) { - - // - // Let the mod context know the max sets have changed - // - MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { - mod_data->Set_Max_Deform_Sets (max); - } - } - - // Cleanup - nodes.DisposeTemporary (); - NotifyDependents (FOREVER, PART_SELECT, REFMSG_CHANGE); - m_MaxInterface->RedrawViews (m_MaxInterface->GetTime ()); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Update_Set_Count -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::Update_Set_Count (void) -{ - m_MaxSets = 1; - if (m_MaxInterface != NULL) { - - // Get a list of contexts that we are part of. - INodeTab nodes; - ModContextList mod_context_list; - m_MaxInterface->GetModContexts (mod_context_list, nodes); - - // Loop through all the modifier contexts - for (int index = 0; index < mod_context_list.Count (); index ++) { - - // - // Get the count of sets for this context - // - MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if ((mod_data != NULL) && (mod_data->Get_Set_Count () > m_MaxSets)) { - m_MaxSets = mod_data->Get_Set_Count (); - } - } - - // Cleanup - nodes.DisposeTemporary (); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Set_Current_Set -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::Set_Current_Set -( - int index, - bool update_selection -) -{ - last_delta.x = 0; - last_delta.y = 0; - last_delta.z = 0; - - m_CurrentSet = index; - if (m_MaxInterface != NULL) { - if (update_selection) { - ClearSelection (1); - } - - // Get a list of contexts that we are part of. - INodeTab nodes; - ModContextList mod_context_list; - m_MaxInterface->GetModContexts (mod_context_list, nodes); - - // Loop through all the modifier contexts - for (int index = 0; index < mod_context_list.Count (); index ++) { - - // - // Have the mod context select the verts in its set - // - MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { - mod_data->Set_Current_Set (m_CurrentSet); - if (update_selection) { - mod_data->Select_Set (m_CurrentSet); - } - m_pPanel->Set_Auto_Apply_Check (mod_data->Is_Auto_Apply ()); - } - } - - // Repaint the model - nodes.DisposeTemporary (); - if (update_selection) { - NotifyDependents (FOREVER, PART_SELECT, REFMSG_CHANGE); - m_MaxInterface->RedrawViews (m_MaxInterface->GetTime ()); - } - - // Update the current 'vertex color' on the UI panel - m_pPanel->Update_Vertex_Color (); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Update_Current_Set -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformClass::Update_Current_Set (void) -{ - if (m_MaxInterface != NULL) { - - // Get a list of contexts that we are part of. - INodeTab nodes; - ModContextList mod_context_list; - m_MaxInterface->GetModContexts (mod_context_list, nodes); - - // Loop through all the modifier contexts - for (int index = 0; index < mod_context_list.Count (); index ++) { - - // - // Notify the mod context so it can update its list of verts - // in the current set. - // - MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { - //mod_data->Update_Set (m_CurrentSet); - } - } - - // Cleanup - nodes.DisposeTemporary (); - m_bSetDirty = false; - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// SaveLocalData -// -/////////////////////////////////////////////////////////////////////////// -IOResult -MeshDeformClass::SaveLocalData (ISave *save_obj, LocalModData *mod_context) -{ - assert (mod_context != NULL); - return ((MeshDeformModData *)mod_context)->Save (save_obj); -} - - -/////////////////////////////////////////////////////////////////////////// -// -// LoadLocalData -// -/////////////////////////////////////////////////////////////////////////// -IOResult -MeshDeformClass::LoadLocalData (ILoad *load_obj, LocalModData **mod_context) -{ - assert (mod_context != NULL); - MeshDeformModData *mod_data = new MeshDeformModData; - (*mod_context) = mod_data; - return mod_data->Load (load_obj); -} - - - - - - -#if 0 - -void SkinModifierClass::SelectAll(int selLevel) -{ - int needsdel = 0; - Interval valid = FOREVER; - ModContextList mclist; - INodeTab nodes; - - if (!InterfacePtr) return; - - InterfacePtr->GetModContexts(mclist,nodes); - InterfacePtr->ClearCurNamedSelSet(); - - for (int i = 0; i < mclist.Count(); i++) { - - SkinDataClass * skindata = (SkinDataClass *)mclist[i]->localData; - - if (skindata==NULL) continue; - - ObjectState os = nodes[i]->EvalWorldState(InterfacePtr->GetTime()); - TriObject * tobj = Get_Tri_Object(InterfacePtr->GetTime(),os,valid,needsdel); - - switch (SubObjSelLevel) { - - case OBJECT_SEL_LEVEL: - assert(0); - return; - - case VERTEX_SEL_LEVEL: -#if 0 // undo/redo - if (theHold.Holding()) { - theHold.Put(new VertexSelRestore(meshData,this)); - } -#endif - tobj->mesh.vertSel.SetAll(); - skindata->VertSel.SetAll(); - break; - } - - if (needsdel) { - tobj->DeleteThis(); - } - } - - /* - ** Get rid of the temporary copies of the INodes. - */ - nodes.DisposeTemporary(); - - /* - ** Tell our dependents that the selection set has changed - */ - NotifyDependents(FOREVER, PART_SELECT, REFMSG_CHANGE); -} - -void SkinModifierClass::InvertSelection(int selLevel) -{ - int needsdel = 0; - Interval valid = FOREVER; - ModContextList mclist; - INodeTab nodes; - - if (!InterfacePtr) return; - - InterfacePtr->GetModContexts(mclist,nodes); - InterfacePtr->ClearCurNamedSelSet(); - - for (int i = 0; i < mclist.Count(); i++) { - - SkinDataClass * skindata = (SkinDataClass *)mclist[i]->localData; - - if (skindata==NULL) continue; - - ObjectState os = nodes[i]->EvalWorldState(InterfacePtr->GetTime()); - TriObject * tobj = Get_Tri_Object(InterfacePtr->GetTime(),os,valid,needsdel); - - switch (SubObjSelLevel) { - - case OBJECT_SEL_LEVEL: - assert(0); - return; - - case VERTEX_SEL_LEVEL: -#if 0 // undo/redo - if (theHold.Holding()) { - theHold.Put(new VertexSelRestore(meshData,this)); - } -#endif - for (int j=0; jmesh.vertSel.GetSize(); j++) { - if (tobj->mesh.vertSel[j]) tobj->mesh.vertSel.Clear(j); - else tobj->mesh.vertSel.Set(j); - } - skindata->VertSel = tobj->mesh.vertSel; - break; - } - - if (needsdel) { - tobj->DeleteThis(); - } - } - - /* - ** Get rid of the temporary copies of the INodes. - */ - nodes.DisposeTemporary(); - - /* - ** Tell our dependents that the selection set has changed - */ - NotifyDependents(FOREVER, PART_SELECT, REFMSG_CHANGE); - -} - -#endif // 0 - - -#if defined W3D_MAX4 //defined as in the project (.dsp) -//////////////////////////////////////////////////////////////////////////////////////// -int MeshDeformClass::NumSubObjTypes() -{ - return 1; -} -//////////////////////////////////////////////////////////////////////////////////////// -ISubObjType *MeshDeformClass::GetSubObjType(int i) -{ - static bool _initialized = false; - if(!_initialized){ - _initialized = true; - _SubObjectTypeVertex.SetName("Vertices"); - } - if(i == -1){ - if(GetSubObjectLevel() > 0){ - return GetSubObjType(GetSubObjectLevel()-1); - } - } - return &_SubObjectTypeVertex; -} -#endif diff --git a/Generals/Code/Tools/WW3D/max2w3d/MeshDeform.h b/Generals/Code/Tools/WW3D/max2w3d/MeshDeform.h deleted file mode 100644 index 9a2810d7b92..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/MeshDeform.h +++ /dev/null @@ -1,201 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/MeshDeform.h 6 4/24/01 6:02p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : MeshDeform.H * - * * - * Programmer : Patrick Smith * - * * - * Start Date : 04/19/99 * - * * - * Last Update : - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef __MESH_DEFORM_H -#define __MESH_DEFORM_H - -#include -#include "Vector.H" - -// Forward declarations -class MeshDeformPanelClass; -class MeshDeformModData; - - -/////////////////////////////////////////////////////////////////////////// -// -// Prototypes -// -/////////////////////////////////////////////////////////////////////////// -ClassDesc *Get_Mesh_Deform_Desc (void); -extern Class_ID _MeshDeformClassID; - - -/////////////////////////////////////////////////////////////////////////// -// -// MeshDeformClass -// -/////////////////////////////////////////////////////////////////////////// -class MeshDeformClass : public OSModifier -{ - public: - - ////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////// - MeshDeformClass (void) - : m_MaxInterface (NULL), - m_ModeMove (NULL), - m_ModeSelect (NULL), - m_ModeRotate (NULL), - m_ModeUScale (NULL), - m_ModeNUScale (NULL), - m_ModeSquash (NULL), - m_DeformState (1.0F), - m_pPanel (NULL), - m_CurrentSet (0), - m_bSetDirty (true), - m_VertColorChanging (false), - m_MaxSets (0), - m_hRollupWnd (NULL) { SetName ("WW Mesh Deformer"); Set_Max_Deform_Sets (1); } - - virtual ~MeshDeformClass (void) { } -#if defined W3D_MAX4 //defined as in the project (.dsp) - NumSubObjTypes(); - GetSubObjType(); -#endif - ////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////// - void Set_Deform_State (float state = 1.0F); - float Get_Deform_State (void) const { return m_DeformState; } - void Set_Vertex_Color (const Point3 &color, bool button_up); - void Get_Vertex_Color (Point3 &color); - void Set_Max_Deform_Sets (int max); - int Get_Max_Deform_Sets (void) const { return m_MaxSets; } - void Set_Current_Set (int index, bool update_selection); - int Get_Current_Set (void) const { return m_CurrentSet; } - void Update_UI (MeshDeformModData *mod_data); - void Auto_Apply (bool auto_apply = true); - - ////////////////////////////////////////////////////////////////////// - // Base class overrides - ////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////// - // From Animatable - ////////////////////////////////////////////////////////////////////// - void DeleteThis (void) { delete this; } - void GetClassName (TSTR& s) { s = TSTR(_T("WWDeform")); } - TCHAR * GetObjectName (void) { return _T("WWDamage"); } - SClass_ID SuperClassID (void) { return OSM_CLASS_ID; } - Class_ID ClassID (void) { return _MeshDeformClassID; } - //RefTargetHandle Clone(RemapDir& remap = NoRemap()); - void BeginEditParams (IObjParam *ip, ULONG flags,Animatable *prev); - void EndEditParams (IObjParam *ip, ULONG flags,Animatable *next); - - ////////////////////////////////////////////////////////////////////// - // From Modifier - ////////////////////////////////////////////////////////////////////// - ChannelMask ChannelsUsed (void); - ChannelMask ChannelsChanged (void); - void ModifyObject (TimeValue t, ModContext &mod_context, ObjectState* os, INode *node); - BOOL DependOnTopology (ModContext &mod_context) { return TRUE; } - int NeedUseSubselButton (void) { return TRUE; } - Class_ID InputType (void); - - ////////////////////////////////////////////////////////////////////// - // From ReferenceMaker - ////////////////////////////////////////////////////////////////////// - RefResult NotifyRefChanged (Interval time, RefTargetHandle htarget, PartID &part_id, RefMessage mesage); - IOResult SaveLocalData (ISave *save_obj, LocalModData *mod_context); - IOResult LoadLocalData (ILoad *load_obj, LocalModData **mod_context); - - ////////////////////////////////////////////////////////////////////// - // From BaseObject - ////////////////////////////////////////////////////////////////////// - CreateMouseCallBack * GetCreateMouseCallBack (void); - void ActivateSubobjSel (int level, XFormModes &modes); - int HitTest (TimeValue time_value, INode * node, int type, int crossing, int flags, IPoint2 *point, ViewExp *viewport, ModContext *mod_context); - void SelectSubComponent (HitRecord *hit_record, BOOL selected, BOOL all, BOOL invert); - - void GetSubObjectCenters (SubObjAxisCallback *cb, TimeValue t, INode *node, ModContext *mc); - void GetSubObjectTMs (SubObjAxisCallback *cb, TimeValue t, INode *node, ModContext *mc); - int SubObjectIndex (HitRecord *hitRec) { return hitRec->hitInfo; } - void ClearSelection (int selLevel); - - // Transformation managment - void Move (TimeValue time_val, Matrix3 &parent_tm, Matrix3 &tm_axis, Point3 &point, BOOL local_origin); - void Rotate (TimeValue time_val, Matrix3 &parent_tm, Matrix3 &tm_axis, Quat &rotation, BOOL local_origin); - void Scale (TimeValue time_val, Matrix3 &parent_tm, Matrix3 &tm_axis, Point3 &value, BOOL local_origin); - - void TransformStart (TimeValue time_val); - void TransformFinish (TimeValue time_val); - void TransformCancel (TimeValue time_val); -#if defined W3D_MAX4 //defined as in the project (.dsp) - ISubObjType * GetSubObjType(int i) ; -#endif - - protected: - - ////////////////////////////////////////////////////////////////////// - // Protected methods - ////////////////////////////////////////////////////////////////////// - void Update_Current_Set (void); - void Update_Set_Count (void); - - private: - - ////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////// - IObjParam * m_MaxInterface; - HWND m_hRollupWnd; - MeshDeformPanelClass * m_pPanel; - float m_DeformState; - bool m_VertColorChanging; - - // Mode handlers - SelectModBoxCMode * m_ModeSelect; - MoveModBoxCMode * m_ModeMove; - RotateModBoxCMode * m_ModeRotate; - UScaleModBoxCMode * m_ModeUScale; - NUScaleModBoxCMode * m_ModeNUScale; - SquashModBoxCMode * m_ModeSquash; - - // Set managment - bool m_bSetDirty; - int m_CurrentSet; - int m_MaxSets; - - // Information - CStr m_OperationName; -}; - - -#endif //__MESH_DEFORM_H diff --git a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformData.cpp b/Generals/Code/Tools/WW3D/max2w3d/MeshDeformData.cpp deleted file mode 100644 index aae3d910d20..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformData.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : MeshDeformData.cpp * - * * - * Programmer : Patrick Smith * - * * - * Start Date : 04/26/99 * - * * - * Last Update : - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "MeshDeformData.h" -#include "util.h" -#include "MeshDeformSaveDefs.h" - - -/////////////////////////////////////////////////////////////////////////// -// -// ~MeshDeformModData -// -/////////////////////////////////////////////////////////////////////////// -MeshDeformModData::~MeshDeformModData (void) -{ - Free_Sets_List (); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Record_Mesh_State -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformModData::Record_Mesh_State (TriObject &tri_obj, float state, bool update_all) -{ - // - // Ask each set to update its state - // - - for (int index = 0; index < m_SetsList.Count (); index ++) { - if (index != m_CurrentSet) { - if (update_all) { - m_SetsList[index]->Set_State (state); - } - m_SetsList[index]->Update_Mesh (tri_obj); - } - } - - if (m_CurrentSet < m_SetsList.Count ()) { - m_SetsList[m_CurrentSet]->Set_State (state); - m_SetsList[m_CurrentSet]->Update_Mesh (tri_obj); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Free_Sets_List -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformModData::Free_Sets_List (void) -{ - // - // Delete all the object pointers in the set list - // - for (int index = 0; index < m_SetsList.Count (); index ++) { - MeshDeformSetClass *set = m_SetsList[index]; - SAFE_DELETE (set); - } - - // Remove all the entries from the list - m_SetsList.Delete_All (); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Set_Max_Deform_Sets -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformModData::Set_Max_Deform_Sets (int max) -{ - int current_max = m_SetsList.Count (); - if (max > current_max) { - - // - // Add the new sets to the list - // - int sets_to_add = max - current_max; - for (int index = 0; index < sets_to_add; index ++) { - MeshDeformSetClass *set = new MeshDeformSetClass; - m_SetsList.Add (set); - } - - } else if (max < current_max) { - - // - // Remove the obsolete sets from the list - // - int sets_to_remove = current_max - max; - for (int index = 0; index < sets_to_remove; index ++) { - - // Restore the set before we delete it - Restore_Set (max); - - // Delete the set - MeshDeformSetClass *set = m_SetsList[max]; - SAFE_DELETE (set); - m_SetsList.Delete (max); - } - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Restore_Set -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformModData::Restore_Set (int set_index) -{ - if (set_index == -1) { - - // Restore ALL the set - for (int index = 0; index < m_SetsList.Count (); index ++) { - m_SetsList[index]->Restore_Members (); - } - - } else { - m_SetsList[set_index]->Restore_Members (); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Save -// -/////////////////////////////////////////////////////////////////////////// -IOResult -MeshDeformModData::Save (ISave *save_obj) -{ - DWORD bytes = 0L; - save_obj->BeginChunk (DEFORM_CHUNK_INFO); - - // - // Write the set count info to the chunk - // - DeformChunk info = { 0 }; - info.SetCount = m_SetsList.Count (); - IOResult result = save_obj->Write (&info, sizeof (info), &bytes); - - save_obj->EndChunk (); - - // - // Now write a chunk for each set - // - for (int index = 0; (index < m_SetsList.Count ()) && (result == IO_OK); index ++) { - result = m_SetsList[index]->Save (save_obj); - } - - // Return IO_OK on success IO_ERROR on failure - return result; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Load -// -/////////////////////////////////////////////////////////////////////////// -IOResult -MeshDeformModData::Load (ILoad *load_obj) -{ - Free_Sets_List (); - DWORD bytes = 0L; - - // - // Is this the chunk we were expecting? - // - IOResult result = load_obj->OpenChunk (); - if ( (result == IO_OK) && - (load_obj->CurChunkID () == DEFORM_CHUNK_INFO)) { - - DeformChunk info = { 0 }; - result = load_obj->Read (&info, sizeof (info), &bytes); - load_obj->CloseChunk (); - - // - // Read the set information from the chunk - // - for (unsigned int index = 0; (index < info.SetCount) && (result == IO_OK); index ++) { - MeshDeformSetClass *set = new MeshDeformSetClass; - m_SetsList.Add (set); - result = set->Load (load_obj); - } - } - - // Return IO_OK on success IO_ERROR on failure - return result; -} - diff --git a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformData.h b/Generals/Code/Tools/WW3D/max2w3d/MeshDeformData.h deleted file mode 100644 index c8cf20e29fb..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformData.h +++ /dev/null @@ -1,128 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : MeshDeformData.h * - * * - * Programmer : Patrick Smith * - * * - * Start Date : 04/26/99 * - * * - * Last Update : - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef __MESH_DEFORM_DATA_H -#define __MESH_DEFORM_DATA_H - -#include -#include "Vector.H" -#include "MeshDeformSet.h" - - -/////////////////////////////////////////////////////////////////////////// -// -// Typedefs -// -/////////////////////////////////////////////////////////////////////////// -typedef DynamicVectorClass SETS_LIST; - - -/////////////////////////////////////////////////////////////////////////// -// -// MeshDeformModData -// -/////////////////////////////////////////////////////////////////////////// -class MeshDeformModData : public LocalModData -{ - public: - - ////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////// - MeshDeformModData (void) - : m_CurrentSet (0) { } - - virtual ~MeshDeformModData (void); - - ////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////// - virtual LocalModData * Clone (void) { return new MeshDeformModData; } - void Record_Mesh_State (TriObject &tri_obj, float state, bool update_all); - - // Inline accessors - Mesh * Peek_Mesh (void) const { return m_SetsList[m_CurrentSet]->Peek_Mesh (); } - const Point3 * Peek_Orig_Vertex_Array (void) const { return m_SetsList[m_CurrentSet]->Peek_Orig_Vertex_Array (); } - Point3 * Peek_Vertex_OPStart_Array (void) const { return m_SetsList[m_CurrentSet]->Peek_Vertex_OPStart_Array (); } - VertColor * Peek_Vertex_Colors (void) const { return m_SetsList[m_CurrentSet]->Peek_Vertex_Colors (); } - - // Auto apply - bool Is_Auto_Apply (void) const { return m_SetsList[m_CurrentSet]->Does_Set_Auto_Apply (); } - void Auto_Apply (bool auto_apply = true) { m_SetsList[m_CurrentSet]->Auto_Apply (auto_apply); } - - // Data modifiers - void Update_Current_Data (void) { m_SetsList[m_CurrentSet]->Update_Current_Data (); } - void Set_Vertex_Position (int index, const Point3 &value) { m_SetsList[m_CurrentSet]->Set_Vertex_Position (index, value); } - void Set_Vertex_Color (int index, int color_index, const VertColor &value) { m_SetsList[m_CurrentSet]->Set_Vertex_Color (index, color_index, value); } - - // Set managment - void Set_Max_Deform_Sets (int max); - void Set_Current_Set (int set_index) { m_CurrentSet = set_index; } - int Get_Current_Set (void) const { return m_CurrentSet; } - void Select_Set (int set_index) { m_SetsList[set_index]->Select_Members (); } - void Update_Set (int set_index, DEFORM_CHANNELS flags) { m_SetsList[set_index]->Update_Members (flags); } - void Restore_Set (int set_index = -1); - MeshDeformSetClass & Peek_Set (int index) { return *(m_SetsList[index]); } - int Get_Set_Count (void) const { return m_SetsList.Count (); } - - // Persistent storage - IOResult Save (ISave *save_obj); - IOResult Load (ILoad *load_obj); - - protected: - - ////////////////////////////////////////////////////////////////////// - // Protected methods - ////////////////////////////////////////////////////////////////////// - void Resize_Vertex_Array (int count, int color_count); - void Copy_Vertex_Array (Mesh &mesh); - void Free_Sets_List (void); - void Util_Restore_Set (int set_index); - - private: - - ////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////// - - // Set managment - int m_CurrentSet; - SETS_LIST m_SetsList; -}; - - -#endif //__MESH_DEFORM_DATA_H - diff --git a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformDefs.h b/Generals/Code/Tools/WW3D/max2w3d/MeshDeformDefs.h deleted file mode 100644 index 22e43e3f311..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformDefs.h +++ /dev/null @@ -1,100 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : MeshDeformDefs.h * - * * - * Programmer : Patrick Smith * - * * - * Start Date : 04/28/99 * - * * - * Last Update : - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef __MESH_DEFORM_DEFS_H -#define __MESH_DEFORM_DEFS_H - -#include -#include "Vector.H" - -/////////////////////////////////////////////////////////////////////////// -// -// Constants -// -/////////////////////////////////////////////////////////////////////////// -typedef enum -{ - VERT_POSITION = 1, - VERT_COLORS = 2, - BOTH = VERT_POSITION | VERT_COLORS -} DEFORM_CHANNELS; - - -/////////////////////////////////////////////////////////////////////////// -// -// Structures -// -/////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////// -// -// VERT_INFO -// -// Used to represent position or color information for a vertex. -// -/////////////////////////////////////////////////////////////////////////// -typedef struct _VERT_INFO -{ - _VERT_INFO (void) - : index (0), - color_index (0), - value (0,0,0) { } - - _VERT_INFO (int vert_index, const Point3 &point, int vert_color_index = 0) - : index (vert_index), - color_index (vert_color_index), - value (point) { } - - UINT index; - UINT color_index; - Point3 value; - - // Don't care, DynamicVectorClass needs these - bool operator== (const _VERT_INFO &src) { return false; } - bool operator!= (const _VERT_INFO &src) { return true; } -} VERT_INFO; - - -/////////////////////////////////////////////////////////////////////////// -// -// Typedefs -// -/////////////////////////////////////////////////////////////////////////// -typedef DynamicVectorClass DEFORM_LIST; - - -#endif //__MESH_DEFORM_DEFS_H - diff --git a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformPanel.cpp b/Generals/Code/Tools/WW3D/max2w3d/MeshDeformPanel.cpp deleted file mode 100644 index 462835a3966..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformPanel.cpp +++ /dev/null @@ -1,365 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : MeshDeformPanel.cpp * - * * - * Programmer : Patrick Smith * - * * - * Start Date : 04/22/99 * - * * - * Last Update : - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "MeshDeformPanel.h" -#include "resource.h" -#include "util.h" -#include "MeshDeform.h" - -/////////////////////////////////////////////////////////////////////////// -// -// Local constants -// -/////////////////////////////////////////////////////////////////////////// -const char * const PANEL_OBJ_PROP = "WWPANELOBJ"; - - -/////////////////////////////////////////////////////////////////////////// -// -// Message_Proc -// -/////////////////////////////////////////////////////////////////////////// -BOOL WINAPI -MeshDeformPanelClass::Message_Proc -( - HWND hwnd, - UINT message, - WPARAM wparam, - LPARAM lparam -) -{ - // Lookup the controlling object for this panel - MeshDeformPanelClass *panel_obj = MeshDeformPanelClass::Get_Object (hwnd); - BOOL result = FALSE; - - switch (message) - { - // Create the controlling panel-object - case WM_INITDIALOG: - panel_obj = new MeshDeformPanelClass (hwnd); - SetProp (hwnd, PANEL_OBJ_PROP, (HANDLE)panel_obj); - break; - - case WM_DESTROY: - result = panel_obj->On_Message (message, wparam, lparam); - RemoveProp (hwnd, PANEL_OBJ_PROP); - SAFE_DELETE (panel_obj); - break; - } - - // Pass the message onto the controlling panel-object - if (panel_obj != NULL) { - result = panel_obj->On_Message (message, wparam, lparam); - } - - // Return the TRUE/FALSE result code - return result; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Get_Object -// -/////////////////////////////////////////////////////////////////////////// -MeshDeformPanelClass * -MeshDeformPanelClass::Get_Object (HWND hwnd) -{ - return (MeshDeformPanelClass *)::GetProp (hwnd, PANEL_OBJ_PROP); -} - - -/////////////////////////////////////////////////////////////////////////// -// -// On_Message -// -/////////////////////////////////////////////////////////////////////////// -BOOL -MeshDeformPanelClass::On_Message -( - UINT message, - WPARAM wparam, - LPARAM lparam -) -{ - switch (message) - { - case WM_INITDIALOG: - m_pColorSwatch = ::GetIColorSwatch (::GetDlgItem (m_hWnd, IDC_VERTEX_COLOR), RGB (0, 0, 0), "Vertex Color"); - m_pMaxSetsEdit = ::GetICustEdit (::GetDlgItem (m_hWnd, IDC_MAX_SETS_EDIT)); - m_pMaxSetsSpin = ::GetISpinner (::GetDlgItem (m_hWnd, IDC_MAX_SETS_SPIN)); - m_pLockSetsButton = ::GetICustButton (::GetDlgItem (m_hWnd, IDC_LOCK_SETS)); - - // - // Setup the 'max-sets' controls - // - m_pMaxSetsSpin->LinkToEdit (::GetDlgItem (m_hWnd, IDC_MAX_SETS_EDIT), EDITTYPE_INT); - m_pMaxSetsSpin->SetLimits (1, 20); - m_pMaxSetsEdit->SetText (1); - m_pMaxSetsSpin->SetValue (1, FALSE); - ::SetDlgItemInt (m_hWnd, IDC_CURRENT_SET_STATIC, 1, FALSE); - - // - // Setup the edit button - // - m_pLockSetsButton->SetType (CBT_CHECK); - m_pLockSetsButton->SetCheck (FALSE); - m_pLockSetsButton->SetHighlightColor (GREEN_WASH); - //m_pEditButton->SetType (CBT_CHECK); - //m_pEditButton->SetCheck (FALSE); - //m_pEditButton->SetHighlightColor (GREEN_WASH); - - // - // Setup the sliders - // - ::SendDlgItemMessage (m_hWnd, IDC_CURRENT_SET_SLIDER, TBM_SETRANGE, (WPARAM)TRUE, MAKELONG (1, 1)); - ::SendDlgItemMessage (m_hWnd, IDC_CURRENT_SET_SLIDER, TBM_SETPOS, (WPARAM)TRUE, 0L); - ::SendDlgItemMessage (m_hWnd, IDC_STATE_SLIDER, TBM_SETRANGE, (WPARAM)FALSE, MAKELONG (0, 10)); - ::SendDlgItemMessage (m_hWnd, IDC_STATE_SLIDER, TBM_SETPOS, (WPARAM)FALSE, 9L); - - // - // Ensure the sliders are repainted - // - //::InvalidateRect (::GetDlgItem (m_hWnd, IDC_STATE_SLIDER), NULL, TRUE); - //::InvalidateRect (::GetDlgItem (m_hWnd, IDC_CURRENT_SET_SLIDER), NULL, TRUE); - break; - - case WM_DESTROY: - ::ReleaseIColorSwatch (m_pColorSwatch); - ::ReleaseICustEdit (m_pMaxSetsEdit); - ::ReleaseISpinner (m_pMaxSetsSpin); - //::ReleaseICustButton (m_pEditButton); - m_pColorSwatch = NULL; - m_pMaxSetsEdit = NULL; - m_pMaxSetsSpin = NULL; - //m_pEditButton = NULL; - break; - - case WM_COMMAND: - On_Command (wparam, lparam); - break; - - case CC_COLOR_CHANGE: - { - // Pass the new color onto the mesh deformer - COLORREF color_ref = m_pColorSwatch->GetColor (); - VertColor color; - color.x = GetRValue (color_ref) / 255.0F; - color.y = GetGValue (color_ref) / 255.0F; - color.z = GetBValue (color_ref) / 255.0F; - m_pMeshDeformer->Set_Vertex_Color (color, HIWORD (wparam) != 0); - } - break; - - case WM_CUSTEDIT_ENTER: - case CC_SPINNER_CHANGE: - { - Set_Max_Sets (m_pMaxSetsEdit->GetInt (), true); - } - break; - - case WM_HSCROLL: - if ((HWND)lparam == ::GetDlgItem (m_hWnd, IDC_CURRENT_SET_SLIDER)) { - int pos = ::SendDlgItemMessage (m_hWnd, IDC_CURRENT_SET_SLIDER, TBM_GETPOS, 0, 0L); - Set_Current_Set (pos - 1, true); - } else { - int pos = ::SendDlgItemMessage (m_hWnd, IDC_STATE_SLIDER, TBM_GETPOS, 0, 0L); - m_pMeshDeformer->Set_Deform_State (((float)pos) / 10.0F); - - if (pos > 0) { - m_pColorSwatch->Enable (); - } else { - m_pColorSwatch->Disable (); - } - } - - break; - } - - return FALSE; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// On_Command -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformPanelClass::On_Command -( - WPARAM wparam, - LPARAM lparam -) -{ - switch (LOWORD (wparam)) - { - case IDC_MANUALAPPLY: - { - m_pMeshDeformer->Auto_Apply (Get_Auto_Apply_Check ()); - } - break; - - //case IDC_EDIT_BUTTON: - /*if (m_pEditButton->IsChecked ()) { - ::SendDlgItemMessage (m_hWnd, IDC_STATE_SLIDER, TBM_SETPOS, (WPARAM)TRUE, 100L); - ::EnableWindow (::GetDlgItem (m_hWnd, IDC_STATE_SLIDER), FALSE); - m_pColorSwatch->Enable (); - m_pMeshDeformer->Set_Deform_State (1.0F); - } else { - ::EnableWindow (::GetDlgItem (m_hWnd, IDC_STATE_SLIDER), TRUE); - m_pColorSwatch->Disable (); - }*/ - //break; - - case IDC_MAX_SETS_EDIT: - break; - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Set_Deformer -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformPanelClass::Set_Deformer (MeshDeformClass *obj) -{ - if (m_pMeshDeformer != obj) { - m_pMeshDeformer = obj; - - // Set the slider position based on the current state of the deformer - float state = m_pMeshDeformer->Get_Deform_State (); - ::SendDlgItemMessage (m_hWnd, IDC_STATE_SLIDER, TBM_SETPOS, (WPARAM)TRUE, LPARAM(state * 10.0F)); - - // Now update the current vertex color - Update_Vertex_Color (); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Update_Vertex_Color -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformPanelClass::Update_Vertex_Color (void) -{ - if (m_pMeshDeformer != NULL) { - - // Update the color swatch with data from the deformer - Point3 color; - m_pMeshDeformer->Get_Vertex_Color (color); - m_pColorSwatch->SetColor (RGB (int(color.x * 255.0F), int(color.y * 255.0F), int(color.z * 255.0F)), FALSE); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Set_Max_Sets -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformPanelClass::Set_Max_Sets -( - int max, - bool notify -) -{ - // Update the UI - ::SendDlgItemMessage (m_hWnd, IDC_CURRENT_SET_SLIDER, TBM_SETRANGE, (WPARAM)TRUE, MAKELONG (1, max)); - ::SetDlgItemInt (m_hWnd, IDC_CURRENT_SET_STATIC, max, TRUE); - - if (notify == false) { - m_pMaxSetsSpin->SetValue (max, TRUE); - } else if (m_pMeshDeformer != NULL) { - - // Update the deformer - m_pMeshDeformer->Set_Max_Deform_Sets (max); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Set_Current_Set -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformPanelClass::Set_Current_Set -( - int set, - bool notify -) -{ - // Update the UI - ::SetDlgItemInt (m_hWnd, IDC_CURRENT_SET_STATIC, set + 1, TRUE); - - if (notify == false) { - ::SendDlgItemMessage (m_hWnd, IDC_CURRENT_SET_SLIDER, TBM_SETPOS, (WPARAM)TRUE, set + 1); - } else if (m_pMeshDeformer != NULL) { - - // Update the deformer - m_pMeshDeformer->Set_Current_Set (set, true); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Set_Current_State -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformPanelClass::Set_Current_State (float state) -{ - ::SendDlgItemMessage (m_hWnd, IDC_STATE_SLIDER, TBM_SETPOS, (WPARAM)TRUE, LPARAM(state * 10.0F)); - return ; -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformPanel.h b/Generals/Code/Tools/WW3D/max2w3d/MeshDeformPanel.h deleted file mode 100644 index 1408c2c52e9..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformPanel.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : MeshDeformPanel.H * - * * - * Programmer : Patrick Smith * - * * - * Start Date : 04/22/99 * - * * - * Last Update : - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef __MESH_DEFORM_PANEL_H -#define __MESH_DEFORM_PANEL_H - -#include -#include "resource.h" - -// Forward declarations -class MeshDeformClass; - -/////////////////////////////////////////////////////////////////////////// -// -// MeshDeformPanelClass -// -/////////////////////////////////////////////////////////////////////////// -class MeshDeformPanelClass -{ - public: - - ////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////// - MeshDeformPanelClass (HWND hwnd) - : m_hWnd (hwnd), - m_pColorSwatch (NULL), - m_pMaxSetsSpin (NULL), - m_pMeshDeformer (NULL), - m_pLockSetsButton (NULL), - m_pMaxSetsEdit (NULL) { } - virtual ~MeshDeformPanelClass (void) { } - - ////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////// - - // Inline accessors - IColorSwatch * Get_Color_Swatch (void) const { return m_pColorSwatch; } - COLORREF Get_Vertex_Color (void) const { return m_pColorSwatch->GetColor (); } - void Set_Vertex_Color (COLORREF color) { m_pColorSwatch->SetColor (color); } - void Set_Deformer (MeshDeformClass *obj); - BOOL Is_Edit_Mode (void) const { return (::SendDlgItemMessage (m_hWnd, IDC_STATE_SLIDER, TBM_GETPOS, 0, 0L) > 0); } - BOOL Are_Sets_Tied (void) const { return m_pLockSetsButton->IsChecked (); } - int Get_Current_Set (void) const { return ::SendDlgItemMessage (m_hWnd, IDC_CURRENT_SET_SLIDER, TBM_GETPOS, 0, 0L); } - void Set_Current_Set (int set, bool notify = false); - void Set_Max_Sets (int max, bool notify = false); - void Set_Current_State (float state); - void Set_Auto_Apply_Check (bool onoff) { ::SendDlgItemMessage (m_hWnd, IDC_MANUALAPPLY, BM_SETCHECK, (WPARAM)(!onoff), 0L); } - bool Get_Auto_Apply_Check (void) const { return ::SendDlgItemMessage (m_hWnd, IDC_MANUALAPPLY, BM_GETCHECK, 0, 0L) == 0; } - - // Update methods - void Update_Vertex_Color (void); - - ////////////////////////////////////////////////////////////////////// - // Static methods - ////////////////////////////////////////////////////////////////////// - static BOOL WINAPI Message_Proc (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); - static MeshDeformPanelClass * Get_Object (HWND hwnd); - - protected: - - ////////////////////////////////////////////////////////////////////// - // Protected methods - ////////////////////////////////////////////////////////////////////// - BOOL On_Message (UINT message, WPARAM wparam, LPARAM lparam); - void On_Command (WPARAM wparam, LPARAM lparam); - - private: - - ////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////// - HWND m_hWnd; - IColorSwatch * m_pColorSwatch; - ICustEdit * m_pMaxSetsEdit; - ISpinnerControl * m_pMaxSetsSpin; - ICustButton * m_pLockSetsButton; - MeshDeformClass * m_pMeshDeformer; -}; - - -#endif //__MESH_DEFORM_PANEL_H diff --git a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSave.cpp b/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSave.cpp deleted file mode 100644 index f9ff592d57b..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSave.cpp +++ /dev/null @@ -1,420 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/MeshDeformSave.cpp 6 11/12/99 11:12a Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : MeshDeformSafe.CPP - * * - * Programmer : Patrick Smith * - * * - * Start Date : 05/28/99 * - * * - * Last Update : - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "MeshDeform.h" -#include "MeshDeformSave.h" -#include "MeshDeformData.h" -#include "MeshDeformSet.h" -#include "MeshDeformSaveSet.h" -#include "util.h" -#include "modstack.h" -#include "meshbuild.h" -#include "meshsave.h" - -/////////////////////////////////////////////////////////////////////////// -// -// Initialize -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSaveClass::Initialize -( - MeshBuilderClass &builder, - Object * object, - Mesh & mesh, - Matrix3 * transform -) -{ - // Start fresh - Reset (); - - // - // Attempt to gain access to the IDerivedObject this node references - // - int test = object->SuperClassID (); - int test2 = GEN_DERIVOB_CLASS_ID; - if ((object != NULL) && - (object->SuperClassID () == GEN_DERIVOB_CLASS_ID)) { - - // - // Loop through all the modifiers and see if we can find the - // Westwood Damage Mesh modifier. - // - IDerivedObject *derived_object = static_cast (object); - int modifier_count = derived_object->NumModifiers (); - bool found = false; - for (int index = 0; (index < modifier_count) && !found; index ++) { - - // - // If this is the right modifier, then initialize using the - // data it contains. - // - Modifier *modifier = derived_object->GetModifier (index); - if ((modifier != NULL) && (modifier->ClassID () == _MeshDeformClassID)) { - - // - // Attempt to get at the modifier data for this context - // - ModContext *mod_context = derived_object->GetModContext (index); - if ((mod_context != NULL) && (mod_context->localData != NULL)) { - MeshDeformModData *mod_data = static_cast (mod_context->localData); - Initialize (builder, mesh, *mod_data, transform); - } - - // Found it! - found = true; - } - } - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Initialize -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSaveClass::Initialize -( - MeshBuilderClass & builder, - Mesh & mesh, - MeshDeformModData & mod_data, - Matrix3 * transform -) -{ - // - // Loop through all the sets in the modifier - // - for (int index = 0; index < mod_data.Get_Set_Count (); index ++) { - - // - // If this set isn't empty then add its data to our list - // - MeshDeformSetClass &deform_set = mod_data.Peek_Set (index); - if (deform_set.Is_Empty () == false) { - - // - // Add this set to our list - // - MeshDeformSaveSetClass *save_set = new MeshDeformSaveSetClass; - deform_set.Save (builder, mesh, *save_set, transform); - m_DeformSets.Add (save_set); - } - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Reset -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSaveClass::Reset (void) -{ - // - // Delete all the damage sets - // - for (int index = 0; index < m_DeformSets.Count (); index ++) { - SAFE_DELETE (m_DeformSets[index]); - } - - m_DeformSets.Delete_All (); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Export -// -/////////////////////////////////////////////////////////////////////////// -bool -MeshDeformSaveClass::Export (ChunkSaveClass &chunk_save) -{ - bool retval = true; - - if (m_DeformSets.Count() > 0) { - - retval = chunk_save.Begin_Chunk (W3D_CHUNK_DEFORM); - if (retval) { - - // - // Write the deform header to the file - // - W3dMeshDeform header = { 0 }; - header.SetCount = m_DeformSets.Count (); - header.AlphaPasses = m_AlphaPasses; - retval &= (chunk_save.Write (&header, sizeof (header)) == sizeof (header)); - if (retval) { - - // - // Export all the sets in the deformation - // - retval &= Export_Sets (chunk_save); - } - - retval &= chunk_save.End_Chunk (); - } - } - - // Return the true/false result code - return retval; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Export_Sets -// -/////////////////////////////////////////////////////////////////////////// -bool -MeshDeformSaveClass::Export_Sets (ChunkSaveClass &chunk_save) -{ - bool retval = true; - - // - // Loop through all the sets and write them to the file - // - for (int set_index = 0; (set_index < m_DeformSets.Count ()) && retval; set_index ++) { - retval &= chunk_save.Begin_Chunk (W3D_CHUNK_DEFORM_SET); - if (retval) { - - // - // Write a chunk of information out for this set - // - MeshDeformSaveSetClass *set_save = m_DeformSets[set_index]; - W3dDeformSetInfo set_info = { 0 }; - set_info.KeyframeCount = set_save->Get_Keyframe_Count (); - set_info.flags = set_save->Get_Flags (); - retval &= (chunk_save.Write (&set_info, sizeof (set_info)) == sizeof (set_info)); - if (retval) { - - // - // Export all the keyframes for this chunk - // - retval &= Export_Keyframes (chunk_save, *set_save); - } - - retval &= chunk_save.End_Chunk (); - } - } - - // Return the true/false result code - return retval; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Export_Keyframes -// -/////////////////////////////////////////////////////////////////////////// -bool -MeshDeformSaveClass::Export_Keyframes -( - ChunkSaveClass & chunk_save, - MeshDeformSaveSetClass &set_save -) -{ - bool retval = true; - - // - // Loop through all the keyframes in the set - // - int count = set_save.Get_Keyframe_Count (); - for (int keyframe_index = 0; (keyframe_index < count) && retval; keyframe_index ++) { - - // - // Write a chunk of information out for this keyframe - // - retval &= chunk_save.Begin_Chunk (W3D_CHUNK_DEFORM_KEYFRAME); - if (retval) { - W3dDeformKeyframeInfo keyframe_info = { 0 }; - keyframe_info.DeformPercent = set_save.Get_Deform_State (keyframe_index); - keyframe_info.DataCount = set_save.Get_Deform_Data_Count (keyframe_index); - - retval &= (chunk_save.Write (&keyframe_info, sizeof (keyframe_info)) == sizeof (keyframe_info)); - if (retval) { - - // - // Loop through all the verticies in this keyframe - // - int data_count = set_save.Get_Deform_Data_Count (keyframe_index); - for (int index = 0; (index < data_count) && retval; index ++) { - MeshDeformSaveSetClass::DEFORM_DATA &data = set_save.Get_Deform_Data (keyframe_index, index); - - // - // Write a chunk of information out for this vertex - // - retval &= chunk_save.Begin_Chunk (W3D_CHUNK_DEFORM_DATA); - if (retval) { - W3dDeformData data_struct = { 0 }; - data_struct.VertexIndex = data.vert_index; - data_struct.Position.X = data.position.x; - data_struct.Position.Y = data.position.y; - data_struct.Position.Z = data.position.z; - data_struct.Color.R = data.color.x * 255; - data_struct.Color.G = data.color.y * 255; - data_struct.Color.B = data.color.z * 255; - - // If we are using vertex alpha instead of vertex color, then convert - // the v-color into an alpha setting - data_struct.Color.A = 255; - if (m_AlphaPasses != 0) { - data_struct.Color.A = (data_struct.Color.R + data_struct.Color.G + data_struct.Color.B) / 3.0F; - } - - retval &= (chunk_save.Write (&data_struct, sizeof (data_struct)) == sizeof (data_struct)); - retval &= chunk_save.End_Chunk (); - } - } - } - - retval &= chunk_save.End_Chunk (); - } - } - - // Return the true/false result code - return retval; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Re_Index -// -/////////////////////////////////////////////////////////////////////////// -/*void -MeshDeformSaveClass::Re_Index (MeshBuilderClass &builder) -{ - DynamicVectorClass temp_list; - - // - // Reindex each set of deform data - // - for (int set_index = 0; set_index < m_DeformSets.Count (); set_index ++) { - MeshDeformSaveSetClass *set_save = m_DeformSets[set_index]; - - // - // Loop through all the deform entries in this set - // - for (int keyframe_index = 0; keyframe_index < set_save->Get_Keyframe_Count (); keyframe_index ++) { - temp_list.Delete_All (); - for (int index = 0; index < set_save->Get_Deform_Data_Count (keyframe_index); index ++) { - MeshDeformSaveSetClass::DEFORM_DATA &data = set_save->Get_Deform_Data (keyframe_index, index); - - // - // Now try to find the 'W3D' index of this vertex (its different than the max version). - // - //bool found = false; - for (int vert_index = 0; vert_index < builder.Get_Vertex_Count (); vert_index++) { - MeshBuilderClass::VertClass &vert = builder.Get_Vertex (vert_index); - - // - // Reindex this vertex if its the one we are looking for. - // - if (vert.Id == (int)data.vert_index) { - MeshDeformSaveSetClass::DEFORM_DATA new_data = data; - new_data.vert_index = vert_index; - temp_list.Add (new_data); - //data.vert_index = vert_index; - //found = true; - } - } - } - - set_save->Replace_Deform_Data (keyframe_index, temp_list); - } - } - - return ; -}*/ - - -/////////////////////////////////////////////////////////////////////////// -// -// Does_Deformer_Modify_DCG -// -/////////////////////////////////////////////////////////////////////////// -bool -MeshDeformSaveClass::Does_Deformer_Modify_DCG (void) -{ - bool retval = false; - - // - // Loop through all the sets - // - for (int set_index = 0; (set_index < m_DeformSets.Count ()) && !retval; set_index ++) { - MeshDeformSaveSetClass *set_save = m_DeformSets[set_index]; - if (set_save) { - - // - // Loop through all the keyframes in this set - // - int count = set_save->Get_Keyframe_Count (); - for (int keyframe_index = 0; (keyframe_index < count) && !retval; keyframe_index ++) { - - // - // Loop through all the entries in this keyframe - // - int data_count = set_save->Get_Deform_Data_Count (keyframe_index); - for (int index = 0; (index < data_count) && !retval; index ++) { - MeshDeformSaveSetClass::DEFORM_DATA &data = set_save->Get_Deform_Data (keyframe_index, index); - - // - // If the color is not 'white' then we will - // modify the DCG array. - // - if ((data.color.x != 1) || - (data.color.y != 1) || - (data.color.z != 1)) { - retval = true; - } - } - } - } - } - - // Return the true/false result code - return retval; -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSave.h b/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSave.h deleted file mode 100644 index 03e2c50d36e..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSave.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/MeshDeformSave.h 4 7/07/99 11:52a Patrick $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : MeshDeformSafe.H - * * - * Programmer : Patrick Smith * - * * - * Start Date : 05/28/99 * - * * - * Last Update : - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef __MESH_DEFORM_SAVE_H -#define __MESH_DEFORM_SAVE_H - -#include -#include "Vector.H" - -// Forward declarations -class ChunkSaveClass; -class MeshDeformModData; -class MeshDeformSaveSetClass; -class MeshBuilderClass; -class MeshDeformSaveSetClass; - - -/////////////////////////////////////////////////////////////////////////// -// -// Typdefs -// -/////////////////////////////////////////////////////////////////////////// -typedef DynamicVectorClass DEFORM_SAVE_LIST; - - -/////////////////////////////////////////////////////////////////////////// -// -// MeshDeformSaveClass -// -/////////////////////////////////////////////////////////////////////////// -class MeshDeformSaveClass -{ - public: - - ////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////// - MeshDeformSaveClass (void) - : m_AlphaPasses (0) { } - ~MeshDeformSaveClass (void) { Reset (); } - - ////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////// - void Initialize (MeshBuilderClass &builder, Object *object, Mesh &mesh, Matrix3 *transform = NULL); - void Initialize (MeshBuilderClass &builder, Mesh &mesh, MeshDeformModData &mod_data, Matrix3 *transform = NULL); - - //void Re_Index (MeshBuilderClass &builder); - bool Export (ChunkSaveClass &chunk_save); - - void Reset (void); - bool Is_Empty (void) const { return m_DeformSets.Count () == 0; } - - bool Does_Deformer_Modify_DCG (void); - - unsigned int Get_Alpha_Passes (void) const { return m_AlphaPasses; } - void Set_Alpha_Passes (unsigned int pass_mask) { m_AlphaPasses = pass_mask; } - - protected: - - ////////////////////////////////////////////////////////////////////// - // Protected methods - ////////////////////////////////////////////////////////////////////// - bool Export_Sets (ChunkSaveClass &chunk_save); - bool Export_Keyframes (ChunkSaveClass &chunk_save, MeshDeformSaveSetClass &set_save); - - private: - - ////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////// - DEFORM_SAVE_LIST m_DeformSets; - unsigned int m_AlphaPasses; -}; - -#endif //__MESH_DEFORM_SAVE_H diff --git a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSaveDefs.h b/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSaveDefs.h deleted file mode 100644 index 1b3b1ccab14..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSaveDefs.h +++ /dev/null @@ -1,114 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : MeshDeformData.cpp * - * * - * Programmer : Patrick Smith * - * * - * Start Date : 06/07/99 * - * * - * Last Update : - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef __MESH_DEFORM_SAVE_DEFS_H -#define __MESH_DEFORM_SAVE_DEFS_H - -#include - -/////////////////////////////////////////////////////////////////////////// -// -// Constants -// -/////////////////////////////////////////////////////////////////////////// -typedef enum -{ - DEFORM_CHUNK_INFO = 0x000000001, - DEFORM_CHUNK_SET_INFO, - DEFORM_CHUNK_KEYFRAME_INFO, - DEFORM_CHUNK_POSITION_DATA, - DEFORM_CHUNK_POSITION_VERTS, - DEFORM_CHUNK_COLOR_DATA, - DEFORM_CHUNK_COLOR_VERTS -} DEFORM_CHUNK_IDS; - -/////////////////////////////////////////////////////////////////////////// -// -// Structures -// -/////////////////////////////////////////////////////////////////////////// - -// -// Deform information. Each mesh can have sets of keyframes of -// deform info associated with it. -// -struct DeformChunk -{ - uint32 SetCount; - uint32 reserved[4]; -}; - -// -// Deform set information. Each set is made up of a series -// of keyframes. -// -struct DeformChunkSetInfo -{ - uint32 KeyframeCount; - uint32 flags; - uint32 NumVerticies; - uint32 NumVertexColors; - uint32 reserved[2]; -}; - -#define DEFORM_SET_MANUAL_DEFORM 0x00000001 // set is isn't applied during sphere or point tests. - -// -// Deform keyframe information. Each keyframe is made up of -// a set of per-vert deform data. -// -struct DeformChunkKeyframeInfo -{ - float32 DeformPercent; - uint32 VertexCount; - uint32 ColorCount; - uint32 reserved[2]; -}; - -// -// Deform data. Contains deform information about a vertex -// in the mesh. -// -struct DeformDataChunk -{ - uint32 VertexIndex; - uint32 ColorIndex; - Point3 Value; - uint32 reserved[2]; -}; - - -#endif //__MESH_DEFORM_SAVE_DEFS_H diff --git a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSaveSet.cpp b/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSaveSet.cpp deleted file mode 100644 index 9992ddb153b..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSaveSet.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/MeshDeformSaveSet.cpp 2 6/16/99 6:56p Patrick $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : MeshDeformSaveSet.CPP - * * - * Programmer : Patrick Smith * - * * - * Start Date : 05/28/99 * - * * - * Last Update : - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "MeshDeformSaveSet.h" -#include "util.h" - - -//////////////////////////////////////////////////////////////////////// -// -// Reset -// -//////////////////////////////////////////////////////////////////////// -void -MeshDeformSaveSetClass::Reset (void) -{ - // - // Free all the keyframe pointers in our list - // - for (int index = 0; index < m_DeformData.Count (); index ++) { - SAFE_DELETE (m_DeformData[index]); - } - - m_DeformData.Delete_All (); - m_CurrentKeyFrame = NULL; - return ; -} - - -//////////////////////////////////////////////////////////////////////// -// -// Begin_Keyframe -// -//////////////////////////////////////////////////////////////////////// -void -MeshDeformSaveSetClass::Begin_Keyframe (float state) -{ - // - // Allocate a new keyframe structure - // - m_CurrentKeyFrame = new KEYFRAME; - m_CurrentKeyFrame->state = state; - - // - // Add this new keyframe to the end of our list - // - m_DeformData.Add (m_CurrentKeyFrame); - return ; -} - - -//////////////////////////////////////////////////////////////////////// -// -// End_Keyframe -// -//////////////////////////////////////////////////////////////////////// -void -MeshDeformSaveSetClass::End_Keyframe (void) -{ - m_CurrentKeyFrame = NULL; - return ; -} - - -//////////////////////////////////////////////////////////////////////// -// -// Add_Vert -// -//////////////////////////////////////////////////////////////////////// -void -MeshDeformSaveSetClass::Add_Vert -( - UINT vert_index, - const Point3 & position, - const VertColor & color -) -{ - // State OK? - assert (m_CurrentKeyFrame != NULL); - if (m_CurrentKeyFrame != NULL) { - - // - // Create a structure that will hold the - // vertex information. - // - DEFORM_DATA data; - data.vert_index = vert_index; - data.position = position; - data.color = color; - - // - // Add this vertex information to the keyframe list - // - m_CurrentKeyFrame->deform_list.Add (data); - } - - return ; -} - - -//////////////////////////////////////////////////////////////////////// -// -// Replace_Deform_Data -// -//////////////////////////////////////////////////////////////////////// -void -MeshDeformSaveSetClass::Replace_Deform_Data -( - int keyframe_index, - DynamicVectorClass &list -) -{ - KEYFRAME *key_frame = m_DeformData[keyframe_index]; - if (key_frame != NULL) { - - // - // Replace the vertex deformation list for the keyframe - // - key_frame->deform_list.Delete_All (); - key_frame->deform_list = list; - } - - return ; -} - - -//////////////////////////////////////////////////////////////////////// -// -// Get_Deform_Count -// -//////////////////////////////////////////////////////////////////////// -/*int -MeshDeformSaveSetClass::Get_Deform_Count (void) const -{ - // - // Count up all the deform entries for all the keyframes - // - int count = 0; - for (int index = 0; index < m_DeformData.Count (); index ++) { - KEYFRAME *key_frame = m_DeformData[index]; - if (key_frame != NULL) { - count += key_frame->deform_list.Count (); - } - } - - return count; -}*/ - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSaveSet.h b/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSaveSet.h deleted file mode 100644 index 59de050ca19..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSaveSet.h +++ /dev/null @@ -1,138 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/MeshDeformSaveSet.h 2 6/16/99 6:56p Patrick $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : MeshDeformSaveSet.H - * * - * Programmer : Patrick Smith * - * * - * Start Date : 05/28/99 * - * * - * Last Update : - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef __MESH_DEFORM_SAVE_SET_H -#define __MESH_DEFORM_SAVE_SET_H - -#include -#include "Vector.H" - -// Forward declarations -class ChunkSaveClass; - - -/////////////////////////////////////////////////////////////////////////// -// -// MeshDeformSaveSetClass -// -/////////////////////////////////////////////////////////////////////////// -class MeshDeformSaveSetClass -{ - public: - - ////////////////////////////////////////////////////////////////////// - // Public friends - ////////////////////////////////////////////////////////////////////// - friend class MeshDeformSaveClass; - - - protected: - - protected: - - ////////////////////////////////////////////////////////////////////// - // Protected data types - ////////////////////////////////////////////////////////////////////// - typedef struct _DEFORM_DATA - { - UINT vert_index; - Point3 position; - VertColor color; - - // Don't care, DynamicVectorClass needs these - bool operator== (const _DEFORM_DATA &src) { return false; } - bool operator!= (const _DEFORM_DATA &src) { return true; } - } DEFORM_DATA; - - ////////////////////////////////////////////////////////////////////// - // Protected data types - ////////////////////////////////////////////////////////////////////// - typedef struct - { - float state; - DynamicVectorClass deform_list; - } KEYFRAME; - - -public: - - ////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////// - MeshDeformSaveSetClass (void) - : m_Flags (0), - m_CurrentKeyFrame (NULL) { } - ~MeshDeformSaveSetClass (void) { Reset (); } - - ////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////// - - // Keyframe managment - void Begin_Keyframe (float state); - void End_Keyframe (void); - - // Vertex managment - void Add_Vert (UINT vert_index, const Point3 &position, const VertColor &color); - - // Misc - void Reset (void); - bool Is_Empty (void) const { return m_DeformData.Count () == 0; } - - // Flag support - bool Get_Flag (unsigned int flag) const { return (m_Flags & flag) == flag; } - void Set_Flag (unsigned int flag, bool value) { if (value) (m_Flags |= flag); else (m_Flags &= ~flag); } - unsigned int Get_Flags (void) const { return m_Flags; } - - // Enumeration - float Get_Deform_State (int key_frame) const { return m_DeformData[key_frame]->state; } - int Get_Keyframe_Count (void) const { return m_DeformData.Count (); } - int Get_Deform_Data_Count (int key_frame) const { return m_DeformData[key_frame]->deform_list.Count (); } - DEFORM_DATA & Get_Deform_Data (int key_frame, int index) { return m_DeformData[key_frame]->deform_list[index]; } - void Replace_Deform_Data (int keyframe_index, DynamicVectorClass &list); - - private: - - ////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////// - DynamicVectorClass m_DeformData; - KEYFRAME * m_CurrentKeyFrame; - unsigned int m_Flags; -}; - -#endif //__MESH_DEFORM_SAVE_SET_H diff --git a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSet.cpp b/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSet.cpp deleted file mode 100644 index aa6088ff087..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSet.cpp +++ /dev/null @@ -1,1534 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : MeshDeformSet.cpp * - * * - * Programmer : Patrick Smith * - * * - * Start Date : 04/26/99 * - * * - * Last Update : - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "MeshDeformSet.h" -#include "util.h" -#include "MeshDeformSaveSet.h" -#include "meshbuild.h" -#include "MeshDeformSaveDefs.h" -#include "MeshDeformDefs.h" - - -/////////////////////////////////////////////////////////////////////////// -// -// Constants -// -/////////////////////////////////////////////////////////////////////////// -const int MAX_DEFORM_KEY_FRAMES = 10; - - -/////////////////////////////////////////////////////////////////////////// -// -// ~MeshDeformSetClass -// -/////////////////////////////////////////////////////////////////////////// -MeshDeformSetClass::~MeshDeformSetClass (void) -{ - SAFE_DELETE (m_pMesh); - SAFE_DELETE (m_pVertexArray); - SAFE_DELETE (m_pVertexOPStartArray); - SAFE_DELETE (m_pVertexColors); - Free_Key_Frames (); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Set_Current_Key_Frame -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Set_Current_Key_Frame (int index) -{ - if (index >= -1 && index < MAX_DEFORM_KEY_FRAMES) { - m_CurrentKeyFrame = index; - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Set_Vertex_Position -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Set_Vertex_Position -( - int index, - const Point3 & value -) -{ - DEFORM_LIST &verticies = m_KeyFrames[m_CurrentKeyFrame]->verticies; - BitArray &affected_verts = m_KeyFrames[m_CurrentKeyFrame]->affected_verts; - - // - // Set the vert's position - // - m_pMesh->verts[index] = value; - verticies.Add (VERT_INFO (index, value)); - - // - // Make sure we remember that this vert is affected - // - affected_verts.Set (index, 1); - m_SetMembers.Set (index, 1); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Set_Vertex_Color -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Set_Vertex_Color -( - int index, - int color_index, - const VertColor & value -) -{ - DEFORM_LIST &colors = m_KeyFrames[m_CurrentKeyFrame]->colors; - BitArray &affected_colors = m_KeyFrames[m_CurrentKeyFrame]->affected_colors; - - // - // Set the vert's color - // - m_pMesh->vertCol[color_index] = value; - colors.Add (VERT_INFO (index, value, color_index)); - - // - // Make sure we remember that this vert color is affected - // - affected_colors.Set (index, 1); - m_SetMembers.Set (index, 1); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Update_Set_Members -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Update_Set_Members (void) -{ - // - // Examine each keyframe - // - m_SetMembers.ClearAll (); - for (int index = 0; index < m_KeyFrames.Count (); index ++) { - BitArray &affected_verts = m_KeyFrames[index]->affected_verts; - BitArray &affected_colors = m_KeyFrames[index]->affected_colors; - - // - // Mark the verts that are affected by this keyframe - // - for (int vert = 0; vert < m_VertexCount; vert ++) { - if (affected_verts[vert] || affected_colors[vert]) { - m_SetMembers.Set (vert, 1); - } - } - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Collapse_Keyframe_Data -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Collapse_Keyframe_Data (int keyframe) -{ - DEFORM_LIST &verticies = m_KeyFrames[keyframe]->verticies; - DEFORM_LIST &colors = m_KeyFrames[keyframe]->colors; - BitArray &affected_verts = m_KeyFrames[keyframe]->affected_verts; - BitArray &affected_colors = m_KeyFrames[keyframe]->affected_colors; - - // - // Collapse the vertex position data - // - for (int index = 0; index < verticies.Count (); index ++) { - VERT_INFO &info = verticies[index]; - - // - // If this vertex is unchanged, then remove it - // from the list. - // - if (m_pVertexArray[index] == info.value) { - verticies.Delete (index); - index --; - } else { - affected_verts.Set (info.index, 1); - m_SetMembers.Set (info.index, 1); - } - } - - - // - // Collapse the vertex color data - // - for (index = 0; index < colors.Count (); index ++) { - VERT_INFO &info = colors[index]; - - // - // If this vertex is unchanged, then remove it - // from the list. - // - if (m_pVertexColors[index] == info.value) { - verticies.Delete (index); - index --; - } else { - affected_colors.Set (info.index, 1); - m_SetMembers.Set (info.index, 1); - } - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Reset_Key_Frame_Verts -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Reset_Key_Frame_Verts (int keyframe) -{ - DEFORM_LIST &verticies = m_KeyFrames[keyframe]->verticies; - BitArray &affected_verts = m_KeyFrames[keyframe]->affected_verts; - - // - // Reset all data for this keyframe - // - affected_verts.ClearAll (); - verticies.Delete_All (); - - // - // Regenerate the list of set members - // - Update_Set_Members (); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Reset_Key_Frame_Colors -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Reset_Key_Frame_Colors (int keyframe) -{ - DEFORM_LIST &colors = m_KeyFrames[keyframe]->colors; - BitArray &affected_colors = m_KeyFrames[keyframe]->affected_colors; - - // - // Reset all data for this keyframe - // - affected_colors.ClearAll (); - colors.Delete_All (); - - // - // Regenerate the list of set members - // - Update_Set_Members (); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Update_Current_Data -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Update_Current_Data (void) -{ - DEFORM_LIST &verticies = m_KeyFrames[m_CurrentKeyFrame]->verticies; - DEFORM_LIST &colors = m_KeyFrames[m_CurrentKeyFrame]->colors; - BitArray &affected_verts = m_KeyFrames[m_CurrentKeyFrame]->affected_verts; - BitArray &affected_colors = m_KeyFrames[m_CurrentKeyFrame]->affected_colors; - - // - // Assume we have no modifications for this keyframe - // - affected_verts.ClearAll (); - affected_colors.ClearAll (); - verticies.Delete_All (); - colors.Delete_All (); - - // - // Record the vertex position data - // - for (int index = 0; index < m_VertexCount; index ++) { - - // Is this vertex's position different than the undeformed mesh? - Point3 orig = m_pVertexArray[index]; - Point3 current = m_pMesh->verts[index]; - - //Apply_Position_Changes (index, m_CurrentKeyFrame, orig); - - if ( (orig.x != current.x) || - (orig.y != current.y) || - (orig.z != current.z)) { - - // - // Record this vertex's position in our lists - // - affected_verts.Set (index, 1); - verticies.Add (VERT_INFO (index, m_pMesh->verts[index])); - } - } - - // Only do this if the mesh is using vertex coloring - if (m_pMesh->numCVerts >= m_pMesh->numVerts) { - - // - // Record the vertex color data - // - for (int face = 0; face < m_pMesh->numFaces; face ++) { - for (int vert = 0; vert < 3; vert ++) { - - // - // Has this vertex color changed? - // - int vertex_index = m_pMesh->faces[face].v[vert]; - int color_index = m_pMesh->vcFace[face].t[vert]; - VertColor orig = m_pVertexColors[color_index]; - VertColor current = m_pMesh->vertCol[color_index]; - if ( (orig.x != current.x) || - (orig.y != current.y) || - (orig.z != current.z)) { - affected_colors.Set (vertex_index, 1); - colors.Add (VERT_INFO (vertex_index, m_pMesh->vertCol[color_index], color_index)); - } - } - } - } - - // - // Rebuild the list of verticies this 'set' affects - // - Update_Set_Members (); - - // - // Collapse all unsused data from the remainder of the keyframes - // - for (index = 0; index < m_KeyFrames.Count (); index ++) { - //Collapse_Keyframe_Data (index); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Update_Key_Frame -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Update_Key_Frame (int key_frame) -{ - DEFORM_LIST &verticies = m_KeyFrames[key_frame]->verticies; - DEFORM_LIST &colors = m_KeyFrames[key_frame]->colors; - BitArray &affected_verts = m_KeyFrames[key_frame]->affected_verts; - BitArray &affected_colors = m_KeyFrames[key_frame]->affected_colors; - - if ((key_frame == m_CurrentKeyFrame) || - (verticies.Count () > 0) || - (colors.Count () > 0)) { - - // Clear all entries from this keyframe - verticies.Delete_All (); - colors.Delete_All (); - - // - // Copy the vertex position changes - // - for (int vert = 0; vert < m_pMesh->numVerts; vert ++) { - if (affected_verts[vert]) { - verticies.Add (VERT_INFO (vert, m_pMesh->verts[vert])); - } - } - - // - // Copy the vertex color changes - // - - // Only do this if the mesh is using vertex coloring - if (m_pMesh->numCVerts >= m_pMesh->numVerts) { - for (int face = 0; face < m_pMesh->numFaces; face ++) { - - if (affected_colors[m_pMesh->faces[face].v[0]]) { - int color_index = m_pMesh->vcFace[face].t[0]; - colors.Add (VERT_INFO (m_pMesh->faces[face].v[0], m_pMesh->vertCol[color_index], color_index)); - } - - if (affected_colors[m_pMesh->faces[face].v[1]]) { - int color_index = m_pMesh->vcFace[face].t[1]; - colors.Add (VERT_INFO (m_pMesh->faces[face].v[1], m_pMesh->vertCol[color_index], color_index)); - } - - if (affected_colors[m_pMesh->faces[face].v[2]]) { - int color_index = m_pMesh->vcFace[face].t[2]; - colors.Add (VERT_INFO (m_pMesh->faces[face].v[2], m_pMesh->vertCol[color_index], color_index)); - } - } - } - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Init_Key_Frames -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Init_Key_Frames (void) -{ - // - // For now, add all the key frames upfront - // - for (int index = 0; index < MAX_DEFORM_KEY_FRAMES; index ++) { - KEY_FRAME *key_frame = new KEY_FRAME; - m_KeyFrames.Add (key_frame); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Free_Key_Frames -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Free_Key_Frames (void) -{ - // - // Loop through and free all the key frames - // - for (int index = 0; index < m_KeyFrames.Count (); index ++) { - KEY_FRAME *key_frame = m_KeyFrames[index]; - SAFE_DELETE (key_frame); - } - - m_KeyFrames.Delete_All (); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Copy_Vertex_Array -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Copy_Vertex_Array (Mesh &mesh) -{ - Resize_Vertex_Array (mesh.numVerts, mesh.numCVerts); - - // - // Copy the vertex positions from the mesh - // - for (int vert = 0; vert < mesh.numVerts; vert ++) { - m_pVertexArray[vert] = mesh.verts[vert]; - } - - // - // Copy the vertex colors from the mesh - // - for (int index = 0; index < mesh.numCVerts; index ++) { - m_pVertexColors[index] = mesh.vertCol[index]; - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Resize_Vertex_Array -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Resize_Vertex_Array (int count, int color_count) -{ - if (count != m_VertexCount) { - - // Allocate a new array of verticies - Point3 *vertex_array = new Point3[count]; - Point3 *opstart_array = new Point3[count]; - - // Delete the old vertex array and remember the new one - SAFE_DELETE (m_pVertexArray); - SAFE_DELETE (m_pVertexOPStartArray); - m_pVertexArray = vertex_array; - m_pVertexOPStartArray = opstart_array; - m_VertexCount = count; - - // - // Reset the bounds of the 'affected verts' per keyframe arrays - // - for (int index = 0; index < m_KeyFrames.Count (); index ++) { - m_KeyFrames[index]->affected_verts.SetSize (count); - m_KeyFrames[index]->affected_colors.SetSize (count); - m_KeyFrames[index]->affected_verts.ClearAll (); - m_KeyFrames[index]->affected_colors.ClearAll (); - - } - - m_SetMembers.SetSize (count); - m_SetMembers.ClearAll (); - } - - if (color_count != m_VertexColorCount) { - - // Recreate the color deltas - Point3 *color_array = new VertColor[color_count]; - for (int index = 0; index < color_count; index ++) { - color_array[index].x = 0; - color_array[index].y = 0; - color_array[index].z = 0; - } - - // Delete the old delta array and remeber the new one - SAFE_DELETE (m_pVertexColors); - m_VertexColorCount = color_count; - m_pVertexColors = color_array; - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Set_State -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Set_State (float state) -{ - m_State = state; - int key_frame = (m_State * MAX_DEFORM_KEY_FRAMES) + 0.5F; - Set_Current_Key_Frame ((key_frame >= 0) ? (key_frame - 1) : -1); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Determine_Interpolation_Indicies -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Determine_Interpolation_Indicies -( - int key_frame, - bool position, - int & from, - int & to, - float & state -) -{ - /*state = m_State; - from = -1; - to = key_frame; - - // - // Determine where we should start interpolation - // - for (int index = 0; index <= key_frame; index ++) { - if (position && m_KeyFrames[index]->verticies.Count () > 0) { - from = index; - } else if (!position && m_KeyFrames[index]->colors.Count () > 0) { - from = index; - } - } - - // - // Determine where we should end interpolation - // - for (index = to; index < MAX_DEFORM_KEY_FRAMES; index ++) { - if (position && m_KeyFrames[index]->verticies.Count () > 0) { - to = index; - break; - } else if (!position && m_KeyFrames[index]->colors.Count () > 0) { - to = index; - break; - } - } - - // - // Determine the state (deformation percent) - // - state = 0; - if (m_State > 0) { - state = 1.0F; - if ((to != from) && (m_CurrentKeyFrame < to)) { - float value = m_CurrentKeyFrame;//key_frame; - state = ((value - ((float)from)) / (float)(to-from)); - } - }*/ - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Apply_Position_Changes -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Apply_Position_Changes -( - UINT vert, - int frame_to_check, - Point3 & position, - Matrix3 *transform -) -{ - // - // Determine where we should start interpolating this vert - // - int from = -1; - for (int key_frame = frame_to_check; (key_frame >= 0) && (from == -1); key_frame --) { - if (m_KeyFrames[key_frame]->affected_verts[vert]) { - from = key_frame; - } - } - - // - // Determine where we should end interpolating this vert - // - int to = -1; - if (frame_to_check >= 0) { - for (key_frame = frame_to_check; (key_frame < m_KeyFrames.Count ()) && (to == -1); key_frame ++) { - if (m_KeyFrames[key_frame]->affected_verts[vert]) { - to = key_frame; - } - } - } - - // - // Determine the deformation percent - // - float state = 0; - if (m_State > 0) { - state = 1.0F; - if ((to != from) && (frame_to_check < to)) { - float value = frame_to_check; - state = ((value - ((float)from)) / (float)(to - from)); - } - } - - if (from != -1) { - - // - // Find the vertex value in the 'from' key frame and set the - // triangle object's vertex to be this value (we will interplate from it). - // - DEFORM_LIST &vert_from = m_KeyFrames[from]->verticies; - for (int index = 0; index < vert_from.Count (); index ++) { - VERT_INFO &info = vert_from[index]; - if (info.index == vert) { - Point3 new_pos = info.value; - - // Transform the new position if necessary - if (transform != NULL) { - new_pos = new_pos * (*transform); - } - - position = new_pos; - } - } - } - - if (to != -1) { - - // - // Find the vertex value in the 'to' key frame and interpolate - // this value from the triangle object's current vertex value. - // - DEFORM_LIST &vert_to = m_KeyFrames[to]->verticies; - for (int index = 0; index < vert_to.Count (); index ++) { - VERT_INFO &info = vert_to[index]; - if (info.index == vert) { - - Point3 new_pos = info.value; - - // Transform the new position if necessary - if (transform != NULL) { - new_pos = new_pos * (*transform); - } - - position += state * (new_pos - position); - //m_pMesh->verts[vert] = position; - } - } - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Apply_Color_Changes -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Apply_Color_Changes -( - UINT vert, - int frame_to_check, - Mesh & mesh - //VertColor & color -) -{ - // - // Determine where we should start interpolating this vert - // - int from = -1; - for (int key_frame = frame_to_check; (key_frame >= 0) && (from == -1); key_frame --) { - if (m_KeyFrames[key_frame]->affected_colors[vert]) { - from = key_frame; - } - } - - // - // Determine where we should end interpolating this vert - // - int to = -1; - if (frame_to_check >= 0) { - for (key_frame = frame_to_check; (key_frame < m_KeyFrames.Count ()) && (to == -1); key_frame ++) { - if (m_KeyFrames[key_frame]->affected_colors[vert]) { - to = key_frame; - } - } - } - - // - // Determine the deformation percent - // - float state = 0; - if (m_State > 0) { - state = 1.0F; - if ((to != from) && (frame_to_check < to)) { - float value = frame_to_check; - state = ((value - ((float)from)) / (float)(to - from)); - } - } - - if (from != -1) { - - // - // Find the color value in the 'from' key frame and set the - // triangle object's color to be this value (we will interplate from it). - // - DEFORM_LIST &color_from = m_KeyFrames[from]->colors; - for (int index = 0; index < color_from.Count (); index ++) { - VERT_INFO &info = color_from[index]; - if (info.index == vert) { - //color = info.value; - mesh.vertCol[info.color_index] = info.value; - m_pMesh->vertCol[info.color_index] = info.value; - } - } - } - - if (to != -1) { - - // - // Find the color value in the 'to' key frame and interpolate - // this value from the triangle object's current color value. - // - DEFORM_LIST &color_to = m_KeyFrames[to]->colors; - for (int index = 0; index < color_to.Count (); index ++) { - VERT_INFO &info = color_to[index]; - if (info.index == vert) { - mesh.vertCol[info.color_index] = m_pMesh->vertCol[info.color_index] + state * (info.value - m_pMesh->vertCol[info.color_index]); - } - } - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Apply_Color_Changes -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Apply_Color_Changes -( - UINT vert_index, - UINT vert_color_index, - int frame_to_check, - VertColor & color -) -{ - // - // Determine where we should start interpolating this vert - // - int from = -1; - for (int key_frame = frame_to_check; (key_frame >= 0) && (from == -1); key_frame --) { - if (m_KeyFrames[key_frame]->affected_colors[vert_index]) { - from = key_frame; - } - } - - // - // Determine where we should end interpolating this vert - // - int to = -1; - for (key_frame = frame_to_check; (key_frame < m_KeyFrames.Count ()) && (to == -1); key_frame ++) { - if (m_KeyFrames[key_frame]->affected_colors[vert_index]) { - to = key_frame; - } - } - - // - // Determine the deformation percent - // - float state = 0; - if (m_State > 0) { - state = 1.0F; - if ((to != from) && (frame_to_check < to)) { - float value = frame_to_check; - state = ((value - ((float)from)) / (float)(to - from)); - } - } - - if (from != -1) { - - // - // Find the color value in the 'from' key frame and set the - // triangle object's color to be this value (we will interplate from it). - // - DEFORM_LIST &color_from = m_KeyFrames[from]->colors; - for (int index = 0; index < color_from.Count (); index ++) { - VERT_INFO &info = color_from[index]; - if (info.color_index == vert_color_index) { - color = info.value; - break; - } - } - } - - if (to != -1) { - - // - // Find the color value in the 'to' key frame and interpolate - // this value from the triangle object's current color value. - // - DEFORM_LIST &color_to = m_KeyFrames[to]->colors; - for (int index = 0; index < color_to.Count (); index ++) { - VERT_INFO &info = color_to[index]; - if (info.color_index == vert_color_index) { - color += state * (info.value - color); - break; - } - } - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Update_Mesh -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Update_Mesh (TriObject &tri_obj) -{ - Copy_Vertex_Array (tri_obj.mesh); - - // Should we update the mesh or copy it? - if (m_pMesh != NULL) { - - // - // Copy the vertex colors from the triangle object - // - for (int vert_color = 0; vert_color < m_pMesh->numCVerts; vert_color ++) { - m_pMesh->vertCol[vert_color] = tri_obj.mesh.vertCol[vert_color]; - } - - // - // Loop through all the verticies and interpolate their - // positions and colors based on the current 'deformation state'. - // - for (UINT vert = 0; vert < (UINT)m_pMesh->numVerts; vert ++) { - - // Is this vertex affected by any keyframe in the set? - if (m_SetMembers[vert]) { - - // Interpolate any changes to this vert - Apply_Position_Changes (vert, m_CurrentKeyFrame, tri_obj.mesh.verts[vert]); - m_pMesh->verts[vert] = tri_obj.mesh.verts[vert]; - Apply_Color_Changes (vert, m_CurrentKeyFrame, tri_obj.mesh); - } - } - - // - // Copy the vertex colors from the triangle object - // - for (vert_color = 0; vert_color < m_pMesh->numCVerts; vert_color ++) { - m_pMesh->vertCol[vert_color] = tri_obj.mesh.vertCol[vert_color]; - } - - - /*for (int index = 0; index < m_pMesh->numCVerts; index ++) { - m_pMesh->vertCol[index] = tri_obj.mesh.vertCol[index]; - } - - // - for (int key_frame = 0; key_frame < m_KeyFrames.Count (); key_frame ++) { - - // - // Update the verticies - // - - int from = 0; - int to = 0; - float state = 0; - Determine_Interpolation_Indicies (key_frame, true, from, to, state); - DEFORM_LIST &vert_to = m_KeyFrames[to]->verticies; - - if (from <= m_CurrentKeyFrame) { - - if (from >= 0) { - DEFORM_LIST &vert_from = m_KeyFrames[from]->verticies; - for (int index = 0; index < vert_from.Count (); index ++) { - VERT_INFO &info = vert_from[index]; - tri_obj.mesh.verts[info.index] = info.value; - } - } else { - - for (int index = 0; index < vert_to.Count (); index ++) { - VERT_INFO &info = vert_to[index]; - tri_obj.mesh.verts[info.index] = m_pVertexArray[info.index]; - } - } - - for (int index = 0; index < vert_to.Count (); index ++) { - VERT_INFO &info = vert_to[index]; - tri_obj.mesh.verts[info.index] += state * (info.value - tri_obj.mesh.verts[info.index]); - m_pMesh->verts[info.index] = tri_obj.mesh.verts[info.index]; - } - } - - // - // Update the vertex colors - // - Determine_Interpolation_Indicies (key_frame, false, from, to, state); - DEFORM_LIST &color_to = m_KeyFrames[to]->colors; - - if (from <= m_CurrentKeyFrame) { - - if (from >= 0) { - DEFORM_LIST &color_from = m_KeyFrames[from]->colors; - for (int index = 0; index < color_from.Count (); index ++) { - VERT_INFO &info = color_from[index]; - tri_obj.mesh.vertCol[info.index] = info.value; - } - } else { - - for (index = 0; index < color_to.Count (); index ++) { - VERT_INFO &info = color_to[index]; - tri_obj.mesh.vertCol[info.index] = m_pMesh->vertCol[info.index]; - } - } - - for (index = 0; index < color_to.Count (); index ++) { - VERT_INFO &info = color_to[index]; - tri_obj.mesh.vertCol[info.index] = m_pMesh->vertCol[info.index] + state * (info.value - m_pMesh->vertCol[info.index]); - //tri_obj.mesh.vertCol[info.index] += state * (info.value - tri_obj.mesh.vertCol[info.index]); - } - } - } - - for (index = 0; index < m_pMesh->numCVerts; index ++) { - m_pMesh->vertCol[index] = tri_obj.mesh.vertCol[index]; - }*/ - - - - - - /*for (int vert = 0; vert < m_VertexCount; vert ++) { - tri_obj.mesh.verts[vert] += (1.0F * m_pVertexDeltaArray[vert]); - m_pMesh->verts[vert] = tri_obj.mesh.verts[vert]; - } - - - // - // Transform the vertex colors based on the current deform state - // - for (vert = 0; vert < m_VertexColorCount; vert ++) { - tri_obj.mesh.vertCol[vert] += (1.0F * m_pVertexColors[vert]); - }*/ - - // - // Pass the new selection onto the mesh - // - tri_obj.mesh.vertSel = m_pMesh->vertSel; - tri_obj.PointsWereChanged (); - - } else { - - // - // Make a copy of the mesh as it currently exists - // - m_pMesh = new Mesh (tri_obj.mesh); - tri_obj.mesh.DeepCopy (m_pMesh, GEOM_CHANNEL | SELECT_CHANNEL | SUBSEL_TYPE_CHANNEL | VERTCOLOR_CHANNEL); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Update_Members -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Update_Members (DEFORM_CHANNELS flags) -{ - assert (m_CurrentKeyFrame >= 0); - - // - // Add all the selected verts to the set array - // - for (int vert = 0; vert < m_pMesh->numVerts; vert ++) { - if (m_pMesh->vertSel[vert]) { - - // - // Should we add this vertex to the array of deformed verts - // the current keyframe? - // - if (flags & VERT_POSITION) { - m_KeyFrames[m_CurrentKeyFrame]->affected_verts.Set (vert, 1); - } - - // - // Should we add this vertex to the array of deformed vertex colors - // the current keyframe? - // - if (flags & VERT_COLORS) { - - m_KeyFrames[m_CurrentKeyFrame]->affected_colors.Set (vert, 1); - - // - // Map indicies in the vertex color array to the vertex array. - // - /*if (m_pMesh->numCVerts >= m_pMesh->numVerts) { - for (int face = 0; face < m_pMesh->numFaces; face ++) { - - if (m_pMesh->faces[face].v[0] == vert) { - int color_index = m_pMesh->vcFace[face].t[0]; - m_KeyFrames[m_CurrentKeyFrame]->affected_colors.Set (color_index, 1); - } - - if (m_pMesh->faces[face].v[1] == vert) { - int color_index = m_pMesh->vcFace[face].t[1]; - m_KeyFrames[m_CurrentKeyFrame]->affected_colors.Set (color_index, 1); - } - - if (m_pMesh->faces[face].v[2] == vert) { - int color_index = m_pMesh->vcFace[face].t[2]; - m_KeyFrames[m_CurrentKeyFrame]->affected_colors.Set (color_index, 1); - } - } - }*/ - } - - // - // Finally, add this vertex to the list of all - // verticies affected by this set. - // - m_SetMembers.Set (vert, 1); - } - } - - //r (int index = m_CurrentKeyFrame; index < MAX_DEFORM_KEY_FRAMES; index ++) { - Update_Key_Frame (m_CurrentKeyFrame); - // - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Select_Members -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Select_Members (void) -{ - // - // Loop through and select the necessary verts - // - for (int vert = 0; vert < m_pMesh->numVerts; vert ++) { - m_pMesh->vertSel.Set (vert, m_SetMembers[vert]); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Restore_Members -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Restore_Members (void) -{ -/* - // - // Loop through and select the necessary verts - // - for (int vert = 0; vert < m_pMesh->numVerts; vert ++) { - - if (m_SetMembers[vert]) { - - // - // Restore the vertex positions - // - m_pMesh->verts[vert] = m_pVertexArray[vert]; - m_pVertexDeltaArray[vert].x = 0; - m_pVertexDeltaArray[vert].y = 0; - m_pVertexDeltaArray[vert].z = 0; - } - } - - // - // Restore the vertex colors - // - - // Only do this if the mesh is using vertex coloring - if (m_pMesh->numCVerts >= m_pMesh->numVerts) { - for (int face = 0; face < m_pMesh->numFaces; face ++) { - - if (m_SetMembers[m_pMesh->faces[face].v[0]]) { - int color_index = m_pMesh->vcFace[face].t[0]; - m_pVertexColors[color_index].x = 0; - m_pVertexColors[color_index].y = 0; - m_pVertexColors[color_index].z = 0; - } - - if (m_SetMembers[m_pMesh->faces[face].v[1]]) { - int color_index = m_pMesh->vcFace[face].t[1]; - m_pVertexColors[color_index].x = 0; - m_pVertexColors[color_index].y = 0; - m_pVertexColors[color_index].z = 0; - } - - if (m_SetMembers[m_pMesh->faces[face].v[2]]) { - int color_index = m_pMesh->vcFace[face].t[2]; - m_pVertexColors[color_index].x = 0; - m_pVertexColors[color_index].y = 0; - m_pVertexColors[color_index].z = 0; - } - } - } - -*/ - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Is_Empty -// -/////////////////////////////////////////////////////////////////////////// -bool -MeshDeformSetClass::Is_Empty (void) const -{ - bool is_empty = true; - - // - // If any vertex is 'selected' then this set is not empty. - // - for (int vert = 0; (vert < m_VertexCount) && is_empty; vert ++) { - is_empty = (m_SetMembers[vert] == 0); - } - - // Return the true/false result code - return is_empty; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Save -// -/////////////////////////////////////////////////////////////////////////// -void -MeshDeformSetClass::Save -( - MeshBuilderClass & builder, - Mesh & mesh, - MeshDeformSaveSetClass & save_set, - Matrix3 * transform -) -{ - // Start fresh - save_set.Reset (); - save_set.Set_Flag (DEFORM_SET_MANUAL_DEFORM, (m_bAutoApply == false)); - - // - // Determine how much each state change (from 0 - 1) - // is associated with each keyframe. - // - int key_frames = m_KeyFrames.Count (); - float state_inc = 1.0F / ((float)key_frames); - float old_state = m_State; - - // - // Loop through all the keyframes - // - for (int key_frame = 0; key_frame < key_frames; key_frame ++) { - - // - // Loop through all the verticies and see if this keyframe - // modifies any of them - // - bool verts_affected = false; - for (int vert = 0; (vert < m_VertexCount) && !verts_affected; vert ++) { - verts_affected = (m_KeyFrames[key_frame]->affected_verts[vert] == 1); - verts_affected |= (m_KeyFrames[key_frame]->affected_colors[vert] == 1); - } - - // - // If the keyframe modifies any of these verts, then save - // the state of all verts in the set. - // - if (verts_affected) { - m_State = state_inc * (key_frame + 1); - save_set.Begin_Keyframe (m_State); - - // - // Save the absolute state of all the verts and colors - // at this keyframe. - // - - for (int w3d_vert_index = 0; w3d_vert_index < builder.Get_Vertex_Count (); w3d_vert_index ++) { - - const MeshBuilderClass::VertClass &w3d_vert = builder.Get_Vertex(w3d_vert_index); - int max_vert_index = w3d_vert.Id; - - if (m_SetMembers[max_vert_index]) { - - // - // Get the absolute position of this vertex - // - Point3 position = mesh.verts[max_vert_index]; - Apply_Position_Changes (max_vert_index, key_frame, position, transform); - - // - // Get the absolute color of this vertex - // - VertColor color (1, 1, 1); - if (mesh.vertCol != NULL) { - int vert_col_index = w3d_vert.MaxVertColIndex; - color = mesh.vertCol[vert_col_index]; - Apply_Color_Changes (max_vert_index, vert_col_index, key_frame, color); - } - - // - // Save this vertex's deformations - // - save_set.Add_Vert (w3d_vert_index, position, color); - } - } - - save_set.End_Keyframe (); - } - } - - m_State = old_state; - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Save -// -/////////////////////////////////////////////////////////////////////////// -IOResult -MeshDeformSetClass::Save (ISave *save_obj) -{ - int key_frames = m_KeyFrames.Count (); - float state_inc = 1.0F / ((float)key_frames); - - DeformChunkSetInfo set_info = { 0 }; - set_info.KeyframeCount = key_frames; - set_info.flags = 0; - set_info.NumVerticies = m_VertexCount; - set_info.NumVertexColors = m_VertexColorCount; - if (m_bAutoApply == false) { - set_info.flags |= DEFORM_SET_MANUAL_DEFORM; - } - DWORD bytes = 0L; - - // - // Write the set info to the chunk - // - save_obj->BeginChunk (DEFORM_CHUNK_SET_INFO); - IOResult result = save_obj->Write (&set_info, sizeof (set_info), &bytes); - - // - // Now write a chunk for each keyframe - // - for (int index = 0; (index < key_frames) && (result == IO_OK); index ++) { - KEY_FRAME &key_frame = *(m_KeyFrames[index]); - - DeformChunkKeyframeInfo keyframe_info = { 0 }; - keyframe_info.DeformPercent = state_inc * (index + 1); - keyframe_info.VertexCount = key_frame.verticies.Count (); - keyframe_info.ColorCount = key_frame.colors.Count (); - - // - // Write keyframe info to the chunk - // - //save_obj->BeginChunk (DEFORM_CHUNK_KEYFRAME_INFO); - result = save_obj->Write (&keyframe_info, sizeof (keyframe_info), &bytes); - //save_obj->EndChunk (); - - // - // Loop through the verticies and save their position - // - for ( unsigned int pos_index = 0; - (pos_index < keyframe_info.VertexCount) && (result == IO_OK); - pos_index ++) - { - VERT_INFO &deform_data = key_frame.verticies[pos_index]; - - DeformDataChunk data; - data.VertexIndex = deform_data.index; - data.ColorIndex = deform_data.color_index; - data.Value = deform_data.value; - - // - // Write vertex position info to the chunk - // - //save_obj->BeginChunk (DEFORM_CHUNK_POSITION_DATA); - result = save_obj->Write (&data, sizeof (data), &bytes); - //save_obj->EndChunk (); - } - - // - // Loop through the verticies and save their color - // - for ( unsigned int color_index = 0; - (color_index < keyframe_info.ColorCount) && (result == IO_OK); - color_index ++) - { - VERT_INFO &deform_data = key_frame.colors[color_index]; - - DeformDataChunk data; - data.VertexIndex = deform_data.index; - data.ColorIndex = deform_data.color_index; - data.Value = deform_data.value; - - // - // Write vertex color info to the chunk - // - //save_obj->BeginChunk (DEFORM_CHUNK_COLOR_DATA); - result = save_obj->Write (&data, sizeof (data), &bytes); - //save_obj->EndChunk (); - } - - // - // Write the list of affected vertex positions to a chunk - // - /*if (result == IO_OK) { - //save_obj->BeginChunk (DEFORM_CHUNK_POSITION_VERTS); - result = key_frame.affected_verts.Save (save_obj); - //save_obj->EndChunk (); - } - - // - // Write the list of affected vertex colors to a chunk - // - if (result == IO_OK) { - //save_obj->BeginChunk (DEFORM_CHUNK_COLOR_VERTS); - result = key_frame.affected_colors.Save (save_obj); - //save_obj->EndChunk (); - }*/ - } - - save_obj->EndChunk (); - - // Return IO_OK on success IO_ERROR on failure - return result; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Load -// -/////////////////////////////////////////////////////////////////////////// -IOResult -MeshDeformSetClass::Load (ILoad *load_obj) -{ - // Start fresh - Free_Key_Frames (); - Init_Key_Frames (); - DWORD bytes = 0L; - - - // - // Is this the chunk we were expecting? - // - IOResult result = load_obj->OpenChunk (); - if ( (result == IO_OK) && - (load_obj->CurChunkID () == DEFORM_CHUNK_SET_INFO)) { - - // - // Read information about this set from the chunk - // - DeformChunkSetInfo set_info = { 0 }; - result = load_obj->Read (&set_info, sizeof (set_info), &bytes); - m_bAutoApply = !(set_info.flags & DEFORM_SET_MANUAL_DEFORM); - - // - // Resize the internal data to fit the saved state - // - if (result == IO_OK) { - Resize_Vertex_Array (set_info.NumVerticies, set_info.NumVertexColors); - } - - // - // Read keyframe information from the chunk - // - for ( unsigned int index = 0; - (index < set_info.KeyframeCount) && (result == IO_OK); - index ++) - { - KEY_FRAME &key_frame = *(m_KeyFrames[index]); - - DeformChunkKeyframeInfo keyframe_info = { 0 }; - result = load_obj->Read (&keyframe_info, sizeof (keyframe_info), &bytes); - - // - // Read all the vertex positions from the chunk - // - for ( unsigned int pos_index = 0; - (pos_index < keyframe_info.VertexCount) && (result == IO_OK); - pos_index ++) - { - // - // Read vertex position info from the chunk - // - DeformDataChunk data; - result = load_obj->Read (&data, sizeof (data), &bytes); - if (result == IO_OK) { - key_frame.verticies.Add (VERT_INFO (data.VertexIndex, data.Value, data.ColorIndex)); - key_frame.affected_verts.Set (data.VertexIndex, 1); - m_SetMembers.Set (data.VertexIndex, 1); - } - } - - // - // Read all the vertex colors from the chunk - // - for ( unsigned int color_index = 0; - (color_index < keyframe_info.ColorCount) && (result == IO_OK); - color_index ++) - { - // - // Read vertex color info from the chunk - // - DeformDataChunk data; - result = load_obj->Read (&data, sizeof (data), &bytes); - if (result == IO_OK) { - key_frame.colors.Add (VERT_INFO (data.VertexIndex, data.Value, data.ColorIndex)); - key_frame.affected_colors.Set (data.VertexIndex, 1); - m_SetMembers.Set (data.VertexIndex, 1); - } - } - - // - // Read the list of affected vertex positions to a chunk - // - /*if (result == IO_OK) { - result = key_frame.affected_verts.Load (load_obj); - } - - // - // Read the list of affected vertex colors to a chunk - // - if (result == IO_OK) { - result = key_frame.affected_colors.Load (load_obj); - }*/ - } - } - - load_obj->CloseChunk (); - - // Return IO_OK on success IO_ERROR on failure - return result; -} - diff --git a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSet.h b/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSet.h deleted file mode 100644 index 4b00123f4e4..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformSet.h +++ /dev/null @@ -1,185 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : MeshDeformSet.h * - * * - * Programmer : Patrick Smith * - * * - * Start Date : 04/26/99 * - * * - * Last Update : - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef __MESH_DEFORM_SET_H -#define __MESH_DEFORM_SET_H - -#include -#include "Vector.H" -#include "MeshDeformDefs.h" - - -// Forward declarations -class MeshDeformSaveSetClass; -class MeshBuilderClass; - - -/////////////////////////////////////////////////////////////////////////// -// -// MeshDeformSetClass -// -/////////////////////////////////////////////////////////////////////////// -class MeshDeformSetClass -{ - public: - - ////////////////////////////////////////////////////////////////////// - // Public data types - ////////////////////////////////////////////////////////////////////// - - - ////////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////////// - MeshDeformSetClass (void) - : m_pMesh (NULL), - m_pVertexArray (NULL), - m_pVertexOPStartArray (NULL), - m_pVertexColors (NULL), - m_VertexColorCount (0), - m_State (0), - m_CurrentKeyFrame (0), - m_bAutoApply (true), - m_VertexCount (0) { Init_Key_Frames (); } - - virtual ~MeshDeformSetClass (void); - - ////////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////////// - //virtual LocalModData * Clone (void) { return new MeshDeformSetClass; } - void Update_Mesh (TriObject &tri_obj); - void Set_State (float state); - - // Inline accessors - Mesh * Peek_Mesh (void) const { return m_pMesh; } - const Point3 * Peek_Orig_Vertex_Array (void) const { return m_pVertexArray; } - Point3 * Peek_Vertex_OPStart_Array (void) const { return m_pVertexOPStartArray; } - VertColor * Peek_Vertex_Colors (void) const { return m_pVertexColors; } - - // Keyframe managment - void Set_Current_Key_Frame (int index); - int Get_Current_Key_Frame (void) const { return m_CurrentKeyFrame; } - void Update_Key_Frame (int key_frame); - void Update_Current_Data (void); - void Update_Set_Members (void); - void Collapse_Keyframe_Data (int keyframe); - void Reset_Key_Frame_Verts (int keyframe); - void Reset_Key_Frame_Colors (int keyframe); - - // Data managment - void Set_Vertex_Position (int index, const Point3 &value); - void Set_Vertex_Color (int index, int color_index, const VertColor &value); - - // Set managment - void Select_Members (void); - void Update_Members (DEFORM_CHANNELS flags); - void Restore_Members (void); - - // Auto apply - bool Does_Set_Auto_Apply (void) const { return m_bAutoApply; } - void Auto_Apply (bool auto_apply = true) { m_bAutoApply = auto_apply; } - - // Information - bool Is_Empty (void) const; - int Get_Vertex_Count (int keyframe) const { return m_KeyFrames[keyframe]->verticies.Count (); } - int Get_Color_Count (int keyframe) const { return m_KeyFrames[keyframe]->colors.Count (); } - const VERT_INFO & Get_Vertex_Data (int keyframe, int index) const { return m_KeyFrames[keyframe]->verticies[index]; } - const VERT_INFO & Get_Color_Data (int keyframe, int index) const { return m_KeyFrames[keyframe]->colors[index]; } - - // Persistent storage - IOResult Save (ISave *save_obj); - IOResult Load (ILoad *load_obj); - - void Save (MeshBuilderClass &builder, Mesh &mesh, MeshDeformSaveSetClass &save_set, Matrix3 *transform = NULL); - - protected: - - ////////////////////////////////////////////////////////////////////// - // Protected methods - ////////////////////////////////////////////////////////////////////// - void Resize_Vertex_Array (int count, int color_count); - void Copy_Vertex_Array (Mesh &mesh); - - // Keyframe methods - void Init_Key_Frames (void); - void Free_Key_Frames (void); - void Determine_Interpolation_Indicies (int key_frame, bool position, int &from, int &to, float &state); - - // Deformation application methods - void Apply_Position_Changes (UINT vert, int frame_to_check, Point3 &position, Matrix3 *transform = NULL); - void Apply_Color_Changes (UINT vert, int frame_to_check, Mesh &mesh); - void Apply_Color_Changes (UINT vert_index, UINT vert_color_index, int frame_to_check, VertColor &color); - - private: - - ////////////////////////////////////////////////////////////////////// - // Private data types - ////////////////////////////////////////////////////////////////////// - typedef struct - { - DEFORM_LIST verticies; - DEFORM_LIST colors; - BitArray affected_verts; - BitArray affected_colors; - } KEY_FRAME; - - typedef DynamicVectorClass KEY_FRAME_LIST; - - ////////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////////// - Mesh * m_pMesh; - Point3 * m_pVertexArray; - Point3 * m_pVertexOPStartArray; - VertColor * m_pVertexColors; - int m_VertexCount; - int m_VertexColorCount; - int m_CurrentKeyFrame; - float m_State; - bool m_bAutoApply; - - // Array representing which verticies are part of the set - BitArray m_SetMembers; - - // List of key frames - KEY_FRAME_LIST m_KeyFrames; -}; - - -#endif //__MESH_DEFORM_DATA_H - diff --git a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformUndo.cpp b/Generals/Code/Tools/WW3D/max2w3d/MeshDeformUndo.cpp deleted file mode 100644 index 2d0de5380c6..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformUndo.cpp +++ /dev/null @@ -1,332 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : MeshDeformUndo.h * - * * - * Programmer : Patrick Smith * - * * - * Start Date : 06/08/99 * - * * - * Last Update : - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "MeshDeformUndo.h" -#include "util.h" -#include "MeshDeformData.h" -#include "MeshDeformSet.h" -#include "MeshDeform.h" - - -/////////////////////////////////////////////////////////////////////////// -// -// VertexRestoreClass -// -/////////////////////////////////////////////////////////////////////////// -VertexRestoreClass::VertexRestoreClass -( - Mesh * mesh, - MeshDeformClass * modifier, - MeshDeformModData * mod_data -) - : m_pModifier (modifier), - m_pModData (mod_data), - m_pMesh (mesh), - m_SetIndex (0), - m_KeyframeIndex (0) -{ - assert (mesh != NULL); - - // - // Remember the deformer's current settings - // - m_SetIndex = m_pModData->Get_Current_Set (); - m_KeyframeIndex = m_pModData->Peek_Set (m_SetIndex).Get_Current_Key_Frame (); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Free_Vertex_Array -// -/////////////////////////////////////////////////////////////////////////// -void -VertexRestoreClass::Free_Vertex_Array (void) -{ - m_VertexList.Delete_All (); - m_RedoVertexList.Delete_All (); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Restore -// -/////////////////////////////////////////////////////////////////////////// -void -VertexRestoreClass::Restore (int is_undo) -{ - assert (m_pMesh != NULL); - assert (m_pModData != NULL); - assert (m_pModifier != NULL); - - // Is this being called as part of an undo operation? - if (is_undo != 0) { - - // - // Ensure the modifier is in the state it was when - // the undo operation was recorded - // - m_pModData->Set_Current_Set (m_SetIndex); - m_pModData->Peek_Set (m_SetIndex).Set_Current_Key_Frame (m_KeyframeIndex); - - // - // Apply the original vertex positions to the mesh - // - Apply_Vertex_Data (m_VertexList); - - // - // Notify the mesh of geometry changes - // - m_pModifier->NotifyDependents (FOREVER, PART_GEOM | PART_VERTCOLOR, REFMSG_CHANGE); - m_pModifier->Update_UI (m_pModData); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Redo -// -/////////////////////////////////////////////////////////////////////////// -void -VertexRestoreClass::Redo (void) -{ - assert (m_pMesh != NULL); - assert (m_pModData != NULL); - assert (m_pModifier != NULL); - - // - // Ensure the modifier is in the state it was when - // the undo operation was recorded - // - m_pModData->Set_Current_Set (m_SetIndex); - m_pModData->Peek_Set (m_SetIndex).Set_Current_Key_Frame (m_KeyframeIndex); - - // - // Apply the original vertex positions to the mesh - // - Apply_Vertex_Data (m_RedoVertexList); - - // - // Notify the mesh of geometry changes - // - m_pModifier->NotifyDependents (FOREVER, PART_GEOM | PART_VERTCOLOR, REFMSG_CHANGE); - m_pModifier->Update_UI (m_pModData); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// EndHold -// -/////////////////////////////////////////////////////////////////////////// -void -VertexRestoreClass::EndHold (void) -{ - // - // Record the position of all the verts we are about to change - // (to support redo). - // - Copy_Vertex_State (m_RedoVertexList); - m_pModifier->ClearAFlag (A_HELD); - return ; -} - - -/***************************************************************************************/ -/* -/* End VertexRestoreClass -/* -/***************************************************************************************/ - -/***************************************************************************************/ -/* -/* Start VertexPositionRestoreClass -/* -/***************************************************************************************/ - - -/////////////////////////////////////////////////////////////////////////// -// -// VertexPositionRestoreClass -// -/////////////////////////////////////////////////////////////////////////// -VertexPositionRestoreClass::VertexPositionRestoreClass -( - Mesh * mesh, - MeshDeformClass * modifier, - MeshDeformModData * mod_data -) - : VertexRestoreClass (mesh, modifier, mod_data) -{ - // - // Make a copy of the vertex positions - // - Copy_Vertex_State (m_VertexList); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Copy_Vertex_State -// -/////////////////////////////////////////////////////////////////////////// -void -VertexPositionRestoreClass::Copy_Vertex_State (DEFORM_LIST &list) -{ - // - // Make a copy of each vertex in the current keyframe - // - list.Delete_All (); - MeshDeformSetClass &set_obj = m_pModData->Peek_Set (m_SetIndex); - int count = set_obj.Get_Vertex_Count (m_KeyframeIndex); - for (int index = 0; index < count; index ++) { - const VERT_INFO &data = set_obj.Get_Vertex_Data (m_KeyframeIndex, index); - list.Add (VERT_INFO (data.index, data.value)); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Apply_Vertex_Data -// -/////////////////////////////////////////////////////////////////////////// -void -VertexPositionRestoreClass::Apply_Vertex_Data (DEFORM_LIST &list) -{ - m_pModData->Peek_Set (m_SetIndex).Reset_Key_Frame_Verts (m_KeyframeIndex); - - // - // Apply each vertex in our list - // - for (int index = 0; index < list.Count (); index ++) { - VERT_INFO &info = list[index]; - m_pModData->Set_Vertex_Position (info.index, info.value); - } - - return ; -} - - - -/***************************************************************************************/ -/* -/* End VertexPositionRestoreClass -/* -/***************************************************************************************/ - -/***************************************************************************************/ -/* -/* Start VertexColorRestoreClass -/* -/***************************************************************************************/ - - -/////////////////////////////////////////////////////////////////////////// -// -// VertexColorRestoreClass -// -/////////////////////////////////////////////////////////////////////////// -VertexColorRestoreClass::VertexColorRestoreClass -( - Mesh * mesh, - MeshDeformClass * modifier, - MeshDeformModData * mod_data -) - : VertexRestoreClass (mesh, modifier, mod_data) -{ - // - // Make a copy of the vertex positions - // - Copy_Vertex_State (m_VertexList); - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Copy_Vertex_State -// -/////////////////////////////////////////////////////////////////////////// -void -VertexColorRestoreClass::Copy_Vertex_State (DEFORM_LIST &list) -{ - // - // Make a copy of each vertex color in the current keyframe - // - list.Delete_All (); - MeshDeformSetClass &set_obj = m_pModData->Peek_Set (m_SetIndex); - int count = set_obj.Get_Color_Count (m_KeyframeIndex); - for (int index = 0; index < count; index ++) { - const VERT_INFO &data = set_obj.Get_Color_Data (m_KeyframeIndex, index); - list.Add (VERT_INFO (data.index, data.value, data.color_index)); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Apply_Vertex_Data -// -/////////////////////////////////////////////////////////////////////////// -void -VertexColorRestoreClass::Apply_Vertex_Data (DEFORM_LIST &list) -{ - m_pModData->Peek_Set (m_SetIndex).Reset_Key_Frame_Colors (m_KeyframeIndex); - - // - // Apply each vertex in our list - // - for (int index = 0; index < list.Count (); index ++) { - VERT_INFO &info = list[index]; - m_pModData->Set_Vertex_Color (info.index, info.color_index, info.value); - } - - return ; -} - diff --git a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformUndo.h b/Generals/Code/Tools/WW3D/max2w3d/MeshDeformUndo.h deleted file mode 100644 index acdf8fe47ae..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/MeshDeformUndo.h +++ /dev/null @@ -1,155 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : MeshDeformUndo.h * - * * - * Programmer : Patrick Smith * - * * - * Start Date : 06/08/99 * - * * - * Last Update : - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef __MESH_DEFORM_UNDO_H -#define __MESH_DEFORM_UNDO_H - -#include -#include "Vector.H" -#include "MeshDeformDefs.h" - -// Forward declarations -class MeshDeformClass; -class MeshDeformModData; - - - -/////////////////////////////////////////////////////////////////////////// -// -// VertexRestoreClass -// -/////////////////////////////////////////////////////////////////////////// -class VertexRestoreClass : public RestoreObj -{ - public: - - ////////////////////////////////////////////////////////////////// - // Public constructors/destructor - ////////////////////////////////////////////////////////////////// - VertexRestoreClass (Mesh *mesh, MeshDeformClass *modifier, MeshDeformModData *mod_data); - virtual ~VertexRestoreClass (void) { Free_Vertex_Array (); }; - - ////////////////////////////////////////////////////////////////// - // RestoreObj overrides - ////////////////////////////////////////////////////////////////// - virtual void Restore (int is_undo); - virtual void Redo (void); - virtual int Size (void) { return (m_VertexList.Count () * sizeof (Point3) * 2) + sizeof (VertexRestoreClass); } - virtual void EndHold (void); - - protected: - - ////////////////////////////////////////////////////////////////// - // Protected methods - ////////////////////////////////////////////////////////////////// - virtual void Copy_Vertex_State (DEFORM_LIST &list) = 0; - virtual void Apply_Vertex_Data (DEFORM_LIST &list) = 0; - void Free_Vertex_Array (void); - - ////////////////////////////////////////////////////////////////// - // Protected member data - ////////////////////////////////////////////////////////////////// - Mesh * m_pMesh; - MeshDeformClass * m_pModifier; - MeshDeformModData * m_pModData; - DEFORM_LIST m_VertexList; - DEFORM_LIST m_RedoVertexList; - int m_SetIndex; - int m_KeyframeIndex; -}; - - -/////////////////////////////////////////////////////////////////////////// -// -// VertexPositionRestoreClass -// -/////////////////////////////////////////////////////////////////////////// -class VertexPositionRestoreClass : public VertexRestoreClass -{ - public: - - ////////////////////////////////////////////////////////////////// - // Public constructors/destructor - ////////////////////////////////////////////////////////////////// - VertexPositionRestoreClass (Mesh *mesh, MeshDeformClass *modifier, MeshDeformModData *mod_data); - virtual ~VertexPositionRestoreClass (void) { }; - - ////////////////////////////////////////////////////////////////// - // RestoreObj overrides - ////////////////////////////////////////////////////////////////// - TSTR Description (void) { return TSTR(_T("Vertex Position")); } - - protected: - - ////////////////////////////////////////////////////////////////// - // Protected methods - ////////////////////////////////////////////////////////////////// - virtual void Copy_Vertex_State (DEFORM_LIST &list); - virtual void Apply_Vertex_Data (DEFORM_LIST &list); -}; - - -/////////////////////////////////////////////////////////////////////////// -// -// VertexColorRestoreClass -// -/////////////////////////////////////////////////////////////////////////// -class VertexColorRestoreClass : public VertexRestoreClass -{ - public: - - ////////////////////////////////////////////////////////////////// - // Public constructors/destructor - ////////////////////////////////////////////////////////////////// - VertexColorRestoreClass (Mesh *mesh, MeshDeformClass *modifier, MeshDeformModData *mod_data); - virtual ~VertexColorRestoreClass (void) { }; - - ////////////////////////////////////////////////////////////////// - // RestoreObj overrides - ////////////////////////////////////////////////////////////////// - TSTR Description (void) { return TSTR(_T("Vertex Color")); } - - protected: - - ////////////////////////////////////////////////////////////////// - // Protected methods - ////////////////////////////////////////////////////////////////// - virtual void Copy_Vertex_State (DEFORM_LIST &list); - virtual void Apply_Vertex_Data (DEFORM_LIST &list); -}; - - -#endif //__MESH_DEFORM_UNDO_H diff --git a/Generals/Code/Tools/WW3D/max2w3d/PCToPS2Material.cpp b/Generals/Code/Tools/WW3D/max2w3d/PCToPS2Material.cpp deleted file mode 100644 index c81fcc3ebc7..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/PCToPS2Material.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project name : Buccaneer Bay * - * * - * File name : PCToPS2Material.cpp * - * * - * Programmer : Mike Lytle * - * * - * Start date : 10/22/1999 * - * * - * Last update : 10/27/1999 * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * PTPMC::BeginEditParams -- Change all W3D materials in the mesh to be PS2 compatible. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include -#include -#include -#include "dllmain.h" -#include "resource.h" -#include "util.h" -#include "utilapi.h" -#include "nodelist.h" -#include "gamemtl.h" - - -Class_ID PCToPS2MaterialClassID(0x40d11cee, 0x68881657); - -class PCToPS2MaterialClass : public UtilityObj { - - public: - - void BeginEditParams(Interface *ip,IUtil *iu); - void EndEditParams(Interface *ip,IUtil *iu) {} - void DeleteThis() {delete this;} - -}; - - -/*********************************************************************************************** - * PTPMC::BeginEditParams -- Change all W3D materials in the mesh to be PS2 compatible. * - * * - * * - * * - * * - * HISTORY: * - * 10/27/1999MLL: Created. * - *=============================================================================================*/ -void PCToPS2MaterialClass::BeginEditParams(Interface *ip,IUtil *iu) -{ - // This function is called when the utility is chosen. - // Since we don't need any window gadgets, we'll just go through all the materials right away. - INode *root = ip->GetRootNode(); - - INodeListClass *meshlist = NULL; - - // Change all materials associated with the mesh, starting with the root node. - if (root) { - meshlist = new INodeListClass(root, 0); - - if (meshlist) { - int i; - - for (i = 0; i < meshlist->Num_Nodes(); i++) { - - Mtl *nodemtl = ((*meshlist)[i])->GetMtl(); - - if (nodemtl == NULL) { - // No material on this node, go to the next. - continue; - } - - if (!nodemtl->IsMultiMtl()) { - // Only change those that are W3D materials. - if (nodemtl->ClassID() == GameMaterialClassID) { - int pass; - - for (pass = 0; pass < ((GameMtl*)nodemtl)->Get_Pass_Count(); pass++) { - // Change the material for each pass. - ((GameMtl*)nodemtl)->Compute_PS2_Shader_From_PC_Shader(pass); - } - - } - } else { - - // Loop through all sub materials of the multi-material. - for (unsigned mi = 0; mi < nodemtl->NumSubMtls(); mi++) { - - // Only change those that are W3D materials. - if (nodemtl->GetSubMtl(mi)->ClassID() == GameMaterialClassID) { - int pass; - - for (pass = 0; pass < ((GameMtl*)nodemtl->GetSubMtl(mi))->Get_Pass_Count(); pass++) { - // Change the material for each pass. - ((GameMtl*)nodemtl->GetSubMtl(mi))->Compute_PS2_Shader_From_PC_Shader(pass); - } - } else if (nodemtl->GetSubMtl(mi)->ClassID() == PS2GameMaterialClassID) { - } - } - } - } - } - - delete meshlist; - } -} - -class PCToPS2MaterialClassDesc:public ClassDesc { - -public: - int IsPublic() { return 1; } - void * Create(BOOL loading) - { - return ((void*)new PCToPS2MaterialClass); - } - const TCHAR * ClassName() { return Get_String(IDS_PC_TO_PS2_MAT_CONVERTER); } - SClass_ID SuperClassID() { return UTILITY_CLASS_ID; } - Class_ID ClassID() { return PCToPS2MaterialClassID; } - const TCHAR* Category() { return _T(""); } -}; - -static PCToPS2MaterialClassDesc _PCToPS2MaterialCD; - -ClassDesc * Get_PS2_Material_Conversion() { return &_PCToPS2MaterialCD; } diff --git a/Generals/Code/Tools/WW3D/max2w3d/PS2GameMtl.cpp b/Generals/Code/Tools/WW3D/max2w3d/PS2GameMtl.cpp deleted file mode 100644 index e6a89eeafe9..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/PS2GameMtl.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project name : Buccaneer Bay * - * * - * File name : PS2GameMtl.cpp * - * * - * Programmer : Mike Lytle * - * * - * Start date : 10/12/1999 * - * * - * Last update : 10/12/1999 * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "gamemtl.h" -#include -#include -#include -#include "dllmain.h" -#include "resource.h" -#include "util.h" - - - -/***************************************************************** -* -* PS2 GameMtl Class Descriptor -* -*****************************************************************/ -Class_ID PS2GameMaterialClassID(0x2ed62ad7, 0x50571dfd); - -// This adds W3D PS2 choice to the Max material selector. -class PS2GameMaterialClassDesc:public ClassDesc { - -public: - int IsPublic() { return 1; } - void * Create(BOOL loading) - { - GameMtl *mtl = new GameMtl(loading); - mtl->Set_Shader_Type(GameMtl::STE_PS2_SHADER); - return ((void*)mtl); - } - const TCHAR * ClassName() { return Get_String(IDS_PS2_GAMEMTL); } - SClass_ID SuperClassID() { return MATERIAL_CLASS_ID; } - Class_ID ClassID() { return PS2GameMaterialClassID; } - const TCHAR* Category() { return _T(""); } -}; - -static PS2GameMaterialClassDesc _PS2GameMaterialCD; - -ClassDesc * Get_PS2_Game_Material_Desc() { return &_PS2GameMaterialCD; } diff --git a/Generals/Code/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.cpp b/Generals/Code/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.cpp deleted file mode 100644 index b7936662970..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.cpp +++ /dev/null @@ -1,371 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project name : Buccaneer Bay * - * * - * File name : PS2GameMtlShaderDlg.cpp * - * * - * Programmer : Mike Lytle * - * * - * Start date : 10/12/1999 * - * * - * Last update : 10/12/1999 * - * * - * Taken from GTH's GameMtlShaderDlg.cpp * - *---------------------------------------------------------------------------------------------* - * Functions: * - * PS2GameMtlShaderDlg -- Constructor. * - * PGMSD::Dialog_Proc -- Respond to user selections. * - * PGMSD::ReloadDialog -- Setup the dialog box. * - * PGMSD::Apply_Preset -- Notify the material of the values for the selected setting. * - * PGMSD::Set_Preset -- Sets the dialog to one of the presets or custom. * - * PGMSD::CompareShaderToBlendPreset -- Determine if the settings conform to one of the prese* - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "PS2GameMtlShaderDlg.h" -#include "GameMtlDlg.h" -#include "gamemtl.h" -#include "resource.h" - - -#define NUM_PS2_SHADER_BLEND_PRESETS 7 - -static char * _PS2ShaderBlendSettingPresetNames[NUM_PS2_SHADER_BLEND_PRESETS + 1] = -{ - "Opaque", - "Additive", - "Source Subtracted", - "Destination Subtracted", - "Alpha Blend", - "Alpha Test", - "Alpha Test and Blend", - "------ Custom -----" -}; - -struct PS2ShaderBlendSettingPreset -{ - int A; - int B; - int C; - int D; - bool DepthMask; - bool AlphaTest; -}; - -// (A - B) * C + D -static const PS2ShaderBlendSettingPreset PS2ShaderBlendSettingPresets[NUM_PS2_SHADER_BLEND_PRESETS] = { - {PSS_SRC, PSS_ZERO, PSS_ONE, PSS_ZERO, true, false}, // Opaque - {PSS_SRC, PSS_ZERO, PSS_ONE, PSS_DEST, false, false}, // Additive - {PSS_DEST, PSS_SRC, PSS_ONE, PSS_ZERO, false, false}, // Src subtracted - {PSS_SRC, PSS_DEST, PSS_ONE, PSS_ZERO, false, false}, // Dest subtracted - {PSS_SRC, PSS_DEST, PSS_SRC_ALPHA, PSS_DEST, false, false}, // Alpha blend - {PSS_SRC, PSS_ZERO, PSS_ONE, PSS_ZERO, true, true}, // Alpha test - {PSS_SRC, PSS_DEST, PSS_SRC_ALPHA, PSS_DEST, true, true}, // Alpha test & blend -}; - - -/*********************************************************************************************** - * PS2GameMtlShaderDlg -- Constructor. * - * * - * * - * * - * * - * HISTORY: * - * 10/12/1999MLL: Created. * - *=============================================================================================*/ -PS2GameMtlShaderDlg::PS2GameMtlShaderDlg -( - HWND parent, - IMtlParams * imp, - GameMtl * mtl, - int pass -) : GameMtlFormClass(imp,mtl,pass) -{ - Create_Form(parent, IDD_GAMEMTL_PS2_SHADER); -} - - -/*********************************************************************************************** - * PGMSD::Dialog_Proc -- Respond to user selections. * - * * - * * - * * - * * - * HISTORY: * - * 10/12/1999MLL: Created. * - *=============================================================================================*/ -BOOL PS2GameMtlShaderDlg::Dialog_Proc (HWND dlg_wnd, UINT message, WPARAM wparam, LPARAM lparam) -{ - int cursel; - int i; - int id = LOWORD(wparam); - int code = HIWORD(wparam); - - switch (message) - { - - case WM_INITDIALOG: - for(i = 0; i <= NUM_PS2_SHADER_BLEND_PRESETS; i++) { - SendDlgItemMessage(dlg_wnd,IDC_PS2_PRESET_COMBO,CB_ADDSTRING,0,(LONG)_PS2ShaderBlendSettingPresetNames[i]); - } - SendDlgItemMessage(dlg_wnd,IDC_PS2_PRESET_COMBO,CB_SETCURSEL,0,0); - break; - - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - { - IParams->RollupMouseMessage(dlg_wnd,message,wparam,lparam); - } - return FALSE; - - case WM_COMMAND: - { - if (code == CBN_SELCHANGE) { - - switch (id) - { - // Shared by both shaders. - case IDC_DEPTHCOMPARE_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_DEPTHCOMPARE_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Depth_Compare(PassIndex,cursel); - break; - case IDC_PRIGRADIENT_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_PRIGRADIENT_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Pri_Gradient(PassIndex,cursel); - TheMtl->Notify_Changed(); - break; - case IDC_SECGRADIENT_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_SECGRADIENT_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Sec_Gradient(PassIndex,cursel); - TheMtl->Notify_Changed(); - break; - case IDC_DETAILCOLOR_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_DETAILCOLOR_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Detail_Color_Func(PassIndex,cursel); - TheMtl->Notify_Changed(); - break; - case IDC_DETAILALPHA_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_DETAILALPHA_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_Detail_Alpha_Func(PassIndex,cursel); - TheMtl->Notify_Changed(); - break; - - // Playstation 2 specific. - case IDC_PS2_PRESET_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_PS2_PRESET_COMBO,CB_GETCURSEL,0,0); - Apply_Preset(cursel); - break; - case IDC_A_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_A_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_PS2_Shader_Param_A(PassIndex,cursel); - TheMtl->Notify_Changed(); - Set_Preset(); - break; - case IDC_B_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_B_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_PS2_Shader_Param_B(PassIndex,cursel); - TheMtl->Notify_Changed(); - Set_Preset(); - break; - case IDC_C_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_C_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_PS2_Shader_Param_C(PassIndex,cursel); - TheMtl->Notify_Changed(); - Set_Preset(); - break; - case IDC_D_COMBO: - cursel = SendDlgItemMessage(dlg_wnd,IDC_D_COMBO,CB_GETCURSEL,0,0); - TheMtl->Set_PS2_Shader_Param_D(PassIndex,cursel); - TheMtl->Notify_Changed(); - Set_Preset(); - break; - } - - } else { - - switch(id) { - - case IDC_DEPTHMASK_CHECK: - if (SendDlgItemMessage(dlg_wnd,IDC_DEPTHMASK_CHECK,BM_GETCHECK,0,0)) { - TheMtl->Set_Depth_Mask(PassIndex,W3DSHADER_DEPTHMASK_WRITE_ENABLE); - } else { - TheMtl->Set_Depth_Mask(PassIndex,W3DSHADER_DEPTHMASK_WRITE_DISABLE); - } - Set_Preset(); - break; - - case IDC_ALPHATEST_CHECK: - if (SendDlgItemMessage(dlg_wnd,IDC_ALPHATEST_CHECK,BM_GETCHECK,0,0)) { - TheMtl->Set_Alpha_Test(PassIndex,W3DSHADER_ALPHATEST_ENABLE); - } else { - TheMtl->Set_Alpha_Test(PassIndex,W3DSHADER_ALPHATEST_DISABLE); - } - Set_Preset(); - break; - - case IDC_SHADER_DEFAULTS_BUTTON: - Set_Advanced_Defaults(); - break; - } - } - } - } - - return FALSE; -} - -/*********************************************************************************************** - * PGMSD::ReloadDialog -- Setup the dialog box. * - * * - * * - * * - * * - * HISTORY: * - * 10/12/1999MLL: Created. * - *=============================================================================================*/ -void PS2GameMtlShaderDlg::ReloadDialog(void) -{ - DebugPrint("GameMtlShaderDlg::ReloadDialog\n"); - SendDlgItemMessage(m_hWnd, IDC_PRIGRADIENT_COMBO, CB_SETCURSEL, TheMtl->Get_Pri_Gradient(PassIndex), 0 ); - SendDlgItemMessage(m_hWnd, IDC_SECGRADIENT_COMBO, CB_SETCURSEL, TheMtl->Get_Sec_Gradient(PassIndex), 0 ); - SendDlgItemMessage(m_hWnd, IDC_DEPTHCOMPARE_COMBO, CB_SETCURSEL, TheMtl->Get_Depth_Compare(PassIndex), 0 ); - SendDlgItemMessage(m_hWnd, IDC_DETAILCOLOR_COMBO, CB_SETCURSEL, TheMtl->Get_Detail_Color_Func(PassIndex), 0 ); - SendDlgItemMessage(m_hWnd, IDC_DETAILALPHA_COMBO, CB_SETCURSEL, TheMtl->Get_Detail_Alpha_Func(PassIndex), 0 ); - SendDlgItemMessage(m_hWnd, IDC_A_COMBO, CB_SETCURSEL, TheMtl->Get_PS2_Shader_Param_A(PassIndex), 0); - SendDlgItemMessage(m_hWnd, IDC_B_COMBO, CB_SETCURSEL, TheMtl->Get_PS2_Shader_Param_B(PassIndex), 0); - SendDlgItemMessage(m_hWnd, IDC_C_COMBO, CB_SETCURSEL, TheMtl->Get_PS2_Shader_Param_C(PassIndex), 0); - SendDlgItemMessage(m_hWnd, IDC_D_COMBO, CB_SETCURSEL, TheMtl->Get_PS2_Shader_Param_D(PassIndex), 0); - - Set_Preset(); - - SetCheckBox(m_hWnd,IDC_DEPTHMASK_CHECK, TheMtl->Get_Depth_Mask(PassIndex)); - SetCheckBox(m_hWnd,IDC_ALPHATEST_CHECK, TheMtl->Get_Alpha_Test(PassIndex)); -} - - -/*********************************************************************************************** - * PGMSD::Apply_Preset -- Notify the material of the values for the selected setting. * - * * - * * - * * - * * - * HISTORY: * - * 10/12/1999MLL: Created. * - *=============================================================================================*/ -void PS2GameMtlShaderDlg::Apply_Preset(int preset_index) -{ - if (preset_index < 0 || preset_index >= NUM_PS2_SHADER_BLEND_PRESETS) return; - - const PS2ShaderBlendSettingPreset &preset = PS2ShaderBlendSettingPresets[preset_index]; - - int depth_mask = preset.DepthMask ? W3DSHADER_DEPTHMASK_WRITE_ENABLE : W3DSHADER_DEPTHMASK_WRITE_DISABLE; - TheMtl->Set_Depth_Mask(PassIndex, depth_mask); - - int alpha_test = preset.AlphaTest ? W3DSHADER_ALPHATEST_ENABLE : W3DSHADER_ALPHATEST_DISABLE; - TheMtl->Set_Alpha_Test(PassIndex, alpha_test); - - TheMtl->Set_PS2_Shader_Param_A(PassIndex, preset.A); - TheMtl->Set_PS2_Shader_Param_B(PassIndex, preset.B); - TheMtl->Set_PS2_Shader_Param_C(PassIndex, preset.C); - TheMtl->Set_PS2_Shader_Param_D(PassIndex, preset.D); - - TheMtl->Notify_Changed(); - ReloadDialog(); - - if (TheMtl->Compute_PC_Shader_From_PS2_Shader(PassIndex)) - SetWindowText(GetDlgItem(m_hWnd,IDC_COMPATIBLE), " Compatible"); - else - SetWindowText(GetDlgItem(m_hWnd,IDC_COMPATIBLE), " NOT Compatible"); - -} - -/*********************************************************************************************** - * PGMSD::Set_Preset -- Sets the dialog to one of the presets or custom. * - * * - * * - * * - * * - * HISTORY: * - * 10/12/1999MLL: Created. * - *=============================================================================================*/ -void PS2GameMtlShaderDlg::Set_Preset(void) -{ - for (int i = 0; i < NUM_PS2_SHADER_BLEND_PRESETS; i++) { - if (CompareShaderToBlendPreset(PS2ShaderBlendSettingPresets[i])) break; - } - SendDlgItemMessage(m_hWnd, IDC_PS2_PRESET_COMBO, CB_SETCURSEL, i, 0); - - if (TheMtl->Compute_PC_Shader_From_PS2_Shader(PassIndex)) - SetWindowText(GetDlgItem(m_hWnd,IDC_COMPATIBLE), " Compatible"); - else - SetWindowText(GetDlgItem(m_hWnd,IDC_COMPATIBLE), " NOT Compatible"); -} - -/*********************************************************************************************** - * PGMSD::CompareShaderToBlendPreset -- Determine if the settings conform to one of the presets* - * * - * * - * * - * * - * HISTORY: * - * 10/12/1999MLL: Created. * - *=============================================================================================*/ -bool PS2GameMtlShaderDlg::CompareShaderToBlendPreset(const PS2ShaderBlendSettingPreset &blend_preset) -{ - bool depthmask = TheMtl->Get_Depth_Mask(PassIndex) != W3DSHADER_DEPTHMASK_WRITE_DISABLE; - if (depthmask != blend_preset.DepthMask) return false; - bool alphatest = TheMtl->Get_Alpha_Test(PassIndex) != W3DSHADER_ALPHATEST_DISABLE; - if (alphatest != blend_preset.AlphaTest) return false; - - if (TheMtl->Get_PS2_Shader_Param_A(PassIndex) != blend_preset.A) return false; - if (TheMtl->Get_PS2_Shader_Param_B(PassIndex) != blend_preset.B) return false; - if (TheMtl->Get_PS2_Shader_Param_C(PassIndex) != blend_preset.C) return false; - if (TheMtl->Get_PS2_Shader_Param_D(PassIndex) != blend_preset.D) return false; - - return true; -} - - -/*********************************************************************************************** - * GameMtlShaderDlg::Set_Advanced_Defaults -- set advanced settings to defaults * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/26/99 NH : Created. * - *=============================================================================================*/ -void PS2GameMtlShaderDlg::Set_Advanced_Defaults(void) -{ - TheMtl->Set_Pri_Gradient(PassIndex, PSS_PRIGRADIENT_MODULATE); - TheMtl->Set_Depth_Compare(PassIndex, PSS_DEPTHCOMPARE_PASS_LEQUAL); - TheMtl->Set_Detail_Color_Func(PassIndex, W3DSHADER_DETAILCOLORFUNC_DEFAULT); - TheMtl->Set_Detail_Alpha_Func(PassIndex, W3DSHADER_DETAILALPHAFUNC_DEFAULT); - - TheMtl->Notify_Changed(); - ReloadDialog(); -} \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.h b/Generals/Code/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.h deleted file mode 100644 index adbe1fa0ee9..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project name : Buccaneer Bay * - * * - * File name : PS2GameMtlShaderDlg.h * - * * - * Programmer : Mike Lytle * - * * - * Start date : 10/12/1999 * - * * - * Last update : 10/12/1999 * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef PS2GAMEMTLSHADERDLG_H -#define PS2GAMEMTLSHADERDLG_H - -#include -#include "GameMtlForm.h" - -// This class was taken from GTH's GameMtlShaderDlg. - -class GameMtl; -struct PS2ShaderBlendSettingPreset; - -class PS2GameMtlShaderDlg : public GameMtlFormClass -{ - -public: - - PS2GameMtlShaderDlg(HWND parent, IMtlParams * imp, GameMtl * m, int pass); - - virtual BOOL Dialog_Proc (HWND dlg_wnd, UINT message, WPARAM wparam, LPARAM lparam); - - void ReloadDialog(void); - - // Pure virtual that must be defined. - void ActivateDlg(BOOL onOff) {} - -private: - - void Apply_Preset(int preset_index); - void Set_Preset(void); - bool CompareShaderToBlendPreset(const PS2ShaderBlendSettingPreset &blend_preset); - void Set_Advanced_Defaults(void); -}; - -#endif \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/SceneSetup.cpp b/Generals/Code/Tools/WW3D/max2w3d/SceneSetup.cpp deleted file mode 100644 index bce702d5e90..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/SceneSetup.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/SceneSetup.cpp $* - * * - * $Author:: Andre_a $* - * * - * $Modtime:: 10/15/99 3:33p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * wwSceneSetup -- Allows the user to select how many LOD and damage models to create. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -/* -** SceneSetup.cpp - Implements the "wwSceneSetup" MAXScript function to -** present a nice dialog to the user for getting a number of parameters -** that will governs the number, placement, and type of LOD and Damage -** models created in the scene. -*/ - - -#include "SceneSetupDlg.h" - -#undef STRICT -#include -#include -#include -#include - - -/* -** Let MAXScript know we're implementing new built-in functions. -*/ -def_visible_primitive(scene_setup, "wwSceneSetup"); - - -/*********************************************************************************************** - * scene_setup_cf - MAXScript function wwSceneSetup * - * * - * wwSceneSetup - Usage: wwSceneSetup arg_array * - * * - * INPUT: * - * The contents of the given array is assumed to be as follows: * - * lod_count (int) - the number of LOD models that will be created * - * lod_offset (float) - X offset to move the LODs by * - * lod_clone (int) - 1==copy 2==instance 3==reference * - * damage_count (int) - the number of damage models that will be created * - * damage_offset (float) - Y offset to move the LODs by * - * damage_clone (int) - 1==copy 2==instance 3==reference * - * * - * OUTPUT: * - * The function returns an array of the new values the user selected in the same format as * - * above. - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/27/1999 AJA : Created. * - *=============================================================================================*/ -Value * scene_setup_cf (Value **arg_list, int count) -{ - // We don't want any arguments for this function. - check_arg_count("wwSceneSetup", 1, count); - type_check(arg_list[0], Array, "Parameter array"); - - SceneSetupDlg dlg(MAXScript_interface); - one_typed_value_local(Array* result); - - // Read the initial values out of the array. - Array *args = (Array*)(arg_list[0]); - dlg.m_LodCount = (args->get(1))->to_int(); - dlg.m_LodOffset = (args->get(2))->to_float(); - dlg.m_LodProc = (args->get(3))->to_int(); - dlg.m_DamageCount = (args->get(4))->to_int(); - dlg.m_DamageOffset = (args->get(5))->to_float(); - dlg.m_DamageProc = (args->get(6))->to_int(); - - // Display the dialog - if (dlg.DoModal() == IDCANCEL) - { - pop_value_locals(); - return &undefined; - } - - // Stuff the values the user chose into the array we'll return. - vl.result = new Array(6); - vl.result->append(Integer::intern(dlg.m_LodCount)); - vl.result->append(Float::intern(dlg.m_LodOffset)); - vl.result->append(Integer::intern(dlg.m_LodProc)); - vl.result->append(Integer::intern(dlg.m_DamageCount)); - vl.result->append(Float::intern(dlg.m_DamageOffset)); - vl.result->append(Integer::intern(dlg.m_DamageProc)); - - // Return the array of new values. - return_value(vl.result); -} - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/SceneSetupDlg.cpp b/Generals/Code/Tools/WW3D/max2w3d/SceneSetupDlg.cpp deleted file mode 100644 index 69c81b74580..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/SceneSetupDlg.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/SceneSetupDlg.cpp $* - * * - * $Author:: Andre_a $* - * * - * $Modtime:: 10/15/99 3:37p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -// SceneSetupDlg.cpp : implementation file -// - -#include "SceneSetupDlg.h" -#include -#include - -static BOOL CALLBACK _thunk_dialog_proc (HWND hWnd, UINT uMsg, WPARAM wAparam, LPARAM lParam); - - - -///////////////////////////////////////////////////////////////////////////// -// SceneSetupDlg dialog - - -SceneSetupDlg::SceneSetupDlg(Interface *max_interface) -{ - m_DamageCount = 0; - m_DamageOffset = -100.0f; - m_LodCount = 0; - m_LodOffset = -100.0f; - m_DamageProc = 3; - m_LodProc = 3; - m_hWnd = NULL; - m_MaxInterface = max_interface; - assert(max_interface != NULL); -} - - -///////////////////////////////////////////////////////////////////////////// -// SceneSetupDlg Protected Methods - -void SceneSetupDlg::SetEditInt (int control_id, int value) -{ - char buf[64]; - sprintf(buf, "%d", value); - HWND edit = GetDlgItem(m_hWnd, control_id); - assert(edit != NULL); - SetWindowText(edit, buf); -} - -void SceneSetupDlg::SetEditFloat (int control_id, float value) -{ - char buf[64]; - sprintf(buf, "%.0f", value); - HWND edit = GetDlgItem(m_hWnd, control_id); - assert(edit != NULL); - SetWindowText(edit, buf); -} - -int SceneSetupDlg::GetEditInt (int control_id) -{ - char buf[64]; - HWND edit = GetDlgItem(m_hWnd, control_id); - assert(edit != NULL); - GetWindowText(edit, buf, sizeof(buf)); - int value = 0; - sscanf(buf, "%d", &value); - return value; -} - -float SceneSetupDlg::GetEditFloat (int control_id) -{ - char buf[64]; - HWND edit = GetDlgItem(m_hWnd, control_id); - assert(edit != NULL); - GetWindowText(edit, buf, sizeof(buf)); - float value = 0; - sscanf(buf, "%f", &value); - return value; -} - -bool SceneSetupDlg::ValidateEditFloat (int control_id) -{ - char buf[64]; - HWND edit = GetDlgItem(m_hWnd, control_id); - assert(edit != NULL); - GetWindowText(edit, buf, sizeof(buf)); - float value = 0; - if (sscanf(buf, "%f", &value) == 1) - return true; - else - return false; -} - -///////////////////////////////////////////////////////////////////////////// -// SceneSetupDlg Public Methods - -int SceneSetupDlg::DoModal (void) -{ - // Put up the dialog box. - BOOL result = DialogBoxParam(AppInstance, MAKEINTRESOURCE(IDD_SCENE_SETUP), - m_MaxInterface->GetMAXHWnd(), (DLGPROC)_thunk_dialog_proc, - (LPARAM)this); - - // Return IDOK if the user accepted the new settings. - return (result == 1) ? IDOK : IDCANCEL; -} - -///////////////////////////////////////////////////////////////////////////// -// SceneSetupDlg DialogProc - -BOOL CALLBACK _thunk_dialog_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - static SceneSetupDlg *dialog = NULL; - - if (uMsg == WM_INITDIALOG) - { - dialog = (SceneSetupDlg*)lParam; - dialog->m_hWnd = hWnd; - } - - if (dialog) - return dialog->DialogProc(hWnd, uMsg, wParam, lParam); - else - return 0; -} - -BOOL CALLBACK SceneSetupDlg::DialogProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - int code = HIWORD(wParam); - - switch (uMsg) - { - - /******************************************************************* - * WM_INITDIALOG - * - * Initialize all of the custom controls for the dialog box - * - *******************************************************************/ - case WM_INITDIALOG: - - OnInitDialog(); - return TRUE; - - - /******************************************************************* - * WM_COMMAND - * - * - *******************************************************************/ - case WM_COMMAND: - - switch (LOWORD(wParam)) - { - case IDOK: - - if (OnOK() == FALSE) - return TRUE; - - SetCursor(LoadCursor(NULL, IDC_WAIT)); - EndDialog(m_hWnd, 1); - break; - - case IDCANCEL: - EndDialog(m_hWnd, 0); - break; - - } - return TRUE; - - } - - return FALSE; -} - - -///////////////////////////////////////////////////////////////////////////// -// SceneSetupDlg message handlers - -void SceneSetupDlg::OnInitDialog() -{ - CenterWindow(m_hWnd, m_MaxInterface->GetMAXHWnd()); - SetCursor(LoadCursor(NULL, IDC_ARROW)); - - // Select the appropriate radio buttons. - switch (m_LodProc) - { - case 1: - CheckDlgButton(m_hWnd, IDC_LOD_AS_COPY, BST_CHECKED); - break; - case 2: - CheckDlgButton(m_hWnd, IDC_LOD_AS_INSTANCE, BST_CHECKED); - break; - case 3: - CheckDlgButton(m_hWnd, IDC_LOD_AS_REFERENCE, BST_CHECKED); - break; - } - switch (m_DamageProc) - { - case 1: - CheckDlgButton(m_hWnd, IDC_DAMAGE_AS_COPY, BST_CHECKED); - break; - case 2: - CheckDlgButton(m_hWnd, IDC_DAMAGE_AS_INSTANCE, BST_CHECKED); - break; - case 3: - CheckDlgButton(m_hWnd, IDC_DAMAGE_AS_REFERENCE, BST_CHECKED); - break; - } - - // Set the text for the edit boxes. - SetEditInt(IDC_LOD_COUNT, m_LodCount); - SetEditFloat(IDC_LOD_OFFSET, m_LodOffset); - SetEditInt(IDC_DAMAGE_COUNT, m_DamageCount); - SetEditFloat(IDC_DAMAGE_OFFSET, m_DamageOffset); -} - -BOOL SceneSetupDlg::OnOK() -{ - if (!ValidateEditFloat(IDC_LOD_OFFSET)) - { - MessageBox(m_hWnd, "You must enter a valid number for the LOD Offset.", - "Not a Number", MB_OK); - SetFocus(GetDlgItem(m_hWnd, IDC_LOD_OFFSET)); - return FALSE; - } - if (!ValidateEditFloat(IDC_DAMAGE_OFFSET)) - { - MessageBox(m_hWnd, "You must enter a valid number for the Damage Offset.", - "Not a Number", MB_OK); - SetFocus(GetDlgItem(m_hWnd, IDC_DAMAGE_OFFSET)); - return FALSE; - } - - // Get the clone procedure the user wants to use. - if (IsDlgButtonChecked(m_hWnd, IDC_LOD_AS_COPY)) - m_LodProc = 1; - else if (IsDlgButtonChecked(m_hWnd, IDC_LOD_AS_INSTANCE)) - m_LodProc = 2; - else if (IsDlgButtonChecked(m_hWnd, IDC_LOD_AS_REFERENCE)) - m_LodProc = 3; - if (IsDlgButtonChecked(m_hWnd, IDC_DAMAGE_AS_COPY)) - m_DamageProc = 1; - else if (IsDlgButtonChecked(m_hWnd, IDC_DAMAGE_AS_INSTANCE)) - m_DamageProc = 2; - else if (IsDlgButtonChecked(m_hWnd, IDC_DAMAGE_AS_REFERENCE)) - m_DamageProc = 3; - - // Get the other values the user selected. - m_LodCount = GetEditInt(IDC_LOD_COUNT); - m_LodOffset = GetEditFloat(IDC_LOD_OFFSET); - m_DamageCount = GetEditInt(IDC_DAMAGE_COUNT); - m_DamageOffset = GetEditFloat(IDC_DAMAGE_OFFSET); - - return TRUE; -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/SceneSetupDlg.h b/Generals/Code/Tools/WW3D/max2w3d/SceneSetupDlg.h deleted file mode 100644 index c76bb972955..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/SceneSetupDlg.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/SceneSetupDlg.h $* - * * - * $Author:: Andre_a $* - * * - * $Modtime:: 10/15/99 4:24p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef SCENESETUPDLG_H -#define SCENESETUPDLG_H - -// SceneSetupDlg.h : header file -// - -#include "dllmain.h" -#include "resource.h" - - -class Interface; - -///////////////////////////////////////////////////////////////////////////// -// SceneSetupDlg dialog - -class SceneSetupDlg -{ -public: - - // Construction - SceneSetupDlg(Interface *max_interface); - - // Methods - int DoModal (void); - - // DialogProc - BOOL CALLBACK DialogProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - - // Dialog data associated with GUI components. - enum { IDD = IDD_SCENE_SETUP }; - int m_DamageCount; - float m_DamageOffset; - int m_LodCount; - float m_LodOffset; - int m_LodProc; - int m_DamageProc; - - // Dialog Data - HWND m_hWnd; - -protected: - - // Message Handlers - void OnInitDialog (void); - BOOL OnOK (void); // TRUE if ok to close dialog - - // Protected Methods - void SetEditInt (int control_id, int value); - void SetEditFloat (int control_id, float value); - int GetEditInt (int control_id); - float GetEditFloat (int control_id); - bool ValidateEditFloat (int control_id); - - // Protected Data - Interface *m_MaxInterface; -}; - -#endif diff --git a/Generals/Code/Tools/WW3D/max2w3d/SkinCopy.cpp b/Generals/Code/Tools/WW3D/max2w3d/SkinCopy.cpp deleted file mode 100644 index 7603f4bcf0d..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/SkinCopy.cpp +++ /dev/null @@ -1,526 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/SkinCopy.cpp $* - * * - * $Author:: Andre_a $* - * * - * $Modtime:: 11/03/99 11:51a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * find_skin_binding -- Find the "WWSkin Binding" modifier on this object. * - * find_skin_wsm -- Finds the node for the WWSkin WSM used by this object. * - * get_skin_wsm_obj -- Gets the SkinWSMObjectClass from a WWSkin WSM node. * - * duplicate_wsm -- Duplicates a WWSkin WSM * - * find_equivalent_node -- Searches a hierarchy for an object equivalent to the given one. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -/* --- Copy the skin info for this object into the target object. --- If we haven't copied the WSM yet, it will be copied. -new_wsm = wwCopySkinInfo source_root target_root new_wsm -*/ - -#include // Main MAXScript header -#include // MAX* Wrapper objects -#include // def_* functions to create static function headers - -#include -#include - -#include "skin.h" -#include "util.h" -#include "w3d_file.h" - - -/* -** Forward declarations -*/ - -Value *find_skin_node_in_tree (INode *root); - -SkinModifierClass *find_skin_binding (INode *skinned_obj); - -INode *find_skin_wsm (INode *skinned_obj); - -SkinWSMObjectClass *get_skin_wsm_obj (INode *wsm_node); - -INode *duplicate_wsm (INode *skinned_obj, INode *tree_root); - -INode *find_equivalent_node (INode *source, INode *tree, bool name_is_valid = false); - -Value *copy_skin_info (INode *source, INode *target, INode *wsm); - -IDerivedObject *setup_wsm_derived_obj (INode *node); - -ModContext *find_skin_mod_context (INode *node); - - -/* -** Let MAXScript know we're implementing a new built-in function. -*/ -def_visible_primitive(find_skin_node, "wwFindSkinNode"); -def_visible_primitive(copy_skin_info, "wwCopySkinInfo"); -def_visible_primitive(dupe_skin_wsm, "wwDuplicateSkinWSM"); - - -/* -** -** MAXScript Function: -** wwFindSkinNode - Usage: wwFindSkinNode tree_root_node -** -** Searches the given hierarchy tree for the node containing -** the WWSkin WSM. Returns the node if found, otherwise it -** returns undefined. -** -** Used by the SceneSetup MAXScript. -*/ -Value *find_skin_node_cf (Value **arg_list, int count) -{ - // Verify the number and type of the arguments. - check_arg_count("wwFindSkinNode", 1, count); - type_check(arg_list[0], MAXNode, "Tree Root INode"); - - // Get the INode that was passed in. - INode *tree_root = arg_list[0]->to_node(); - - // Search the tree for the WWSkin WSM, and return - // the node which references it. - return find_skin_node_in_tree(tree_root); -} - -/* -** -** MAXScript Function: -** wwCopySkinInfo - Usage: wwCopySkinInfo from_node to_node wsm_node to_tree_root -** -** Copies the skin info for the given node to the target node. -** If wsm_node is "undefined" then we will create a new WWSkin WSM -** with the same values as the one being used by from_node. -** If from_node doesn't have a WWSkin binding, the return value -** is "undefined". If the function succeeds, it returns the -** wsm_node (the new WSM if it was created, otherwise the old wsm_node). -** -** Used by the SceneSetup MAXScript. -*/ -Value * copy_skin_info_cf (Value **arg_list, int count) -{ - // Verify the number and type of the arguments. - check_arg_count("wwCopySkinInfo", 4, count); - type_check(arg_list[0], MAXNode, "Source INode"); - type_check(arg_list[1], MAXNode, "Target INode"); - type_check(arg_list[3], MAXNode, "Target Tree Root INode"); - - // Get the INode pointers that were passed in. - INode *src_node = arg_list[0]->to_node(); - INode *dest_node = arg_list[1]->to_node(); - INode *wsm_node = NULL; - INode *tree_root = arg_list[3]->to_node(); - if (arg_list[2] == &undefined) - { - // Duplicate the WSM used by src_node. - wsm_node = duplicate_wsm(find_skin_wsm(src_node), tree_root); - if (wsm_node == NULL) - return &undefined; - } - else - wsm_node = arg_list[2]->to_node(); - - return copy_skin_info(src_node, dest_node, wsm_node); -} - - -/* -** -** MAXScript Function: -** wwDuplicateSkinWSM - Usage: wwDuplicateSkinWSM wwskin_wsm_node tree_root -** -** Duplicates the given WWSkin WSM. tree_root is the root node of a hierarchy -** containing bones similar to the ones used by the given WSM. The hierarchy -** will be searched for equivalent bones (ie. names the same except their -** extension), and those bones will be used by the newly duplicated WSM. -** -** Used by the SceneSetup MAXScript. -*/ -Value * dupe_skin_wsm_cf (Value **arg_list, int count) -{ - // Verify the number and type of the arguments. - check_arg_count("wwDuplicateSkinWSM", 2, count); - type_check(arg_list[0], MAXNode, "WWSkin Object INode"); - type_check(arg_list[1], MAXNode, "Target Tree Root INode"); - - // Get the INode pointers that were passed in. - INode *wsm_node = arg_list[0]->to_node(); - INode *root_node = arg_list[1]->to_node(); - - // Return the duplicated WWSkin WSM. - INode *dupe = duplicate_wsm(wsm_node, root_node); - if (!dupe) - return &undefined; - else - { - // Return the WSM. - one_typed_value_local(Value* wsm_node); - vl.wsm_node = MAXNode::intern(dupe); - return_value(vl.wsm_node); - } -} - - -Value *find_skin_node_in_tree (INode *root) -{ - if (root == NULL) - return &undefined; - - // Is this the node we're looking for? - if (get_skin_wsm_obj(root)) - { - one_typed_value_local(Value* wsm_node); - vl.wsm_node = MAXNode::intern(root); - return_value(vl.wsm_node); - } - - // Search the children of this node. - for (int i = 0; i < root->NumChildren(); i++) - { - Value *retval = find_skin_node_in_tree(root->GetChildNode(i)); - if (retval != &undefined) - return retval; - } - - // Didn't find it anywhere! - return &undefined; -} - - -/*********************************************************************************************** - * find_skin_binding -- Find the "WWSkin Binding" modifier on this object. * - * * - * INPUT: The skinned object. * - * * - * OUTPUT: The skin modifier, or NULL if one doesn't exist. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/19/1999 AJA : Created. * - *=============================================================================================*/ -SkinModifierClass *find_skin_binding (INode *skinned_obj) -{ - // WWSkin Binding ties us to a space warp, so search the node's - // WSM Derived Object for the WWSkin Binding modifier. - IDerivedObject *dobj = skinned_obj->GetWSMDerivedObject(); - if (dobj == NULL) - return NULL; // not bound to a space warp - - // Search for the WWSkin Binding modifier on this derived object. - for (int i = 0; i < dobj->NumModifiers(); i++) - { - Modifier *mod = dobj->GetModifier(i); - if (mod->ClassID() != SKIN_MOD_CLASS_ID) - continue; - - // We found the skin modifier. - return (SkinModifierClass*)mod; - } - - // Skin modifier not found. - return NULL; -} - - -/*********************************************************************************************** - * find_skin_wsm -- Finds the node for the WWSkin WSM used by this object. * - * * - * INPUT: The node of an object with a WWSkin Binding. * - * * - * OUTPUT: The node of the WWSkin WSM referenced by the given object. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/1999 AJA : Created. * - *=============================================================================================*/ -INode *find_skin_wsm (INode *skinned_obj) -{ - // Find the skin modifier on this object. - SkinModifierClass *skin_mod = find_skin_binding(skinned_obj); - if (skin_mod == NULL) - return NULL; - - // Using the skin modifer, find the WSM's INode. - INode *wsm = (INode*)( skin_mod->GetReference(SkinModifierClass::NODE_REF) ); - if (wsm == NULL) - { - char buf[256]; - sprintf(buf, "%s has a WWSkin Binding, but I can't find its WWSkin WSM!", - skinned_obj->GetName()); - throw RuntimeError(buf); - } - - return wsm; -} - - -/*********************************************************************************************** - * get_skin_wsm_obj -- Gets the SkinWSMObjectClass from a WWSkin WSM node. * - * * - * INPUT: The node for the WWSkin WSM's representation in the scene. * - * * - * OUTPUT: The SkinWSMObjectClass. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/1999 AJA : Created. * - *=============================================================================================*/ -SkinWSMObjectClass *get_skin_wsm_obj (INode *wsm_node) -{ - // We need a valid node. - if (!wsm_node) - return NULL; - - // The node must reference an object. - Object *obj = wsm_node->GetObjectRef(); - if (!obj) - return NULL; - - // That BASE object must be a SkinWSMObject - while (obj) - { - // If this is a derived object, burrow deeper, - // otherwise we're at the base object. - if (obj->SuperClassID() == GEN_DERIVOB_CLASS_ID) - obj = ((IDerivedObject*)obj)->GetObjRef(); - else - break; - } - if (obj->ClassID() != SKIN_OBJ_CLASS_ID) - return NULL; - - // Return it. - return (SkinWSMObjectClass*)obj; -} - - -/*********************************************************************************************** - * duplicate_wsm -- Duplicates a WWSkin WSM * - * * - * INPUT: wsm_node - INode of the WWSkin WSM object. * - * tree - The root of a tree containing equivalents of the bones in the WWSkin used * - * by skinned_obj. The bone names must be the same (after being processed by * - * Set_W3D_Name() * - * * - * OUTPUT: The node of the newly duplicated WWSkin WSM. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/1999 AJA : Created. * - * 11/3/1999 AJA : Changed first argument from skinned_obj to wsm_node. * - *=============================================================================================*/ -INode *duplicate_wsm (INode *wsm_node, INode *tree) -{ - SkinWSMObjectClass *wsm_obj = get_skin_wsm_obj(wsm_node); - - if (!wsm_node || !wsm_obj) - return NULL; - - /* - ** Duplicate the WSM. - */ - - SkinWSMObjectClass *new_wsm_obj = - (SkinWSMObjectClass*)CreateInstance(WSM_OBJECT_CLASS_ID, SKIN_OBJ_CLASS_ID); - if (!new_wsm_obj) - return NULL; - - // Create a new node in the scene that points to the new WSM object. - INode *new_wsm_node = MAXScript_interface->CreateObjectNode(new_wsm_obj); - if (!new_wsm_node) - return NULL; - - // Copy the bones from one to the other. - for (int i = 0; i < wsm_obj->Num_Bones(); i++) - { - INode *src_bone = wsm_obj->Get_Bone(i); - INode *dst_bone = find_equivalent_node(src_bone, tree); - if (!src_bone || !dst_bone) - return NULL; - - new_wsm_obj->Add_Bone(dst_bone); - } - - // Return a pointer to the new WSM node. - return new_wsm_node; -} - - -/*********************************************************************************************** - * find_equivalent_node -- Searches a hierarchy for an object equivalent to the given one. * - * * - * INPUT: source - The node to search for an equivalent of. * - * tree - The hierarchy to search in. * - * * - * OUTPUT: The equivalent node, or NULL if none was found. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/19/1999 AJA : Created. * - *=============================================================================================*/ -INode *find_equivalent_node (INode *source, INode *tree, bool name_is_valid) -{ - // We need a valid source and tree. - if (!source || !tree) - return NULL; - - // The name of the source object. We'll only evaluate this once as an easy optimization. - static char src_name[W3D_NAME_LEN]; - if (!name_is_valid) - Set_W3D_Name(src_name, source->GetName()); - - // The name of the current object we're examining. - char chk_name[W3D_NAME_LEN]; - Set_W3D_Name(chk_name, tree->GetName()); - - // Is this the node we're looking for? - if (strcmp(src_name, chk_name) == 0) - return tree; // Yup, sure is. - - // Nope. Check its children. - for (int i = 0; i < tree->NumberOfChildren(); i++) - { - INode *retval = find_equivalent_node(source, tree->GetChildNode(i), true); - if (retval != NULL) - return retval; // we found the node in our children - } - - // No equivalent node was found. - return NULL; -} - - -Value *copy_skin_info (INode *source, INode *target, INode *wsm) -{ - // Get the "WWSkin Binding" modifier on the source object. - SkinModifierClass *source_modifier = find_skin_binding(source); - if (source_modifier == NULL) - return &undefined; - - // Get the WSMDerivedObject we can add our skin binding modifier to. - IDerivedObject *dobj = setup_wsm_derived_obj(target); - - // Create a new skin modifier and copy the source modifier's settings to it. - SkinModifierClass *new_modifier = new SkinModifierClass(wsm, get_skin_wsm_obj(wsm)); - if (new_modifier == NULL) - throw RuntimeError("Out of memory - Unable to allocate a new SkinModifierClass object!"); - new_modifier->SubObjSelLevel = source_modifier->SubObjSelLevel; - - // Dupe the mod context, especially the local mod data hanging off of it. - ModContext *source_context = find_skin_mod_context(source); - ModContext *new_context = new ModContext(source_context->tm, source_context->box, - source_context->localData); - if (new_context == NULL) - throw RuntimeError("Out of memory - Unable to allocate a new ModContext object!"); - - // Add a new "WWSkin Binding" modifier to the target object to associate - // the object with the skin WSM. All of the settings should be correct, - // and the target object becomes a "skinned object". - dobj->AddModifier(new_modifier, new_context); - - // Return the WSM. - one_typed_value_local(Value* wsm_node); - vl.wsm_node = MAXNode::intern(wsm); - return_value(vl.wsm_node); -} - - -IDerivedObject *setup_wsm_derived_obj (INode *node) -{ - // Check if the target object is already bound to a space warp. - IDerivedObject *dobj = node->GetWSMDerivedObject(); - if (dobj != NULL) - { - // It's bound to a space warp. Check if WWSkin is one of the - // space warp bindings. If so, remove it (we don't want to - // be bound to an old skin). - for (int i = 0; i < dobj->NumModifiers(); i++) - { - Modifier *mod = dobj->GetModifier(i); - if (mod->ClassID() != SKIN_MOD_CLASS_ID) - continue; - - // We found the skin modifier, remove it. - dobj->DeleteModifier(i); - break; - } - } - else - { - // This object isn't bound to a space warp. Create a - // WSMDerivedObject for the node to play with. - dobj = CreateWSDerivedObject(node->GetObjectRef()); - if (dobj == NULL) - { - char msg[128]; - sprintf(msg, "Error setting up the WSMDerivedObject for %s", node->GetName()); - throw RuntimeError(msg); - } - node->SetObjectRef(dobj); - } - - return dobj; -} - - -ModContext *find_skin_mod_context (INode *node) -{ - // We need a valid node - if (node == NULL) - return NULL; - - // The node needs to be bound to a space warp (ie. must have - // a WSMDerivedObject). - IDerivedObject *dobj = node->GetWSMDerivedObject(); - if (dobj == NULL) - return NULL; - - // It's bound to a space warp. Find the WWSkin modifier. - for (int i = 0; i < dobj->NumModifiers(); i++) - { - Modifier *mod = dobj->GetModifier(i); - if (mod->ClassID() != SKIN_MOD_CLASS_ID) - continue; - - // We found the skin modifier, return its mod context. - return dobj->GetModContext(i); - } - - // We didn't find a WWSkin binding. - return NULL; -} \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/SnapPoints.cpp b/Generals/Code/Tools/WW3D/max2w3d/SnapPoints.cpp deleted file mode 100644 index 0f1ea46d4de..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/SnapPoints.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/SnapPoints.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 11/23/98 11:05a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#include "SnapPoints.h" -#include "chunkio.h" -#include "max.h" -#include "nodelist.h" -#include "w3d_file.h" - - -class PointFilterClass : public INodeFilterClass -{ -public: - PointFilterClass(void) { } - - virtual BOOL Accept_Node(INode * node, TimeValue time) - { - if (node == NULL) return FALSE; - Object * obj = node->EvalWorldState(time).obj; - if (obj == NULL) return FALSE; - - if - ( - obj->ClassID() == Class_ID(POINTHELP_CLASS_ID,0) && - !node->IsHidden() - ) - { - return TRUE; - } else { - return FALSE; - } - } -}; - - -void SnapPointsClass::Export_Points(INode * scene_root,TimeValue time,ChunkSaveClass & csave) -{ - if (scene_root == NULL) return; - - PointFilterClass pointfilter; - INodeListClass pointlist(scene_root,time,&pointfilter); - - if (pointlist.Num_Nodes() > 0) { - - csave.Begin_Chunk(W3D_CHUNK_POINTS); - - for (unsigned int ci=0; ciGetNodeTM(time).GetTrans(); - vect.X = pos.x; - vect.Y = pos.y; - vect.Z = pos.z; - csave.Write(&vect,sizeof(vect)); - - } - - csave.End_Chunk(); - } -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/SnapPoints.h b/Generals/Code/Tools/WW3D/max2w3d/SnapPoints.h deleted file mode 100644 index 6071e1d96f8..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/SnapPoints.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/SnapPoints.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 11/19/98 4:36p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef SNAPPOINTS_H -#define SNAPPOINTS_H - -#include "max.h" - -class ChunkSaveClass; -class INode; - -/* -** This class simply contains static functions which will find -** helper points that should be exported with a w3d render object and -** export them in a chunk using the given ChunkSaveClass object. -*/ -class SnapPointsClass -{ -public: - static void Export_Points(INode * scene_root,TimeValue time,ChunkSaveClass & csave); -}; - -#endif diff --git a/Generals/Code/Tools/WW3D/max2w3d/TARGA.CPP b/Generals/Code/Tools/WW3D/max2w3d/TARGA.CPP deleted file mode 100644 index ba77e106d12..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/TARGA.CPP +++ /dev/null @@ -1,1397 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/**************************************************************************** -* -* 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 -* -*---------------------------------------------------------------------------- -* -* FILE -* targa.cpp -* -* DESCRIPTION -* Targa image file class. -* -* PROGRAMMER -* Denzil E. Long, Jr. -* -* DATE -* August 8, 1995 -* -*---------------------------------------------------------------------------- -* -* PUBLIC -* Open - Open Targa image file. -* Close - Close Targa image file. -* Load - Load Targa image file. -* Save - Save a Targa Image File. -* XFlip - X flip the image. -* YFlip - Y flip the image. -* SetImage - Set the image buffer. -* GetImage - Get the current image buffer address. -* SetPalette - Set the palette buffer. -* GetPalette - Retrieve the current palette buffer address. -* GetExtension - Get Extension data. (Targa 2.0 files only) -* -* PRIVATE -* DecodeImage - Decompress Targa image data. -* EncodeImage - Compress the image using targa RLE. -* InvertImage - Invert TrueColor image data. -* -* MODIFICATIONS: -* Converted to work with FileClass, FileFactory (changes are inside -* ifdefs, so can be easily reversed). Naty Hoffman, January 25, 2001 -* -****************************************************************************/ - -#include "TARGA.H" -#ifndef TGA_USES_WWLIB_FILE_CLASSES -#include -#endif -#include -#include -#include -#ifdef TGA_USES_WWLIB_FILE_CLASSES -#include "wwfile.h" -#include "ffactory.h" -#else -#include -#include -#include -#endif - - -/**************************************************************************** -* -* NAME -* Targa::Targa - Initialize a Targa instance. -* -* SYNOPSIS -* Targa() -* -* void Targa(void); -* -* FUNCTION -* Initialize the targa class instance. -* -* INPUTS -* NONE -* -* RESULT -* NONE -* -****************************************************************************/ - -Targa::Targa(void) - { - mImage = NULL; - mPalette = NULL; - Clear_File(); - mAccess = TGA_READMODE; - mFlags = 0; - memset(&Header, 0, sizeof(TGAHeader)); - memset(&mExtension, 0, sizeof(TGA2Extension)); - } - - -/**************************************************************************** -* -* NAME -* Targa::~Targa - Targa class destructor. -* -* SYNOPSIS -* ~Targa() -* -* void ~Targa(void); -* -* FUNCTION -* -* INPUTS -* NONE -* -* RESULT -* NONE -* -****************************************************************************/ - -Targa::~Targa(void) -{ - /* Close the file if has been left open. */ - Close(); - - /* Free the palette buffer if we allocated it. */ - if ((mPalette != NULL) && (mFlags & TGAF_PAL)) - free(mPalette); - - /* Free the image buffer if we allocated it. */ - if ((mImage != NULL) && (mFlags & TGAF_IMAGE)) - free(mImage); -} - - -/**************************************************************************** -* -* NAME -* Targa::Open - Open Targa image file. -* -* SYNOPSIS -* Error = Open(Name, Mode) -* -* long Open(char *, long); -* -* FUNCTION -* Open a Targa image file and read in its header. The file stream will -* positioned after the ID field (if there is one). -* -* INPUTS -* Name - Pointer to name of Targa file. -* Mode - Access mode. -* -* RESULT -* Error - Error code, 0 if okay. -* -****************************************************************************/ - -long Targa::Open(const char* name, long mode) -{ - TGA2Footer footer; - long size; - long error = 0; - - /* File already open? */ - if (Is_File_Open() && (mAccess == mode)) { - return (0); - } - - Close(); - - /* Initialize the access mode. */ - mAccess = mode; - mFlags &= ~TGAF_TGA2; - - switch (mode) { - - /* Open targa file for read. */ - case TGA_READMODE: - if (File_Open_Read(name)) { - - /* Check for 2.0 targa file by loading the footer */ - if (File_Seek(-26, SEEK_END) == -1) { - error = TGAERR_READ; - } - - if (!error) { - if (File_Read(&footer, sizeof(TGA2Footer)) != sizeof(TGA2Footer)) { - error = TGAERR_READ; - } else { - /* If this a 2.0 file with an extension? */ - if (strncmp(footer.Signature, TGA2_SIGNATURE, 16) == 0) { - if (footer.Extension != 0) { - mFlags |= TGAF_TGA2; - } - } - } - } - - /* Read in Extension data */ - if (!error && (mFlags & TGAF_TGA2)) { - - if (File_Seek(footer.Extension, SEEK_SET) == -1) { - error = TGAERR_READ; - } - - if (!error) { - if (File_Read(&mExtension, sizeof(TGA2Extension)) != sizeof(TGA2Extension)) { - error = TGAERR_READ; - } - } - } - - /* Read in header. */ - if (!error && (File_Seek(0, SEEK_SET) == -1)) { - error = TGAERR_READ; - } else { - - size = File_Read(&Header, sizeof(TGAHeader)); - if (size != sizeof(TGAHeader)) { - error = TGAERR_READ; - } - } - - /* Skip the ID field */ - if (!error && (Header.IDLength != 0)) { - if (File_Seek(Header.IDLength, SEEK_CUR) == -1) { - error = TGAERR_READ; - } - } - - } else { - error = TGAERR_OPEN; - } - break; - - /* Open targa file for write. */ - case TGA_WRITEMODE: - if (!File_Open_Write(name)) { - error = TGAERR_OPEN; - } else { -// printf("\r"); - } - break; - - /* Open targa file for read/write.*/ - case TGA_RDWRMODE: - if (File_Open_ReadWrite(name)) { - - /* Read in header. */ - size = File_Read(&Header, sizeof(TGAHeader)); - - if (size != sizeof(TGAHeader)) { - error = TGAERR_READ; - } - /* Skip the ID field */ - if (!error && (Header.IDLength != 0)) { - if (File_Seek(Header.IDLength, SEEK_CUR) == -1) { - error = TGAERR_READ; - } - } - - } else { - error = TGAERR_OPEN; - } - break; - } - - /* Close on any error! */ - if (error) { - Close(); - } - - return (error); -} - - -/**************************************************************************** -* -* NAME -* Targa::Close - Close Targa image file. -* -* SYNOPSIS -* Close() -* -* void Close(void); -* -* FUNCTION -* Close the Targa image file and free its handle. -* -* INPUTS -* NONE -* -* RESULT -* NONE -* -****************************************************************************/ - -void Targa::Close(void) -{ -#ifdef TGA_USES_WWLIB_FILE_CLASSES - if (TGAFile) { - TGAFile->Close(); - _TheFileFactory->Return_File(TGAFile); - TGAFile = NULL; - } -#else - /* Close the file if it is open. */ - if (mFH != -1) { - close(mFH); - mFH = -1; - } -#endif -} - - -/**************************************************************************** -* -* NAME -* Targa::Load - Load Targa Image File into specified buffers. -* -* SYNOPSIS -* Error = Load(Name, Palette, ImageBuffer) -* -* long Load(char *, char *, char *); -* -* FUNCTION -* Open and load the Targa into the specified buffers. If either buffer -* pointer is NULL then that field will not be processed. -* -* INPUTS -* Name - Name of Targa image file to load. -* Palette - Pointer to buffer to load the palette into. -* ImageBuffer - Pointer to buffer to load the image data into. -* -* RESULT -* Error - 0 if successful, or TGAERR_??? error code. -* -****************************************************************************/ - -long Targa::Load(const char* name, char* palette, char* image,bool invert_image) -{ - long size; - long depth; - long error = 0; - - /* Open the Targa */ - if (Open(name, TGA_READMODE) == NULL) { - - /* Process ColorMap (palette) */ - if (Header.ColorMapType == 1) { - - depth = (Header.CMapDepth >> 3); - size = (Header.CMapLength * depth); - - /* Load the palette from the TGA if a palette buffer is provided - * otherwise we will skip it. - */ - if ((palette != NULL) && (Header.CMapLength > 0)) { - - /* Adjust palette to the starting color entry. */ - palette += (Header.CMapStart * depth); - - /* Read in the palette. */ - if (File_Read(palette, size) != size) { - error = TGAERR_READ; - } - - } else { - if (File_Seek(size, SEEK_CUR) == -1) { - error = TGAERR_READ; - } - } - } - - /* Load the image data from the TGA if an image buffer is provided - * otherwise we are done. - */ - if (!error && (image != NULL)) { - - depth = TGA_BytesPerPixel(Header.PixelDepth); - size = ((Header.Width * Header.Height) * depth); - - switch (Header.ImageType) { - case TGA_CMAPPED: - if (File_Read(image, size) != size) { - error = TGAERR_READ; - } - break; - - case TGA_TRUECOLOR: - if (File_Read(image, size) == size) { - if (invert_image) InvertImage(); - } else { - error = TGAERR_READ; - } - break; - - case TGA_MONO: - if (File_Read(image, size) != size) { - error = TGAERR_READ; - } - break; - - case TGA_CMAPPED_ENCODED: - error = DecodeImage(); - break; - - case TGA_TRUECOLOR_ENCODED: - if ((error = DecodeImage()) == NULL) { - if (invert_image) InvertImage(); - } - break; - - default: - error = TGAERR_NOTSUPPORTED; - break; - } - - /* Arrange the image so that the origin position (coordinate 0,0) - * is the upperleft hand corner of the image. - */ - if (!error) { - if ( Header.ImageDescriptor & TGAIDF_XORIGIN ) { - XFlip(); - Header.ImageDescriptor &= ~TGAIDF_XORIGIN; - } - - // Mod (IML) : Locate the origin at the bottom-left corner instead. This - // will make ot consistent with .TGA's that have been generated with our - // existing software. - // if (( Header.ImageDescriptor & TGAIDF_YORIGIN ) == 0){ - if ( Header.ImageDescriptor & TGAIDF_YORIGIN ) { - YFlip(); - // Bug fix (IML) : Clear this flag to indicate to the targa reader - // that the Y-origin is at the bottom of the image. - Header.ImageDescriptor &= ~TGAIDF_YORIGIN; - } - } - } - - /* Close the Targa */ - Close(); - - } else { - error = TGAERR_OPEN; - } - - return (error); -} - - -/**************************************************************************** -* -* NAME -* Targa::Load - Load Targa Image File. (Auto buffer allocation). -* -* SYNOPSIS -* Error = Load(Name, Flags) -* -* long Load(char, long); -* -* FUNCTION -* Open and load the Targa into buffers allocated by this function. -* -* INPUTS -* Name - Name of Targa image file to load. -* Flags - -* -* RESULT -* Error - 0 if successful, or TGAERR_??? error code. -* -****************************************************************************/ - -long Targa::Load(const char* name, long flags, bool invert_image) -{ - long size; - long error = 0; - - /* Open the file to get the header. */ - if (Open(name, TGA_READMODE) == 0) { - - /* Allocate palette memory if requested to and the targa has one. */ - if ((flags & TGAF_PAL) && (Header.ColorMapType == 1)) { - - /* Dispose of any previous palette. */ - if ((mPalette != NULL) && (mFlags & TGAF_PAL)) { - free(mPalette); - mPalette = NULL; - mFlags &= ~TGAF_PAL; - } - - /* Only allocate a palette if the client hasn't assigned one. */ - if ((mPalette == NULL) && !(mFlags & TGAF_PAL)) { - - /* Compute the size of the palette from the targa header. */ - size = (Header.CMapLength * (Header.CMapDepth >> 3)); - - if (size != 0) { - /* Allocate memory for the palette. */ - if ((mPalette = (char *)malloc(size)) != NULL) { - mFlags |= TGAF_PAL; /* We allocated the palette. */ - } else { - error = TGAERR_NOMEM; - } - } - } - } - - /* Allocate image memory if requested to. */ - if (!error && (flags & TGAF_IMAGE)) { - - /* Dispose of any previous image. */ - if ((mImage != NULL) && (mFlags & TGAF_IMAGE)) { - free(mImage); - mImage = NULL; - mFlags &= ~TGAF_IMAGE; - } - - /* Only allocate an image if the client hasn't assigned one. */ - if ((mImage == NULL) && !(mFlags & TGAF_IMAGE)) { - - /* Compute the size of the image data from the targa header. */ - size = ((Header.Width * Header.Height) * TGA_BytesPerPixel(Header.PixelDepth)); - if (size != 0) { - /* Allocate memory for the image. */ - if ((mImage = (char *)malloc(size)) != NULL) { - mFlags |= TGAF_IMAGE; /* We allocated the image. */ - } else { - error = TGAERR_NOMEM; - } - } - } - } - - /* Read in the file contents. */ - if (!error) { - error = Load(name, mPalette, mImage, invert_image); - } - - /* Close the file. */ - Close(); - - } else { - error = TGAERR_OPEN; - } - - return (error); -} - - -/**************************************************************************** -* -* NAME -* Targa::Save - Save a Targa Image File. -* -* SYNOPSIS -* Error = Save(Name, Flags) -* -* long Save(char *, long); -* -* FUNCTION -* -* INPUTS -* Name - Pointer to name of file to save. -* Flags - -* -* RESULT -* Error - 0 if successful, or TGAERR_??? error code. -* -****************************************************************************/ - -long Targa::Save(const char* name, long flags, bool addextension) - { - long size; - long depth; - char *palette; - char *temppal; - char *ptr; - //long i,n; - //char c; - long error = 0; - TGA2Footer footer; - - /* Open the Targa for write. */ - if (Open(name, TGA_WRITEMODE) == NULL) - { - Header.IDLength = 0; - - /* Set the ImageType for compression. */ - if (flags & TGAF_COMPRESS) - { - switch (Header.ImageType) - { - case TGA_CMAPPED: - case TGA_TRUECOLOR: - case TGA_MONO: - Header.ImageType += 8; - break; - - case TGA_CMAPPED_ENCODED: - case TGA_TRUECOLOR_ENCODED: - case TGA_MONO_ENCODED: - break; - - /* Turn off compression for unknown types. */ - default: - flags &= ~TGAF_COMPRESS; - break; - } - } - - /*----------------------------------------------------------------------- - * WRITE THE HEADER DATA SECTION - *---------------------------------------------------------------------*/ - if (File_Write(&Header, sizeof(TGAHeader)) != sizeof(TGAHeader)) - error = TGAERR_WRITE; - - /*----------------------------------------------------------------------- - * WRITE THE COLORMAP (PALETTE) DATA SECTION - *---------------------------------------------------------------------*/ - if (!error && (flags & TGAF_PAL) && (mPalette != NULL) - && (Header.CMapLength > 0)) - { - /* Adjust palette to the starting color entry. */ - depth = (Header.CMapDepth >> 3); - palette = mPalette + (Header.CMapStart * depth); - size = (Header.CMapLength * depth); - - /* Allocate temporary buffer for palette manipulation. */ - if ((temppal = (char *)malloc(size)) != NULL) - { - memcpy(temppal, palette, size); - ptr = temppal; - - #if(0) - /* Swap the byte ordering of the palette entries. */ - for (i = 0; i < Header.CMapLength; i++) - { - c = *ptr; - *ptr = *(ptr + (depth - 1)); - *(ptr + (depth - 1)) = c; - - /* Next entry */ - palette += depth; - } - #endif - - /* Write the palette. */ - if (File_Write(temppal, size) != size) - error = TGAERR_WRITE; - - /* Free temporary palette buffer. */ - free(temppal); - } - else - error = TGAERR_NOMEM; - } - - /*----------------------------------------------------------------------- - * WRITE THE IMAGE DATA SECTION - *---------------------------------------------------------------------*/ - if (!error && (flags & TGAF_IMAGE) && (mImage != NULL)) - { - - bool imageinverted; - - /* Invert truecolor data. */ - if ((Header.ImageType == TGA_TRUECOLOR) || (Header.ImageType == TGA_TRUECOLOR_ENCODED)) { - InvertImage(); - imageinverted = true; - } else { - imageinverted = false; - } - - /* Write the image. */ - if (flags & TGAF_COMPRESS) - EncodeImage(); - else - { - depth = TGA_BytesPerPixel(Header.PixelDepth); - size = (((Header.Width * Header.Height)) * depth); - - if (File_Write(mImage, size) != size) - error = TGAERR_WRITE; - } - - // Bug fix (IML) : If the image was inverted, invert it again to restore it to its prior state. - if (imageinverted) InvertImage(); - } - - /*----------------------------------------------------------------------- - * WRITE THE EXTENSION DATA SECTION - *---------------------------------------------------------------------*/ - - // Mod (IML) Optionally add an extension to the file. - if (addextension) { - if (!error) { - - mExtension.ExtSize = 495; - strncpy(mExtension.SoftID, "Denzil's Targa Code", 41); - mExtension.SoftVer.Number = (1 * 100); - mExtension.SoftVer.Letter = 0; - - /* Save position of extension area. */ - if ((footer.Extension = File_Seek(0, SEEK_CUR)) == -1) - error = TGAERR_WRITE; - - if (!error && (File_Write(&mExtension, sizeof(TGA2Extension)) - != sizeof(TGA2Extension))) - error = TGAERR_WRITE; - } - } else { - footer.Extension = 0; - } - - /*----------------------------------------------------------------------- - * WRITE THE FOOTER DATA SECTION - *---------------------------------------------------------------------*/ - if (!error) - { - footer.Developer = 0; - strncpy(footer.Signature, TGA2_SIGNATURE, 16); - footer.RsvdChar = '.'; - footer.BZST = 0; - - if (File_Write(&footer, sizeof(TGA2Footer)) != sizeof(TGA2Footer)) - error = TGAERR_WRITE; - } - - /* Close targa file. */ - Close(); - } - else - error = TGAERR_OPEN; - - return (error); - } - - -/**************************************************************************** -* -* NAME -* Targa::XFlip - X flip the image. -* -* SYNOPSIS -* XFlip() -* -* void XFlip(); -* -* FUNCTION -* Flip the image in memory on its X axis. (left to right) -* -* INPUTS -* NONE -* -* RESULT -* NONE -* -****************************************************************************/ - -void Targa::XFlip(void) - { - char *ptr,*ptr1; - long x,y,d; - char v,v1; - char depth; - - /* Pixel depth in bytes. */ - depth = TGA_BytesPerPixel(Header.PixelDepth); - - for (y = 0; y < Header.Height; y++) - { - ptr = (mImage + ((Header.Width * depth) * y)); - ptr1 = (ptr + ((Header.Width * depth) - depth)); - - for (x = 0; x < (Header.Width / 2); x++) - { - for (d = 0; d < depth; d++) - { - v = *(ptr + d); - v1 = *(ptr1 + d); - *(ptr + d) = v1; - *(ptr1 + d) = v; - } - - ptr += depth; - ptr1 -= depth; - } - } - } - - -/**************************************************************************** -* -* NAME -* Targa::YFlip - Y flip the image. -* -* SYNOPSIS -* YFlip() -* -* void YFlip(); -* -* FUNCTION -* Flip the image in memory on its Y axis. (top to bottom) -* -* INPUTS -* NONE -* -* RESULT -* NONE -* -****************************************************************************/ - -void Targa::YFlip(void) - { - char *ptr,*ptr1; - long x,y; - char v,v1; - char depth; - - /* Pixel depth in bytes. */ - depth = TGA_BytesPerPixel(Header.PixelDepth); - - for (y = 0; y < (Header.Height >> 1); y++) - { - /* Compute address of lines to exchange. */ - ptr = (mImage + ((Header.Width * y) * depth)); - ptr1 = (mImage + ((Header.Width * (Header.Height - 1)) * depth)); - ptr1 -= ((Header.Width * y) * depth); - - /* Exchange all the pixels on this scan line. */ - for (x = 0; x < (Header.Width * depth); x++) - { - v = *ptr; - v1 = *ptr1; - *ptr = v1; - *ptr1 = v; - ptr++; - ptr1++; - } - } - } - - -/**************************************************************************** -* -* NAME -* Targa::SetImage - Set the image buffer. -* -* SYNOPSIS -* OldImage = SetImage(Image) -* -* char *SetImage(char *); -* -* FUNCTION -* Set the image buffer to one provided by the caller. -* -* INPUTS -* Image - Pointer to buffer to use for the image buffer. -* -* RESULT -* OldImage - Previous caller assigned image buffer. -* -****************************************************************************/ - -char *Targa::SetImage(char *buffer) -{ - char *oldbuffer = NULL; - - /* Free any image buffer before assigning another. */ - if ((mImage != NULL) && (mFlags & TGAF_IMAGE)) - { - free(mImage); - mImage = NULL; - mFlags &= ~TGAF_IMAGE; - } - - /* Get the old user buffer. */ - if (mImage != NULL) - oldbuffer = mImage; - - /* Assign the new image buffer. */ - mImage = buffer; - - return (oldbuffer); -} - - -/**************************************************************************** -* -* NAME -* Targa::SetPalette - Set the palette buffer. -* -* SYNOPSIS -* OldPal = SetPalette(Pal) -* -* char *SetPalette(char *); -* -* FUNCTION -* -* INPUTS -* Pal - Pointer to buffer to use for palette. -* -* RESULT -* OldPal - Pointer to previous user palette. -* -****************************************************************************/ - -char *Targa::SetPalette(char *buffer) -{ - char *oldbuffer = NULL; - - /* Free any image buffer before assigning another. */ - if ((mPalette != NULL) && (mFlags & TGAF_PAL)) - { - free(mPalette); - mPalette = NULL; - mFlags &= ~TGAF_PAL; - } - - /* Get the old user buffer. */ - if (mPalette != NULL) - oldbuffer = mPalette; - - /* Assign the new image buffer. */ - mPalette = buffer; - - return (oldbuffer); -} - - -bool Targa::IsCompressed(void) - { - if (Header.ImageType > 8) - return true; - - return false; - } - - -/**************************************************************************** -* -* NAME -* Targa::GetExtension - Get Extension data. (Targa 2.0 files only) -* -* SYNOPSIS -* Ext = GetExtension() -* -* TGA2Extension *GetExtension(void); -* -* FUNCTION -* Retrieve a pointer to the Targa 2.0 extension data area. If the file -* version is 1.0 OR there is no extensio area then a NULL will be returned. -* -* INPUTS -* NONE -* -* RESULT -* Ext - Pointer to Extension data, NULL if not available. -* -****************************************************************************/ - -TGA2Extension *Targa::GetExtension(void) - { - if (mFlags & TGAF_TGA2) - return (&mExtension); - - return (NULL); - } - - -/**************************************************************************** -* -* NAME -* Targa::DecodeImage - Decompress Targa image data. -* -* SYNOPSIS -* Error = DecodeImage() -* -* long DecodeImage(); -* -* FUNCTION -* Decode the RLE compressed image data into the specified buffer from -* the file I/O stream. -* -* INPUTS -* NONE -* -* RESULT -* Error - 0 if successful, or TGAERR_??? error code. -* -****************************************************************************/ - -long Targa::DecodeImage() - { - char *image; - char *color; - unsigned char count; - unsigned char depth; - unsigned long pixel_count; - unsigned long size; - unsigned long c,i; - long error = 0; - - /* Initialize */ - image = mImage; - - /* Compute pixel depth in bytes. */ - depth = TGA_BytesPerPixel(Header.PixelDepth); - - /* Total number of pixels compressed in this image. */ - pixel_count = (Header.Width * Header.Height); - - while ((pixel_count > 0) && !error) - { - /* Read count. */ - if (File_Read(&count, 1) == 1) - { - /* If bit 8 of the count is set then we have a run of pixels, - * otherwise the data is raw pixels. - */ - if (count & 0x80) - { - count &= 0x7F; - count++; - - /* Read in run pixel. */ - if (File_Read(image, depth) == depth) - { - color = image; - image += depth; - - /* Repeat the pixel for the run count in the image buffer. */ - for (c = 1; c < count; c++) - for (i = 0; i < depth; i++) - *image++ = *(color + i); - } - else - error = TGAERR_READ; - } - else - { - count++; - size = (count * depth); - - /* Read in raw pixels. */ - if ((unsigned)File_Read(image, size) == size) - image += size; - else - error = TGAERR_READ; - } - - /* Adjust the pixel count. */ - pixel_count -= count; - } - else - error = TGAERR_READ; - } - - return (error); - } - - -/**************************************************************************** -* -* NAME -* Targa::EncodeImage - Compress the image using targa RLE. -* -* SYNOPSIS -* EncodeImage() -* -* void EncodeImage(void); -* -* FUNCTION -* Encode the image data using the RLE algorithm outlined in the TARGA -* file specification. -* -* INPUTS -* NONE -* -* RESULT -* NONE -* -****************************************************************************/ - -long Targa::EncodeImage() - { - char *packet; - long packet_index; - char *start; - char *end; - long depth; - long pixels; - long count; - long match; - long i; - long error = 0; - - /* Initialize variables. */ - depth = TGA_BytesPerPixel(Header.PixelDepth); - - /* Allocate packet buffer to hold maximum encoded data run. */ - if ((packet = (char *)malloc(128 * depth)) != NULL) - { - pixels = Header.Width * Header.Height; - start = mImage; - end = start; - count = 0; - packet[0] = 0; - packet_index = 1; - - while ((pixels != 0) && !error) - { - match = 1; - - /* Advance to the next pixel */ - end += depth; - pixels--; - - /* Compare pixels. */ - for (i = 0; i < depth; i++) - { - if (start[i] != end[i]) - { - match = 0; - break; - } - } - - /* Run of pixels */ - if (match == 1) - { - count++; - - /* Continue counting until the maximum has been reached. */ - if (count < 128) - { - if (packet[0] == 0) - continue; - } - else - count--; - } - - /* If there is a count then write out the run. Otherwise, write - * the raw pixel to the packet. - */ - if ((count != 0) && (packet[0] == 0)) - { - /* Run count */ - packet[0] = (count | 0x80); - - /* Run pixel */ - for (i = 0; i < depth; i++) - packet[i + 1] = start[i]; - - /* Write the run packet. */ - if (File_Write(packet, (depth + 1)) != (depth + 1)) - error = TGAERR_WRITE; - - /* Reposition start and reset. */ - start = end; - count = 0; - packet[0] = 0; - } - else - { - if (count == 0) - { - /* Copy the raw pixel to the packet. */ - for (i = 0; i < depth; i++) - packet[packet_index + i] = start[i]; - - /* Increment the raw packet count. */ - packet[0]++; - - /* Reposition start */ - start = end; - packet_index += depth; - } - - /* Write the raw packet if the packet is full or a run has started - * or all the pixels have been processed. - */ - if ((packet[0] == 127) || (count != 0) || (pixels == 0)) - { - i = packet[0]; - packet[0]--; - - if (File_Write(packet, ((i * depth) + 1)) != ((i * depth) + 1)) - error = TGAERR_WRITE; - - packet_index = 1; - packet[0] = 0; - } - } - } - - /* Free the packet buffer. */ - free(packet); - } - else - error = TGAERR_NOMEM; - - return (error); - } - - -/**************************************************************************** -* -* NAME -* Targa::InvertImage - Invert TrueColor image data. -* -* SYNOPSIS -* InvertImage() -* -* void InvertImage(void); -* -* FUNCTION -* -* INPUTS -* NONE -* -* RESULT -* NONE -* -****************************************************************************/ - -void Targa::InvertImage(void) - { - char *buffer; - long depth; - long pixel_count; - long i; - char c; - - /* Initialize */ - buffer = mImage; - - /* Compute the pixel depth in bytes. */ - depth = TGA_BytesPerPixel(Header.PixelDepth); - - /* Total number of pixels in this image. */ - pixel_count = (Header.Width * Header.Height); - - /* 16-bit pixel layout is different that 24-bit and 32-bit. */ - if (depth > 2) - { - while (pixel_count > 0) - { - for (i = 0; i < (depth / 2); i++) - { - c = *(buffer + i); - *(buffer + i) = *(buffer + ((depth - 1) - i)); - *(buffer + ((depth - 1) - i)) = c; - } - - /* Next pixel */ - pixel_count--; - buffer += depth; - } - } - } - - -/* -** These functions are just for ease of ifdef'ing between standard io calls and FileClass. -*/ -void Targa::Clear_File(void) -{ -#ifdef TGA_USES_WWLIB_FILE_CLASSES - TGAFile = NULL; -#else - mFH = -1; -#endif -} -bool Targa::Is_File_Open(void) -{ -#ifdef TGA_USES_WWLIB_FILE_CLASSES - return (TGAFile != NULL); -#else - return (mFH != -1); -#endif -} -bool Targa::File_Open_Read(const char* name) -{ -#ifdef TGA_USES_WWLIB_FILE_CLASSES - TGAFile = _TheFileFactory->Get_File(name); - if (TGAFile && TGAFile->Is_Available()) { - return (TGAFile->Open(FileClass::READ) != 0); - } else { - return false; - } -#else - mFH = open(name, (O_RDONLY|O_BINARY)); - return (mFH != -1); -#endif -} -bool Targa::File_Open_Write(const char* name) -{ -#ifdef TGA_USES_WWLIB_FILE_CLASSES - TGAFile = _TheWritingFileFactory->Get_File(name); - if (TGAFile) { - return (TGAFile->Open(FileClass::WRITE) != 0); - } else { - return false; - } -#else - mFH = open(name, (O_CREAT|O_TRUNC|O_WRONLY|O_BINARY), (S_IREAD|S_IWRITE)); - return (mFH != -1); -#endif -} -bool Targa::File_Open_ReadWrite(const char* name) -{ -#ifdef TGA_USES_WWLIB_FILE_CLASSES - TGAFile = _TheWritingFileFactory->Get_File(name); - if (TGAFile && TGAFile->Is_Available()) { - return (TGAFile->Open(FileClass::READ|FileClass::WRITE) != 0); - } else { - return false; - } -#else - mFH = open(name, (O_RDWR|O_BINARY), (S_IREAD|S_IWRITE)); - return (mFH != -1); -#endif -} -int Targa::File_Seek(int pos, int dir) -{ -#ifdef TGA_USES_WWLIB_FILE_CLASSES - return TGAFile->Seek(pos, dir); -#else - return lseek(mFH, pos, dir); -#endif -} -int Targa::File_Read(void *buffer, int size) -{ -#ifdef TGA_USES_WWLIB_FILE_CLASSES - return TGAFile->Read(buffer, size); -#else - return read(mFH, buffer, size); -#endif -} -int Targa::File_Write(void *buffer, int size) -{ -#ifdef TGA_USES_WWLIB_FILE_CLASSES - return TGAFile->Write(buffer, size); -#else - return write(mFH, buffer, size); -#endif -} - -// ---------------------------------------------------------------------------- -// -// Output targa load error message. -// -// ---------------------------------------------------------------------------- - -long Targa_Error_Handler(long load_err,const char* filename) -{ - switch (load_err) { - case 0: - return 0; - case TGAERR_OPEN: -// WWDEBUG_SAY(("Targa: Failed to open file \"%s\"\n", filename)); - break; - - case TGAERR_READ: -// WWDEBUG_SAY(("Targa: Failed to read file \"%s\"\n", filename)); - break; - - case TGAERR_NOTSUPPORTED: -// WWDEBUG_SAY(("Targa: File \"%s\" is an unsupported Targa type\n", filename)); - break; - - case TGAERR_NOMEM: -// WWDEBUG_SAY(("Targa: Failed to allocate memory for file \"%s\"\n", filename)); - break; - - default: -// WWDEBUG_SAY(("Targa: Unknown error when loading file \"%s\"\n", filename)); - break; - } - return load_err; -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/TARGA.H b/Generals/Code/Tools/WW3D/max2w3d/TARGA.H deleted file mode 100644 index c0b1472ed1b..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/TARGA.H +++ /dev/null @@ -1,320 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#ifndef _TARGA_H_ -#define _TARGA_H_ -/**************************************************************************** -* -* 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 -* -*---------------------------------------------------------------------------- -* -* FILE -* Targa.h -* -* DESCRIPTION -* Targa image file class definitions. -* -* PROGRAMMER -* Denzil E. Long, Jr. -* -* DATE -* July 15, 1998 -* -****************************************************************************/ - -#pragma pack(push, 1) - -// If you wish to display loading error messages call targa functions inside of -// the following macro - for example TARGA_ERROR_HANDLER(targa.Open(filename, TGA_READMODE)); -// The error code is returned back from the handler so it can be used in an expression. -long Targa_Error_Handler(long error_code,const char* filename); -#define TARGA_ERROR_HANDLER(call,filename) Targa_Error_Handler(call,filename) - -/*--------------------------------------------------------------------------- - * STRUCTURES AND RELATED DEFINITIONS - *-------------------------------------------------------------------------*/ - -/* TGAHeader - Targa Image File header. - * - * IDLength - Size of Image ID field - * ColorMapType - Color map type. - * ImageType - Image type code. - * CMapStart - Color map origin. - * CMapLength - Color map length. - * CMapDepth - Depth of color map entries. - * XOffset - X origin of image. - * YOffset - Y origin of image. - * Width - Width of image. - * Height - Height of image. - * PixelDepth - Image pixel size - * ImageDescriptor - Image descriptor byte. - */ -typedef struct _TGAHeader - { - char IDLength; - char ColorMapType; - char ImageType; - short CMapStart; - short CMapLength; - char CMapDepth; - short XOffset; - short YOffset; - short Width; - short Height; - char PixelDepth; - char ImageDescriptor; - } TGAHeader; - -/* ImageType definiton */ -#define TGA_NOIMAGE 0 /* No image data included in file */ -#define TGA_CMAPPED 1 /* Color-mapped image data */ -#define TGA_TRUECOLOR 2 /* Truecolor image data */ -#define TGA_MONO 3 /* Monochrome image data */ -#define TGA_CMAPPED_ENCODED 9 /* Color-mapped image data (Encoded) */ -#define TGA_TRUECOLOR_ENCODED 10 /* Truecolor image data (Encoded) */ -#define TGA_MONO_ENCODED 11 /* Monochrome image data (Encoded) */ - -/* ImageDescriptor definition */ -#define TGAIDF_ATTRIB_BITS (0x0F<<0) /* Number of attribute bits per pixel */ -#define TGAIDF_XORIGIN (1<<4) -#define TGAIDF_YORIGIN (1<<5) - -/* Access modes. */ -#define TGA_READMODE 0 -#define TGA_WRITEMODE 1 -#define TGA_RDWRMODE 2 - -/* Error codes */ -#define TGAERR_OPEN -1 -#define TGAERR_READ -2 -#define TGAERR_WRITE -3 -#define TGAERR_SYNTAX -4 -#define TGAERR_NOMEM -5 -#define TGAERR_NOTSUPPORTED -6 - -/* Flags definitions */ -#define TGAF_IMAGE (1<<0) -#define TGAF_PAL (1<<1) -#define TGAF_COMPRESS (1<<2) -#define TGAF_TGA2 (1<<3) - -/* Macro definitions */ -#define TGA_BytesPerPixel(a) ((a+7) >> 3) - -/*--------------------------------------------------------------------------- - * TARGA 2.0 DEFINITIONS - *-------------------------------------------------------------------------*/ - -#define TGA2_SIGNATURE "TRUEVISION-XFILE" - -/* TGA2Footer - Targa 2.0 footer - * - * Extension - Offset to the Extension area from start of file. - * Developer - Offset to the Developer area from start of file. - * Signature - 16 byte Targa 2.0 signature "TRUEVISION-XFILE" - * RsvdChar - Reserved character, must be ASCII "." (period) - * BZST - Binary Zero String Terminator. - */ -typedef struct _TGA2Footer - { - long Extension; - long Developer; - char Signature[16]; - char RsvdChar; - char BZST; - _TGA2Footer() {} - } TGA2Footer; - -/* TGA2DateStamp - A series of 3 WORD values which define the integer value - * for the date the image was saved. - * - * Month - Month number (1 - 12) - * Day - Day number (1 - 31) - * Year - Year number (4 digit, ie. 1989) - */ -typedef struct _TGA2DateStamp - { - short Month; - short Day; - short Year; - } TGA2DateStamp; - -/* TGA2TimeStamp - A series of 3 WORD values which define the integer value - * for the time the image was saved. - * - * Hour - Hour number, military time (0 - 23) - * Minute - Minute number (0 - 59) - * Second - Second number (0 - 59) - */ -typedef struct _TGA2TimeStamp - { - short Hour; - short Minute; - short Second; - } TGA2TimeStamp; - -/* TGA2SoftVer - Define the version of the software used to generate file. - * - * Number - Version number * 100 - * Letter - Version letter - */ -typedef struct _TGA2SoftVer - { - short Number; - char Letter; - } TGA2SoftVer; - -/* TGA2Ratio - Numerator and denominator which when taken together specify - * a ratio. - * - * Numer - Numerator - * Denom - Denominator (a value of zero indicates no ratio specified) - */ -typedef struct _TGA2Ratio - { - short Numer; - short Denom; - } TGA2Ratio; - -/* TGA2Extension - Extension area, provided for additional file information. - * This data is pointed to by the Extension offset in the - * TGA2Footer. - * - * ExtSize - Extension area size. (495 bytes for 2.0) - * AuthName - Name of the person who created image (NULL terminated ASCII) - * AuthComment - Comments of the author (NULL terminated ASCII) - * DateStamp - Date the file was created. (See TGA2DateStamp) - * TimeStamp - Time the file was created. (See TGA2TimeStamp) - * JobName - Name of job image belongs to (NULL terminated ASCII) - * JobTime - Elapsed time of the job. - * SoftID - ID of software used to create image (NULL terminated ASCII) - * SoftVer - Version number of software used. - * KeyColor - Tranparent color value. - * Aspect - Pixel aspect ratio. - * Gamma - Fractional gamma value. - * ColorCor - Color correction table offset. - * PostStamp - Postage stamp image offset. - * ScanLine - Scan line table offset. - * Attributes - Alpha channel attributes. (Set defines below) - */ -typedef struct _TGA2Extension - { - short ExtSize; - char AuthName[41]; - char AuthComment[324]; - TGA2DateStamp Date; - TGA2TimeStamp Time; - char JobName[41]; - TGA2TimeStamp JobTime; - char SoftID[41]; - TGA2SoftVer SoftVer; - long KeyColor; - TGA2Ratio Aspect; - TGA2Ratio Gamma; - long ColorCor; - long PostStamp; - long ScanLine; - char Attributes; - } TGA2Extension; - -/* Alpha channel attributes (Extension Area) */ -#define EXTA_NOALPHA 0 /* No alpha data included */ -#define EXTA_IGNORE 1 /* Undefined alpha data, can ignore */ -#define EXTA_RETAIN 2 /* Undefined alpha data, should retain */ -#define EXTA_USEFUL 3 /* Useful alpha channel */ -#define EXTA_PREMULT 4 /* Pre-Multiplied alpha data */ - -#pragma pack(pop) - -/* -** This define changes this code from code that works with standard IO calls, -** to code that uses FileClass and FileFactoryClass. -*/ -//#define TGA_USES_WWLIB_FILE_CLASSES - -#ifdef TGA_USES_WWLIB_FILE_CLASSES -class FileClass; -#endif - -/*--------------------------------------------------------------------------- - * CLASS DEFINITION - *-------------------------------------------------------------------------*/ - -class Targa - { - public: - /* Constructor/destructor */ - Targa(void); - ~Targa(); - - /* Function prototypes. */ - long Open(const char* name, long mode); - void Close(void); - - long Load(const char* name, char* palette, char* image,bool invert_image=true); - long Load(const char* name, long flags, bool invert_image=true); - long Save(const char* name, long flags, bool addextension = false); - - void XFlip(void); - void YFlip(void); - - char* SetImage(char* buffer); - char* GetImage(void) const {return (mImage);} - - char* SetPalette(char* buffer); - char* GetPalette(void) const {return (mPalette);} - - bool IsCompressed(void); - - TGA2Extension* GetExtension(void); - - TGAHeader Header; - - protected: -#ifdef TGA_USES_WWLIB_FILE_CLASSES - FileClass *TGAFile; -#else - long mFH; -#endif - long mAccess; - long mFlags; - char* mImage; - char* mPalette; - TGA2Extension mExtension; - - private: - // Utility functions - long DecodeImage(void); - long EncodeImage(void); - void InvertImage(void); - - // These functions are for ease of ifdef'ing between standard io calls - // and FileClass. - void Clear_File(void); - bool Is_File_Open(void); - bool File_Open_Read(const char* name); - bool File_Open_Write(const char* name); - bool File_Open_ReadWrite(const char* name); - int File_Seek(int pos, int dir); - int File_Read(void *buffer, int size); - int File_Write(void *buffer, int size); - }; - -#endif /* _TARGA_H_ */ - diff --git a/Generals/Code/Tools/WW3D/max2w3d/Utility.cpp b/Generals/Code/Tools/WW3D/max2w3d/Utility.cpp deleted file mode 100644 index ca44363ebad..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/Utility.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/Utility.cpp $* - * * - * $Author:: Andre_a $* - * * - * $Modtime:: 5/08/00 11:51a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * wwGetAbsolutePath -- Returns the absolute path based on a relative one. * - * wwInputBox -- Retrive a string from the user in a nice friendly manner. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -/* -** Utility.cpp - Implementation of a some convenient features the WIN32 API provides -** that the MAXScript API doesn't. -*/ - - -#include -#include -#include -#include - -#include "util.h" -#include "InputDlg.h" - - -/* -** Let MAXScript know we're implementing new built-in functions. -*/ -def_visible_primitive(get_absolute_path, "wwGetAbsolutePath"); -def_visible_primitive(input_box, "wwInputBox"); - - -/*********************************************************************************************** - * get_absolute_path_cf -- Returns the absolute path based on a relative one. * - * * - * wwGetAbsolutePath - Usage: wwGetAbsolutePath * - * * - * INPUT: A string containing a relative path, and its context. * - * * - * OUTPUT: The equivalent absolute path. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/4/1999 AJA : Created. * - *=============================================================================================*/ -Value * get_absolute_path_cf (Value **arg_list, int count) -{ - // We want an array as an argument - check_arg_count("wwGetAbsolutePath", 2, count); - type_check(arg_list[0], String, "Relative path"); - type_check(arg_list[1], String, "Context"); - - // Grab the arguments out of the array. - char absolute[MAX_PATH]; - char *relative = arg_list[0]->to_string(); - char *context = arg_list[1]->to_string(); - - // Turn the relative path into an absolute one. - Create_Full_Path(absolute, context, relative); - - // Return the absolute path. - one_typed_value_local(String *abs); - vl.abs = new String(absolute); - return_value(vl.abs); -} - - -/*********************************************************************************************** - * input_box_cf -- Retrive a string from the user in a nice friendly manner. * - * * - * wwInputBox - Usage: wwInputBox [caption:'caption'] [label:'label'] [value:'value'] * - * * - * INPUT: Three optional named arguments. If they are not given values, defaults are used. * - * * - * OUTPUT: Returns the string entered by the user. * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -Value * input_box_cf (Value **arg_list, int count) -{ - // Create the input box (but don't show it yet). - InputDlg input_box(MAXScript_interface->GetMAXHWnd()); - Value *param = NULL; - - // Check the 'caption' parameter. - param = key_arg(caption); - if (param && param != &unsupplied) - input_box.SetCaption(param->to_string()); - - // Check the 'label' parameter. - param = key_arg(label); - if (param && param != &unsupplied) - input_box.SetLabel(param->to_string()); - - // Check the 'value' parameter. - param = key_arg(value); - if (param && param != &unsupplied) - input_box.SetValue(param->to_string()); - - // Show the dialog and let the user enter a value. - if (input_box.DoModal() == IDCANCEL) - return &undefined; - - // Return the value the user entered. - one_typed_value_local(String *val); - vl.val = new String(input_box.m_Value); - return_value(vl.val); -} - diff --git a/Generals/Code/Tools/WW3D/max2w3d/aabtreebuilder.cpp b/Generals/Code/Tools/WW3D/max2w3d/aabtreebuilder.cpp deleted file mode 100644 index 52edb974b1a..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/aabtreebuilder.cpp +++ /dev/null @@ -1,930 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/aabtreebuilder.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 5/24/00 8:41a $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * AABTreeBuilderClass::AABTreeBuilderClass -- Constructor * - * AABTreeBuilderClass::~AABTreeBuilderClass -- Destructor * - * AABTreeBuilderClass::Reset -- reset the builder, delete all arrays * - * AABTreeBuilderClass::Build_AABTree -- Build an AABTree for the given mesh. * - * AABTreeBuilderClass::Build_Tree -- recursivly builds the culling tree * - * AABTreeBuilderClass::Select_Splitting_Plane -- select a partition for the given polys * - * AABTreeBuilderClass::Compute_Plane_Score -- evaluate the suitability of a partition plane * - * AABTreeBuilderClass::Which_Side -- which side of a plane is the given poly * - * AABTreeBuilderClass::Split_Polys -- partition the polys with a plane * - * AABTreeBuilderClass::Compute_Bounding_Box -- compute bounding boxes for the cull nodes * - * AABTreeBuilderClass::Assign_Index -- assign an array index to each node * - * AABTreeBuilderClass::Node_Count -- Count the nodes in the tree * - * AABTreeBuilderClass::Poly_Count -- returns number of polys * - * AABTreeBuilderClass::Node_Count_Recursive -- internal implementation of Node_Count * - * AABTreeBuilderClass::Submit_Tree -- install nodes into an AABTreeClass * - * AABTreeBuilderClass::Submit_Tree_Recursive -- internal implementation of Submit_Tree * - * AABTreeBuilderClass::Update_Min -- ensure given vector is < min of the poly * - * AABTreeBuilderClass::Update_Max -- ensure given vector is > max of poly * - * AABTreeBuilderClass::Update_Min_Max -- ensure given vector is in min max of poly * - * AABTreeBuilderClass::Export -- Saves this AABTree into a W3D chunk * - * AABTreeBuilderClass::Build_W3D_AABTree_Recursive -- Build array of indices and W3dMeshAAB * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "aabtreebuilder.h" -#include "chunkio.h" -#include "w3d_file.h" -#include -#include -#include - -#define WWASSERT assert // can't use WWASSERT because we use this module in the MAX plugin... -const float COINCIDENCE_EPSILON = 0.001f; - - -/*********************************************************************************************** - * AABTreeBuilderClass::AABTreeBuilderClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -AABTreeBuilderClass::AABTreeBuilderClass(void) : - Root(NULL), - CurPolyIndex(0), - PolyCount(0), - Polys(NULL), - VertCount(0), - Verts(NULL) -{ -} - - -/*********************************************************************************************** - * AABTreeBuilderClass::~AABTreeBuilderClass -- Destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/19/2000 gth : Created. * - *=============================================================================================*/ -AABTreeBuilderClass::~AABTreeBuilderClass(void) -{ - Reset(); -} - - -/*********************************************************************************************** - * AABTreeBuilderClass::Reset -- reset the builder, delete all arrays * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/19/2000 gth : Created. * - *=============================================================================================*/ -void AABTreeBuilderClass::Reset(void) -{ - if (Root) { - delete Root; Root = NULL; - } - - if (Verts != NULL) { - delete[] Verts; - Verts = NULL; - } - - if (Polys != NULL) { - delete[] Polys; - Polys = NULL; - } -} - -/*********************************************************************************************** - * AABTreeBuilderClass::Build_AABTree -- Build an AABTree for the given mesh. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/19/98 GTH : Created. * - *=============================================================================================*/ -void AABTreeBuilderClass::Build_AABTree(int polycount,Vector3i * polys,int vertcount,Vector3 * verts) -{ - WWASSERT(polycount > 0); - WWASSERT(vertcount > 0); - WWASSERT(polys != NULL); - WWASSERT(verts != NULL); - - /* - ** If we already have allocated data, release it - */ - Reset(); - - /* - ** Copy the mesh data - */ - VertCount = vertcount; - PolyCount = polycount; - Verts = new Vector3[VertCount]; - Polys = new Vector3i[PolyCount]; - - for (int vi=0; viPolyCount = polycount; - node->PolyIndices = polyindices; - return; - } - - /* - ** Try to find a suitable partitioning plane. - */ - SplitChoiceStruct sc; - - sc = Select_Splitting_Plane(polycount,polyindices); - - /* - ** If the algorithm could not separate any polys, just install the polys - ** in this node and terminate. TODO: explore how this happens. - */ - if (sc.FrontCount + sc.BackCount != polycount) { - node->PolyCount = polycount; - node->PolyIndices = polyindices; - return; - } - - /* - ** Decide whether to actually partition this node. If the partitioning - ** will not gain us anything, just install the polys in this node and terminate - ** the tree. - */ -#if 0 - if (sc.Cost == MAX_COST) { - node->PolyCount = polycount; - node->PolyIndices = polyindices; - return; - } -#endif - - /* - ** Ok, split the polys - */ - SplitArraysStruct arrays; - Split_Polys(polycount,polyindices,sc,&arrays); - - /* - ** Free the memory in use by the input tile-list - */ - delete[] polyindices; - - /* - ** Build a front tree if necessary. Remember that the Build function - ** deletes the poly array. - */ - if (arrays.FrontCount) { - WWASSERT(arrays.FrontPolys != NULL); - node->Front = new CullNodeStruct; - Build_Tree(node->Front,arrays.FrontCount,arrays.FrontPolys); - arrays.FrontPolys = NULL; - } - - /* - ** Build a back tree if necessary. Remember that the build function - ** deletes the tile array. - */ - if (arrays.BackCount) { - WWASSERT(arrays.BackPolys != NULL); - - node->Back = new CullNodeStruct; - Build_Tree(node->Back,arrays.BackCount,arrays.BackPolys); - arrays.BackPolys = NULL; - } - -} - - -/*********************************************************************************************** - * AABTreeBuilderClass::Select_Splitting_Plane -- select a partition for the given polys * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/19/98 GTH : Created. * - *=============================================================================================*/ -AABTreeBuilderClass::SplitChoiceStruct -AABTreeBuilderClass::Select_Splitting_Plane(int polycount,int * polyindices) -{ - WWASSERT(polyindices != NULL); - - const int NUM_TRYS = 50; - - SplitChoiceStruct best_plane_stats; - SplitChoiceStruct considered_plane_stats; - - /* - ** Try putting axis-aligned planes through some random vertices - */ - for (int trys = 0; trys < MIN(NUM_TRYS,polycount); trys++) { - - AAPlaneClass plane; - - /* - ** Select a random poly and vertex index; - */ - int poly_index = polyindices[rand() % polycount]; - int vert_index = rand() % 3; - const Vector3i * polyverts = Polys + poly_index; - const Vector3 * vert = Verts + (*polyverts)[vert_index]; - - /* - ** Select a random plane - */ - switch(rand() % 3) { - case 0: plane.Set(AAPlaneClass::XNORMAL,vert->X); break; - case 1: plane.Set(AAPlaneClass::YNORMAL,vert->Y); break; - case 2: plane.Set(AAPlaneClass::ZNORMAL,vert->Z); break; - }; - - /* - ** Get the score for this plane - */ - considered_plane_stats = Compute_Plane_Score(polycount,polyindices,plane); - - if (considered_plane_stats.Cost < best_plane_stats.Cost) { - best_plane_stats = considered_plane_stats; - } - } - - return best_plane_stats; -} - - -/*********************************************************************************************** - * AABTreeBuilderClass::Compute_Plane_Score -- evaluate the suitability of a partition plane * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/19/98 GTH : Created. * - *=============================================================================================*/ -AABTreeBuilderClass::SplitChoiceStruct -AABTreeBuilderClass::Compute_Plane_Score(int polycount,int * polyindices,const AAPlaneClass & plane) -{ - /* - ** The score of a splitting plane is based on the following factors: - ** - the volumes of the resulting two children volumes, - ** - the number of polys in each child volume - */ - SplitChoiceStruct sc; - sc.Plane = plane; - - for (int i=0; i COINCIDENCE_EPSILON) { - mask |= POS; - } - if (delta < -COINCIDENCE_EPSILON) { - mask |= NEG; - } - mask |= ON; - } - - /* - ** Now evaluate the status of all of the verts to determine whether the - ** triangle is in front, behind, on or overlapping the plane - */ - - /* - ** If all verts were ON the plane, the triangle is ON the plane - */ - if (mask == ON) { - return ON; - } - - /* - ** If all verts were POS or ON, the triangle is POS (IN_FRONT) - */ - if ((mask & ~(POS | ON)) == 0) { - return POS; - } - - /* - ** If all verts were NEG or ON, the triangle is NEG (BEHIND) - */ - if ((mask & ~(NEG | ON)) == 0) { - return NEG; - } - - /* - ** Otherwise, the triangle spans the plane - */ - return BOTH; -} - - -/*********************************************************************************************** - * AABTreeBuilderClass::Split_Polys -- partition the polys with a plane * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/19/98 GTH : Created. * - *=============================================================================================*/ -void AABTreeBuilderClass::Split_Polys -( - int polycount, - int * polyindices, - const SplitChoiceStruct & sc, - SplitArraysStruct * arrays -) -{ - /* - ** Note that this routine arrays of polygons. The caller is then responsible for keeping - ** track of the memory this routine allocates. - */ - if (sc.FrontCount > 0) { - arrays->FrontPolys = new int[sc.FrontCount]; - } - - if (sc.BackCount > 0) { - arrays->BackPolys = new int[sc.BackCount]; - } - - arrays->FrontCount = 0; - arrays->BackCount = 0; - - for (int i=0; iFrontPolys[arrays->FrontCount++] = polyindices[i]; - break; - - case BACK: - arrays->BackPolys[arrays->BackCount++] = polyindices[i]; - break; - } - } - - /* - ** when we are all done, the counts should match. - */ - WWASSERT(arrays->FrontCount == sc.FrontCount); - WWASSERT(arrays->BackCount == sc.BackCount); -} - - -/*********************************************************************************************** - * AABTreeBuilderClass::Compute_Bounding_Box -- compute bounding boxes for the cull nodes * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/19/98 GTH : Created. * - *=============================================================================================*/ -void AABTreeBuilderClass::Compute_Bounding_Box(CullNodeStruct * node) -{ - /* - ** compute bounding volumes of the children - */ - if (node->Front) { - Compute_Bounding_Box(node->Front); - } - - if (node->Back) { - Compute_Bounding_Box(node->Back); - } - - /* - ** compute bounding volume for the polys in this node - */ - node->Min.Set(100000.0f,100000.0f,100000.0f); - node->Max.Set(-100000.0f,-100000.0f,-100000.0f); - - for (int poly_index = 0; poly_index < node->PolyCount; poly_index++) { - Update_Min_Max(node->PolyIndices[poly_index],node->Min,node->Max ); - } - - /* - ** bound the polys in the front child node - */ - if (node->Front) { - if (node->Front->Min.X < node->Min.X) node->Min.X = node->Front->Min.X; - if (node->Front->Max.X > node->Max.X) node->Max.X = node->Front->Max.X; - - if (node->Front->Min.Y < node->Min.Y) node->Min.Y = node->Front->Min.Y; - if (node->Front->Max.Y > node->Max.Y) node->Max.Y = node->Front->Max.Y; - - if (node->Front->Min.Z < node->Min.Z) node->Min.Z = node->Front->Min.Z; - if (node->Front->Max.Z > node->Max.Z) node->Max.Z = node->Front->Max.Z; - } - - /* - ** bound the polys in the back child node - */ - if (node->Back) { - if (node->Back->Min.X < node->Min.X) node->Min.X = node->Back->Min.X; - if (node->Back->Max.X > node->Max.X) node->Max.X = node->Back->Max.X; - - if (node->Back->Min.Y < node->Min.Y) node->Min.Y = node->Back->Min.Y; - if (node->Back->Max.Y > node->Max.Y) node->Max.Y = node->Back->Max.Y; - - if (node->Back->Min.Z < node->Min.Z) node->Min.Z = node->Back->Min.Z; - if (node->Back->Max.Z > node->Max.Z) node->Max.Z = node->Back->Max.Z; - } - - WWASSERT(node->Min.X != 100000.0f); - WWASSERT(node->Min.Y != 100000.0f); - WWASSERT(node->Min.Z != 100000.0f); - WWASSERT(node->Max.X != -100000.0f); - WWASSERT(node->Max.Y != -100000.0f); - WWASSERT(node->Max.Z != -100000.0f); -} - - -/*********************************************************************************************** - * AABTreeBuilderClass::Assign_Index -- assign an array index to each node * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/19/98 GTH : Created. * - *=============================================================================================*/ -int AABTreeBuilderClass::Assign_Index(CullNodeStruct * node,int index) -{ - /* - ** This function is used to assign a sequential index to - ** each node in the tree. The AABTree stores its nodes in - ** an array so this index is used to determine which slot - ** in the array to put each node into. - */ - WWASSERT(node); - node->Index = index; - index++; - - if (node->Front) { - index = Assign_Index(node->Front,index); - } - - if (node->Back) { - index = Assign_Index(node->Back,index); - } - - return index; -} - - -/*********************************************************************************************** - * AABTreeBuilderClass::Node_Count -- Count the nodes in the tree * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/19/98 GTH : Created. * - *=============================================================================================*/ -int AABTreeBuilderClass::Node_Count(void) -{ - if (Root) { - return Node_Count_Recursive(Root,0); - } else { - return 0; - } -} - - -/*********************************************************************************************** - * AABTreeBuilderClass::Poly_Count -- returns number of polys * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/23/98 GTH : Created. * - *=============================================================================================*/ -int AABTreeBuilderClass::Poly_Count(void) -{ - return PolyCount; -} - -/*********************************************************************************************** - * AABTreeBuilderClass::Node_Count_Recursive -- internal implementation of Node_Count * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/19/98 GTH : Created. * - *=============================================================================================*/ -int AABTreeBuilderClass::Node_Count_Recursive(CullNodeStruct * node,int curcount) -{ - curcount++; - if (node->Front) { - curcount = Node_Count_Recursive(node->Front,curcount); - } - if (node->Back) { - curcount = Node_Count_Recursive(node->Back,curcount); - } - return curcount; -} - - -/*********************************************************************************************** - * AABTreeBuilderClass::Update_Min -- ensure given vector is < min of the poly * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/22/98 GTH : Created. * - *=============================================================================================*/ -void AABTreeBuilderClass::Update_Min(int poly_index,Vector3 & min) -{ - for (int vert_index = 0; vert_index < 3; vert_index++) { - - const Vector3i * polyverts = Polys + poly_index; - const Vector3 * point = Verts + (*polyverts)[vert_index]; - - if (point->X < min.X) min.X = point->X; - if (point->Y < min.Y) min.Y = point->Y; - if (point->Z < min.Z) min.Z = point->Z; - } -} - - -/*********************************************************************************************** - * AABTreeBuilderClass::Update_Max -- ensure given vector is > max of poly * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/22/98 GTH : Created. * - *=============================================================================================*/ -void AABTreeBuilderClass::Update_Max(int poly_index,Vector3 & max) -{ - for (int vert_index = 0; vert_index < 3; vert_index++) { - - const Vector3i * polyverts = Polys + poly_index; - const Vector3 * point = Verts + (*polyverts)[vert_index]; - - if (point->X > max.X) max.X = point->X; - if (point->Y > max.Y) max.Y = point->Y; - if (point->Z > max.Z) max.Z = point->Z; - } -} - - -/*********************************************************************************************** - * AABTreeBuilderClass::Update_Min_Max -- ensure given vector is in min max of poly * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/24/98 BMG : Created. * - *=============================================================================================*/ -void AABTreeBuilderClass::Update_Min_Max(int poly_index, Vector3 & min, Vector3 & max) -{ - for (int vert_index = 0; vert_index < 3; vert_index++) { - - const Vector3i * polyverts = Polys + poly_index; - const Vector3 * point = Verts + (*polyverts)[vert_index]; - - if (point->X < min.X) min.X = point->X; - if (point->Y < min.Y) min.Y = point->Y; - if (point->Z < min.Z) min.Z = point->Z; - - if (point->X > max.X) max.X = point->X; - if (point->Y > max.Y) max.Y = point->Y; - if (point->Z > max.Z) max.Z = point->Z; - } -} - - - -/*********************************************************************************************** - * AABTreeBuilderClass::Export -- Saves this AABTree into a W3D chunk * - * * - * This function will export the AABTree into a W3D chunk so that it can be loaded by its * - * sister class "AABTreeClass" in the WW3D library. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/22/2000 gth : Created. * - *=============================================================================================*/ -void AABTreeBuilderClass::Export(ChunkSaveClass & csave) -{ - csave.Begin_Chunk(W3D_CHUNK_AABTREE); - - /* - ** Pack the tree into an array of W3dMeshAABTreeNode's and polygon indices - */ - W3dMeshAABTreeNode * nodes = new W3dMeshAABTreeNode[Node_Count()]; - uint32 * poly_indices = new uint32[Poly_Count()]; - - int cur_node = 0; - int cur_poly = 0; - Build_W3D_AABTree_Recursive(Root,nodes,poly_indices,cur_node,cur_poly); - - /* - ** Write out the header - */ - csave.Begin_Chunk(W3D_CHUNK_AABTREE_HEADER); - W3dMeshAABTreeHeader header; - memset(&header,0,sizeof(header)); - header.NodeCount = Node_Count(); - header.PolyCount = Poly_Count(); - csave.Write(&header,sizeof(header)); - csave.End_Chunk(); - - /* - ** Write out the array of polygon indices - */ - csave.Begin_Chunk(W3D_CHUNK_AABTREE_POLYINDICES); - csave.Write(poly_indices,Poly_Count() * sizeof(uint32)); - csave.End_Chunk(); - - /* - ** Write out the array of nodes - */ - csave.Begin_Chunk(W3D_CHUNK_AABTREE_NODES); - for (int ni=0; niIndex]); - newnode->Min.X = node->Min.X; - newnode->Min.Y = node->Min.Y; - newnode->Min.Z = node->Min.Z; - newnode->Max.X = node->Max.X; - newnode->Max.Y = node->Max.Y; - newnode->Max.Z = node->Max.Z; - - /* - ** If this is a non-leaf node, set up the child indices, otherwise set up the polygon indices - */ - if (node->Front != NULL) { - - WWASSERT(node->Back != NULL); // if we have one child, we better have both! - newnode->FrontOrPoly0 = node->Front->Index; - newnode->BackOrPolyCount = node->Back->Index; - - } else { - - newnode->FrontOrPoly0 = cur_poly | 0x80000000; - newnode->BackOrPolyCount = node->PolyCount; - - } - - /* - ** Copy the polygon indices for this node into our array - */ - for (int pcounter = 0; pcounter < node->PolyCount; pcounter++) { - poly_indices[cur_poly++] = node->PolyIndices[pcounter]; - } - - /* - ** Install the children - */ - if (node->Front) { - Build_W3D_AABTree_Recursive(node->Front,w3d_nodes,poly_indices,cur_node,cur_poly); - } - if (node->Back) { - Build_W3D_AABTree_Recursive(node->Back,w3d_nodes,poly_indices,cur_node,cur_poly); - } -} - - - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/aabtreebuilder.h b/Generals/Code/Tools/WW3D/max2w3d/aabtreebuilder.h deleted file mode 100644 index 25a843a8edf..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/aabtreebuilder.h +++ /dev/null @@ -1,209 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/aabtreebuilder.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 5/22/00 2:02p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef AABTREEBUILDER_H -#define AABTREEBUILDER_H - -#include "always.h" -#include "vector3.h" -#include "vector3i.h" -#include "aaplane.h" -#include "BITTYPE.H" -#include - -class AABTreeClass; -class ChunkSaveClass; -struct W3dMeshAABTreeNode; - -/* -** AABTreeBuilderClass -** This class serves simply to build AABTreeClasses. It first builds a tree -** which uses an easier to manage data structure (but uses more memory). Then -** the tree is converted into the representation used in the AABTreeClass. -*/ -class AABTreeBuilderClass -{ -public: - - AABTreeBuilderClass(void); - ~AABTreeBuilderClass(void); - - void Build_AABTree(int polycount,Vector3i * polys,int vertcount,Vector3 * verts); - void Export(ChunkSaveClass & csave); - - int Node_Count(void); - int Poly_Count(void); - - enum - { - MIN_POLYS_PER_NODE = 4, - SMALL_VERTEX = -100000, - BIG_VERTEX = 100000 - }; - -private: - - /* - ** This CullNodeStruct is used in building the AABTree. It is much more - ** wasteful in terms of memory footprint and number of allocations than the - ** streamlined version found in the actual AABTreeClass. - */ - struct CullNodeStruct - { - CullNodeStruct(void) : Index(0),Min(0,0,0),Max(0,0,0),Front(NULL),Back(NULL),PolyCount(0),PolyIndices(NULL) {} - ~CullNodeStruct(void) - { - if (Front) { delete Front; } - if (Back) { delete Back; } - if (PolyIndices) { delete[] PolyIndices; } - } - - int Index; - Vector3 Min; - Vector3 Max; - CullNodeStruct * Front; - CullNodeStruct * Back; - int PolyCount; - int * PolyIndices; - }; - - /* - ** SplitChoiceStruct - encapsulates the results of evaluating the suitability of a partition - */ - struct SplitChoiceStruct - { - SplitChoiceStruct(void) : - Cost(FLT_MAX), - FrontCount(0), - BackCount(0), - BMin(BIG_VERTEX,BIG_VERTEX,BIG_VERTEX), - BMax(SMALL_VERTEX,SMALL_VERTEX,SMALL_VERTEX), - FMin(BIG_VERTEX,BIG_VERTEX,BIG_VERTEX), - FMax(SMALL_VERTEX,SMALL_VERTEX,SMALL_VERTEX), - Plane(AAPlaneClass::XNORMAL,0) - { - } - - float Cost; // try to minimize this! - int FrontCount; // number of polys in front of the plane - int BackCount; // number of polys behind the plane - Vector3 BMin; // min of the bounding box of the "back" child - Vector3 BMax; // max of the bounding box of the "back" child - Vector3 FMin; // min of the bounding box of the "front" child - Vector3 FMax; // max of the bounding box of the "front" child - AAPlaneClass Plane; // partitioning plane - }; - - struct SplitArraysStruct - { - SplitArraysStruct(void) : - FrontCount(0), - BackCount(0), - FrontPolys(NULL), - BackPolys(NULL) - { - } - - int FrontCount; - int BackCount; - int * FrontPolys; - int * BackPolys; - }; - - enum OverlapType - { - POS = 0x01, - NEG = 0x02, - ON = 0x04, - BOTH = 0x08, - OUTSIDE = POS, - INSIDE = NEG, - OVERLAPPED = BOTH, - FRONT = POS, - BACK = NEG, - }; - - - /* - ** Internal functions - */ - void Reset(); - void Build_Tree(CullNodeStruct * node,int polycount,int * polyindices); - SplitChoiceStruct Select_Splitting_Plane(int polycount,int * polyindices); - SplitChoiceStruct Compute_Plane_Score(int polycont,int * polyindices,const AAPlaneClass & plane); - void Split_Polys(int polycount,int * polyindices,const SplitChoiceStruct & sc,SplitArraysStruct * arrays); - OverlapType Which_Side(const AAPlaneClass & plane,int poly_index); - void Compute_Bounding_Box(CullNodeStruct * node); - int Assign_Index(CullNodeStruct * node,int index); - int Node_Count_Recursive(CullNodeStruct * node,int curcount); - void Update_Min(int poly_index,Vector3 & set_min); - void Update_Max(int poly_index,Vector3 & set_max); - void Update_Min_Max(int poly_index, Vector3 & set_min, Vector3 & set_max); - - void Build_W3D_AABTree_Recursive(CullNodeStruct * node, - W3dMeshAABTreeNode * w3dnodes, - uint32 * poly_indices, - int & cur_node, - int & cur_poly); - /* - ** Tree - */ - CullNodeStruct * Root; - int CurPolyIndex; - - /* - ** Mesh data - */ - int PolyCount; - Vector3i * Polys; - int VertCount; - Vector3 * Verts; - - friend class AABTreeClass; -}; - - - - -#endif //AABTREEBUILDER_H - diff --git a/Generals/Code/Tools/WW3D/max2w3d/animationcompressionsettings.cpp b/Generals/Code/Tools/WW3D/max2w3d/animationcompressionsettings.cpp deleted file mode 100644 index 00d939acfc6..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/animationcompressionsettings.cpp +++ /dev/null @@ -1,291 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/animationcompressionsettings.cpp $* - * * - * Original Author:: Patrick Smith * - * * - * $Author:: Patrick $* - * * - * $Modtime:: 10/30/00 1:57p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "animationcompressionsettings.h" -#include "dllmain.h" -#include "resource.h" -#include "w3dexp.h" - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// AnimationCompressionSettingsDialogClass -// -//////////////////////////////////////////////////////////////////////////////////////// -AnimationCompressionSettingsDialogClass::AnimationCompressionSettingsDialogClass (Interface *maxinterface, HWND parent_wnd) : - MaxInterface (maxinterface), - Options (NULL), - Wnd (NULL), - ParentWnd (parent_wnd) -{ - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// ~AnimationCompressionSettingsDialogClass -// -//////////////////////////////////////////////////////////////////////////////////////// -AnimationCompressionSettingsDialogClass::~AnimationCompressionSettingsDialogClass (void) -{ - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Do_Modal -// -//////////////////////////////////////////////////////////////////////////////////////// -int -AnimationCompressionSettingsDialogClass::Do_Modal (void) -{ - int retval = ::DialogBoxParam (AppInstance, MAKEINTRESOURCE (IDD_ANIMATION_COMPRESSION), - ParentWnd, Real_Message_Proc, (LPARAM)this); - return retval; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Real_Message_Proc -// -//////////////////////////////////////////////////////////////////////////////////////// -BOOL CALLBACK -AnimationCompressionSettingsDialogClass::Real_Message_Proc -( - HWND wnd, - UINT message, - WPARAM wparam, - LPARAM lparam -) -{ - AnimationCompressionSettingsDialogClass *dialog_obj = NULL; - - // - // Setup the framework we need so that the instance - // can process the messages instead of this static callback. - // - if (message == WM_INITDIALOG) { - dialog_obj = (AnimationCompressionSettingsDialogClass *)lparam; - dialog_obj->Wnd = wnd; - ::SetProp (wnd, "DIALOG_OBJ", (HANDLE)dialog_obj); - } else { - dialog_obj = (AnimationCompressionSettingsDialogClass *)::GetProp (wnd, "DIALOG_OBJ"); - } - - // - // Allow the instance to handle the call - // - BOOL retval = FALSE; - if (dialog_obj != NULL) { - retval = dialog_obj->Message_Proc (message, wparam, lparam); - } - - // - // Cleanup the framework - // - if (message == WM_DESTROY) { - ::RemoveProp (wnd, "DIALOG_OBJ"); - } - - return retval; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Message_Proc -// -//////////////////////////////////////////////////////////////////////////////////////// -BOOL -AnimationCompressionSettingsDialogClass::Message_Proc -( - UINT message, - WPARAM wparam, - LPARAM lparam -) -{ - BOOL retval = FALSE; - - switch (message) - { - case WM_INITDIALOG: - { - // - // Center the dialog - // - RECT parent_rect = { 0 }; - RECT rect = { 0 }; - ::GetWindowRect (ParentWnd, &parent_rect); - ::GetWindowRect (Wnd, &rect); - int width = parent_rect.right - parent_rect.left; - int height = parent_rect.bottom - parent_rect.top; - ::SetWindowPos ( Wnd, NULL, - parent_rect.left + (width / 2) - ((rect.right - rect.left) / 2), - parent_rect.top + (height / 2) - ((rect.bottom - rect.top) / 2), - 0, 0, SWP_NOZORDER | SWP_NOSIZE); - - // - // Initialize the dialog controls - // - Initialize_Controls (); - } - break; - - case WM_COMMAND: - { - switch (LOWORD (wparam)) - { - case IDCANCEL: - EndDialog (Wnd, IDCANCEL); - break; - - case IDOK: - Save_Settings (); - EndDialog (Wnd, IDOK); - break; - } - } - break; - } - - return retval; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Initialize_Controls -// -//////////////////////////////////////////////////////////////////////////////////////// -void -AnimationCompressionSettingsDialogClass::Initialize_Controls (void) -{ - SetCheckBox (Wnd, IDC_REDUCE_ANIMATION_CHECK, Options->ReduceAnimation); - char string[128] = { 0 }; - - // - // Populate the reduction percent combo box - // - HWND percent_combo = ::GetDlgItem (Wnd, IDC_REDUCE_ANIMATION_COMBO); - for (int index = 1; index < 100; index ++) { - sprintf (string, "%d", index); - ComboBox_AddString (percent_combo, string); - } - - // - // Populate the animation type combo box - // - HWND flavor_combo = ::GetDlgItem (Wnd, IDC_COMPRESS_ANIMATION_FLAVOR_COMBO); - ComboBox_AddString (flavor_combo, "TimeCoded"); - ComboBox_AddString (flavor_combo, "Adaptive Delta"); - - // - // Bounds check the parameters - // - if ((Options->ReduceAnimationPercent < 1) || (Options->ReduceAnimationPercent > 99)) { - Options->ReduceAnimationPercent = 50; - - } - - if ((Options->CompressAnimationFlavor < 0) || (Options->CompressAnimationFlavor >= ANIM_FLAVOR_VALID)) { - Options->CompressAnimationFlavor = 0; - } - - // - // Select the correct entries in the combo boxes - // - ComboBox_SetCurSel (percent_combo, Options->ReduceAnimationPercent - 1); - ComboBox_SetCurSel (flavor_combo, Options->CompressAnimationFlavor); - - // - // Fill in the error fields - // - ::sprintf (string, "%f", Options->CompressAnimationTranslationError); - ::SetDlgItemText (Wnd, IDC_MAX_TRANS_ERROR_EDIT, string); - - ::sprintf (string, "%f", Options->CompressAnimationRotationError); - ::SetDlgItemText (Wnd, IDC_MAX_ROT_ERROR_EDIT, string); - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Save_Settings -// -//////////////////////////////////////////////////////////////////////////////////////// -void -AnimationCompressionSettingsDialogClass::Save_Settings (void) -{ - // - // Read the compression type setting - // - int flavor = ComboBox_GetCurSel (::GetDlgItem (Wnd, IDC_COMPRESS_ANIMATION_FLAVOR_COMBO)); - Options->CompressAnimationFlavor = flavor; - - // - // Determine whether or not we want to force reduction - // - Options->ReduceAnimation = (IsDlgButtonChecked (Wnd, IDC_REDUCE_ANIMATION_CHECK) == 1); - - // - // Read the reduction percent setting - // - int reduce_percent = ComboBox_GetCurSel (::GetDlgItem (Wnd, IDC_REDUCE_ANIMATION_COMBO)) + 1; - Options->ReduceAnimationPercent = reduce_percent; - - // - // Read the amount of compression error we'll allow in the translational component - // - char string[128]; - ::GetDlgItemText (Wnd, IDC_MAX_TRANS_ERROR_EDIT, string, sizeof (string)); - float trans_error = ::atof (string); - Options->CompressAnimationTranslationError = trans_error; - - // - // Read the amount of compression error we'll allow in the rotational component - // - ::GetDlgItemText (Wnd, IDC_MAX_ROT_ERROR_EDIT, string, sizeof (string)); - float rot_error = ::atof (string); - Options->CompressAnimationRotationError = rot_error; - return ; -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/animationcompressionsettings.h b/Generals/Code/Tools/WW3D/max2w3d/animationcompressionsettings.h deleted file mode 100644 index 5e6ab3ca3cd..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/animationcompressionsettings.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/animationcompressionsettings.h $* - * * - * Original Author:: Patrick Smith * - * * - * $Author:: Patrick $* - * * - * $Modtime:: 10/30/00 1:57p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef __ANIMATION_COMPRESSION_SETTINGS_H -#define __ANIMATION_COMPRESSION_SETTINGS_H - -#include -#include -#include "w3dutil.h" - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// AnimationCompressionSettingsDialogClass -// -//////////////////////////////////////////////////////////////////////////////////////// -class AnimationCompressionSettingsDialogClass -{ -public: - - ////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////// - AnimationCompressionSettingsDialogClass (Interface *maxinterface, HWND parent_wnd = NULL); - ~AnimationCompressionSettingsDialogClass (void); - - - ////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////// - - void Set_Options (W3dExportOptionsStruct *options) { Options = options; } - int Do_Modal (void); - -private: - - ////////////////////////////////////////////////////////////////// - // Static methods - ////////////////////////////////////////////////////////////////// - static BOOL CALLBACK Real_Message_Proc (HWND wnd, UINT message, WPARAM wparam, LPARAM lparam); - - ////////////////////////////////////////////////////////////////// - // Private methods - ////////////////////////////////////////////////////////////////// - BOOL Message_Proc (UINT message, WPARAM wparam, LPARAM lparam); - void Initialize_Controls (void); - void Save_Settings (void); - - ////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////// - W3dExportOptionsStruct * Options; - Interface * MaxInterface; - HWND Wnd; - HWND ParentWnd; -}; - - -#endif //__ANIMATION_COMPRESSION_SETTINGS_H - diff --git a/Generals/Code/Tools/WW3D/max2w3d/bchannel.cpp b/Generals/Code/Tools/WW3D/max2w3d/bchannel.cpp deleted file mode 100644 index 1682caf8b1f..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/bchannel.cpp +++ /dev/null @@ -1,319 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : W3D Tools * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/bchannel.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/30/00 5:25p $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "bchannel.h" -#include "w3d_file.h" -#include "logdlg.h" -#include "exportlog.h" - - -BitChannelClass::BitChannelClass -( - uint32 id, - int maxframes, - uint32 chntype, - bool default_val -) : - ID(id), - ChannelType(chntype), - MaxFrames(maxframes), - IsEmpty(true), - DefaultVal(default_val), - Data(maxframes), - Begin(0), - End(0) -{ - // start "Begin" at the end of the array, whenever we set a value - // at an index less than "Begin", we push "Begin" back. - Begin = MaxFrames; - End = 0; -} - -BitChannelClass::~BitChannelClass(void) -{ -} - -void BitChannelClass::Set_Bit(int frameidx,bool bit) -{ - assert(frameidx >= 0); - assert(frameidx < MaxFrames); - - Data[frameidx] = bit; - - if (!is_default(bit)) { - IsEmpty = false; - } -} - -void BitChannelClass::Set_Bits(BooleanVectorClass & bits) -{ - for (int i=0; i= 0); - assert(frameidx < MaxFrames); - - return Data[frameidx]; -} - - -bool BitChannelClass::Save(ChunkSaveClass & csave, bool compress) -{ - if (IsEmpty) return true; - - if (compress) { - // Save the Channel Data Compressed - // TIMECODED - if (!csave.Begin_Chunk(W3D_CHUNK_COMPRESSED_BIT_CHANNEL)) { - return false; - } - - uint32 channelsize = sizeof(W3dTimeCodedBitChannelStruct); - uint32 packetsize = sizeof(uint32); - - channelsize += packetsize * MaxFrames; - channelsize -= sizeof(uint32); - - W3dTimeCodedBitChannelStruct * chn = (W3dTimeCodedBitChannelStruct *)malloc(channelsize); - - if (chn == NULL) { - return false; - } - - chn->NumTimeCodes = MaxFrames; - chn->Pivot = ID; - chn->Flags = ChannelType; - chn->DefaultVal = DefaultVal; - - // copy data into the channel struct, in timecoded raw format - - for (uint32 fcount=0; fcount < chn->NumTimeCodes; fcount++) { - - if (Get_Bit(fcount)) { - chn->Data[fcount] = fcount | W3D_TIMECODED_BIT_MASK; - } - else { - chn->Data[fcount] = fcount; - } - } - - // Compress the new structure - - BitChannelClass::compress( chn ); - - float originalchannelsize = channelsize; - - // Update Channel Size - channelsize = sizeof(W3dTimeCodedBitChannelStruct); - channelsize += packetsize * chn->NumTimeCodes; - channelsize -= sizeof(uint32); - - float percent = (((float) channelsize) / originalchannelsize) * 100.0f; - - ExportLog::printf("%.0f", percent); - - - // save - - if (csave.Write(chn,channelsize) != channelsize) { - return false; - } - - if (chn != NULL) { - free(chn); - } - - if (!csave.End_Chunk()) { - return false; - } - - } - else { - // Stock Raw Save - if (!csave.Begin_Chunk(W3D_CHUNK_BIT_CHANNEL)) { - return false; - } - - compute_range(); - - int numbits = End - Begin + 1; - assert(numbits > 0); - int numbytes = (numbits + 7) / 8; - - unsigned int channelsize = sizeof(W3dBitChannelStruct); - channelsize += numbytes - 1; // one byte inside the W3dBitChannelStruct... - - W3dBitChannelStruct * chn = (W3dBitChannelStruct *)malloc(channelsize); - - if (chn == NULL) { - return false; - } - - chn->FirstFrame = Begin; - chn->LastFrame = End; - chn->Flags = ChannelType; - chn->Pivot = ID; - chn->DefaultVal = DefaultVal; - - uint8 * bits = (uint8 *)&(chn->Data[0]); - - for (int fcount=0; fcount < End-Begin+1; fcount++) { - ::Set_Bit(bits,fcount,Get_Bit(Begin + fcount)); - } - - if (csave.Write(chn,channelsize) != channelsize) { - return false; - } - - if (chn != NULL) { - free(chn); - } - - if (!csave.End_Chunk()) { - return false; - } - - } - - return true; -} - - -bool BitChannelClass::is_default(bool bit) -{ - return (bit == DefaultVal); -} - -void BitChannelClass::compute_range(void) -{ - Begin = 0; - while ((Begin < MaxFrames) && (is_default(Get_Bit(Begin)))) { - Begin++; - } - - End = MaxFrames-1; - while ((End >= 0) && (is_default(Get_Bit(End)))) { - End--; - } -} // compute_range - - -// -// find a packet that isn't needed, and return the index -// if all packets are necessary, then return back PACKETS_ALL_USEFUL -// a useless packet is defined, as a packet that can be recreated -// -#define PACKETS_ALL_USEFUL (0xFFFFFFFF) -// -uint32 BitChannelClass::find_useless_packet(W3dTimeCodedBitChannelStruct * c) -{ - - assert( c ); // make sure pointer exists - assert( c->NumTimeCodes ); // make sure some packets exist - - if (c->NumTimeCodes > 2) { - - for(uint32 try_idx = 0; try_idx < (c->NumTimeCodes - 1); try_idx++) { - - if ((c->Data[try_idx] & W3D_TIMECODED_BIT_MASK) == - (c->Data[try_idx+1] & W3D_TIMECODED_BIT_MASK)) { - return(try_idx + 1); - } - - } // for - } - - return( PACKETS_ALL_USEFUL ); - -} // find_useless_packet - - -// -// Remove a packet from a W3dTimeCodedBitChannelStruct -// -void BitChannelClass::remove_packet(W3dTimeCodedBitChannelStruct * c, uint32 packet_idx) -{ - assert( c ); - assert( c->NumTimeCodes > 1 ); - - uint32 packet_size = 1; - uint32 packet_len = packet_size * sizeof(uint32); - - uint32 *src, *dst; - - dst = (uint32 *) &c->Data[ packet_size * packet_idx ]; - src = (uint32 *) &c->Data[ packet_size * (packet_idx + 1) ]; - - uint32 copy_length = (c->NumTimeCodes - (packet_idx + 1)) * packet_len; - - if (copy_length) { - - memcpy(dst, src, copy_length); - - } - - // Decrement Packet Count - c->NumTimeCodes--; - -} // remove_packet - -// -// Take a non-compressed TimeCoded Bit Channel -// and compress the packets -// -void BitChannelClass::compress(W3dTimeCodedBitChannelStruct * c) -{ - while(1) { - - uint32 idx = find_useless_packet( c ); - - if (PACKETS_ALL_USEFUL == idx) break; - - remove_packet( c, idx ); - - } - -} // compress - - - - -// EOF - bchannel.cpp diff --git a/Generals/Code/Tools/WW3D/max2w3d/bchannel.h b/Generals/Code/Tools/WW3D/max2w3d/bchannel.h deleted file mode 100644 index 88225578c44..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/bchannel.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : W3D Tools * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/bchannel.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/30/00 5:25p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef BCHANNEL_H -#define BCHANNEL_H - -#ifndef ALWAYS_H -#include "always.h" -#endif - -#ifndef BITTYPE_H -#include "BITTYPE.H" -#endif - -#ifndef CHUNKIO_H -#include "chunkio.h" -#endif - -#ifndef VECTOR_H -#include "Vector.H" -#endif - -#ifndef W3D_FILE_H -#include "w3d_file.h" -#endif - -class LogDataDialogClass; - -class BitChannelClass -{ -public: - - BitChannelClass(uint32 id,int maxframes,uint32 chntype,bool def_val); - ~BitChannelClass(void); - - void Set_Bit(int framenumber,bool bit); - void Set_Bits(BooleanVectorClass & bits); - bool Get_Bit(int frameidx); - bool Is_Empty(void) { return IsEmpty; } - bool Save(ChunkSaveClass & csave, bool compress); - -private: - - uint32 ID; - uint32 ChannelType; - int MaxFrames; - bool IsEmpty; - - bool DefaultVal; - BooleanVectorClass Data; - int Begin; - int End; - - // Test a bit against the "default" bit - bool is_default(bool bit); - - // This function finds the start and end of the "non-default" data - void compute_range(void); - - // compress functions - void remove_packet(W3dTimeCodedBitChannelStruct * c, uint32 packet_idx); - uint32 find_useless_packet(W3dTimeCodedBitChannelStruct * c); - void compress(W3dTimeCodedBitChannelStruct * c); - - -}; - - -#endif \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/boneicon.cpp b/Generals/Code/Tools/WW3D/max2w3d/boneicon.cpp deleted file mode 100644 index 75e34564b82..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/boneicon.cpp +++ /dev/null @@ -1,606 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/boneicon.cpp 6 1/12/98 4:02p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - WWSkin * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/boneicon.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 1/09/98 3:09p $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "boneicon.h" - -const int NumBoneIconVerts = 184; -const int NumBoneIconFaces = 366; - -/* -** Don't try this at home :-) -*/ -#pragma warning(disable:4305) - -VertexStruct BoneIconVerts[NumBoneIconVerts] = { - - { 0.07, -0.37, 0.23 }, - { 0.07, -0.38, 0.22 }, - { 0.07, -0.37, 0.22 }, - { -0.07, -0.38, 0.22 }, - { -0.07, -0.38, 0.22 }, - { -0.05, -0.31, 0.21 }, - { -0.07, -0.38, 0.22 }, - { -0.07, -0.37, 0.21 }, - { 0.07, -0.38, 0.22 }, - { 0.06, -0.34, 0.18 }, - { 0.07, -0.38, 0.23 }, - { -0.07, -0.38, 0.22 }, - { -0.10, -0.42, 0.19 }, - { -0.04, -0.47, 0.11 }, - { -0.04, -0.51, 0.21 }, - { -0.04, -0.36, 0.12 }, - { 0.05, -0.41, 0.10 }, - { 0.05, -0.51, 0.15 }, - { 0.05, -0.49, 0.26 }, - { 0.11, -0.42, 0.19 }, - { -0.05, -0.45, 0.26 }, - { -0.06, -0.43, 0.25 }, - { -0.04, -0.45, 0.27 }, - { -0.07, -0.40, 0.23 }, - { 0.00, -0.46, 0.27 }, - { 0.04, -0.45, 0.27 }, - { 0.05, -0.44, 0.27 }, - { -0.00, -0.46, 0.27 }, - { 0.06, -0.43, 0.25 }, - { 0.07, -0.39, 0.24 }, - { -0.11, -0.37, 0.28 }, - { -0.05, -0.47, 0.30 }, - { -0.05, -0.38, 0.37 }, - { -0.05, -0.29, 0.32 }, - { 0.04, -0.44, 0.35 }, - { 0.04, -0.33, 0.36 }, - { 0.04, -0.28, 0.26 }, - { 0.10, -0.37, 0.28 }, - { 0.04, -0.30, 0.23 }, - { 0.04, -0.29, 0.24 }, - { 0.01, -0.29, 0.24 }, - { -0.03, -0.30, 0.25 }, - { -0.05, -0.31, 0.22 }, - { -0.04, -0.35, 0.15 }, - { -0.03, -0.35, 0.13 }, - { -0.02, -0.35, 0.13 }, - { 0.04, -0.36, 0.14 }, - { 0.05, -0.34, 0.16 }, - { -0.05, 0.36, -0.16 }, - { -0.05, 0.36, -0.15 }, - { -0.07, 0.41, -0.22 }, - { 0.05, 0.33, -0.22 }, - { 0.06, 0.35, -0.21 }, - { 0.07, 0.41, -0.22 }, - { 0.04, 0.38, -0.14 }, - { 0.07, 0.40, -0.20 }, - { 0.07, 0.41, -0.21 }, - { 0.04, 0.38, -0.13 }, - { 0.01, 0.38, -0.13 }, - { -0.03, 0.38, -0.13 }, - { -0.07, 0.40, -0.21 }, - { -0.04, 0.33, -0.22 }, - { -0.07, 0.41, -0.22 }, - { -0.03, 0.32, -0.24 }, - { -0.02, 0.32, -0.24 }, - { 0.04, 0.33, -0.24 }, - { -0.10, 0.40, -0.27 }, - { -0.04, 0.36, -0.35 }, - { -0.04, 0.31, -0.25 }, - { -0.04, 0.47, -0.34 }, - { 0.05, 0.41, -0.36 }, - { 0.05, 0.32, -0.31 }, - { 0.05, 0.50, -0.28 }, - { 0.11, 0.40, -0.27 }, - { -0.06, 0.46, -0.24 }, - { -0.07, 0.42, -0.23 }, - { -0.05, 0.48, -0.25 }, - { -0.04, 0.48, -0.25 }, - { 0.00, 0.49, -0.26 }, - { 0.04, 0.48, -0.25 }, - { 0.05, 0.48, -0.25 }, - { -0.00, 0.49, -0.26 }, - { 0.07, 0.43, -0.21 }, - { 0.06, 0.46, -0.24 }, - { -0.11, 0.45, -0.18 }, - { -0.05, 0.44, -0.08 }, - { -0.05, 0.54, -0.14 }, - { -0.05, 0.52, -0.25 }, - { 0.04, 0.39, -0.11 }, - { 0.04, 0.50, -0.10 }, - { 0.04, 0.54, -0.20 }, - { 0.10, 0.45, -0.18 }, - { 0.07, 0.37, 0.22 }, - { 0.07, 0.37, 0.22 }, - { 0.07, 0.37, 0.21 }, - { -0.07, 0.37, 0.22 }, - { -0.07, 0.37, 0.22 }, - { -0.05, 0.33, 0.17 }, - { -0.07, 0.37, 0.22 }, - { -0.07, 0.36, 0.22 }, - { 0.07, 0.37, 0.22 }, - { 0.06, 0.31, 0.21 }, - { 0.07, 0.37, 0.22 }, - { -0.07, 0.37, 0.22 }, - { -0.10, 0.37, 0.27 }, - { -0.04, 0.32, 0.36 }, - { -0.04, 0.43, 0.34 }, - { -0.04, 0.27, 0.25 }, - { 0.05, 0.28, 0.31 }, - { 0.05, 0.38, 0.37 }, - { 0.05, 0.46, 0.29 }, - { 0.11, 0.37, 0.27 }, - { -0.05, 0.44, 0.26 }, - { -0.06, 0.43, 0.25 }, - { -0.04, 0.45, 0.26 }, - { -0.07, 0.39, 0.24 }, - { 0.00, 0.46, 0.26 }, - { 0.04, 0.45, 0.26 }, - { 0.05, 0.44, 0.25 }, - { -0.00, 0.46, 0.27 }, - { 0.06, 0.42, 0.25 }, - { 0.07, 0.40, 0.22 }, - { -0.11, 0.42, 0.19 }, - { -0.05, 0.48, 0.26 }, - { -0.05, 0.50, 0.15 }, - { -0.05, 0.41, 0.09 }, - { 0.04, 0.51, 0.21 }, - { 0.04, 0.46, 0.10 }, - { 0.04, 0.35, 0.12 }, - { 0.10, 0.42, 0.19 }, - { 0.04, 0.35, 0.15 }, - { 0.04, 0.35, 0.14 }, - { 0.01, 0.34, 0.13 }, - { -0.03, 0.35, 0.14 }, - { -0.05, 0.33, 0.16 }, - { -0.04, 0.30, 0.23 }, - { -0.03, 0.28, 0.24 }, - { -0.02, 0.28, 0.24 }, - { 0.04, 0.29, 0.25 }, - { 0.05, 0.30, 0.22 }, - { -0.05, -0.34, -0.21 }, - { -0.05, -0.34, -0.22 }, - { -0.07, -0.41, -0.22 }, - { 0.05, -0.37, -0.16 }, - { 0.06, -0.37, -0.17 }, - { 0.07, -0.41, -0.22 }, - { 0.04, -0.33, -0.23 }, - { 0.07, -0.40, -0.22 }, - { 0.07, -0.41, -0.23 }, - { 0.04, -0.32, -0.24 }, - { 0.01, -0.32, -0.24 }, - { -0.03, -0.33, -0.24 }, - { -0.07, -0.40, -0.21 }, - { -0.04, -0.38, -0.15 }, - { -0.07, -0.41, -0.22 }, - { -0.03, -0.38, -0.13 }, - { -0.02, -0.38, -0.13 }, - { 0.04, -0.39, -0.14 }, - { -0.10, -0.45, -0.19 }, - { -0.04, -0.50, -0.11 }, - { -0.04, -0.39, -0.12 }, - { -0.04, -0.54, -0.21 }, - { 0.05, -0.54, -0.15 }, - { 0.05, -0.44, -0.10 }, - { 0.05, -0.52, -0.26 }, - { 0.11, -0.45, -0.19 }, - { -0.06, -0.46, -0.26 }, - { -0.07, -0.43, -0.23 }, - { -0.05, -0.48, -0.26 }, - { -0.04, -0.48, -0.27 }, - { 0.00, -0.49, -0.27 }, - { 0.04, -0.48, -0.27 }, - { 0.05, -0.47, -0.27 }, - { -0.00, -0.49, -0.27 }, - { 0.07, -0.42, -0.24 }, - { 0.06, -0.46, -0.25 }, - { -0.11, -0.40, -0.28 }, - { -0.05, -0.32, -0.32 }, - { -0.05, -0.41, -0.37 }, - { -0.05, -0.50, -0.30 }, - { 0.04, -0.31, -0.26 }, - { 0.04, -0.35, -0.36 }, - { 0.04, -0.47, -0.35 }, - { 0.10, -0.40, -0.28 } -}; - - -FaceStruct BoneIconFaces[NumBoneIconFaces] = { - - { 0, 1, 2 }, - { 3, 4, 5 }, - { 6, 3, 7 }, - { 1, 8, 9 }, - { 1, 0, 10 }, - { 4, 3, 11 }, - { 11, 3, 6 }, - { 11, 4, 11 }, - { 10, 8, 1 }, - { 12, 13, 14 }, - { 12, 15, 13 }, - { 13, 16, 17 }, - { 14, 17, 18 }, - { 17, 14, 13 }, - { 16, 13, 15 }, - { 19, 18, 17 }, - { 19, 17, 16 }, - { 12, 14, 20 }, - { 21, 12, 20 }, - { 14, 22, 20 }, - { 22, 14, 18 }, - { 12, 21, 23 }, - { 24, 18, 25 }, - { 18, 26, 25 }, - { 26, 18, 19 }, - { 18, 24, 27 }, - { 22, 18, 27 }, - { 26, 19, 28 }, - { 19, 29, 28 }, - { 30, 31, 32 }, - { 30, 32, 33 }, - { 32, 34, 35 }, - { 33, 35, 36 }, - { 34, 32, 31 }, - { 35, 33, 32 }, - { 37, 35, 34 }, - { 37, 36, 35 }, - { 31, 30, 21 }, - { 20, 31, 21 }, - { 31, 20, 22 }, - { 30, 23, 21 }, - { 34, 31, 24 }, - { 25, 34, 24 }, - { 34, 25, 37 }, - { 37, 25, 26 }, - { 31, 27, 24 }, - { 27, 31, 22 }, - { 28, 37, 26 }, - { 37, 28, 29 }, - { 38, 36, 37 }, - { 37, 2, 38 }, - { 2, 37, 29 }, - { 0, 2, 29 }, - { 36, 38, 39 }, - { 33, 36, 40 }, - { 40, 36, 39 }, - { 33, 40, 41 }, - { 33, 42, 30 }, - { 42, 33, 41 }, - { 5, 30, 42 }, - { 23, 30, 4 }, - { 30, 5, 4 }, - { 12, 23, 6 }, - { 7, 12, 6 }, - { 12, 7, 15 }, - { 43, 15, 7 }, - { 15, 43, 44 }, - { 16, 15, 45 }, - { 45, 15, 44 }, - { 16, 45, 46 }, - { 47, 16, 46 }, - { 16, 47, 19 }, - { 9, 19, 47 }, - { 9, 19, 9 }, - { 29, 19, 8 }, - { 19, 9, 8 }, - { 29, 10, 0 }, - { 6, 23, 11 }, - { 11, 23, 11 }, - { 11, 23, 4 }, - { 10, 29, 8 }, - { 48, 3, 49 }, - { 49, 3, 5 }, - { 50, 3, 48 }, - { 3, 50, 7 }, - { 51, 1, 9 }, - { 1, 51, 52 }, - { 53, 1, 52 }, - { 1, 53, 2 }, - { 56, 38, 2 }, - { 38, 54, 39 }, - { 38, 56, 55 }, - { 38, 55, 54 }, - { 2, 53, 56 }, - { 57, 39, 54 }, - { 39, 57, 40 }, - { 40, 58, 41 }, - { 57, 58, 40 }, - { 59, 41, 58 }, - { 41, 59, 42 }, - { 42, 59, 5 }, - { 49, 5, 59 }, - { 7, 50, 43 }, - { 43, 50, 60 }, - { 43, 60, 61 }, - { 43, 61, 44 }, - { 60, 50, 62 }, - { 63, 44, 61 }, - { 44, 63, 45 }, - { 45, 63, 64 }, - { 45, 64, 46 }, - { 65, 46, 64 }, - { 46, 65, 47 }, - { 47, 65, 9 }, - { 51, 9, 65 }, - { 66, 67, 68 }, - { 66, 69, 67 }, - { 67, 70, 71 }, - { 69, 72, 70 }, - { 71, 68, 67 }, - { 70, 67, 69 }, - { 73, 70, 72 }, - { 73, 71, 70 }, - { 74, 66, 75 }, - { 66, 74, 69 }, - { 69, 74, 76 }, - { 77, 69, 76 }, - { 69, 77, 72 }, - { 72, 78, 79 }, - { 80, 72, 79 }, - { 72, 80, 73 }, - { 78, 72, 81 }, - { 72, 77, 81 }, - { 82, 73, 83 }, - { 73, 80, 83 }, - { 84, 85, 86 }, - { 84, 86, 87 }, - { 85, 88, 89 }, - { 86, 89, 90 }, - { 89, 86, 85 }, - { 90, 87, 86 }, - { 91, 89, 88 }, - { 91, 90, 89 }, - { 75, 84, 87 }, - { 75, 87, 74 }, - { 87, 76, 74 }, - { 76, 87, 77 }, - { 87, 90, 78 }, - { 90, 79, 78 }, - { 79, 90, 91 }, - { 79, 91, 80 }, - { 81, 87, 78 }, - { 87, 81, 77 }, - { 91, 83, 80 }, - { 83, 91, 82 }, - { 84, 48, 85 }, - { 49, 85, 48 }, - { 48, 84, 50 }, - { 84, 75, 50 }, - { 51, 71, 73 }, - { 73, 52, 51 }, - { 52, 73, 53 }, - { 73, 82, 53 }, - { 56, 82, 91 }, - { 88, 54, 91 }, - { 91, 54, 55 }, - { 91, 55, 56 }, - { 56, 53, 82 }, - { 54, 88, 57 }, - { 88, 85, 58 }, - { 57, 88, 58 }, - { 58, 85, 59 }, - { 49, 59, 85 }, - { 66, 60, 75 }, - { 68, 60, 66 }, - { 68, 61, 60 }, - { 62, 75, 60 }, - { 75, 62, 50 }, - { 61, 68, 63 }, - { 64, 68, 71 }, - { 68, 64, 63 }, - { 64, 71, 65 }, - { 51, 65, 71 }, - { 92, 93, 94 }, - { 95, 96, 97 }, - { 98, 95, 99 }, - { 93, 100, 101 }, - { 93, 92, 102 }, - { 96, 95, 103 }, - { 103, 95, 98 }, - { 103, 96, 103 }, - { 102, 100, 93 }, - { 104, 105, 106 }, - { 104, 107, 105 }, - { 105, 108, 109 }, - { 106, 109, 110 }, - { 109, 106, 105 }, - { 108, 105, 107 }, - { 111, 110, 109 }, - { 111, 109, 108 }, - { 104, 106, 112 }, - { 113, 104, 112 }, - { 106, 114, 112 }, - { 114, 106, 110 }, - { 104, 113, 115 }, - { 116, 110, 117 }, - { 110, 118, 117 }, - { 118, 110, 111 }, - { 110, 116, 119 }, - { 114, 110, 119 }, - { 118, 111, 120 }, - { 111, 121, 120 }, - { 122, 123, 124 }, - { 122, 124, 125 }, - { 124, 126, 127 }, - { 125, 127, 128 }, - { 126, 124, 123 }, - { 127, 125, 124 }, - { 129, 127, 126 }, - { 129, 128, 127 }, - { 123, 122, 113 }, - { 112, 123, 113 }, - { 123, 112, 114 }, - { 122, 115, 113 }, - { 126, 123, 116 }, - { 117, 126, 116 }, - { 126, 117, 129 }, - { 129, 117, 118 }, - { 123, 119, 116 }, - { 119, 123, 114 }, - { 120, 129, 118 }, - { 129, 120, 121 }, - { 130, 128, 129 }, - { 129, 94, 130 }, - { 94, 129, 121 }, - { 92, 94, 121 }, - { 128, 130, 131 }, - { 125, 128, 132 }, - { 132, 128, 131 }, - { 125, 132, 133 }, - { 125, 134, 122 }, - { 134, 125, 133 }, - { 97, 122, 134 }, - { 115, 122, 96 }, - { 122, 97, 96 }, - { 104, 115, 98 }, - { 99, 104, 98 }, - { 104, 99, 107 }, - { 135, 107, 99 }, - { 107, 135, 136 }, - { 108, 107, 137 }, - { 137, 107, 136 }, - { 108, 137, 138 }, - { 139, 108, 138 }, - { 108, 139, 111 }, - { 101, 111, 139 }, - { 101, 111, 101 }, - { 121, 111, 100 }, - { 111, 101, 100 }, - { 121, 102, 92 }, - { 98, 115, 103 }, - { 103, 115, 103 }, - { 103, 115, 96 }, - { 102, 121, 100 }, - { 140, 95, 141 }, - { 141, 95, 97 }, - { 142, 95, 140 }, - { 95, 142, 99 }, - { 143, 93, 101 }, - { 93, 143, 144 }, - { 145, 93, 144 }, - { 93, 145, 94 }, - { 148, 130, 94 }, - { 130, 146, 131 }, - { 130, 148, 147 }, - { 130, 147, 146 }, - { 94, 145, 148 }, - { 149, 131, 146 }, - { 131, 149, 132 }, - { 132, 150, 133 }, - { 149, 150, 132 }, - { 151, 133, 150 }, - { 133, 151, 134 }, - { 134, 151, 97 }, - { 141, 97, 151 }, - { 99, 142, 135 }, - { 135, 142, 152 }, - { 135, 152, 153 }, - { 135, 153, 136 }, - { 152, 142, 154 }, - { 155, 136, 153 }, - { 136, 155, 137 }, - { 137, 155, 156 }, - { 137, 156, 138 }, - { 157, 138, 156 }, - { 138, 157, 139 }, - { 139, 157, 101 }, - { 143, 101, 157 }, - { 158, 159, 160 }, - { 158, 161, 159 }, - { 159, 162, 163 }, - { 161, 164, 162 }, - { 163, 160, 159 }, - { 162, 159, 161 }, - { 165, 162, 164 }, - { 165, 163, 162 }, - { 166, 158, 167 }, - { 158, 166, 161 }, - { 161, 166, 168 }, - { 169, 161, 168 }, - { 161, 169, 164 }, - { 164, 170, 171 }, - { 172, 164, 171 }, - { 164, 172, 165 }, - { 170, 164, 173 }, - { 164, 169, 173 }, - { 174, 165, 175 }, - { 165, 172, 175 }, - { 176, 177, 178 }, - { 176, 178, 179 }, - { 177, 180, 181 }, - { 178, 181, 182 }, - { 181, 178, 177 }, - { 182, 179, 178 }, - { 183, 181, 180 }, - { 183, 182, 181 }, - { 167, 176, 179 }, - { 167, 179, 166 }, - { 179, 168, 166 }, - { 168, 179, 169 }, - { 179, 182, 170 }, - { 182, 171, 170 }, - { 171, 182, 183 }, - { 171, 183, 172 }, - { 173, 179, 170 }, - { 179, 173, 169 }, - { 183, 175, 172 }, - { 175, 183, 174 }, - { 176, 140, 177 }, - { 141, 177, 140 }, - { 140, 176, 142 }, - { 176, 167, 142 }, - { 143, 163, 165 }, - { 165, 144, 143 }, - { 144, 165, 145 }, - { 165, 174, 145 }, - { 148, 174, 183 }, - { 180, 146, 183 }, - { 183, 146, 147 }, - { 183, 147, 148 }, - { 148, 145, 174 }, - { 146, 180, 149 }, - { 180, 177, 150 }, - { 149, 180, 150 }, - { 150, 177, 151 }, - { 141, 151, 177 }, - { 158, 152, 167 }, - { 160, 152, 158 }, - { 160, 153, 152 }, - { 154, 167, 152 }, - { 167, 154, 142 }, - { 153, 160, 155 }, - { 156, 160, 163 }, - { 160, 156, 155 }, - { 156, 163, 157 }, - { 143, 157, 163 } -}; \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/boneicon.h b/Generals/Code/Tools/WW3D/max2w3d/boneicon.h deleted file mode 100644 index 81d8afbb0b9..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/boneicon.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/boneicon.h 5 10/28/97 6:08p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - WWSkin * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/boneicon.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/21/97 2:06p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef BONEICON_H -#define BONEICON_H - -struct VertexStruct -{ - float X,Y,Z; -}; - -struct FaceStruct -{ - int V0,V1,V2; -}; - -extern const int NumBoneIconVerts; -extern const int NumBoneIconFaces; -extern VertexStruct BoneIconVerts[]; -extern FaceStruct BoneIconFaces[]; - -#endif diff --git a/Generals/Code/Tools/WW3D/max2w3d/bpick.cpp b/Generals/Code/Tools/WW3D/max2w3d/bpick.cpp deleted file mode 100644 index d1ed8630cdf..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/bpick.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/bpick.cpp 7 1/04/01 11:12a Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - WWSkin * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/bpick.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 1/04/01 11:12a $* - * * - * $Revision:: 7 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * BonePickerClass::Filter -- determine whether the passed node is suitable * - * BonePickerClass::HitTest -- MAX HitTest method * - * BonePickerClass::Pick -- MAX Pick method * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "bpick.h" -#include "dllmain.h" -#include "resource.h" - - -/* -** Global instance of a bone picker :-) -*/ -BonePickerClass TheBonePicker; - - -/*********************************************************************************************** - * BonePickerClass::Filter -- determine whether the passed node is suitable * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -BOOL BonePickerClass::Filter(INode *node) -{ - if (BoneList == NULL) { - ObjectState os = node->EvalWorldState(0); - if (os.obj) { - return TRUE; - } - - } else { - for (int i=0; iCount(); i++) { - if ((*BoneList)[i] == node) return TRUE; - } - } - - return FALSE; -} - -/*********************************************************************************************** - * BonePickerClass::HitTest -- MAX HitTest method * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -BOOL BonePickerClass::HitTest(IObjParam *ip,HWND hwnd,ViewExp *vpt,IPoint2 m,int flags) -{ - if (ip->PickNode(hwnd,m,GetFilter())) { - return TRUE; - } else { - return FALSE; - } -} - -/*********************************************************************************************** - * BonePickerClass::Pick -- MAX Pick method * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -BOOL BonePickerClass::Pick(IObjParam *ip,ViewExp *vpt) -{ - INode *node = vpt->GetClosestHit(); - - if (node) { - - /* - ** Tell the "owning" skin modifier about the - ** bone which was picked. - */ - assert(User); - User->User_Picked_Bone(node); - User = NULL; - BoneList = NULL; - } - - return TRUE; -} - -BOOL BonePickerClass::filter(INode * inode) -{ - return Filter(inode); -} - -void BonePickerClass::proc(INodeTab & nodetab) -{ - assert(User != NULL); - User->User_Picked_Bones(nodetab); - User = NULL; - BoneList = NULL; -} - -TCHAR * BonePickerClass::dialogTitle(void) -{ - return Get_String(IDS_PICK_BONE_DIALOG_TITLE); -} - -TCHAR * BonePickerClass::buttonText(void) -{ - return Get_String(IDS_PICK_BONE_BUTTON_TEXT); -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/bpick.h b/Generals/Code/Tools/WW3D/max2w3d/bpick.h deleted file mode 100644 index ca6078c4a87..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/bpick.h +++ /dev/null @@ -1,129 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/bpick.h 6 10/28/97 6:08p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - WWSkin * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/bpick.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/21/97 2:05p $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef BPICK_H -#define BPICK_H - -#include "max.h" -//#include "dllmain.h" -//#include "resource.h" - - -/* -** To use the Bone picking class, you should inherit from this class -** and implement the User_Picked... functions. -*/ -class BonePickerUserClass -{ -public: - virtual void User_Picked_Bone(INode * node) = 0; - virtual void User_Picked_Bones(INodeTab & nodetab) = 0; -}; - - -/* -** BonePickerClass -** Uses Max's interface to let the user pick bones out of the scene -** or by using a dialog box to pick by name. -*/ -class BonePickerClass : public PickNodeCallback, public PickModeCallback, public HitByNameDlgCallback -{ -public: - - BonePickerClass(void) : User(NULL), BoneList(NULL), SinglePick(FALSE) {} - - /* - ** Tell this class who is using it and optionally the list - ** of bones to allow the user to select from. - ** Call this before giving this class to MAX... - */ - void Set_User(BonePickerUserClass * user,int singlepick = FALSE, INodeTab * bonelist = NULL) { User = user; SinglePick = singlepick; BoneList = bonelist; } - - /* - ** From BonePickNodeCallback: - */ - BOOL Filter(INode *node); - - /* - ** From BonePickModeCallback: - */ - BOOL HitTest(IObjParam *ip,HWND hWnd,ViewExp *vpt,IPoint2 m,int flags); - BOOL Pick(IObjParam *ip,ViewExp *vpt); - - void EnterMode(IObjParam *ip) { } - void ExitMode(IObjParam *ip) { } - - PickNodeCallback * GetFilter() {return this;} - BOOL RightClick(IObjParam *ip,ViewExp *vpt) { return TRUE; } - - /* - ** From HitByNameDlgCallback - */ - virtual TCHAR * dialogTitle(void); - virtual TCHAR * buttonText(void); - virtual BOOL singleSelect(void) { return SinglePick; } - virtual BOOL useFilter(void) { return TRUE; } - virtual BOOL useProc(void) { return TRUE; } - virtual BOOL doCustomHilite(void) { return FALSE; } - virtual BOOL filter(INode * inode); - virtual void proc(INodeTab & nodeTab); - -protected: - - /* - ** The bone picker will pass the bones on to the "user" of - ** the class. - */ - BonePickerUserClass * User; - - /* - ** List of bones that the user is being allowed to pick from. - ** If this is NULL, then the user can pick any bone - */ - INodeTab * BoneList; - - /* - ** Flag for whether to allow multiple selection or not - */ - int SinglePick; -}; - -extern BonePickerClass TheBonePicker; - - -#endif diff --git a/Generals/Code/Tools/WW3D/max2w3d/colboxsave.cpp b/Generals/Code/Tools/WW3D/max2w3d/colboxsave.cpp deleted file mode 100644 index 80b2f8ac1b5..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/colboxsave.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/colboxsave.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 12/06/00 4:06p $* - * * - * $Revision:: 7 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "colboxsave.h" -#include "w3d_file.h" -#include "util.h" -#include "w3dappdata.h" -#include "errclass.h" - - -CollisionBoxSaveClass::CollisionBoxSaveClass -( - char * mesh_name, - char * container_name, - INode * inode, - Matrix3 & exportspace, - TimeValue curtime, - Progress_Meter_Class & meter -) -{ - ////////////////////////////////////////////////////////////////////// - // wrestle the mesh out of 3dsMAX - ////////////////////////////////////////////////////////////////////// - Object * obj = inode->EvalWorldState(curtime).obj; - TriObject * tri = (TriObject *)obj->ConvertToType(curtime, triObjectClassID); - Mesh mesh = tri->mesh; - DWORD wirecolor = inode->GetWireColor(); - - if (mesh.getNumVerts() == 0) { - throw ErrorClass("Mesh %s has no vertices!\n",mesh_name); - } - - ////////////////////////////////////////////////////////////////////// - // Generate the AABox or OBBox data. - ////////////////////////////////////////////////////////////////////// - memset(&BoxData,0,sizeof(BoxData)); - - BoxData.Version = W3D_BOX_CURRENT_VERSION; - if ((container_name != NULL) && (strlen(container_name) > 0)) { - strcpy(BoxData.Name,container_name); - strcat(BoxData.Name,"."); - } - strcat(BoxData.Name,mesh_name); - - BoxData.Attributes = 0; - if (Is_Collision_AABox(inode)) { - BoxData.Attributes |= W3D_BOX_ATTRIBUTE_ALIGNED; - } else { - BoxData.Attributes |= W3D_BOX_ATTRIBUTE_ORIENTED; - } - if (Is_Physical_Collision(inode)) { - BoxData.Attributes |= W3D_BOX_ATTRIBTUE_COLLISION_TYPE_PHYSICAL; - } - if (Is_Projectile_Collision(inode)) { - BoxData.Attributes |= W3D_BOX_ATTRIBTUE_COLLISION_TYPE_PROJECTILE; - } - if (Is_Vis_Collision(inode)) { - BoxData.Attributes |= W3D_BOX_ATTRIBTUE_COLLISION_TYPE_VIS; - } - if (Is_Camera_Collision(inode)) { - BoxData.Attributes |= W3D_BOX_ATTRIBTUE_COLLISION_TYPE_CAMERA; - } - if (Is_Vehicle_Collision(inode)) { - BoxData.Attributes |= W3D_BOX_ATTRIBTUE_COLLISION_TYPE_VEHICLE; - } - - BoxData.Color.R = GetRValue(wirecolor); - BoxData.Color.G = GetGValue(wirecolor); - BoxData.Color.B = GetBValue(wirecolor); - - // if this is an axis-aligned box, then use the world coord system - if (Is_Collision_AABox(inode)) { - exportspace.NoRot(); - } - - // Transform the mesh into the desired coordinate system - Matrix3 node_matrix = inode->GetObjectTM(curtime); - Matrix3 offset_matrix = node_matrix * Inverse(exportspace); - int ivert; - - for (ivert = 0; ivert < mesh.getNumVerts (); ++ivert) { - mesh.verts[ivert] = mesh.verts[ivert] * offset_matrix; - } - - // Find the center and extent of the box. - Point3 min_point = mesh.verts[0]; - Point3 max_point = mesh.verts[1]; - - for (ivert=0; ivert < mesh.getNumVerts(); ++ivert) { - if (mesh.verts[ivert].x < min_point.x) min_point.x = mesh.verts[ivert].x; - if (mesh.verts[ivert].y < min_point.y) min_point.y = mesh.verts[ivert].y; - if (mesh.verts[ivert].z < min_point.z) min_point.z = mesh.verts[ivert].z; - - if (mesh.verts[ivert].x > max_point.x) max_point.x = mesh.verts[ivert].x; - if (mesh.verts[ivert].y > max_point.y) max_point.y = mesh.verts[ivert].y; - if (mesh.verts[ivert].z > max_point.z) max_point.z = mesh.verts[ivert].z; - } - - Point3 center = (max_point + min_point) / 2.0f; - Point3 extent = (max_point - min_point) / 2.0f; - - BoxData.Center.X = center.x; - BoxData.Center.Y = center.y; - BoxData.Center.Z = center.z; - - BoxData.Extent.X = extent.x; - BoxData.Extent.Y = extent.y; - BoxData.Extent.Z = extent.z; -} - - - -int CollisionBoxSaveClass::Write_To_File(ChunkSaveClass & csave) -{ - csave.Begin_Chunk(W3D_CHUNK_BOX); - csave.Write(&BoxData,sizeof(BoxData)); - csave.End_Chunk(); - return 0; -} - - - \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/colboxsave.h b/Generals/Code/Tools/WW3D/max2w3d/colboxsave.h deleted file mode 100644 index a9f05c3ebdb..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/colboxsave.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/colboxsave.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 3/16/99 8:37a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef COLBOXSAVE_H -#define COLBOXSAVE_H - -#include -#include "w3d_file.h" -#include "chunkio.h" -#include "PROGRESS.H" - - -/******************************************************************************************* -** -** CollisionBoxSaveClass - Create an AABox or an OBBox from a Max mesh (typically the -** artist should use a 'box' to generate this. In any case, we're just using the bounding -** box). -** -*******************************************************************************************/ -class CollisionBoxSaveClass -{ -public: - - enum { - EX_UNKNOWN = 0, // exception error codes - EX_CANCEL = 1 - }; - - CollisionBoxSaveClass( char * mesh_name, - char * container_name, - INode * inode, - Matrix3 & exportspace, - TimeValue curtime, - Progress_Meter_Class & meter); - - int Write_To_File(ChunkSaveClass & csave); - -private: - - W3dBoxStruct BoxData; // contains same information as the W3dOBBoxStruct - -}; - - - -#endif //COLBOXSAVE_H \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/dazzlesave.cpp b/Generals/Code/Tools/WW3D/max2w3d/dazzlesave.cpp deleted file mode 100644 index 9f95b876a29..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/dazzlesave.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/dazzlesave.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 9/21/00 4:14p $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "dazzlesave.h" -#include "w3d_file.h" -#include "util.h" -#include "w3dappdata.h" -#include "errclass.h" - - -DazzleSaveClass::DazzleSaveClass -( - char * mesh_name, - char * container_name, - INode * inode, - Matrix3 & exportspace, - TimeValue curtime, - Progress_Meter_Class & meter -) -{ - assert(mesh_name != NULL); - assert(container_name != NULL); - - /* - ** Set up the render object name - */ - memset(&W3DName,0,sizeof(W3DName)); - if ((container_name != NULL) && (strlen(container_name) > 0)) { - strcpy(W3DName,container_name); - strcat(W3DName,"."); - } - strcat(W3DName,mesh_name); - - /* - ** Dig the dazzle-type out of the appropriate App-Data chunk on - ** the INode. - */ - W3DDazzleAppDataStruct * dazzle_data = W3DDazzleAppDataStruct::Get_App_Data(inode); - strncpy(DazzleType,dazzle_data->DazzleType,sizeof(DazzleType)); -} - - - -int DazzleSaveClass::Write_To_File(ChunkSaveClass & csave) -{ - csave.Begin_Chunk(W3D_CHUNK_DAZZLE); - - csave.Begin_Chunk(W3D_CHUNK_DAZZLE_NAME); - csave.Write(W3DName,strlen(W3DName) + 1); - csave.End_Chunk(); - - csave.Begin_Chunk(W3D_CHUNK_DAZZLE_TYPENAME); - csave.Write(DazzleType,strlen(DazzleType) + 1); - csave.End_Chunk(); - - csave.End_Chunk(); - return 0; -} - - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/dazzlesave.h b/Generals/Code/Tools/WW3D/max2w3d/dazzlesave.h deleted file mode 100644 index 943fb89454c..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/dazzlesave.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/dazzlesave.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 9/21/00 4:09p $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef DAZZLESAVE_H -#define DAZZLESAVE_H - -#include -#include "w3d_file.h" -#include "chunkio.h" -#include "PROGRESS.H" - - -/******************************************************************************************* -** -** DazzleSaveClass - Create a Dazzle definition from an INode. Basically, we just save -** the transform and the dazzle type that the user has selected. -** -*******************************************************************************************/ -class DazzleSaveClass -{ -public: - - enum { - EX_UNKNOWN = 0, // exception error codes - EX_CANCEL = 1 - }; - - DazzleSaveClass( char * mesh_name, - char * container_name, - INode * inode, - Matrix3 & exportspace, - TimeValue curtime, - Progress_Meter_Class & meter); - - int Write_To_File(ChunkSaveClass & csave); - -private: - - char W3DName[128]; - char DazzleType[128]; - -}; - - - - - - - -#endif //DAZZLESAVE_H - diff --git a/Generals/Code/Tools/WW3D/max2w3d/dllmain.cpp b/Generals/Code/Tools/WW3D/max2w3d/dllmain.cpp deleted file mode 100644 index e992552b212..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/dllmain.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/dllmain.cpp 8 7/24/01 5:11p Moumine_ballo $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G * - * * - * File Name : DLLMAIN.CPP * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 06/09/97 * - * * - * Last Update : June 9, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * DllMain -- Entry point for the dll * - * LibDescription -- Returns description of this library * - * LibNumberClasses -- Returns number of classes in this library * - * LibClassDesc -- Returns a ClassDesc for the specified class * - * LibVersion -- Returns the version number of this library * - * GetString -- Gets a string out of the resources * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include -#include -#include "dllmain.h" -#include "w3ddesc.h" -#include "w3dexp.h" -#include "w3dutil.h" -#include "skin.h" -#include "gamemtl.h" -#include "gamemaps.h" -#include "MeshDeform.h" -#include "AlphaModifier.h" -#include "gridsnapmodifier.h" - -#include "resource.h" - -#define DLLEXPORT __declspec(dllexport) - - -/***************************************************************************** -* Globals -*****************************************************************************/ - -HINSTANCE AppInstance = NULL; -static int ControlsInit = FALSE; -static W3dClassDesc W3d_Export_Class_Descriptor; - - - -/*********************************************************************************************** - * DllMain -- Entry point for the dll * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG /*fdwReason*/,LPVOID /*lpvReserved*/) -{ - AppInstance = hinstDLL; - - if ( !ControlsInit ) - { - ControlsInit = TRUE; - InitCustomControls(AppInstance); - InitCommonControls(); - } - - return TRUE; -} - - -/*********************************************************************************************** - * LibDescription -- Returns description of this library * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -DLLEXPORT const TCHAR * LibDescription() -{ - return Get_String(IDS_LIB_DESCRIPTION); -} - -/*********************************************************************************************** - * LibNumberClasses -- Returns number of classes in this library * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -DLLEXPORT int LibNumberClasses() -{ - return 9; //Moumine 7/24/2001 4:38:27 PM was 10. Removed Mesh_Deformation(#6) -} - - -/*********************************************************************************************** - * LibClassDesc -- Returns a ClassDesc for the specified class * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -DLLEXPORT ClassDesc * LibClassDesc(int i) -{ - switch(i) - { - case 0: return & W3d_Export_Class_Descriptor; break; - case 1: return Get_W3D_Utility_Desc(); break; - case 2: return Get_Skin_Obj_Desc(); break; - case 3: return Get_Skin_Mod_Desc(); break; - case 4: return Get_Game_Material_Desc(); break; - case 5: return Get_Game_Maps_Desc(); break; - case 6: return Get_PS2_Game_Material_Desc(); break; - case 7: return Get_PS2_Material_Conversion(); break; - case 8: return Get_Alpha_Desc(); break; - //case 6: return Get_Mesh_Deform_Desc(); break; - //Moumine 7/24/2001 4:33:52 PM Removed #6 and shifted up instead of returning NULL - // NULL causes a crash in "File->Summary info->Plug-in ifo..." - default: return NULL; break; - } -} - - -/*********************************************************************************************** - * LibVersion -- Returns the version number of this library * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -DLLEXPORT ULONG LibVersion() -{ - return VERSION_3DSMAX; -} - - -/*********************************************************************************************** - * Get_String -- Gets a string out of the resources * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -TCHAR * Get_String( int id ) -{ - static TCHAR buf[256]; - if (AppInstance) - return LoadString(AppInstance, id, buf, sizeof(buf)) ? buf : NULL; - return NULL; -} - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/dllmain.h b/Generals/Code/Tools/WW3D/max2w3d/dllmain.h deleted file mode 100644 index fd94fdefe03..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/dllmain.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/dllmain.h 4 10/28/97 6:08p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G * - * * - * File Name : DLLMAIN.H * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 06/09/97 * - * * - * Last Update : June 9, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef DLLMAIN_H -#define DLLMAIN_H - -#include - -extern HINSTANCE AppInstance; - -#define MAX_STRING_LENGTH 256 -#define MAX_PATH_LENGTH _MAX_PATH - -TCHAR * Get_String(int id); - -#endif /*DLLMAIN_H*/ \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/exportlog.cpp b/Generals/Code/Tools/WW3D/max2w3d/exportlog.cpp deleted file mode 100644 index 6c90bda55be..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/exportlog.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/exportlog.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 11/07/00 3:16p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * ExportLog::Init -- Initialize the export logging system * - * ExportLog::Shutdown -- Shutdown the export logging system * - * ExportLog::printf -- Print a string to the log window * - * ExportLog::rprintf -- Print a string over the last line printed * - * ExportLog::updatebar -- Set the position of the progress bar * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "exportlog.h" -#include "logdlg.h" -#include - - -/* -** Static variables -*/ -LogDataDialogClass * _LogDialog = NULL; - - -/* -** -** ExportLog implementation. Note, this is a class which only contains static functions. -** -*/ - - -/*********************************************************************************************** - * ExportLog::Init -- Initialize the export logging system * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/30/2000 gth : Created. * - *=============================================================================================*/ -void ExportLog::Init(HWND parent) -{ - assert(_LogDialog == NULL); - _LogDialog = new LogDataDialogClass(parent); -} - - -/*********************************************************************************************** - * ExportLog::Shutdown -- Shutdown the export logging system * - * * - * INPUT: * - * wait_for_ok - should we wait for the user to press OK on the dialog? * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/30/2000 gth : Created. * - *=============================================================================================*/ -void ExportLog::Shutdown(bool wait_for_ok) -{ - if (_LogDialog != NULL) { - - if (wait_for_ok) { - _LogDialog->Wait_OK(); - } - - delete _LogDialog; - _LogDialog = NULL; - } -} - - -/*********************************************************************************************** - * ExportLog::printf -- Print a string to the log window * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/30/2000 gth : Created. * - *=============================================================================================*/ -void ExportLog::printf(const char * format, ...) -{ - if (_LogDialog != NULL) { - va_list arguments; - va_start(arguments, format); - _LogDialog->printf(format,arguments); - } -} - - -/*********************************************************************************************** - * ExportLog::rprintf -- Print a string over the last line printed * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/30/2000 gth : Created. * - *=============================================================================================*/ -void ExportLog::rprintf(const char * format, ...) -{ - if (_LogDialog != NULL) { - va_list arguments; - va_start(arguments, format); - _LogDialog->rprintf(format,arguments); - } -} - - -/*********************************************************************************************** - * ExportLog::updatebar -- Set the position of the progress bar * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/30/2000 gth : Created. * - *=============================================================================================*/ -void ExportLog::updatebar(float position, float total) -{ - if (_LogDialog != NULL) { - _LogDialog->updatebar(position,total); - } -} - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/exportlog.h b/Generals/Code/Tools/WW3D/max2w3d/exportlog.h deleted file mode 100644 index 4c9e8797c52..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/exportlog.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/exportlog.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 11/07/00 3:18p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef EXPORTLOG_H -#define EXPORTLOG_H - -#include - -/** -** ExportLog -** This is an interface to the export log dialog. -*/ -class ExportLog -{ -public: - static void Init(HWND parent); - static void Shutdown(bool wait_for_ok); - - static void printf(const char *, ...); - static void rprintf(const char *, ...); - static void updatebar(float position, float total); -}; - - -#endif //EXPORTLOG_H - diff --git a/Generals/Code/Tools/WW3D/max2w3d/floaterdialog.cpp b/Generals/Code/Tools/WW3D/max2w3d/floaterdialog.cpp deleted file mode 100644 index dd0518116b6..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/floaterdialog.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/floaterdialog.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/30/00 2:58p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * FloaterDialogClass::FloaterDialogClass -- Constructor * - * FloaterDialogClass::~FloaterDialogClass -- Destructor * - * FloaterDialogClass::Is_Created -- test whether the floater has already been created * - * FloaterDialogClass::Create -- create the window * - * FloaterDialogClass::Dialog_Proc -- Dialog Proc for the floater * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "floaterdialog.h" -#include "dllmain.h" -#include "resource.h" -#include - - -/********************************************************************************************** -** -** FloaterDialogClass Implementation -** -**********************************************************************************************/ - -BOOL CALLBACK _floater_dialog_proc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) -{ - if (message == WM_INITDIALOG) { - FloaterDialogClass * floater = (FloaterDialogClass *)lParam; - ::SetProp(hwnd,"FloaterDialogClass",(HANDLE)floater); - } - - FloaterDialogClass * floater = (FloaterDialogClass *)::GetProp(hwnd,"FloaterDialogClass"); - - if (message == WM_DESTROY) { - ::RemoveProp(hwnd,"FloaterDialogClass"); - } - - - if (floater) { - return floater->Dialog_Proc(hwnd,message,wParam,lParam); - } else { - return FALSE; - } -} - - -/*********************************************************************************************** - * FloaterDialogClass::FloaterDialogClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -FloaterDialogClass::FloaterDialogClass(void) : - Hwnd(NULL), - ChildDialogTemplateID(-1), - ChildDialogProc(NULL) -{ -} - - -/*********************************************************************************************** - * FloaterDialogClass::~FloaterDialogClass -- Destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -FloaterDialogClass::~FloaterDialogClass(void) -{ - if (Hwnd != NULL) { - ::DestroyWindow(Hwnd); - } -} - - -/*********************************************************************************************** - * FloaterDialogClass::Is_Created -- test whether the floater has already been created * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/11/2000 gth : Created. * - *=============================================================================================*/ -bool FloaterDialogClass::Is_Created(void) -{ - return (Hwnd != NULL); -} - - -/*********************************************************************************************** - * FloaterDialogClass::Create -- create the window * - * * - * This function will return automatically if the floater has been created already. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/11/2000 gth : Created. * - *=============================================================================================*/ -void FloaterDialogClass::Create(Interface * ip, int child_dlg_id, DLGPROC child_dlg_proc) -{ - /* - ** Don't create multiple ones - */ - if (Is_Created()) { - return; - } - - /* - ** Copy down the data needed to create the child window later - */ - ChildDialogTemplateID = child_dlg_id; - ChildDialogProc = child_dlg_proc; - - - /* - ** Create the dialog box - */ - Hwnd = CreateDialogParam( - AppInstance, - MAKEINTRESOURCE(IDD_W3DUTILITY_FLOATER_DIALOG), - ::GetCOREInterface()->GetMAXHWnd(), - (DLGPROC) _floater_dialog_proc, - (LPARAM) this - ); - ::GetCOREInterface()->RegisterDlgWnd(Hwnd); -} - - - -/*********************************************************************************************** - * FloaterDialogClass::Dialog_Proc -- Dialog Proc for the floater * - * * - * The only thing we need to do here is to create the child dialog and resize ourselves to * - * contain it. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/11/2000 gth : Created. * - *=============================================================================================*/ -bool FloaterDialogClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM) -{ - switch (message ) { - - case WM_INITDIALOG: - { - HWND childhwnd = CreateDialogParam( - AppInstance, - MAKEINTRESOURCE(ChildDialogTemplateID), - hWnd, - ChildDialogProc, - 0 - ); - if (childhwnd!= NULL) { - RECT rect; - LONG style = ::GetWindowLong(hWnd,GWL_STYLE); - ::GetWindowRect(childhwnd,&rect); - ::AdjustWindowRect(&rect,style,FALSE); - ::SetWindowPos(hWnd,NULL,0,0,rect.right - rect.left,rect.bottom - rect.top,SWP_NOZORDER|SWP_NOMOVE); - ::SetWindowPos(childhwnd,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_SHOWWINDOW); - } - } - return 1; - - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDCANCEL: - DestroyWindow(Hwnd); - break; - } - return 1; - - case WM_DESTROY: - ::GetCOREInterface()->UnRegisterDlgWnd(Hwnd); - Hwnd = NULL; - break; - } - return 0; -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/floaterdialog.h b/Generals/Code/Tools/WW3D/max2w3d/floaterdialog.h deleted file mode 100644 index 6d7a94d883c..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/floaterdialog.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/floaterdialog.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/11/00 11:23a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef FLOATERDIALOG_H -#define FLOATERDIALOG_H - -#include - -class Interface; - -/** -** FloaterDialogClass -** This class is designed to be used by modeless dialog boxes. See w3dutil.cpp for an -** example of how to embed an arbitrary dialog template and dialog proc into a floating -** window. -*/ -class FloaterDialogClass -{ -public: - - FloaterDialogClass(void); - ~FloaterDialogClass(); - - bool Is_Created(void); - void Create(Interface * ip, int child_dialog_id, DLGPROC child_dlg_proc); - bool Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM); - -private: - - HWND Hwnd; - int ChildDialogTemplateID; - DLGPROC ChildDialogProc; - -}; - - - -#endif //FLOATERDIALOG_H - diff --git a/Generals/Code/Tools/WW3D/max2w3d/gamemaps.cpp b/Generals/Code/Tools/WW3D/max2w3d/gamemaps.cpp deleted file mode 100644 index de0aed7a34b..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/gamemaps.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/gamemaps.cpp 5 10/28/97 6:08p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : GAMEMAPS.CPP * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 06/26/97 * - * * - * Last Update : June 26, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * GameMapsClass::ClassID -- Returns the ClassID for GameMapsClass * - * GameMapsClass::AssignController -- Assigns a controller to one of the Sub-Anims * - * GameMapsClass::NotifyRefChanged -- Max is notifying GameMapsClass that a reference has cha* - * GameMapsClass::Clone -- Create a clone of the GameMapsClass * - * GameMapsClass::Save -- Saves the GameMapsClass data into a MAX file * - * GameMapsClass::Load -- Loads GameMapsClass data from a MAX file * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "gamemaps.h" - - -/***************************************************************** -* -* Chunk ID's for saving data in the MAX file. -* -*****************************************************************/ -#define GAMEMAPS_ONOFF_CHUNK 0x0000 -#define GAMEMAPS_AMT0_CHUNK 0x0001 -#define GAMEMAPS_AMT1_CHUNK 0x0002 -#define GAMEMAPS_AMT2_CHUNK 0x0003 -#define GAMEMAPS_AMT3_CHUNK 0x0004 -#define GAMEMAPS_AMT4_CHUNK 0x0005 -#define GAMEMAPS_AMT5_CHUNK 0x0006 -#define GAMEMAPS_AMT6_CHUNK 0x0007 -#define GAMEMAPS_AMT7_CHUNK 0x0008 -#define GAMEMAPS_AMT8_CHUNK 0x0009 -#define GAMEMAPS_AMT9_CHUNK 0x000A -#define GAMEMAPS_AMTA_CHUNK 0x000B - - -/***************************************************************** -* -* A PostLoadCallback which does nothing... -* -*****************************************************************/ -class GameMapsPostLoad : public PostLoadCallback -{ -public: - GameMapsClass *tm; - GameMapsPostLoad(GameMapsClass *b) {tm=b;} - void proc(ILoad *iload) { delete this; } -}; - - -/***************************************************************** -* -* GameMapsClass Class Desriptor -* -*****************************************************************/ -static Class_ID _GameMapsClassID(0x36d23f7b, 0x79ce63e1); - -class GameMapsClassDesc : public ClassDesc -{ - public: - int IsPublic() { return 0; } - void * Create(BOOL loading) { return new GameMapsClass(NULL); } - const TCHAR * ClassName() { return _T("GameMaps"); } - SClass_ID SuperClassID() { return REF_MAKER_CLASS_ID; } - Class_ID ClassID() { return _GameMapsClassID; } - const TCHAR* Category() { return _T(""); } -}; - -static GameMapsClassDesc _GameMapsCD; - -ClassDesc * Get_Game_Maps_Desc() { return &_GameMapsCD; } - - -/*********************************************************************************************** - * GameMapsClass::ClassID -- Returns the ClassID for GameMapsClass * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -Class_ID GameMapsClass::ClassID() -{ - return _GameMapsClassID; -} - -/*********************************************************************************************** - * GameMapsClass::AssignController -- Assigns a controller to one of the Sub-Anims * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -BOOL GameMapsClass::AssignController(Animatable *control,int subAnim) -{ - ReplaceReference(SubNumToRefNum(subAnim),(ReferenceTarget *)control); - return TRUE; -} - -/*********************************************************************************************** - * GameMapsClass::NotifyRefChanged -- Max is notifying GameMapsClass that a reference has chan * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -RefResult GameMapsClass::NotifyRefChanged -( - Interval changeInt, - RefTargetHandle hTarget, - PartID & partID, - RefMessage message -) -{ - switch (message) { - case REFMSG_GET_PARAM_DIM: { - GetParamDim *gpd = (GetParamDim*)partID; - break; - } - case REFMSG_GET_PARAM_NAME: { - GetParamName *gpn = (GetParamName*)partID; - return REF_STOP; - } - } - return(REF_SUCCEED); -} - -/*********************************************************************************************** - * GameMapsClass::Clone -- Create a clone of the GameMapsClass * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -RefTargetHandle GameMapsClass::Clone(RemapDir &remap) -{ - GameMapsClass *tm = new GameMapsClass(NULL); - - for (int i=0; iTextureSlot[i].MapOn = TextureSlot[i].MapOn; - tm->TextureSlot[i].Map = NULL; - - if (TextureSlot[i].Map) { - tm->ReplaceReference(i,remap.CloneRef(TextureSlot[i].Map)); - } - } - - return tm; -} - - -/*********************************************************************************************** - * GameMapsClass::Save -- Saves the GameMapsClass data into a MAX file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -IOResult GameMapsClass::Save(ISave * isave) -{ - ULONG nb,f=0; - - isave->BeginChunk(GAMEMAPS_ONOFF_CHUNK); - for (int i=0; iWrite(&f,sizeof(f),&nb); - isave->EndChunk(); - - for (i=0; iBeginChunk(GAMEMAPS_AMT0_CHUNK + i); - isave->Write(&(TextureSlot[i].Amount),sizeof(float),&nb); - isave->EndChunk(); - } - } - return IO_OK; -} - - -/*********************************************************************************************** - * GameMapsClass::Load -- Loads GameMapsClass data from a MAX file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -IOResult GameMapsClass::Load(ILoad * iload) -{ - ULONG nb; - int id; - IOResult res; - - while (IO_OK==(res=iload->OpenChunk())) { - - switch (id = iload->CurChunkID()) { - case GAMEMAPS_ONOFF_CHUNK: - { - ULONG f; - res = iload->Read(&f,sizeof(f), &nb); - for (int i=0; iRead(&(TextureSlot[index].Amount),sizeof(float),&nb); - break; - } - - iload->CloseChunk(); - if (res!=IO_OK) { - return res; - } - } - return IO_OK; -} - diff --git a/Generals/Code/Tools/WW3D/max2w3d/gamemaps.h b/Generals/Code/Tools/WW3D/max2w3d/gamemaps.h deleted file mode 100644 index 983377e87d5..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/gamemaps.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/gamemaps.h 7 10/28/97 6:08p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : GAMEMAPS.H * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 06/26/97 * - * * - * Last Update : June 26, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef GAMEMAPS_H -#define GAMEMAPS_H - -#include -#include "stdmat.h" - - -ClassDesc * Get_Game_Maps_Desc(); - - -/////////////////////////////////////////////////////////////////////////// -// -// TexmapSlotClass -// -/////////////////////////////////////////////////////////////////////////// -class TexmapSlotClass -{ -public: - - BOOL MapOn; - float Amount; - Texmap * Map; - - TexmapSlotClass() : MapOn(FALSE), Amount(1.0f), Map(NULL) {}; - - RGBA Eval(ShadeContext& sc) { return Map->EvalColor(sc); } - float EvalMono(ShadeContext& sc) { return Map->EvalMono(sc); } - Point3 EvalNormalPerturb(ShadeContext &sc) { return Map->EvalNormalPerturb(sc); } - BOOL IsActive() { return (Map && MapOn); } - void Update(TimeValue t, Interval &ivalid) { if (IsActive()) Map->Update(t,ivalid); }; - float GetAmount(TimeValue t) { return Amount; } -}; - - -/////////////////////////////////////////////////////////////////////////// -// -// Texture Maps for In-Game material -// -// This class can contain a collection of all of the maps which -// MAX uses but the GameMtl plugin will only give the user access -// to the ones we can actually use in the game. -// -/////////////////////////////////////////////////////////////////////////// -class GameMapsClass: public ReferenceTarget -{ -public: - - MtlBase * Client; - TexmapSlotClass TextureSlot[NTEXMAPS]; - - GameMapsClass() { Client = NULL; } - GameMapsClass(MtlBase *mb) { Client = mb; } - - void DeleteThis() { delete this; } - void SetClientPtr(MtlBase *mb) { Client = mb; } - TexmapSlotClass & operator[](int i) { return TextureSlot[i]; } - Class_ID ClassID(); - SClass_ID SuperClassID() { return REF_MAKER_CLASS_ID; } - int NumSubs() { return NTEXMAPS; } - Animatable * SubAnim(int i) { return TextureSlot[i].Map; } - TSTR SubAnimName(int i) { return Client->GetSubTexmapTVName(i); } - int NumRefs() { return NTEXMAPS; } - RefTargetHandle GetReference(int i) { return TextureSlot[i].Map; } - void SetReference(int i, RefTargetHandle rtarg) { TextureSlot[i].Map = (Texmap*)rtarg; } - int SubNumToRefNum(int subNum) { return subNum; } - - - BOOL AssignController(Animatable *control,int subAnim); - RefTargetHandle Clone(RemapDir &remap); - RefResult NotifyRefChanged( Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message); - - IOResult Save(ISave * isave); - IOResult Load(ILoad * iload); -}; - - -#endif /*GAMEMAPS_H*/ \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/gamemtl.h b/Generals/Code/Tools/WW3D/max2w3d/gamemtl.h deleted file mode 100644 index 8c96c984e06..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/gamemtl.h +++ /dev/null @@ -1,373 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/gamemtl.h 38 8/22/01 7:56a Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : GAMEMTL.H * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 06/26/97 * - * * - * Last Update : June 26, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef GAMEMTL_H -#define GAMEMTL_H - -#include -#include "w3dmtl.h" -#include "w3d_file.h" - - -// GameMtl flags values -#define GAMEMTL_CONVERTED_TO_NOLOD (1<<0) // this material has been converted to use the NO_LOD flag on textures - -#define GAMEMTL_DISPLACEMENT_ROLLUP_OPEN (1<<25) -#define GAMEMTL_SURFACE_ROLLUP_OPEN (1<<26) -#define GAMEMTL_PASSCOUNT_ROLLUP_OPEN (1<<27) -#define GAMEMTL_PASS0_ROLLUP_OPEN (1<<28) -#define GAMEMTL_PASS1_ROLLUP_OPEN (1<<29) -#define GAMEMTL_PASS2_ROLLUP_OPEN (1<<30) -#define GAMEMTL_PASS3_ROLLUP_OPEN (1<<31) - -#define GAMEMTL_ROLLUP_FLAGS ( GAMEMTL_SURFACE_ROLLUP_OPEN | \ - GAMEMTL_DISPLACEMENT_ROLLUP_OPEN | \ - GAMEMTL_PASSCOUNT_ROLLUP_OPEN | \ - GAMEMTL_PASS0_ROLLUP_OPEN | \ - GAMEMTL_PASS1_ROLLUP_OPEN | \ - GAMEMTL_PASS2_ROLLUP_OPEN | \ - GAMEMTL_PASS3_ROLLUP_OPEN ) - -#define GAMEMTL_ID_PARTA 0x29397211 -#define GAMEMTL_ID_PARTB 0x28c016c2 - -/////////////////////////////////////////////////////////////////////////// -// -// Mapping types -// -/////////////////////////////////////////////////////////////////////////// -#define GAMEMTL_MAPPING_UV 0 -#define GAMEMTL_MAPPING_ENV 1 -#define GAMEMTL_MAPPING_CHEAP_ENV 2 -#define GAMEMTL_MAPPING_SCREEN 3 -#define GAMEMTL_MAPPING_LINEAR_OFFSET 4 -#define GAMEMTL_MAPPING_SILHOUETTE 5 -#define GAMEMTL_MAPPING_SCALE 6 -#define GAMEMTL_MAPPING_GRID 7 -#define GAMEMTL_MAPPING_ROTATE 8 -#define GAMEMTL_MAPPING_SINE_LINEAR_OFFSET 9 -#define GAMEMTL_MAPPING_STEP_LINEAR_OFFSET 10 -#define GAMEMTL_MAPPING_ZIGZAG_LINEAR_OFFSET 11 -#define GAMEMTL_MAPPING_WS_CLASSIC_ENV 12 -#define GAMEMTL_MAPPING_WS_ENVIRONMENT 13 -#define GAMEMTL_MAPPING_GRID_CLASSIC_ENV 14 -#define GAMEMTL_MAPPING_GRID_ENVIRONMENT 15 -#define GAMEMTL_MAPPING_RANDOM 16 -#define GAMEMTL_MAPPING_EDGE 17 -#define GAMEMTL_MAPPING_BUMPENV 18 - - -/////////////////////////////////////////////////////////////////////////// -// -// PSX Translucency Type -// -/////////////////////////////////////////////////////////////////////////// -#define GAMEMTL_PSX_TRANS_NONE 0 -#define GAMEMTL_PSX_TRANS_100 1 -#define GAMEMTL_PSX_TRANS_50 2 -#define GAMEMTL_PSX_TRANS_25 3 -#define GAMEMTL_PSX_TRANS_MINUS_100 4 - -class GameMtlDlg; -class GameMapsClass; - -extern Class_ID GameMaterialClassID; -extern ClassDesc * Get_Game_Material_Desc(); - -// MLL -// For Playstation 2 materials. -extern Class_ID PS2GameMaterialClassID; -extern ClassDesc * Get_PS2_Game_Material_Desc(); - -extern Class_ID PCToPS2MaterialClassID; -extern ClassDesc * Get_PS2_Material_Conversion(); - -/////////////////////////////////////////////////////////////////////////// -// -// Game Material -// This is a plugin-material which attempts to emulate the material -// used in our in-game 3D engine. It has varying degrees of success -// at making Max render things like our game but it gives us the -// ability to have control over all parameters in our material. -// -/////////////////////////////////////////////////////////////////////////// -class GameMtl: public Mtl -{ - -public: - - enum ShaderTypeEnum - { - STE_PC_SHADER, - STE_PS2_SHADER, - }; - - GameMtl(BOOL loading = FALSE); - ~GameMtl(void); - - Class_ID ClassID(); - SClass_ID SuperClassID(); - - // From Animatable - void GetClassName(TSTR& s); - void DeleteThis() { delete this; } - int NumSubs(); - Animatable * SubAnim(int i); - TSTR SubAnimName(int i); - - // References - int NumRefs() { return REF_COUNT; } - RefTargetHandle Clone(RemapDir &remap = NoRemap()); - RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message); - void SetReference(int i, RefTargetHandle rtarg); - RefTargetHandle GetReference(int i); - - // From MtlBase and Mtl - void SetAmbient(Color c, TimeValue t) { Set_Ambient(0,t,c); } - void SetDiffuse(Color c, TimeValue t) { Set_Diffuse(0,t,c); } - void SetSpecular(Color c, TimeValue t) { Set_Specular(0,t,c); } - void SetShininess(float v, TimeValue t) { Set_Shininess(0,t,v); } - Color GetAmbient(int mtlNum=0, BOOL backFace=FALSE) { return Get_Ambient(0,0); } - Color GetDiffuse(int mtlNum=0, BOOL backFace=FALSE) { return Get_Diffuse(0,0); } - Color GetSpecular(int mtlNum=0, BOOL backFace=FALSE) { return Get_Specular(0,0); } - float GetXParency(int mtlNum=0, BOOL backFace=FALSE) { return 0.0f; } - float GetShininess(int mtlNum=0, BOOL backFace=FALSE) { return Get_Shininess(0,0); } - float GetShinStr(int mtlNum=0, BOOL backFace=FALSE) { return 1.0f; } - void Reset(void); - void Update(TimeValue t, Interval& validr); - Interval Validity(TimeValue t); - - int NumSubTexmaps(void); - void SetSubTexmap(int i, Texmap * m); - Texmap * GetSubTexmap(int i); - - float EvalDisplacement(ShadeContext& sc); - Interval DisplacementValidity(TimeValue t); - - // Rendering - void Shade(ShadeContext& sc); - ULONG Requirements(int subMtlNum); - //ULONG LocalRequirements(int subMtlNum); - - // Material editor - void SetParamDlg(GameMtlDlg * pd) { MaterialDialog = pd; } - ParamDlg* CreateParamDlg(HWND hwMtlEdit, IMtlParams *imp); - - // IO stuff - IOResult Save(ISave* iSave); - IOResult Load(ILoad* iLoad); - - // Accessors... - void Set_Flag(ULONG f, ULONG val) { if (val) Flags|=f; else Flags &= ~f; } - int Get_Flag(ULONG f) { return ((Flags&f) ? 1 : 0); } - - void Set_Surface_Type(unsigned int type) { SurfaceType = type; } - unsigned int Get_Surface_Type(void) const { return SurfaceType; } - - void Set_Sort_Level(int level) { SortLevel = level; } - int Get_Sort_Level(void) const { return SortLevel; } - - void Set_Pass_Count(int passcount); - int Get_Pass_Count(void); - - IParamBlock * Get_Parameter_Block(int pass); - int Get_Current_Page(int pass) { return CurPage[pass]; } - Color Get_Ambient(int pass,TimeValue t); - Color Get_Diffuse(int pass,TimeValue t); - Color Get_Specular(int pass,TimeValue t); - Color Get_Emissive(int pass,TimeValue t); - float Get_Shininess(int pass,TimeValue t); - float Get_Opacity(int pass,TimeValue t); - float Get_Translucency(int pass,TimeValue t); - int Get_Copy_Specular_To_Diffuse(int pass); - int Get_Mapping_Type(int pass, int stage=0); - int Get_PSX_Translucency(int pass); - int Get_PSX_Lighting(int pass); - - int Get_Depth_Compare(int pass); - int Get_Depth_Mask(int pass); - int Get_Alpha_Test(int pass); - int Get_Dest_Blend(int pass); - int Get_Pri_Gradient(int pass); - int Get_Sec_Gradient(int pass); - int Get_Src_Blend(int pass); - int Get_Detail_Color_Func(int pass); - int Get_Detail_Alpha_Func(int pass); - int Get_PS2_Shader_Param_A(int pass); - int Get_PS2_Shader_Param_B(int pass); - int Get_PS2_Shader_Param_C(int pass); - int Get_PS2_Shader_Param_D(int pass); - - int Get_Texture_Enable(int pass,int stage); - int Get_Texture_Publish(int pass,int stage); - int Get_Texture_Resize(int pass,int stage); // NOTE: obsolete, replaced by Get_Texture_No_LOD - int Get_Texture_No_Mipmap(int pass,int stage); // NOTE: obsolete, replaced by Get_Texture_No_LOD - int Get_Texture_Clamp_U(int pass,int stage); - int Get_Texture_Clamp_V(int pass,int stage); - int Get_Texture_No_LOD(int pass,int stage); - int Get_Texture_Alpha_Bitmap(int pass,int stage); - int Get_Texture_Hint(int pass,int stage); - int Get_Texture_Display(int pass,int stage); - float Get_Texture_Frame_Rate(int pass,int stage); - int Get_Texture_Frame_Count(int pass,int stage); - int Get_Texture_Anim_Type(int pass,int stage); - Texmap * Get_Texture(int pass,int stage); - Texmap * Get_Displacement_Map(void) const { return DisplacementMap; } - float Get_Displacement_Amount(void) const { return DisplacementAmt; } - int Get_Displacement_Map_Index(void) const; - int Get_Map_Channel(int pass,int stage); - - void Set_Current_Page(int pass,int page) { CurPage[pass] = page; } - void Set_Ambient(int pass,TimeValue t,Color color); - void Set_Diffuse(int pass,TimeValue t,Color color); - void Set_Specular(int pass,TimeValue t,Color color); - void Set_Emissive(int pass,TimeValue t,Color color); - void Set_Shininess(int pass,TimeValue t,float val); - void Set_Opacity(int pass,TimeValue t,float val); - void Set_Translucency(int pass,TimeValue t,float val); - void Set_Copy_Specular_To_Diffuse(int pass,bool val); - void Set_Mapping_Type(int pass,int stage,int val); - void Set_PSX_Translucency(int pass,int val); - void Set_PSX_Lighting(int pass,bool val); - - void Set_Depth_Compare(int pass,int val); - void Set_Depth_Mask(int pass,int val); - void Set_Alpha_Test(int pass,int val); - void Set_Dest_Blend(int pass,int val); - void Set_Pri_Gradient(int pass,int val); - void Set_Sec_Gradient(int pass,int val); - void Set_Src_Blend(int pass,int val); - void Set_Detail_Color_Func(int pass,int val); - void Set_Detail_Alpha_Func(int pass,int val); - void Set_PS2_Shader_Param_A(int pass,int val); - void Set_PS2_Shader_Param_B(int pass,int val); - void Set_PS2_Shader_Param_C(int pass,int val); - void Set_PS2_Shader_Param_D(int pass,int val); - - void Set_Texture_Enable(int pass,int stage,bool val); - void Set_Texture_Publish(int pass,int stage,bool val); - void Set_Texture_Resize(int pass,int stage,bool val); // NOTE: obsolete: replaced by Set_Texture_No_LOD - void Set_Texture_No_Mipmap(int pass,int stage,bool val); // NOTE: obsolete: replaced by Set_Texture_No_LOD - void Set_Texture_Clamp_U(int pass,int stage,bool val); - void Set_Texture_Clamp_V(int pass,int stage,bool val); - void Set_Texture_No_LOD(int pass,int stage,bool val); - void Set_Texture_Alpha_Bitmap(int pass,int stage,bool val); - void Set_Texture_Hint(int pass,int stage,int val); - void Set_Texture_Display(int pass,int stage,bool val); - void Set_Texture_Frame_Rate(int pass,int stage,float val); - void Set_Texture_Frame_Count(int pass,int stage,int val); - void Set_Texture_Anim_Type(int pass,int stage,int val); - void Set_Texture(int pass,int stage,Texmap * tex); - void Set_Displacement_Amount(float amount) { DisplacementAmt = amount; Notify_Changed (); } - - void Set_Map_Channel(int pass,int stage,int channel); - - void Notify_Changed(void); - - // This returns the mapping args string buffer for that pass after - // assuring that it is at least of length 'len'. - char * Get_Mapping_Arg_Buffer(int pass, int stage=0, unsigned int len = 0U); - - int pass_stage_to_texmap_index(int pass,int stage); - void texmap_index_to_pass_stage(int index,int * set_pass,int * set_stage); - - // Set and get the type of shader, PC or PS2. - // MLL - int Get_Shader_Type() {return (ShaderType);} - void Set_Shader_Type(int shadertype) {ShaderType = shadertype;} - - // Approximate the PS2 shader on the PC. - int Compute_PC_Shader_From_PS2_Shader(int pass); - int Compute_PS2_Shader_From_PC_Shader(int pass); - - // IML: Get/set substitute material. - Mtl* Substitute_Material() {return (SubstituteMaterial);} - void Set_Substitute_Material (Mtl *m) {SubstituteMaterial = m;} - -private: - - int texture_ref_index(int pass,int stage) { return REF_TEXTURE + pass*W3dMaterialClass::MAX_STAGES + stage; } - int pass_ref_index(int pass) { return REF_PASS_PARAMETERS + pass; } - - void update_viewport_display(); - - // Do the shade functions specific to the Playstation 2. - void ps2_shade(ShadeContext& sc); - - - unsigned int SurfaceType; - int SortLevel; - - Interval Ivalid; // Valid interval - GameMtlDlg * MaterialDialog; // Dialog - ULONG Flags; // Flags - int RollScroll; // Rollup scroll position - int CurPage[W3dMaterialClass::MAX_PASSES]; // which page was last open for each pass - - GameMapsClass * Maps; // ref 0 (obsolete...) - IParamBlock * MainParameterBlock; - IParamBlock * PassParameterBlock[W3dMaterialClass::MAX_PASSES]; - Texmap * Texture[W3dMaterialClass::MAX_PASSES][W3dMaterialClass::MAX_STAGES]; - char * MapperArg[W3dMaterialClass::MAX_PASSES][W3dMaterialClass::MAX_STAGES]; - unsigned int MapperArgLen[W3dMaterialClass::MAX_PASSES][W3dMaterialClass::MAX_STAGES]; - Texmap * DisplacementMap; - float DisplacementAmt; - - // MLL - int ShaderType; - enum - { - REF_MAPS = 0, // obsolete, gamemaps object - REF_MAIN = 1, // main parameter block is ref 1 - REF_PASS_PARAMETERS = 2, // pass parameter blocks are refs 2,3,4,5 - REF_TEXTURE = 6, // textures are refs 6,7,8,9,10,11,12,13,14 (14 is the displacement map) - REF_COUNT = 15 - }; - - Mtl *SubstituteMaterial; // IML: Temporary material used during game to standard material conversion and vice-versa. - - friend class GameMtlDlg; - friend class GameMtlPostLoad; -}; - -Mtl * CreateGameMtl(); - -#endif - - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/genlodextensiondialog.cpp b/Generals/Code/Tools/WW3D/max2w3d/genlodextensiondialog.cpp deleted file mode 100644 index 1684038e172..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/genlodextensiondialog.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/genlodextensiondialog.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/10/00 11:14a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * GenLodExtensionDialogClass::GenLodExtensionDialogClass -- Constructor * - * GenLodExtensionDialogClass::~GenLodExtensionDialogClass -- Destructor * - * GenLodExtensionDialogClass::Get_Options -- Presents the dialog, gets user input * - * GenLodExtensionDialogClass::Dialog_Proc -- Windows message handling * - * _gen_lod_ext_dialog_proc -- windows dialog proc * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "genlodextensiondialog.h" -#include "dllmain.h" -#include "resource.h" -#include - - -/********************************************************************************************** -** -** GenLodExtensionDialogClass Implementation -** -**********************************************************************************************/ - - -/*********************************************************************************************** - * GenLodExtensionDialogClass::GenLodExtensionDialogClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -GenLodExtensionDialogClass::GenLodExtensionDialogClass(Interface * maxinterface) : - Hwnd(NULL), - Options(NULL), - MaxInterface(maxinterface), - LodIndexSpin(NULL) -{ -} - - -/*********************************************************************************************** - * GenLodExtensionDialogClass::~GenLodExtensionDialogClass -- Destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/10/2000 gth : Created. * - *=============================================================================================*/ -GenLodExtensionDialogClass::~GenLodExtensionDialogClass(void) -{ - ReleaseISpinner(LodIndexSpin); -} - - -/*********************************************************************************************** - * GenLodExtensionDialogClass::Get_Options -- Presents the dialog, gets user input * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/10/2000 gth : Created. * - *=============================================================================================*/ -bool GenLodExtensionDialogClass::Get_Options(OptionsStruct * options) -{ - Options = options; - - // Put up the options dialog box. - BOOL result = DialogBoxParam - ( - AppInstance, - MAKEINTRESOURCE (IDD_GENERATE_LOD_EXTENSION_DIALOG), - MaxInterface->GetMAXHWnd(), - (DLGPROC) _gen_lod_ext_dialog_proc, - (LPARAM) this - ); - - if (result == TRUE) { - return true; - } else { - return false; - } -} - - -/*********************************************************************************************** - * GenLodExtensionDialogClass::Dialog_Proc -- Windows message handling * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/10/2000 gth : Created. * - *=============================================================================================*/ -bool GenLodExtensionDialogClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM) -{ - switch (message ) { - - case WM_INITDIALOG: - - // Setup the LOD spinner control. - LodIndexSpin = SetupIntSpinner - ( - Hwnd, - IDC_LOD_INDEX_SPIN, - IDC_LOD_INDEX_EDIT, - MIN_LOD_INDEX,MAX_LOD_INDEX,INITIAL_LOD_INDEX - ); - - return 1; - - case WM_COMMAND: - - switch (LOWORD(wParam)) - { - case IDOK: - Options->LodIndex = LodIndexSpin->GetIVal(); - EndDialog(Hwnd, 1); - break; - - case IDCANCEL: - EndDialog(Hwnd, 0); - break; - } - return 1; - } - return 0; -} - - -/*********************************************************************************************** - * _gen_lod_ext_dialog_proc -- windows dialog proc * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/10/2000 gth : Created. * - *=============================================================================================*/ -static BOOL CALLBACK _gen_lod_ext_dialog_proc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam) -{ - static GenLodExtensionDialogClass * dialog = NULL; - - if (message == WM_INITDIALOG) { - dialog = (GenLodExtensionDialogClass *)lparam; - dialog->Hwnd = hwnd; - } - - if (dialog) { - return dialog->Dialog_Proc(hwnd, message, wparam, lparam); - } else { - return FALSE; - } -} - - - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/genlodextensiondialog.h b/Generals/Code/Tools/WW3D/max2w3d/genlodextensiondialog.h deleted file mode 100644 index a3ef870f59e..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/genlodextensiondialog.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/genlodextensiondialog.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/10/00 11:14a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef GENLODEXTENSIONDIALOG_H -#define GENLODEXTENSIONDIALOG_H - -#include - -class Interface; -class ISpinnerControl; - -/********************************************************************************************** -** -** GenLodExtensionDialogClass - Dialog box for the LOD extension naming parameters -** -**********************************************************************************************/ -class GenLodExtensionDialogClass -{ -public: - - GenLodExtensionDialogClass(Interface * maxinterface); - ~GenLodExtensionDialogClass(); - - struct OptionsStruct - { - OptionsStruct(void) : LodIndex(0) - { - } - - // name options - int LodIndex; - }; - - bool Get_Options(OptionsStruct * options); - bool Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM); - -private: - - enum - { - MIN_LOD_INDEX = 0, - MAX_LOD_INDEX = 99, - INITIAL_LOD_INDEX = 0, - }; - - HWND Hwnd; - - OptionsStruct * Options; - Interface * MaxInterface; - ISpinnerControl * LodIndexSpin; - - friend BOOL CALLBACK _gen_lod_ext_dialog_proc(HWND Hwnd,UINT message,WPARAM wParam,LPARAM lParam); - -}; - - - - -#endif //GENLODEXTENSIONDIALOG_H \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/genmtlnamesdialog.cpp b/Generals/Code/Tools/WW3D/max2w3d/genmtlnamesdialog.cpp deleted file mode 100644 index 7240376c96f..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/genmtlnamesdialog.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/genmtlnamesdialog.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/10/00 11:12a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * GenMtlNamesDialogClass::GenMtlNamesDialogClass -- Constructor * - * GenMtlNamesDialogClass::~GenMtlNamesDialogClass -- Destructor * - * GenMtlNamesDialogClass::Get_Options -- present the dialog, get user input * - * GenMtlNamesDialogClass::Ok_To_Exit -- verify that the input is valid * - * GenMtlNamesDialogClass::Dialog_Proc -- windows message handling * - * _gen_mtl_names_dialog_proc -- windows dialog proc for GenMtlNamesDialog * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "genmtlnamesdialog.h" -#include "dllmain.h" -#include "resource.h" -#include "w3d_file.h" -#include - -static BOOL CALLBACK _gen_mtl_names_dialog_proc(HWND Hwnd,UINT message,WPARAM wParam,LPARAM lParam); - - -/********************************************************************************************** -** -** GenMtlNamesDialogClass Implementation -** -**********************************************************************************************/ - - -/*********************************************************************************************** - * GenMtlNamesDialogClass::GenMtlNamesDialogClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -GenMtlNamesDialogClass::GenMtlNamesDialogClass(Interface * maxinterface) : - Hwnd(NULL), - Options(NULL), - MaxInterface(maxinterface), - NameIndexSpin(NULL) -{ -} - - -/*********************************************************************************************** - * GenMtlNamesDialogClass::~GenMtlNamesDialogClass -- Destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/10/2000 gth : Created. * - *=============================================================================================*/ -GenMtlNamesDialogClass::~GenMtlNamesDialogClass(void) -{ - ReleaseISpinner(NameIndexSpin); -} - - -/*********************************************************************************************** - * GenMtlNamesDialogClass::Get_Options -- present the dialog, get user input * - * * - * INPUT: * - * options - pointer to structure to hold the user's input * - * * - * OUTPUT: * - * true - user pressed ok and the input is valid * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/10/2000 gth : Created. * - *=============================================================================================*/ -bool GenMtlNamesDialogClass::Get_Options(OptionsStruct * options) -{ - Options = options; - - // Put up the options dialog box. - BOOL result = DialogBoxParam - ( - AppInstance, - MAKEINTRESOURCE (IDD_GENERATE_MTL_NAMES_DIALOG), - MaxInterface->GetMAXHWnd(), - (DLGPROC) _gen_mtl_names_dialog_proc, - (LPARAM) this - ); - - if (result == TRUE) { - return true; - } else { - return false; - } -} - - -/*********************************************************************************************** - * GenMtlNamesDialogClass::Ok_To_Exit -- verify that the input is valid * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/10/2000 gth : Created. * - *=============================================================================================*/ -bool GenMtlNamesDialogClass::Ok_To_Exit(void) -{ - // just check that the user entered a name - char buf[W3D_NAME_LEN]; - GetWindowText(GetDlgItem(Hwnd,IDC_BASE_NAME_EDIT),buf,sizeof(buf)); - - if (strlen(buf) == 0) { - MessageBox(Hwnd,"Please enter a root name to use.\n","Error",MB_OK); - return false; - } else { - return true; - } - - return true; -} - - -/*********************************************************************************************** - * GenMtlNamesDialogClass::Dialog_Proc -- windows message handling * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/10/2000 gth : Created. * - *=============================================================================================*/ -bool GenMtlNamesDialogClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM) -{ - switch (message ) { - - case WM_INITDIALOG: - - NameIndexSpin = SetupIntSpinner - ( - Hwnd, - IDC_NAME_INDEX_SPIN, - IDC_NAME_INDEX_EDIT, - MIN_NAME_INDEX,MAX_NAME_INDEX,INITIAL_NAME_INDEX - ); - - // limit the edit box characters - SendDlgItemMessage(Hwnd,IDC_BASE_NAME_EDIT,EM_LIMITTEXT,MAX_ROOT_NAME_LEN,0); - - // set initial name to root of the filename - char buf[_MAX_FNAME]; - _splitpath(MaxInterface->GetCurFileName(),NULL,NULL,buf,NULL); - buf[MAX_ROOT_NAME_LEN+1] = 0; - SetWindowText(GetDlgItem(Hwnd,IDC_BASE_NAME_EDIT),buf); - - // init radio buttons - CheckDlgButton(Hwnd,IDC_AFFECT_ALL_RADIO,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_AFFECT_SELECTED_RADIO,BST_CHECKED); - - return 1; - - case WM_COMMAND: - - switch (LOWORD(wParam)) - { - case IDOK: - if (Ok_To_Exit()) { - // general options - Options->OnlyAffectSelected = (IsDlgButtonChecked(Hwnd,IDC_AFFECT_SELECTED_RADIO) == BST_CHECKED); - - // naming options - Options->NameIndex = NameIndexSpin->GetIVal(); - GetWindowText(GetDlgItem(Hwnd,IDC_BASE_NAME_EDIT),Options->RootName,sizeof(Options->RootName)); - - EndDialog(Hwnd, 1); - } - break; - - case IDCANCEL: - EndDialog(Hwnd, 0); - break; - - } - return 1; - } - return 0; -} - - -/*********************************************************************************************** - * _gen_mtl_names_dialog_proc -- windows dialog proc for GenMtlNamesDialog * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/10/2000 gth : Created. * - *=============================================================================================*/ -static BOOL CALLBACK _gen_mtl_names_dialog_proc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam) -{ - static GenMtlNamesDialogClass * dialog = NULL; - - if (message == WM_INITDIALOG) { - dialog = (GenMtlNamesDialogClass *)lparam; - dialog->Hwnd = hwnd; - } - - if (dialog) { - return dialog->Dialog_Proc(hwnd, message, wparam, lparam); - } else { - return FALSE; - } -} - diff --git a/Generals/Code/Tools/WW3D/max2w3d/genmtlnamesdialog.h b/Generals/Code/Tools/WW3D/max2w3d/genmtlnamesdialog.h deleted file mode 100644 index f53bbb012e3..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/genmtlnamesdialog.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/genmtlnamesdialog.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/10/00 11:12a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef GENMTLNAMESDIALOG_H -#define GENMTLNAMESDIALOG_H - -#include - -class Interface; -class ISpinnerControl; - -/********************************************************************************************** -** -** GenMtlNamesDialogClass - Dialog box for the material naming parameters -** -**********************************************************************************************/ -class GenMtlNamesDialogClass -{ -public: - - GenMtlNamesDialogClass(Interface * maxinterface); - ~GenMtlNamesDialogClass(); - - enum - { - MAX_MATERIAL_NAME_LEN = 32, - MIN_NAME_INDEX = 0, - MAX_NAME_INDEX = 999, - INITIAL_NAME_INDEX = 0, - MAX_ROOT_NAME_LEN = 28, - }; - - struct OptionsStruct - { - OptionsStruct(void) : OnlyAffectSelected(true), NameIndex(0) - { - memset(RootName,0,sizeof(RootName)); - } - - // overall options - bool OnlyAffectSelected; - - // name options - char RootName[MAX_MATERIAL_NAME_LEN]; - int NameIndex; - }; - - bool Get_Options(OptionsStruct * options); - bool Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM); - bool Ok_To_Exit(void); - -private: - - HWND Hwnd; - - OptionsStruct * Options; - Interface * MaxInterface; - ISpinnerControl * NameIndexSpin; - - friend BOOL CALLBACK _gen_mtl_names_dialog_proc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam); - -}; - - -#endif //GENMTLNAMESDIALOG_H - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/gennamesdialog.cpp b/Generals/Code/Tools/WW3D/max2w3d/gennamesdialog.cpp deleted file mode 100644 index 5beb4ded9c3..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/gennamesdialog.cpp +++ /dev/null @@ -1,357 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/gennamesdialog.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 12/06/00 3:24p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * GenNamesDialogClass::GenNamesDialogClass -- Constructor * - * GenNamesDialogClass::~GenNamesDialogClass -- Destructor * - * GenNamesDialogClass::Get_Options -- Get_Options * - * GenNamesDialogClass::Ok_To_Exit -- verifies that the input is valid * - * GenNamesDialogClass::Toggle_Name_Assignment -- toggles the controls related to name assig * - * GenNamesDialogClass::Toggle_Collision_Bits_Assignment -- toggles the controls related to * - * GenNamesDialogClass::Dialog_Proc -- windows dialog proc * - * _gen_names_dialog_proc -- dialog proc that "thunks" to the class's dialog proc * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "gennamesdialog.h" -#include "dllmain.h" -#include "resource.h" - - -static BOOL CALLBACK _gen_names_dialog_proc(HWND Hwnd,UINT message,WPARAM wParam,LPARAM lParam); - - -/********************************************************************************************** -** -** GenNamesDialogClass Implementation -** -**********************************************************************************************/ - - -/*********************************************************************************************** - * GenNamesDialogClass::GenNamesDialogClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -GenNamesDialogClass::GenNamesDialogClass(Interface * maxinterface) : - Hwnd(NULL), - Options(NULL), - MaxInterface(maxinterface), - NameIndexSpin(NULL) -{ -} - - -/*********************************************************************************************** - * GenNamesDialogClass::~GenNamesDialogClass -- Destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/10/2000 gth : Created. * - *=============================================================================================*/ -GenNamesDialogClass::~GenNamesDialogClass(void) -{ - ReleaseISpinner(NameIndexSpin); -} - - -/*********************************************************************************************** - * GenNamesDialogClass::Get_Options -- Get_Options * - * * - * presents the dialog to the user and records his selections into the passed-in options * - * structure. * - * * - * INPUT: * - * options - pointer to a OptionsStruct to store the users input in. * - * * - * OUTPUT: * - * true - user pressed ok and entered valid input * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/10/2000 gth : Created. * - *=============================================================================================*/ -bool GenNamesDialogClass::Get_Options(OptionsStruct * options) -{ - Options = options; - - // Put up the options dialog box. - BOOL result = DialogBoxParam - ( - AppInstance, - MAKEINTRESOURCE (IDD_GENERATE_NAMES_DIALOG), - MaxInterface->GetMAXHWnd(), - (DLGPROC) _gen_names_dialog_proc, - (LPARAM) this - ); - - if (result == TRUE) { - return true; - } else { - return false; - } -} - - -/*********************************************************************************************** - * GenNamesDialogClass::Ok_To_Exit -- verifies that the input is valid * - * * - * INPUT: * - * * - * OUTPUT: * - * true - dialog contains valid input * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/10/2000 gth : Created. * - *=============================================================================================*/ -bool GenNamesDialogClass::Ok_To_Exit(void) -{ - if (IsDlgButtonChecked(Hwnd,IDC_ASSIGN_NAMES_CHECK) == BST_CHECKED) { - - // just check that the user entered a name - char buf[W3D_NAME_LEN]; - GetWindowText(GetDlgItem(Hwnd,IDC_BASE_NAME_EDIT),buf,sizeof(buf)); - - if (strlen(buf) == 0) { - MessageBox(Hwnd,"Please enter a root name to use.\n","Error",MB_OK); - return false; - } else { - return true; - } - } - - return true; -} - - -/*********************************************************************************************** - * GenNamesDialogClass::Toggle_Name_Assignment -- toggles the controls related to name assignm * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/10/2000 gth : Created. * - *=============================================================================================*/ -void GenNamesDialogClass::Toggle_Name_Assignment(void) -{ - bool onoff = (IsDlgButtonChecked(Hwnd,IDC_ASSIGN_NAMES_CHECK) == BST_CHECKED); - EnableWindow(GetDlgItem(Hwnd,IDC_BASE_NAME_EDIT),onoff); - EnableWindow(GetDlgItem(Hwnd,IDC_LOD_INDEX_EDIT),onoff); - EnableWindow(GetDlgItem(Hwnd,IDC_LOD_INDEX_SPIN),onoff); - EnableWindow(GetDlgItem(Hwnd,IDC_NAME_INDEX_EDIT),onoff); - EnableWindow(GetDlgItem(Hwnd,IDC_NAME_INDEX_SPIN),onoff); -} - - -/*********************************************************************************************** - * GenNamesDialogClass::Toggle_Collision_Bits_Assignment -- toggles the controls related to co * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/10/2000 gth : Created. * - *=============================================================================================*/ -void GenNamesDialogClass::Toggle_Collision_Bits_Assignment(void) -{ - bool onoff = (IsDlgButtonChecked(Hwnd,IDC_ASSIGN_COLLISION_BITS_CHECK) == BST_CHECKED); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_PHYSICAL),onoff); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_PROJECTILE),onoff); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_VIS),onoff); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_CAMERA),onoff); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_VEHICLE),onoff); -} - - -/*********************************************************************************************** - * GenNamesDialogClass::Dialog_Proc -- windows dialog proc * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/10/2000 gth : Created. * - *=============================================================================================*/ -bool GenNamesDialogClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM) -{ - switch (message ) { - - case WM_INITDIALOG: - - NameIndexSpin = SetupIntSpinner - ( - Hwnd, - IDC_NAME_INDEX_SPIN, - IDC_NAME_INDEX_EDIT, - MIN_NAME_INDEX,MAX_NAME_INDEX,INITIAL_NAME_INDEX - ); - - // limit the base name edit box to 10 characters - SendDlgItemMessage(Hwnd,IDC_BASE_NAME_EDIT,EM_LIMITTEXT,MAX_ROOT_NAME_LEN,0); - - // limit the suffix and prefix edit boxes - SendDlgItemMessage(Hwnd,IDC_PREFIX_EDIT,EM_LIMITTEXT,MAX_PREFIX_LEN,0); - SendDlgItemMessage(Hwnd,IDC_SUFFIX_EDIT,EM_LIMITTEXT,MAX_SUFFIX_LEN,0); - - // set initial name to root of the filename - char buf[_MAX_FNAME]; - _splitpath(MaxInterface->GetCurFileName(),NULL,NULL,buf,NULL); - buf[MAX_ROOT_NAME_LEN+1] = 0; - SetWindowText(GetDlgItem(Hwnd,IDC_BASE_NAME_EDIT),buf); - - // init radio buttons - CheckDlgButton(Hwnd,IDC_AFFECT_ALL_RADIO,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_AFFECT_SELECTED_RADIO,BST_CHECKED); - - // init the check boxes - CheckDlgButton(Hwnd,IDC_ASSIGN_NAMES_CHECK,BST_CHECKED); - CheckDlgButton(Hwnd,IDC_ASSIGN_PREFIX_CHECK,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_ASSIGN_SUFFIX_CHECK,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_ASSIGN_COLLISION_BITS_CHECK,BST_CHECKED); - CheckDlgButton(Hwnd,IDC_COLLISION_PHYSICAL,BST_CHECKED); - CheckDlgButton(Hwnd,IDC_COLLISION_PROJECTILE,BST_CHECKED); - CheckDlgButton(Hwnd,IDC_COLLISION_VIS,BST_CHECKED); - CheckDlgButton(Hwnd,IDC_COLLISION_CAMERA,BST_CHECKED); - CheckDlgButton(Hwnd,IDC_COLLISION_VEHICLE,BST_CHECKED); - return 1; - - case WM_COMMAND: - - switch (LOWORD(wParam)) - { - case IDOK: - if (Ok_To_Exit()) { - // general options - Options->AssignNames = (IsDlgButtonChecked(Hwnd,IDC_ASSIGN_NAMES_CHECK) == BST_CHECKED); - Options->AssignPrefix = (IsDlgButtonChecked(Hwnd,IDC_ASSIGN_PREFIX_CHECK) == BST_CHECKED); - Options->AssignSuffix = (IsDlgButtonChecked(Hwnd,IDC_ASSIGN_SUFFIX_CHECK) == BST_CHECKED); - Options->AssignCollisionBits = (IsDlgButtonChecked(Hwnd,IDC_ASSIGN_COLLISION_BITS_CHECK) == BST_CHECKED); - Options->OnlyAffectSelected = (IsDlgButtonChecked(Hwnd,IDC_AFFECT_SELECTED_RADIO) == BST_CHECKED); - - // naming options - Options->NameIndex = NameIndexSpin->GetIVal(); - GetWindowText(GetDlgItem(Hwnd,IDC_BASE_NAME_EDIT),Options->RootName,sizeof(Options->RootName)); - GetWindowText(GetDlgItem(Hwnd,IDC_PREFIX_EDIT),Options->PrefixName,sizeof(Options->PrefixName)); - GetWindowText(GetDlgItem(Hwnd,IDC_SUFFIX_EDIT),Options->SuffixName,sizeof(Options->SuffixName)); - - // collision options - Options->PhysicalCollision = (IsDlgButtonChecked(Hwnd,IDC_COLLISION_PHYSICAL) == BST_CHECKED); - Options->ProjectileCollision = (IsDlgButtonChecked(Hwnd,IDC_COLLISION_PROJECTILE) == BST_CHECKED); - Options->VisCollision = (IsDlgButtonChecked(Hwnd,IDC_COLLISION_VIS) == BST_CHECKED); - Options->CameraCollision = (IsDlgButtonChecked(Hwnd,IDC_COLLISION_CAMERA) == BST_CHECKED); - Options->VehicleCollision = (IsDlgButtonChecked(Hwnd,IDC_COLLISION_VEHICLE) == BST_CHECKED); - EndDialog(Hwnd, 1); - } - break; - - case IDCANCEL: - EndDialog(Hwnd, 0); - break; - - case IDC_ASSIGN_NAMES_CHECK: - Toggle_Name_Assignment(); - break; - - case IDC_ASSIGN_PREFIX_CHECK: - EnableWindow(GetDlgItem(Hwnd,IDC_PREFIX_EDIT),(IsDlgButtonChecked(Hwnd,IDC_ASSIGN_SUFFIX_CHECK) == BST_CHECKED)); - break; - - case IDC_ASSIGN_SUFFIX_CHECK: - EnableWindow(GetDlgItem(Hwnd,IDC_SUFFIX_EDIT),(IsDlgButtonChecked(Hwnd,IDC_ASSIGN_SUFFIX_CHECK) == BST_CHECKED)); - break; - - case IDC_ASSIGN_COLLISION_BITS_CHECK: - Toggle_Collision_Bits_Assignment(); - break; - } - return 1; - } - return 0; -} - - -/*********************************************************************************************** - * _gen_names_dialog_proc -- dialog proc that "thunks" to the class's dialog proc * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/10/2000 gth : Created. * - *=============================================================================================*/ -static BOOL CALLBACK _gen_names_dialog_proc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam) -{ - static GenNamesDialogClass * dialog = NULL; - - if (message == WM_INITDIALOG) { - dialog = (GenNamesDialogClass *)lparam; - dialog->Hwnd = hwnd; - } - - if (dialog) { - return dialog->Dialog_Proc(hwnd, message, wparam, lparam); - } else { - return FALSE; - } -} - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/gennamesdialog.h b/Generals/Code/Tools/WW3D/max2w3d/gennamesdialog.h deleted file mode 100644 index 6c52343ee5b..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/gennamesdialog.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/gennamesdialog.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 12/06/00 3:25p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include -#include "w3d_file.h" - - -/********************************************************************************************** -** -** GenNamesDialogClass - Dialog box for the node naming parameters -** -**********************************************************************************************/ -class GenNamesDialogClass -{ -public: - - GenNamesDialogClass(Interface * maxinterface); - ~GenNamesDialogClass(); - - struct OptionsStruct - { - OptionsStruct(void) : OnlyAffectSelected(false), NameIndex(0), AssignCollisionBits(false) - { - memset(RootName,0,sizeof(RootName)); - memset(PrefixName,0,sizeof(PrefixName)); - memset(SuffixName,0,sizeof(SuffixName)); - } - - // overall options - bool AssignNames; - bool AssignPrefix; - bool AssignSuffix; - bool AssignCollisionBits; - bool OnlyAffectSelected; - - // name options - char RootName[W3D_NAME_LEN]; - char PrefixName[W3D_NAME_LEN]; - char SuffixName[W3D_NAME_LEN]; - int NameIndex; - - // collision bit options - bool PhysicalCollision; - bool ProjectileCollision; - bool VisCollision; - bool CameraCollision; - bool VehicleCollision; - }; - - bool Get_Options(OptionsStruct * options); - bool Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM); - bool Ok_To_Exit(void); - void Toggle_Collision_Bits_Assignment(void); - void Toggle_Name_Assignment(void); - -private: - - enum - { - MIN_NAME_INDEX = 0, - MAX_NAME_INDEX = 999, - INITIAL_NAME_INDEX = 0, - MAX_ROOT_NAME_LEN = 10, - MAX_PREFIX_LEN = 3, - MAX_SUFFIX_LEN = 3, - }; - - HWND Hwnd; - - OptionsStruct * Options; - Interface * MaxInterface; - ISpinnerControl * NameIndexSpin; - - friend BOOL CALLBACK _gen_names_dialog_proc(HWND Hwnd,UINT message,WPARAM wParam,LPARAM lParam); - -}; - diff --git a/Generals/Code/Tools/WW3D/max2w3d/geometryexportcontext.h b/Generals/Code/Tools/WW3D/max2w3d/geometryexportcontext.h deleted file mode 100644 index ce86342bdf9..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/geometryexportcontext.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/geometryexportcontext.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/19/00 11:32a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef GEOMETRYEXPORTCONTEXT_H -#define GEOMETRYEXPORTCONTEXT_H - -#include - -class ChunkSaveClass; -class MaxWorldInfoClass; -class HierarchySaveClass; -class INodeListClass; -class Progress_Meter_Class; -struct W3dExportOptionsStruct; - - -/** -** ExportContextClass -** This class encapsulates a bunch of datastructures needed during the geometry export -** process. -** NOTE: The user must plug in a valid ProgressMeter before each export operation. -*/ -class GeometryExportContextClass -{ -public: - GeometryExportContextClass( char * model_name, - ChunkSaveClass & csave, - MaxWorldInfoClass & world_info, - W3dExportOptionsStruct & options, - HierarchySaveClass * htree, - INode * origin, - INodeListClass * origin_list, - TimeValue curtime, - unsigned int *materialColors - ) : - CSave(csave), - WorldInfo(world_info), - Options(options), - CurTime(curtime), - HTree(htree), - OriginList(origin_list), - Origin(origin), - OriginTransform(1), - ProgressMeter(NULL), - materialColors(materialColors), - numMaterialColors(0), - numHouseColors(0), - materialColorTexture(NULL) - { - ModelName = strdup(model_name); - OriginTransform = Origin->GetNodeTM(CurTime); - } - - ~GeometryExportContextClass(void) - { - delete[] ModelName; - } - - char * ModelName; - ChunkSaveClass & CSave; - MaxWorldInfoClass & WorldInfo; - W3dExportOptionsStruct & Options; - TimeValue CurTime; - HierarchySaveClass * HTree; - INodeListClass * OriginList; - - INode * Origin; - Matrix3 OriginTransform; - Progress_Meter_Class * ProgressMeter; - unsigned int * materialColors; ///MW: holds all used material colors. - int numMaterialColors; ///MW: number of used material colors. - int numHouseColors; ///MW: number of used house colors - char * materialColorTexture; //MW: texture to hold material colors -}; - - - -#endif //GEOMETRYEXPORTCONTEXT_H - diff --git a/Generals/Code/Tools/WW3D/max2w3d/geometryexporttask.cpp b/Generals/Code/Tools/WW3D/max2w3d/geometryexporttask.cpp deleted file mode 100644 index be3baf4bef0..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/geometryexporttask.cpp +++ /dev/null @@ -1,1176 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/geometryexporttask.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/31/00 10:35a $* - * * - * $Revision:: 7 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * GeometryExportTaskClass::GeometryExportTaskClass -- Constructor * - * GeometryExportTaskClass::GeometryExportTaskClass -- Copy Constructor * - * GeometryExportTaskClass::~GeometryExportTaskClass -- Destructor * - * GeometryExportTaskClass::Get_Full_Name -- Composes the full name of this robj * - * GeometryExportTaskClass::Create_Task -- virtual constructor for export tasks * - * GeometryExportTaskClass::Optimize_Geometry -- Optimizes the export tasks * - * GeometryExportTaskClass::Generate_Unique_Name -- create a unique name for this object * - * MeshGeometryExportTaskClass::Is_Single_Material -- Tests if this mesh uses a single mater * - * MeshGeometryExportTaskClass::Get_Single_Material -- returns pointer to the material * - * MeshGeometryExportTaskClass::Cache_Single_Material -- updates the cached material pointer * - * MeshGeometryExportTaskClass::Split -- Splits into single material meshes * - * MeshGeometryExportTaskClass::Reduce_To_Single_Material -- deletes polys * - * MeshGeometryExportTaskClass::Can_Combine -- can this mesh combine with anything * - * MeshGeometryExportTaskClass::Can_Combine_With -- can this mesh be combined with the given * - * MeshGeometryExportTaskClass::Combine_Mesh -- Add the given mesh into this mesh * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "geometryexporttask.h" -#include "geometryexportcontext.h" -#include "util.h" -#include "w3dutil.h" -#include "w3dappdata.h" -#include "hiersave.h" -#include "maxworldinfo.h" -#include "meshsave.h" -#include "colboxsave.h" -#include "dazzlesave.h" -#include - - -const int OPTIMIZATION_FACECOUNT_LIMIT = 256; // TODO: what should this number be... -const float OPTIMIZATION_COMBINING_DISTANCE = 20.0f; // TODO: need a smarter method for combining... - - -/** -** MeshGeometryExportTaskClass -** Export task for INodes which are to generate W3D meshes -*/ -class MeshGeometryExportTaskClass : public GeometryExportTaskClass -{ -public: - - MeshGeometryExportTaskClass(INode * node,GeometryExportContextClass & context) : - GeometryExportTaskClass(node,context), - NameDirty(false), - SingleMtl(NULL) - { - /* - ** Copy the export options - */ - ExportOptions = *(W3DAppData2Struct::Get_App_Data(Node)); - - /* - ** Copy the mesh - */ - Object * obj = Node->EvalWorldState(CurTime).obj; - TriObject * tri = (TriObject *)obj->ConvertToType(CurTime, triObjectClassID); - MeshData = tri->mesh; - - /* - ** Store a pointer to the material if this mesh uses only one material (even inside a Multi-Sub) - */ - Update_Cached_Data(); - } - - MeshGeometryExportTaskClass(const MeshGeometryExportTaskClass & that) : - GeometryExportTaskClass(that), - MeshData(that.MeshData), - ExportOptions(that.ExportOptions), - NameDirty(false) - { - } - - virtual ~MeshGeometryExportTaskClass(void) - { - } - - virtual void Export_Geometry(GeometryExportContextClass & context) - { - /* - ** Create the mesh - */ - context.WorldInfo.Set_Current_Task(this); - context.WorldInfo.Set_Export_Transform(ExportSpace); - - MeshSaveClass * mesh = new MeshSaveClass( Name, - ContainerName, - Node, - &MeshData, - ExportSpace, - ExportOptions, - context.HTree, - context.CurTime, - *context.ProgressMeter, - context.materialColors, - context.numMaterialColors, - context.numHouseColors, - context.materialColorTexture, - &context.WorldInfo - ); - - /* - ** Export It - */ - mesh->Write_To_File(context.CSave,!context.Options.DisableExportAABTrees); - delete mesh; - context.ProgressMeter->Add_Increment(); - }; - - /* - ** Naming. During the optimization phase, sometimes new meshes are created and require - ** new unique names. These meshes are flagged and then new names are generated prior - ** to exporting. - */ - bool Is_Name_Dirty(void) { return NameDirty; } - void Set_Name_Dirty(bool onoff) { NameDirty = onoff; } - - /* - ** Vertex Normal smoothing support! - */ - virtual Point3 Get_Shared_Vertex_Normal(const Point3 & pos,int smgroup); - - /* - ** Optimization functions - */ - bool Is_Single_Material(void); - Mtl * Get_Single_Material(void); - void Split(DynamicVectorClass & simple_meshes); - void Reduce_To_Single_Material(int mat_id); - bool Can_Combine(void); - bool Can_Combine_With(MeshGeometryExportTaskClass * other_mesh); - void Combine_Mesh(MeshGeometryExportTaskClass * other_mesh); - -protected: - - virtual int Get_Geometry_Type(void) { return MESH; } - void Update_Cached_Data(void); - - Mesh MeshData; // Copy of the mesh data to be exported. - W3DAppData2Struct ExportOptions; // Copy of the export options in case we want to change them during optimization - bool NameDirty; - - // Cached Data about the Node/Mesh. Updated by calling Update_Cached_Data whenever the mesh changes. - Mtl * SingleMtl; // Pointer to the single material (if the mesh uses only one, even in a multi-mtl) - Point3 BoxCenter; // Center of the bounding box (in object space) - Point3 BoxExtent; // Extent of the bounding box (in object space) - Box3 WorldBounds; // World-space bounding box -}; - - - - - -/** -** CollisionBoxGeometryExportTaskClass -** Export task for INodes which are to generate W3D AABoxes or OBBoxes -*/ -class CollisionBoxGeometryExportTaskClass : public GeometryExportTaskClass -{ -public: - CollisionBoxGeometryExportTaskClass(INode * node,GeometryExportContextClass & context) : - GeometryExportTaskClass(node,context) - { - } - - virtual void Export_Geometry(GeometryExportContextClass & context) - { - /* - ** Create the collision box - */ - CollisionBoxSaveClass * colbox = new CollisionBoxSaveClass( Name, - ContainerName, - Node, - ExportSpace, - context.CurTime, - *context.ProgressMeter); - - /* - ** Export it - */ - colbox->Write_To_File(context.CSave); - delete colbox; - context.ProgressMeter->Add_Increment(); - }; - -protected: - - virtual int Get_Geometry_Type(void) { return COLLISIONBOX; } - -}; - - - - - -/** -** DazzleGeometryExportTaskClass -** Export task for INodes which are to generate W3D Dazzle objects -*/ -class DazzleGeometryExportTaskClass : public GeometryExportTaskClass -{ -public: - DazzleGeometryExportTaskClass(INode * node,GeometryExportContextClass & context) : - GeometryExportTaskClass(node,context) - { - } - - virtual void Export_Geometry(GeometryExportContextClass & context) - { - /* - ** Create the dazzle object - */ - DazzleSaveClass * dazzle = new DazzleSaveClass( Name, - ContainerName, - Node, - ExportSpace, - context.CurTime, - *context.ProgressMeter); - /* - ** Export it. - */ - dazzle->Write_To_File(context.CSave); - delete dazzle; - context.ProgressMeter->Add_Increment(); - }; - -protected: - - virtual int Get_Geometry_Type(void) { return DAZZLE; } - -}; - - - - -/** -** NullGeometryExportTaskClass -** Export task for INodes which are to generate W3D NULL objects. Note that this -** does not do anything in the Export_Geometry call, these only create entries in -** any Hierarhcical model or collection object being exported. -*/ -class NullGeometryExportTaskClass : public GeometryExportTaskClass -{ -public: - NullGeometryExportTaskClass(INode * node,GeometryExportContextClass & context) : - GeometryExportTaskClass(node,context) - { - memset(ContainerName,0,sizeof(ContainerName)); - memset(Name,0,sizeof(Name)); - strcpy(Name,"NULL"); - } - - virtual void Export_Geometry(GeometryExportContextClass & context) - { - context.ProgressMeter->Add_Increment(); - }; - -protected: - - virtual int Get_Geometry_Type(void) { return NULLOBJ; } - -}; - - -/** -** AggregateGeometryExportTaskClass -** Export task for INodes which are to generate W3D Aggregates. These are nodes -** that refer to some external W3D object. This export task doesn't export any -** geometry (similer to the Null export task) and it clears its container name -** because the object to be attached is not a sub-object of the model we are -** currently exporting. -*/ -class AggregateGeometryExportTaskClass : public GeometryExportTaskClass -{ -public: - AggregateGeometryExportTaskClass(INode * node,GeometryExportContextClass & context) : - GeometryExportTaskClass(node,context) - { - memset(ContainerName,0,sizeof(ContainerName)); - } - - virtual void Export_Geometry(GeometryExportContextClass & context) - { - context.ProgressMeter->Add_Increment(); - }; - - virtual bool Is_Aggregate(void) - { - return true; - } - -protected: - - virtual int Get_Geometry_Type(void) { return AGGREGATE; } - -}; - - -/** -** ProxyExportTaskClass -** These are used by the Renegade Level Editor to cause game objects to be -** instantiated at the specified transform. Like aggregates they have to -** be handled specially and therefore have the Is_Proxy member function devoted -** solely to them :-) Hopefully we don't have any more geometry types which -** have to be handled specially or this is going to get messy again. -*/ -class ProxyExportTaskClass : public GeometryExportTaskClass -{ -public: - - ProxyExportTaskClass(INode * node,GeometryExportContextClass & context) : - GeometryExportTaskClass(node,context) - { - /* - ** clear the container name - */ - memset(ContainerName,0,sizeof(ContainerName)); - - /* - ** strip the trailing ~ - */ - char *tilda = ::strchr(Name, '~'); - memset(tilda,0,sizeof(Name) - ((int)tilda - (int)Name)); - - } - - virtual void Export_Geometry(GeometryExportContextClass & context) - { - context.ProgressMeter->Add_Increment(); - }; - - virtual bool Is_Proxy(void) { return true; } - -protected: - - virtual int Get_Geometry_Type(void) { return PROXY; } - -}; - - - - - -/*********************************************************************************************** -** -** Implementations -** -***********************************************************************************************/ - -/*********************************************************************************************** - * GeometryExportTaskClass::GeometryExportTaskClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/20/2000 gth : Created. * - *=============================================================================================*/ -GeometryExportTaskClass::GeometryExportTaskClass(INode * node,GeometryExportContextClass & context) : - BoneIndex(0), - ExportSpace(1), - CurTime(context.CurTime), - Node(node) -{ - /* - ** Set up the names - */ - Set_W3D_Name(Name,Node->GetName()); - Append_Lod_Character(Name,Get_Lod_Level(context.Origin),context.OriginList); - Set_W3D_Name(ContainerName,context.ModelName); - - /* - ** Set up the bone index and export coordinate system. - */ - if (context.HTree != NULL) { - if (!Is_Skin(node)) { - context.HTree->Get_Export_Coordinate_System(Node,&BoneIndex,NULL,&ExportSpace); - } else { - BoneIndex = 0; - ExportSpace = context.OriginTransform; - } - } -} - - -/*********************************************************************************************** - * GeometryExportTaskClass::GeometryExportTaskClass -- Copy Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/20/2000 gth : Created. * - *=============================================================================================*/ -GeometryExportTaskClass::GeometryExportTaskClass(const GeometryExportTaskClass & that) : - BoneIndex(that.BoneIndex), - ExportSpace(that.ExportSpace), - CurTime(that.CurTime), - Node(that.Node) -{ - Set_W3D_Name(Name,that.Name); - Set_W3D_Name(ContainerName,that.ContainerName); -} - - -/*********************************************************************************************** - * GeometryExportTaskClass::~GeometryExportTaskClass -- Destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -GeometryExportTaskClass::~GeometryExportTaskClass(void) -{ -} - - -/*********************************************************************************************** - * GeometryExportTaskClass::Get_Full_Name -- Composes the full name of this robj * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/24/2000 gth : Created. * - *=============================================================================================*/ -void GeometryExportTaskClass::Get_Full_Name(char * buffer,int size) -{ - char tmp[128]; - memset(tmp,0,sizeof(tmp)); - if (strlen(ContainerName) > 0) { - strcat(tmp,ContainerName); - strcat(tmp,"."); - } - strcat(tmp,Name); - - strncpy(buffer,tmp,size); -} - - -/*********************************************************************************************** - * GeometryExportTaskClass::Create_Task -- virtual constructor for export tasks * - * * - * Virtual constructor for geometry export tasks. Will create the proper task * - * type depending on the W3D flag settings. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/20/2000 gth : Created. * - *=============================================================================================*/ -GeometryExportTaskClass * -GeometryExportTaskClass::Create_Task(INode * node,GeometryExportContextClass & context) -{ - if (!::Is_Geometry(node)) { - return NULL; - } - - // NOTE: we *have* to check Is_Proxy first because it is tied to a naming convention - // rather than an explicit UI setting like the rest of the types. - if (::Is_Proxy(*node)) { - return new ProxyExportTaskClass(node,context); - } - - if (::Is_Normal_Mesh(node) || Is_Camera_Aligned_Mesh(node) || Is_Camera_Oriented_Mesh(node) || Is_Skin(node)) { - return new MeshGeometryExportTaskClass(node,context); - } - - if (::Is_Collision_AABox(node) || Is_Collision_OBBox(node)) { - return new CollisionBoxGeometryExportTaskClass(node,context); - } - - if (::Is_Null_Object(node)) { - return new NullGeometryExportTaskClass(node,context); - } - - if (::Is_Dazzle(node)) { - return new DazzleGeometryExportTaskClass(node,context); - } - - if (::Is_Aggregate(node)) { - return new AggregateGeometryExportTaskClass(node,context); - } - - return NULL; -} - - -/*********************************************************************************************** - * GeometryExportTaskClass::Optimize_Geometry -- Optimizes the export tasks * - * * - * This function will attempt to split meshes so that they use only a single material and * - * then try to combine small meshes that use the same material. Export tasks may be * - * removed and new ones added. * - * * - * INPUT: * - * tasks - dynamic vector of export task pointers. Some tasks may be deleted, some added * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/20/2000 gth : Created. * - *=============================================================================================*/ -void GeometryExportTaskClass::Optimize_Geometry -( - DynamicVectorClass & tasks, - GeometryExportContextClass & context -) -{ - int j=0,i=0; - - /* - ** Pass 1: Extract all mesh geometry tasks from the input task array. - ** NOTE: We're not optimizing Skin meshes so we leave them in the task array. - */ - DynamicVectorClass meshes; - while (iGet_Geometry_Type() == GeometryExportTaskClass::MESH) && - (!Is_Skin(tasks[i]->Get_Object_Node())) ) - { - /* - ** Add to the mesh array, remove from the tasks array - */ - meshes.Add((MeshGeometryExportTaskClass *)(tasks[i])); - tasks.Delete(i); - } else { - - /* - ** Leave in the task array and move to the next one. - */ - i++; - } - } - - /* - ** Pass 2: Split all meshes which use more than one material - */ - DynamicVectorClass simple_meshes; - while (meshes.Count() > 0) { - - int cur_index = meshes.Count() - 1; - MeshGeometryExportTaskClass * cur_mesh = meshes[cur_index]; - - /* - ** If this mesh already uses only one material, just transfer it to the simple_meshes array. - ** Otherwise, have it split into new tasks, add them to the simple_meshes array, and delete this task. - */ - if (cur_mesh->Is_Single_Material()) { - simple_meshes.Add(cur_mesh); - } else { - cur_mesh->Split(simple_meshes); - delete cur_mesh; - } - meshes.Delete(cur_index); - } - - /* - ** Pass 3: Combine meshes which satisfy the following - ** - They use the same (single) material - ** - They have fewer than 'x' polygons - ** - They are 'close' to each other - */ - i=0; - while (i < simple_meshes.Count()) { - - if (simple_meshes[i]->Can_Combine()) { - - j=i+1; - while (j < simple_meshes.Count()) { - if (simple_meshes[i]->Can_Combine_With(simple_meshes[j])) { - - /* - ** Add mesh 'j' into mesh 'i', delete its task. - */ - simple_meshes[i]->Combine_Mesh(simple_meshes[j]); - delete simple_meshes[j]; - simple_meshes.Delete(j); - - /* - ** If we've just exceeded the max poly count, move to the next mesh - */ - if (simple_meshes[i]->Can_Combine() == false) { - j = simple_meshes.Count(); - } - - } else { - - /* - ** Otherwise, move to the next mesh - */ - j++; - } - } - } - i++; - } - - - - /* - ** Generate names for each of the meshes that were created - */ - for (i=0; iIs_Name_Dirty()) { - simple_meshes[i]->Generate_Name("MESH",i,context); -// } - } - - /* - ** Finally, transfer all of the optimized tasks into the big task array - */ - for (i=0; iGetMtl(); - - /* - ** Set the SingleMtl pointer if this mesh uses only one material (again, even if its in a Multi-Sub) - */ - if (nodemtl == NULL) { - - SingleMtl = NULL; - - } else if (nodemtl->NumSubMtls() <= 1) { - - SingleMtl = nodemtl; - - } else { - - int mat_index; - int face_index; - int sub_mtl_count = nodemtl->NumSubMtls(); - bool * sub_mtl_flags = new bool[sub_mtl_count]; - - /* - ** Initialize each sub-material flag to false (indicates that the material is un-used) - */ - for (mat_index=0; mat_indexGetSubMtl(mat_index); - mat_count++; - } - } - - if (mat_count > 1) { - SingleMtl = NULL; - } - } - - /* - ** Update the bounding box - */ - Point3 boxmin(0,0,0); - Point3 boxmax(0,0,0); - - if (MeshData.numVerts > 0) { - boxmin = MeshData.verts[1]; - boxmax = MeshData.verts[0]; - for (int i=0; iGetObjectTM(CurTime); -} - - -/*********************************************************************************************** - * MeshGeometryExportTaskClass::Is_Single_Material -- Tests if this mesh uses a single materia * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/20/2000 gth : Created. * - *=============================================================================================*/ -bool MeshGeometryExportTaskClass::Is_Single_Material(void) -{ - return ((SingleMtl != NULL) || (Node->GetMtl() == NULL)); -} - - -/*********************************************************************************************** - * MeshGeometryExportTaskClass::Get_Single_Material -- returns pointer to the material * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/23/2000 gth : Created. * - *=============================================================================================*/ -Mtl* MeshGeometryExportTaskClass::Get_Single_Material(void) -{ - return SingleMtl; -} - -/*********************************************************************************************** - * MeshGeometryExportTaskClass::Split -- Splits into single material meshes * - * * - * This function will create new export tasks and add them to the supplied array. Each of * - * these will be single-material meshes. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/20/2000 gth : Created. * - *=============================================================================================*/ -void MeshGeometryExportTaskClass::Split(DynamicVectorClass & simple_meshes) -{ - assert(!Is_Single_Material()); - - Mtl * nodemtl = Node->GetMtl(); - - int mat_index; - int face_index; - int sub_mtl_count = nodemtl->NumSubMtls(); - bool * sub_mtl_flags = new bool[sub_mtl_count]; - - /* - ** Initialize each sub-material flag to false (indicates that the material is un-used) - */ - for (mat_index=0; mat_indexReduce_To_Single_Material(mat_index); - new_task->Set_Name_Dirty(true); - simple_meshes.Add(new_task); - - } - } -} - - -/*********************************************************************************************** - * MeshGeometryExportTaskClass::Reduce_To_Single_Material -- deletes polys * - * * - * This function deletes all polys (and subsequent un-used vertices) except for the ones * - * that use the specified material. * - * * - * INPUT: * - * mat_id - only faces using this material id will remain in the mesh. * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/20/2000 gth : Created. * - *=============================================================================================*/ -void MeshGeometryExportTaskClass::Reduce_To_Single_Material(int mat_id) -{ - int sub_mtl_count = Node->GetMtl()->NumSubMtls(); - - BitArray faces_to_delete(MeshData.getNumFaces()); - BitArray verts_to_delete(MeshData.getNumVerts()); - - faces_to_delete.ClearAll(); - verts_to_delete.ClearAll(); - - for (int i=0; i OPTIMIZATION_FACECOUNT_LIMIT) { - return false; - } - if (ExportOptions.Is_Vis_Collision_Enabled()) { - return false; - } - return true; -} - - -/*********************************************************************************************** - * MeshGeometryExportTaskClass::Can_Combine_With -- can this mesh be combined with the given m * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/24/2000 gth : Created. * - *=============================================================================================*/ -bool MeshGeometryExportTaskClass::Can_Combine_With(MeshGeometryExportTaskClass * other_mesh) -{ - /* - ** Does the mesh attach to the same W3D bone that we do? - */ - if (other_mesh->BoneIndex != BoneIndex) { - return false; - } - - /* - ** Does the mesh use the same (single) material that we do? - */ - Mtl * other_mtl = other_mesh->Get_Single_Material(); - if (other_mtl == NULL) { - return false; - } - - Mtl * my_mtl = Get_Single_Material(); - if (my_mtl != other_mtl) { - return false; - } - - /* - ** Are its relevant W3D options the same as ours? - */ - if (ExportOptions.Geometry_Options_Match(other_mesh->ExportOptions)) { - return false; - } - - /* - ** Would our combined polygon count be reasonable - */ - if (MeshData.numFaces + other_mesh->MeshData.numFaces > OPTIMIZATION_FACECOUNT_LIMIT) { - return false; - } - - /* - ** Is the other mesh near me? - */ - Point3 my_center = Node->GetObjectTM(CurTime) * BoxCenter; - Point3 other_center = other_mesh->Node->GetObjectTM(CurTime) * BoxCenter; - float dist = ::FLength(my_center - other_center); - if (dist > OPTIMIZATION_COMBINING_DISTANCE) { - return false; - } - - return true; -} - - -/*********************************************************************************************** - * MeshGeometryExportTaskClass::Combine_Mesh -- Add the given mesh into this mesh * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/24/2000 gth : Created. * - *=============================================================================================*/ -void MeshGeometryExportTaskClass::Combine_Mesh(MeshGeometryExportTaskClass * other_mesh) -{ - /* - ** Compute the transform from other_mesh's coordinate system to ours so that - ** its polygons can be combined with ours (by calling CombineMeshes) - */ - Matrix3 our_tm = Node->GetObjectTM(CurTime); - Matrix3 his_tm = other_mesh->Node->GetObjectTM(CurTime); - Matrix3 tm = Inverse(our_tm) * his_tm; - - /* - ** Store our current material index - */ - int matid = MeshData.faces[0].getMatID(); - if (Node->GetMtl()->NumSubMtls() > 1) { - matid = matid % Node->GetMtl()->NumSubMtls(); - } - - /* - ** Combine the meshes - */ - Mesh new_mesh; - ::CombineMeshes(new_mesh,MeshData,other_mesh->MeshData,&our_tm,&his_tm,0); - MeshData = new_mesh; - - /* - ** Set all material ID's - */ - for (int i=0; iGetObjectTM(CurTime); - Point3 obj_pos = world_pos * Inverse(tm); - - /* - ** Loop through all the faces in this mesh and find out which ones - ** share the same smoothing group as the vertex we are looking for. - */ - for (int face_index = 0; face_index < MeshData.numFaces; face_index ++) { - Face &maxface = MeshData.faces[face_index]; - int face_smgroup = maxface.getSmGroup(); - if ((face_smgroup & smgroup) || (face_smgroup == smgroup)) { - - /* - ** Find out if any of the verticies of this face share the - ** same space as the vertex we are looking for. - */ - bool found = false; - for (int vert_index = 0; (vert_index < 3) && !found; vert_index ++) { - int max_vert_index = maxface.v[vert_index]; - Point3 delta = obj_pos - MeshData.verts[max_vert_index]; - if ((fabs (delta.x) < EPSILON) && - (fabs (delta.y) < EPSILON) && - (fabs (delta.z) < EPSILON)) - { - - /* - ** Compute the normal for this face - */ - Point3 v0 = MeshData.verts[maxface.v[0]]; - Point3 v1 = MeshData.verts[maxface.v[1]]; - Point3 v2 = MeshData.verts[maxface.v[2]]; - Point3 face_normal = (v1-v0)^(v2-v1); - face_normal = ::Normalize(face_normal); - - /* - ** Add this face normal to the sum - */ - normal.x += face_normal.x; - normal.y += face_normal.y; - normal.z += face_normal.z; - - /* - ** Done with this face, look for more - */ - found = true; - } - } - } - } - - /* - ** Transform the "normal" to world space. Note that this vector isn't - ** normalized because we are basically summing the contributions of each - ** face in each mesh which shares this normal. The final normal - ** will be normalized in the MeshBuilderClass. - */ - tm.NoTrans(); - normal = tm.PointTransform(normal); - } - - return normal; -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/geometryexporttask.h b/Generals/Code/Tools/WW3D/max2w3d/geometryexporttask.h deleted file mode 100644 index 36114cd7e23..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/geometryexporttask.h +++ /dev/null @@ -1,155 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/geometryexporttask.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/27/00 5:00p $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef GEOMETRYEXPORTTASK_H -#define GEOMETRYEXPORTTASK_H - -#include -#include -#include "w3d_file.h" -#include "Vector.H" - - -class GeometryExportContextClass; - - -/** -** GeometryExportTaskClass -** This abstract base class defines the interface for a geometry export task. -** Derived classes will encapsulate the job of exporting meshes, collision -** boxes, dazzles, etc. The factory function Create_Task will create the -** appropriate task for a given INode. -*/ -class GeometryExportTaskClass -{ -public: - - GeometryExportTaskClass(INode * node,GeometryExportContextClass & context); - GeometryExportTaskClass(const GeometryExportTaskClass & that); - virtual ~GeometryExportTaskClass(void); - - virtual void Export_Geometry(GeometryExportContextClass & context) = 0; - - /* - ** Accessors - */ - char * Get_Name(void) { return Name; } - char * Get_Container_Name(void) { return ContainerName; } - void Get_Full_Name(char * buffer,int size); - - int Get_Bone_Index(void) { return BoneIndex; } - INode * Get_Object_Node(void) { return Node; } - Matrix3 Get_Export_Transform(void) { return ExportSpace; } - - void Set_Name(char * name) { strncpy(Name,name,sizeof(Name)); } - void Set_Container_Name(char * name) { strncpy(ContainerName,name,sizeof(ContainerName)); } - /* - ** Unique Name generation. During optimization, new meshes may get created. When this happens, - ** we have to create a unique name for each one. The name will be generated from the original - ** mesh's name, the index passed in, and the LOD level of the original mesh. - */ - void Generate_Name(char * root,int index,GeometryExportContextClass & context); - - - /* - ** Get vertex normal. This function should return the normal of a vertex at the - ** specified x,y,z and smoothing_group if one exists. It is used in the algorithm which - ** smooths the vertex normals on the boundaries of meshes. - */ - virtual Point3 Get_Shared_Vertex_Normal(const Point3 & world_space_point,int smgroup) { return Point3(0,0,0); } - - /* - ** Aggregate Model Detection. An "aggregate" is an external W3D model that we are requesting - ** to be attached to a bone in the model being exported. In order for our LOD system to work - ** properly, some special handling of aggregates is required (they must be added into the model - ** as "additional models" rather than being placed in the normal LOD arrays). This virtual - ** can be used to detect "aggregate" models. - */ - virtual bool Is_Aggregate(void) { return false; } - - /* - ** Proxy Detection. A "proxy" is a reference (by name) to an external game object that should - ** be instantiated at the specified transform. Like the aggregates, these had to unfortunately - ** be handled with special cases and therefore have this virtual function devoted solely to them. - */ - virtual bool Is_Proxy(void) { return false; } - - /* - ** Virtual Constructor - */ - static GeometryExportTaskClass * Create_Task(INode * node,GeometryExportContextClass & context); - - /* - ** Pre-Export Optimization of a set of geometry export tasks. This does things like - ** separating multi-material meshes, combining small meshes which are nearby and use the - ** same material, etc. - */ - static void Optimize_Geometry( DynamicVectorClass & tasks, - GeometryExportContextClass & context ); - -protected: - - /* - ** Internal RTTI - */ - enum - { - MESH = 0, - COLLISIONBOX, - DAZZLE, - NULLOBJ, - AGGREGATE, - PROXY, - }; - virtual int Get_Geometry_Type(void) = 0; - -protected: - - char Name[W3D_NAME_LEN]; - char ContainerName[W3D_NAME_LEN]; - int BoneIndex; - - Matrix3 ExportSpace; - TimeValue CurTime; - INode * Node; -}; - - - -#endif //GEOMETRYEXPORTTASK_H - diff --git a/Generals/Code/Tools/WW3D/max2w3d/gmtldlg.cpp b/Generals/Code/Tools/WW3D/max2w3d/gmtldlg.cpp deleted file mode 100644 index e7d393341c0..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/gmtldlg.cpp +++ /dev/null @@ -1,1235 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/gmtldlg.cpp 18 5/27/98 8:34a Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : GMTLDLG.CPP * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 06/26/97 * - * * - * Last Update : June 26, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * GameMtlDlg::GameMtlDlg -- constructor * - * GameMtlDlg::~GameMtlDlg -- destructor! * - * GameMtlDlg::ClassID -- Returns the ClassID of GameMtl * - * GameMtlDlg::Invalidate -- causes the dialog to be redrawn * - * GameMtlDlg::ReloadDialog -- Updates the values in all of the dialog's controls * - * GameMtlDlg::SetTime -- Sets the time value, updates the material and the dialog * - * GameMtlDlg::PanelProc -- Windows Message handler * - * PanelDlgProc -- Windows Proc which thunks into GameMtlDlg::PanelProc * - * GameMtlDlg::LoadDialog -- Sets the state of all of the dialog's controls * - * GameMtlDlg::UpdateMtlDisplay -- Informs MAX that the material parameters have changed * - * GameMtlDlg::ActivateDlg -- Activates and deactivates the dialog * - * GameMtlDlg::SetThing -- Sets the material to be edited * - * GameMtlDlg::BuildDialog -- Adds the dialog to the material editor * - * GameMtlDlg::UpdateTexmapDisplay -- Updates the texture map buttons * - * NotesDlgProc -- Dialog Proc which thunks to GameMtlDlg::NotesProc * - * GameMtlDlg::NotesProc -- Dialog Proc for the Notes panel * - * HintsDlgProc -- Dialog proc which thunks to GameMtlDlg::HintsProc * - * GameMtlDlg::HintsProc -- Dialog Proc for the hints panel * - * GameMtlDlg::PsxProc -- Dialog proc for the PSX options panel * - * PsxDlgProc -- Dialog proc which thunks into GameMtlDlg::PsxProc * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include -#include -#include -#include - -#include "gmtldlg.h" -#include "gamemtl.h" -#include "gamemaps.h" -#include "dllmain.h" -#include "resource.h" -#include "w3d_file.h" - - - -static inline float PcToFrac(int pc) -{ - return (float)pc/100.0f; -} - -static inline int FracToPc(float f) -{ - if (f<0.0) return (int)(100.0f*f - .5f); - else return (int) (100.0f*f + .5f); -} - - -/*********************************************************************************************** - * GameMtlDlg::GameMtlDlg -- constructor * - * * - * INPUT: * - * hwMtlEdit - windows handle of the MAX material editor * - * imp - Interface object for MAX materials and textures * - * m - pointer to a GameMtl to be edited * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -GameMtlDlg::GameMtlDlg(HWND hwMtlEdit, IMtlParams *imp, GameMtl *m) -{ - HwndEdit = hwMtlEdit; - HwndPanel = NULL; - HwndHints = NULL; - HwndPsx = NULL; - HwndNotes = NULL; - HpalOld = NULL; - - TheMtl = m; - IParams = imp; - Valid = FALSE; - IsActive = 0; - InstCopy = FALSE; - - DiffuseSwatch = NULL; - SpecularSwatch = NULL; - - AmbientCoeffSwatch = NULL; - DiffuseCoeffSwatch = NULL; - SpecularCoeffSwatch = NULL; - EmissiveCoeffSwatch = NULL; - - DCTFramesSpin = NULL; - DITFramesSpin = NULL; - SCTFramesSpin = NULL; - SITFramesSpin = NULL; - - DCTRateSpin = NULL; - DITRateSpin = NULL; - SCTRateSpin = NULL; - SITRateSpin = NULL; - - OpacitySpin = NULL; - TranslucencySpin = NULL; - ShininessSpin = NULL; - FogSpin = NULL; -} - -/*********************************************************************************************** - * GameMtlDlg::~GameMtlDlg -- destructor! * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -GameMtlDlg::~GameMtlDlg() -{ - if (DiffuseSwatch) { - ReleaseIColorSwatch(DiffuseSwatch); - DiffuseSwatch = NULL; - } - - if (SpecularSwatch) { - ReleaseIColorSwatch(SpecularSwatch); - SpecularSwatch = NULL; - } - - if (AmbientCoeffSwatch) { - ReleaseIColorSwatch(AmbientCoeffSwatch); - AmbientCoeffSwatch = NULL; - } - - if (DiffuseCoeffSwatch) { - ReleaseIColorSwatch(DiffuseCoeffSwatch); - DiffuseCoeffSwatch = NULL; - } - - if (SpecularCoeffSwatch) { - ReleaseIColorSwatch(SpecularCoeffSwatch); - SpecularCoeffSwatch = NULL; - } - - if (EmissiveCoeffSwatch) { - ReleaseIColorSwatch(EmissiveCoeffSwatch); - EmissiveCoeffSwatch = NULL; - } - - if (HwndPanel) { - HDC hdc = GetDC(HwndPanel); - GetGPort()->RestorePalette(hdc, HpalOld); - ReleaseDC(HwndPanel,hdc); - } - - TheMtl->SetFlag(GAMEMTL_ROLLUP1_OPEN,IParams->IsRollupPanelOpen(HwndPanel)); - TheMtl->SetFlag(GAMEMTL_ROLLUP2_OPEN,IParams->IsRollupPanelOpen(HwndPsx)); - TheMtl->SetFlag(GAMEMTL_ROLLUP3_OPEN,IParams->IsRollupPanelOpen(HwndHints)); - TheMtl->SetFlag(GAMEMTL_ROLLUP4_OPEN,IParams->IsRollupPanelOpen(HwndNotes)); - TheMtl->RollScroll = IParams->GetRollupScrollPos(); - TheMtl->SetParamDlg(NULL); - - IParams->UnRegisterDlgWnd(HwndPanel); - IParams->DeleteRollupPage(HwndPanel); - HwndPanel = NULL; - - IParams->UnRegisterDlgWnd(HwndPsx); - IParams->DeleteRollupPage(HwndPsx); - HwndPsx = NULL; - - IParams->UnRegisterDlgWnd(HwndHints); - IParams->DeleteRollupPage(HwndHints); - HwndHints = NULL; - - IParams->UnRegisterDlgWnd(HwndNotes); - IParams->DeleteRollupPage(HwndNotes); - HwndNotes = NULL; -} - - -/*********************************************************************************************** - * GameMtlDlg::ClassID -- Returns the ClassID of GameMtl * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -Class_ID GameMtlDlg::ClassID() -{ - return GameMaterialClassID; -} - -/*********************************************************************************************** - * GameMtlDlg::Invalidate -- causes the dialog to be redrawn * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -void GameMtlDlg::Invalidate() -{ - Valid = FALSE; - InvalidateRect(HwndPanel,NULL,0); - InvalidateRect(HwndPsx,NULL,0); - InvalidateRect(HwndHints,NULL,0); - InvalidateRect(HwndNotes,NULL,0); -} - -/*********************************************************************************************** - * GameMtlDlg::ReloadDialog -- Updates the values in all of the dialog's controls * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -void GameMtlDlg::ReloadDialog() -{ - Interval v; - TheMtl->Update(IParams->GetTime(),v); - LoadDialog(FALSE); -} - -/*********************************************************************************************** - * GameMtlDlg::SetTime -- Sets the time value, updates the material and the dialog * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -void GameMtlDlg::SetTime(TimeValue t) -{ - if (t!=CurTime) { - CurTime = t; - Interval v; - TheMtl->Update(IParams->GetTime(),v); - LoadDialog(TRUE); - } -} - - -/*********************************************************************************************** - * GameMtlDlg::PanelProc -- Windows Message handler * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -BOOL GameMtlDlg::PanelProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam ) -{ - int id = LOWORD(wParam); - int code = HIWORD(wParam); - int mtype; - - switch (msg) { - - case WM_INITDIALOG: - { - HDC theHDC = GetDC(hwndDlg); - HpalOld = GetGPort()->PlugPalette(theHDC); - ReleaseDC(hwndDlg,theHDC); - - DiffuseSwatch = GetIColorSwatch(GetDlgItem(hwndDlg, IDC_DIFFUSE_COLOR),TheMtl->GetDiffuse(),Get_String(IDS_DIFFUSE_COLOR)); - SpecularSwatch = GetIColorSwatch(GetDlgItem(hwndDlg, IDC_SPECULAR_COLOR),TheMtl->GetSpecular(),Get_String(IDS_SPECULAR_COLOR)); - - AmbientCoeffSwatch = GetIColorSwatch(GetDlgItem(hwndDlg, IDC_AMBIENT_COEFF),TheMtl->GetAmbientCoeff(),Get_String(IDS_AMBIENT_COEFF)); - DiffuseCoeffSwatch = GetIColorSwatch(GetDlgItem(hwndDlg, IDC_DIFFUSE_COEFF),TheMtl->GetDiffuseCoeff(),Get_String(IDS_DIFFUSE_COEFF)); - SpecularCoeffSwatch = GetIColorSwatch(GetDlgItem(hwndDlg, IDC_SPECULAR_COEFF),TheMtl->GetSpecularCoeff(),Get_String(IDS_SPECULAR_COEFF)); - EmissiveCoeffSwatch = GetIColorSwatch(GetDlgItem(hwndDlg, IDC_EMISSIVE_COEFF),TheMtl->GetEmissiveCoeff(),Get_String(IDS_EMISSIVE_COEFF)); - - DCTFramesSpin = SetupIntSpinner(hwndDlg,IDC_DCT_FRAMES_SPIN,IDC_DCT_FRAMES_EDIT,1,999,TheMtl->DCTFrames); - DITFramesSpin = SetupIntSpinner(hwndDlg,IDC_DIT_FRAMES_SPIN,IDC_DIT_FRAMES_EDIT,1,999,TheMtl->DITFrames); - SCTFramesSpin = SetupIntSpinner(hwndDlg,IDC_SCT_FRAMES_SPIN,IDC_SCT_FRAMES_EDIT,1,999,TheMtl->SCTFrames); - SITFramesSpin = SetupIntSpinner(hwndDlg,IDC_SIT_FRAMES_SPIN,IDC_SIT_FRAMES_EDIT,1,999,TheMtl->SITFrames); - - DCTRateSpin = SetupFloatSpinner(hwndDlg,IDC_DCT_RATE_SPIN,IDC_DCT_RATE_EDIT,0.0f,60.0f,TheMtl->DCTFrameRate,5.0f); - DITRateSpin = SetupFloatSpinner(hwndDlg,IDC_DIT_RATE_SPIN,IDC_DIT_RATE_EDIT,0.0f,60.0f,TheMtl->DITFrameRate,5.0f); - SCTRateSpin = SetupFloatSpinner(hwndDlg,IDC_SCT_RATE_SPIN,IDC_SCT_RATE_EDIT,0.0f,60.0f,TheMtl->SCTFrameRate,5.0f); - SITRateSpin = SetupFloatSpinner(hwndDlg,IDC_SIT_RATE_SPIN,IDC_SIT_RATE_EDIT,0.0f,60.0f,TheMtl->SITFrameRate,5.0f); - - OpacitySpin = SetupFloatSpinner(hwndDlg,IDC_OPACITY_SPIN,IDC_OPACITY_EDIT,0.0f,1.0f,TheMtl->GetOpacity(),0.01f); - TranslucencySpin = SetupFloatSpinner(hwndDlg,IDC_TRANSLUCENCY_SPIN,IDC_TRANSULCENCY_EDIT,0.0f,1.0f,TheMtl->GetTranslucency(),0.01f); - ShininessSpin = SetupFloatSpinner(hwndDlg,IDC_SHININESS_SPIN,IDC_SHININESS_EDIT,1.0f,1000.0f,TheMtl->GetShininess(),1.0f); - FogSpin = SetupFloatSpinner(hwndDlg,IDC_FOG_SPIN,IDC_FOG_EDIT,0.0f,1.0f,TheMtl->FogCoeff,0.01f); - - SendDlgItemMessage( hwndDlg, IDC_DCT_MAPPING_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Get_String(IDS_UV_MAPPING)); - SendDlgItemMessage( hwndDlg, IDC_DCT_MAPPING_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Get_String(IDS_ENVIRONMENT_MAPPING) ); - - SendDlgItemMessage( hwndDlg, IDC_DIT_MAPPING_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Get_String(IDS_UV_MAPPING)); - SendDlgItemMessage( hwndDlg, IDC_DIT_MAPPING_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Get_String(IDS_ENVIRONMENT_MAPPING) ); - - SendDlgItemMessage( hwndDlg, IDC_SCT_MAPPING_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Get_String(IDS_UV_MAPPING)); - SendDlgItemMessage( hwndDlg, IDC_SCT_MAPPING_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Get_String(IDS_ENVIRONMENT_MAPPING) ); - - SendDlgItemMessage( hwndDlg, IDC_SIT_MAPPING_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Get_String(IDS_UV_MAPPING)); - SendDlgItemMessage( hwndDlg, IDC_SIT_MAPPING_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) Get_String(IDS_ENVIRONMENT_MAPPING) ); - - /* Installing a windproc for texmap buttons which will handle drag-n-drop - HWND hw = GetDlgItem(hwndDlg, texMapID[i]); - WNDPROC oldp = (WNDPROC)GetWindowLong(hw, GWL_WNDPROC); - SetWindowLong( hw, GWL_WNDPROC, (LONG)TexSlotWndProc); - SetWindowLong( hw, GWL_USERDATA, (LONG)oldp); - */ - - return TRUE; - } - break; - - case WM_COMMAND: - { - switch (id) { - - case IDC_DCT_BUTTON: - { - BitmapInfo bmi; - BitmapTex * texture; - - if (TheManager->SelectFileInput(&bmi, HwndEdit)) { - texture = NewDefaultBitmapTex(); - if (texture) { - texture->SetMapName((char *)bmi.Name()); - TheMtl->SetSubTexmap(ID_DI,texture); - UpdateMtlDisplay(); - TheMtl->NotifyChanged(); - } - } - } - break; - - case IDC_DIT_BUTTON: - { - BitmapInfo bmi; - BitmapTex * texture; - - if (TheManager->SelectFileInput(&bmi, HwndEdit)) { - texture = NewDefaultBitmapTex(); - if (texture) { - texture->SetMapName((char *)bmi.Name()); - TheMtl->SetSubTexmap(ID_SI,texture); - UpdateMtlDisplay(); - TheMtl->NotifyChanged(); - } - } - } - break; - - case IDC_SCT_BUTTON: - { - BitmapInfo bmi; - BitmapTex * texture; - - if (TheManager->SelectFileInput(&bmi, HwndEdit)) { - texture = NewDefaultBitmapTex(); - if (texture) { - texture->SetMapName((char *)bmi.Name()); - TheMtl->SetSubTexmap(ID_SP,texture); - UpdateMtlDisplay(); - TheMtl->NotifyChanged(); - } - } - } - break; - - case IDC_SIT_BUTTON: - { - BitmapInfo bmi; - BitmapTex * texture; - - if (TheManager->SelectFileInput(&bmi, HwndEdit)) { - texture = NewDefaultBitmapTex(); - if (texture) { - texture->SetMapName((char *)bmi.Name()); - TheMtl->SetSubTexmap(ID_RL,texture); - UpdateMtlDisplay(); - TheMtl->NotifyChanged(); - } - } - } - break; - - case IDC_MAPON_DCT: - TheMtl->EnableMap(ID_DI,GetCheckBox(hwndDlg, id)); - if (!GetCheckBox(hwndDlg,id)) TheMtl->SetSubTexmap(ID_DI,NULL); - UpdateTexmapDisplay(ID_DI); - UpdateMtlDisplay(); - TheMtl->NotifyChanged(); - break; - case IDC_MAPON_DIT: - TheMtl->EnableMap(ID_SI,GetCheckBox(hwndDlg, id)); - if (!GetCheckBox(hwndDlg,id)) TheMtl->SetSubTexmap(ID_SI,NULL); - UpdateTexmapDisplay(ID_SI); - UpdateMtlDisplay(); - TheMtl->NotifyChanged(); - break; - case IDC_MAPON_SCT: - TheMtl->EnableMap(ID_SP,GetCheckBox(hwndDlg, id)); - if (!GetCheckBox(hwndDlg,id)) TheMtl->SetSubTexmap(ID_SP,NULL); - UpdateTexmapDisplay(ID_SP); - UpdateMtlDisplay(); - TheMtl->NotifyChanged(); - break; - case IDC_MAPON_SIT: - TheMtl->EnableMap(ID_RL,GetCheckBox(hwndDlg, id)); - if (!GetCheckBox(hwndDlg,id)) TheMtl->SetSubTexmap(ID_RL,NULL); - UpdateTexmapDisplay(ID_RL); - UpdateMtlDisplay(); - TheMtl->NotifyChanged(); - break; - case IDC_USE_ALPHA_CHECK: - TheMtl->SetAttribute(GAMEMTL_USE_ALPHA,GetCheckBox(hwndDlg,IDC_USE_ALPHA_CHECK)); - UpdateMtlDisplay(); - TheMtl->NotifyChanged(); - break; - case IDC_USE_SORTING_CHECK: - TheMtl->SetAttribute(GAMEMTL_USE_SORTING,GetCheckBox(hwndDlg,IDC_USE_SORTING_CHECK)); - break; - case IDC_DCT_MAPPING_COMBO: - mtype = SendDlgItemMessage(hwndDlg,IDC_DCT_MAPPING_COMBO,CB_GETCURSEL,0,0); - TheMtl->DCTMappingType = mtype; - break; - case IDC_DIT_MAPPING_COMBO: - mtype = SendDlgItemMessage(hwndDlg,IDC_DIT_MAPPING_COMBO,CB_GETCURSEL,0,0); - TheMtl->DITMappingType = mtype; - break; - case IDC_SCT_MAPPING_COMBO: - mtype = SendDlgItemMessage(hwndDlg,IDC_SCT_MAPPING_COMBO,CB_GETCURSEL,0,0); - TheMtl->SCTMappingType = mtype; - break; - case IDC_SIT_MAPPING_COMBO: - mtype = SendDlgItemMessage(hwndDlg,IDC_SIT_MAPPING_COMBO,CB_GETCURSEL,0,0); - TheMtl->SITMappingType = mtype; - break; - case IDC_VIEWPORT_DISPLAY_CHECK: - TheMtl->Set_Viewport_Display_Status(GetCheckBox(hwndDlg,IDC_VIEWPORT_DISPLAY_CHECK)); - TheMtl->NotifyChanged(); - UpdateMtlDisplay(); - break; - } - } - break; - - case CC_COLOR_CHANGE: - { - // just update all of the colors - TheMtl->Diffuse = DiffuseSwatch->GetColor(); - TheMtl->Specular = SpecularSwatch->GetColor(); - TheMtl->AmbientCoeff = AmbientCoeffSwatch->GetColor(); - TheMtl->DiffuseCoeff = DiffuseCoeffSwatch->GetColor(); - TheMtl->SpecularCoeff = SpecularCoeffSwatch->GetColor(); - TheMtl->EmissiveCoeff = EmissiveCoeffSwatch->GetColor(); - - TheMtl->NotifyChanged(); - UpdateMtlDisplay(); - } - break; - - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - { - IParams->RollupMouseMessage(hwndDlg,msg,wParam,lParam); - } - return FALSE; - - case CC_SPINNER_CHANGE: - { - TheMtl->DCTFrames = DCTFramesSpin->GetIVal(); - TheMtl->DITFrames = DITFramesSpin->GetIVal(); - TheMtl->SCTFrames = SCTFramesSpin->GetIVal(); - TheMtl->SITFrames = SITFramesSpin->GetIVal(); - - TheMtl->DCTFrameRate = DCTRateSpin->GetFVal(); - TheMtl->DITFrameRate = DITRateSpin->GetFVal(); - TheMtl->SCTFrameRate = SCTRateSpin->GetFVal(); - TheMtl->SITFrameRate = SITRateSpin->GetFVal(); - - TheMtl->SetOpacity(OpacitySpin->GetFVal()); - TheMtl->SetTranslucency(TranslucencySpin->GetFVal()); - TheMtl->SetShininess(ShininessSpin->GetFVal()); - TheMtl->FogCoeff = FogSpin->GetFVal(); - - TheMtl->NotifyChanged(); - UpdateMtlDisplay(); - } - break; - - case CC_SPINNER_BUTTONUP: - { - #if 0 - UpdateMtlDisplay(); - #endif - } - break; - - case WM_PAINT: - { - if (!Valid) { - Valid = TRUE; - ReloadDialog(); - } - } - return FALSE; - - case WM_CLOSE: - break; - - case WM_DESTROY: - - TheMtl->DCTFrames = DCTFramesSpin->GetIVal(); - TheMtl->DITFrames = DITFramesSpin->GetIVal(); - TheMtl->SCTFrames = SCTFramesSpin->GetIVal(); - TheMtl->SITFrames = SITFramesSpin->GetIVal(); - - TheMtl->DCTFrameRate = DCTRateSpin->GetFVal(); - TheMtl->DITFrameRate = DITRateSpin->GetFVal(); - TheMtl->SCTFrameRate = SCTRateSpin->GetFVal(); - TheMtl->SITFrameRate = SITRateSpin->GetFVal(); - - TheMtl->SetOpacity(OpacitySpin->GetFVal()); - TheMtl->SetTranslucency(TranslucencySpin->GetFVal()); - TheMtl->SetShininess(ShininessSpin->GetFVal()); - TheMtl->FogCoeff = FogSpin->GetFVal(); - - ReleaseISpinner(DCTFramesSpin); - ReleaseISpinner(DITFramesSpin); - ReleaseISpinner(SCTFramesSpin); - ReleaseISpinner(SITFramesSpin); - ReleaseISpinner(DCTRateSpin); - ReleaseISpinner(DITRateSpin); - ReleaseISpinner(SCTRateSpin); - ReleaseISpinner(SITRateSpin); - ReleaseISpinner(OpacitySpin); - ReleaseISpinner(TranslucencySpin); - ReleaseISpinner(ShininessSpin); - ReleaseISpinner(FogSpin); - - DCTFramesSpin = DITFramesSpin = SCTFramesSpin = SITFramesSpin = NULL; - DCTRateSpin = DITRateSpin = SCTRateSpin = SITRateSpin = NULL; - OpacitySpin = TranslucencySpin = ShininessSpin = FogSpin = NULL; - - break; - - } - - return FALSE; -} - - -/*********************************************************************************************** - * PanelDlgProc -- Windows Proc which thunks into GameMtlDlg::PanelProc * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -static BOOL CALLBACK PanelDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - GameMtlDlg *theDlg; - - if (msg==WM_INITDIALOG) { - theDlg = (GameMtlDlg*)lParam; - theDlg->HwndPanel = hwndDlg; - SetWindowLong(hwndDlg, GWL_USERDATA,lParam); - } else { - if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) { - return FALSE; - } - } - - BOOL res; - theDlg->IsActive = 1; - res = theDlg->PanelProc(hwndDlg,msg,wParam,lParam); - theDlg->IsActive = 0; - return res; -} - -/*********************************************************************************************** - * GameMtlDlg::NotesProc -- Dialog Proc for the Notes panel * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -BOOL GameMtlDlg::NotesProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - int id = LOWORD(wParam); - int code = HIWORD(wParam); - - switch (msg) { - - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - { - IParams->RollupMouseMessage(hwndDlg,msg,wParam,lParam); - return FALSE; - } - - case WM_COMMAND: - { - int i = lParam; - } - break; - - } - return FALSE; -} - - -/*********************************************************************************************** - * NotesDlgProc -- Dialog Proc which thunks to GameMtlDlg::NotesProc * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -static BOOL CALLBACK NotesDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - GameMtlDlg *theDlg; - - if (msg==WM_INITDIALOG) { - theDlg = (GameMtlDlg*)lParam; - theDlg->HwndNotes = hwndDlg; - SetWindowLong(hwndDlg, GWL_USERDATA,lParam); - } else { - if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) { - return FALSE; - } - } - - BOOL res; - theDlg->IsActive = 1; - res = theDlg->NotesProc(hwndDlg,msg,wParam,lParam); - theDlg->IsActive = 0; - return res; -} - - -/*********************************************************************************************** - * GameMtlDlg::HintsProc -- Dialog Proc for the hints panel * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/30/98 GTH : Created. * - *=============================================================================================*/ -BOOL GameMtlDlg::HintsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - int id = LOWORD(wParam); - int code = HIWORD(wParam); - - switch (msg) { - - - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - { - IParams->RollupMouseMessage(hwndDlg,msg,wParam,lParam); - return FALSE; - } - - case WM_COMMAND: - { - switch(id) - { - case IDC_DIT_OVER_DCT_CHECK: - TheMtl->SetAttribute(GAMEMTL_DIT_OVER_DCT, GetCheckBox(hwndDlg, IDC_DIT_OVER_DCT_CHECK)); - break; - - case IDC_SIT_OVER_SCT_CHECK: - TheMtl->SetAttribute(GAMEMTL_SIT_OVER_SCT, GetCheckBox(hwndDlg, IDC_SIT_OVER_SCT_CHECK)); - break; - - case IDC_DIT_OVER_DIG_CHECK: - TheMtl->SetAttribute(GAMEMTL_DIT_OVER_DIG, GetCheckBox(hwndDlg, IDC_DIT_OVER_DIG_CHECK)); - break; - - case IDC_SIT_OVER_SIG_CHECK: - TheMtl->SetAttribute(GAMEMTL_SIT_OVER_SIG, GetCheckBox(hwndDlg, IDC_SIT_OVER_SIG_CHECK)); - break; - - case IDC_FAST_SPECULAR_AFTER_ALPHA_CHECK: - TheMtl->SetAttribute(GAMEMTL_FAST_SPECULAR_AFTER_ALPHA, GetCheckBox(hwndDlg, IDC_FAST_SPECULAR_AFTER_ALPHA_CHECK)); - break; - } - } - break; - } - return FALSE; -} - - -/*********************************************************************************************** - * HintsDlgProc -- Dialog proc which thunks to GameMtlDlg::HintsProc * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/30/98 GTH : Created. * - *=============================================================================================*/ -static BOOL CALLBACK HintsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - GameMtlDlg *theDlg; - - if (msg==WM_INITDIALOG) { - theDlg = (GameMtlDlg*)lParam; - theDlg->HwndHints = hwndDlg; - SetWindowLong(hwndDlg, GWL_USERDATA,lParam); - } else { - if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) { - return FALSE; - } - } - - BOOL res; - theDlg->IsActive = 1; - res = theDlg->HintsProc(hwndDlg,msg,wParam,lParam); - theDlg->IsActive = 0; - return res; -} - - -/*********************************************************************************************** - * GameMtlDlg::PsxProc -- Dialog proc for the PSX options panel * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/31/98 GTH : Created. * - *=============================================================================================*/ -BOOL GameMtlDlg::PsxProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - int id = LOWORD(wParam); - int code = HIWORD(wParam); - - switch (msg) { - - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - { - IParams->RollupMouseMessage(hwndDlg,msg,wParam,lParam); - return FALSE; - } - - case WM_COMMAND: - { - switch(id) - { - case IDC_NO_TRANS: - TheMtl->SetMaskedAttribute(GAMEMTL_PSX_TRANS_MASK,0); - break; - - case IDC_100_TRANS: - TheMtl->SetMaskedAttribute(GAMEMTL_PSX_TRANS_MASK,GAMEMTL_PSX_100_TRANS); - break; - - case IDC_50_TRANS: - TheMtl->SetMaskedAttribute(GAMEMTL_PSX_TRANS_MASK,GAMEMTL_PSX_50_TRANS); - break; - - case IDC_25_TRANS: - TheMtl->SetMaskedAttribute(GAMEMTL_PSX_TRANS_MASK,GAMEMTL_PSX_25_TRANS); - break; - - case IDC_MINUS_100_TRANS: - TheMtl->SetMaskedAttribute(GAMEMTL_PSX_TRANS_MASK,GAMEMTL_PSX_MINUS_100_TRANS); - break; - - case IDC_NO_RT_LIGHTING: - TheMtl->SetAttribute(GAMEMTL_PSX_NO_RT_LIGHTING, GetCheckBox(hwndDlg, IDC_NO_RT_LIGHTING)); - break; - } - } - break; - } - return FALSE; -} - - -/*********************************************************************************************** - * PsxDlgProc -- Dialog proc which thunks into GameMtlDlg::PsxProc * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/31/98 GTH : Created. * - *=============================================================================================*/ -static BOOL CALLBACK PsxDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - GameMtlDlg *theDlg; - - if (msg==WM_INITDIALOG) { - theDlg = (GameMtlDlg*)lParam; - theDlg->HwndPsx = hwndDlg; - SetWindowLong(hwndDlg, GWL_USERDATA,lParam); - } else { - if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) { - return FALSE; - } - } - - BOOL res; - theDlg->IsActive = 1; - res = theDlg->PsxProc(hwndDlg,msg,wParam,lParam); - theDlg->IsActive = 0; - return res; -} - - -/*********************************************************************************************** - * GameMtlDlg::LoadDialog -- Sets the state of all of the dialog's controls * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -void GameMtlDlg::LoadDialog(BOOL draw) -{ - - /* - ** Set the state of the entire panel based on the current material. - */ - if (TheMtl && HwndPanel) { - - /* - ** Init all of the color swatches - */ - if (DiffuseSwatch) { - DiffuseSwatch->InitColor(TheMtl->GetDiffuse()); - } - if (SpecularSwatch) { - SpecularSwatch->InitColor(TheMtl->GetSpecular()); - } - if (AmbientCoeffSwatch) { - AmbientCoeffSwatch->InitColor(TheMtl->GetAmbientCoeff()); - } - if (DiffuseCoeffSwatch) { - DiffuseCoeffSwatch->InitColor(TheMtl->GetDiffuseCoeff()); - } - if (SpecularCoeffSwatch) { - SpecularCoeffSwatch->InitColor(TheMtl->GetSpecularCoeff()); - } - if (EmissiveCoeffSwatch) { - EmissiveCoeffSwatch->InitColor(TheMtl->GetEmissiveCoeff()); - } - - /* - ** Checkboxes - */ - SetCheckBox(HwndPanel,IDC_USE_ALPHA_CHECK, TheMtl->GetAttribute(GAMEMTL_USE_ALPHA)); - SetCheckBox(HwndPanel,IDC_USE_SORTING_CHECK, TheMtl->GetAttribute(GAMEMTL_USE_SORTING)); - SetCheckBox(HwndPanel,IDC_VIEWPORT_DISPLAY_CHECK,TheMtl->Get_Viewport_Display_Status()); - - /* - ** Texture maps enable checks. - */ - SetCheckBox(HwndPanel,IDC_MAPON_DCT, TheMtl->SubTexmapOn(ID_DI)); - SetCheckBox(HwndPanel,IDC_MAPON_DIT, TheMtl->SubTexmapOn(ID_SI)); - SetCheckBox(HwndPanel,IDC_MAPON_SCT, TheMtl->SubTexmapOn(ID_SP)); - SetCheckBox(HwndPanel,IDC_MAPON_SIT, TheMtl->SubTexmapOn(ID_RL)); - - /* - ** Mapping types - */ - SendDlgItemMessage( HwndPanel, IDC_DCT_MAPPING_COMBO, CB_SETCURSEL, TheMtl->DCTMappingType, 0 ); - SendDlgItemMessage( HwndPanel, IDC_DIT_MAPPING_COMBO, CB_SETCURSEL, TheMtl->DITMappingType, 0 ); - SendDlgItemMessage( HwndPanel, IDC_SCT_MAPPING_COMBO, CB_SETCURSEL, TheMtl->SCTMappingType, 0 ); - SendDlgItemMessage( HwndPanel, IDC_SIT_MAPPING_COMBO, CB_SETCURSEL, TheMtl->SITMappingType, 0 ); - - /* - ** Texture animation parameters - */ - DCTFramesSpin->SetValue(TheMtl->DCTFrames,FALSE); - DITFramesSpin->SetValue(TheMtl->DITFrames,FALSE); - SCTFramesSpin->SetValue(TheMtl->SCTFrames,FALSE); - SITFramesSpin->SetValue(TheMtl->SITFrames,FALSE); - - DCTRateSpin->SetValue(TheMtl->DCTFrameRate,FALSE); - DITRateSpin->SetValue(TheMtl->DITFrameRate,FALSE); - SCTRateSpin->SetValue(TheMtl->SCTFrameRate,FALSE); - SITRateSpin->SetValue(TheMtl->SITFrameRate,FALSE); - - /* - ** Opacity, translucency, etc - */ - OpacitySpin->SetValue(TheMtl->Opacity,FALSE); - TranslucencySpin->SetValue(TheMtl->Translucency,FALSE); - ShininessSpin->SetValue(TheMtl->Shininess,FALSE); - FogSpin->SetValue(TheMtl->FogCoeff,FALSE); - - /* - ** Init the Psx flags state - */ - SetCheckBox(HwndPsx,IDC_NO_RT_LIGHTING, TheMtl->GetAttribute(GAMEMTL_PSX_NO_RT_LIGHTING)); - - SetCheckBox(HwndPsx,IDC_NO_TRANS, false); - SetCheckBox(HwndPsx,IDC_100_TRANS, false); - SetCheckBox(HwndPsx,IDC_50_TRANS, false); - SetCheckBox(HwndPsx,IDC_25_TRANS, false); - SetCheckBox(HwndPsx,IDC_MINUS_100_TRANS, false); - - switch (TheMtl->GetMaskedAttribute(GAMEMTL_PSX_TRANS_MASK)) { - case 0: - SetCheckBox(HwndPsx,IDC_NO_TRANS,true); - break; - case GAMEMTL_PSX_100_TRANS: - SetCheckBox(HwndPsx,IDC_100_TRANS,true); - break; - case GAMEMTL_PSX_50_TRANS: - SetCheckBox(HwndPsx,IDC_50_TRANS,true); - break; - case GAMEMTL_PSX_25_TRANS: - SetCheckBox(HwndPsx,IDC_25_TRANS,true); - break; - case GAMEMTL_PSX_MINUS_100_TRANS: - SetCheckBox(HwndPsx,IDC_MINUS_100_TRANS,true); - break; - } - - - /* - ** Init the Hints state - */ - SetCheckBox(HwndHints,IDC_DIT_OVER_DCT_CHECK, TheMtl->GetAttribute(GAMEMTL_DIT_OVER_DCT)); - SetCheckBox(HwndHints,IDC_SIT_OVER_SCT_CHECK, TheMtl->GetAttribute(GAMEMTL_SIT_OVER_SCT)); - SetCheckBox(HwndHints,IDC_DIT_OVER_DIG_CHECK, TheMtl->GetAttribute(GAMEMTL_DIT_OVER_DIG)); - SetCheckBox(HwndHints,IDC_SIT_OVER_SIG_CHECK, TheMtl->GetAttribute(GAMEMTL_SIT_OVER_SIG)); - SetCheckBox(HwndHints,IDC_FAST_SPECULAR_AFTER_ALPHA_CHECK, TheMtl->GetAttribute(GAMEMTL_FAST_SPECULAR_AFTER_ALPHA)); - - /* - ** Init the texmaps state - */ - for (int i=0; iMtlChanged(); -} - - -/*********************************************************************************************** - * GameMtlDlg::ActivateDlg -- Activates and deactivates the dialog * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -void GameMtlDlg::ActivateDlg(BOOL onOff) -{ - if (DiffuseSwatch) { - DiffuseSwatch->Activate(onOff); - } - if (SpecularSwatch) { - SpecularSwatch->Activate(onOff); - } - if (AmbientCoeffSwatch) { - AmbientCoeffSwatch->Activate(onOff); - } - if (DiffuseCoeffSwatch) { - DiffuseCoeffSwatch->Activate(onOff); - } - if (SpecularCoeffSwatch) { - SpecularCoeffSwatch->Activate(onOff); - } - if (EmissiveCoeffSwatch) { - EmissiveCoeffSwatch->Activate(onOff); - } -} - -/*********************************************************************************************** - * GameMtlDlg::SetThing -- Sets the material to be edited * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -void GameMtlDlg::SetThing(ReferenceTarget *m) -{ - assert (m->SuperClassID()==MATERIAL_CLASS_ID); - assert (m->ClassID()==GameMaterialClassID); - - if (TheMtl) { - TheMtl->ParamPanel = NULL; - } - - TheMtl = (GameMtl *)m; - - if (TheMtl) { - TheMtl->ParamPanel = this; - } - - LoadDialog(TRUE); - - if (HwndPanel && DiffuseSwatch) { - DiffuseSwatch->InitColor(TheMtl->GetDiffuse()); - } - if (HwndPanel && SpecularSwatch) { - SpecularSwatch->InitColor(TheMtl->GetSpecular()); - } - if (HwndPanel && AmbientCoeffSwatch) { - AmbientCoeffSwatch->InitColor(TheMtl->GetAmbientCoeff()); - } - if (HwndPanel && DiffuseCoeffSwatch) { - DiffuseCoeffSwatch->InitColor(TheMtl->GetDiffuseCoeff()); - } - if (HwndPanel && SpecularCoeffSwatch) { - SpecularCoeffSwatch->InitColor(TheMtl->GetSpecularCoeff()); - } - if (HwndPanel && EmissiveCoeffSwatch) { - EmissiveCoeffSwatch->InitColor(TheMtl->GetEmissiveCoeff()); - } -} - -/*********************************************************************************************** - * GameMtlDlg::BuildDialog -- Adds the dialog to the material editor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -void GameMtlDlg::BuildDialog() -{ - if ((TheMtl->Flags&(GAMEMTL_ROLLUP_FLAGS))==0) { - TheMtl->SetFlag(GAMEMTL_ROLLUP1_OPEN,TRUE); - } - - HwndPanel = IParams->AddRollupPage( - AppInstance, - MAKEINTRESOURCE(IDD_GAMEMTL_PANEL), - PanelDlgProc, - Get_String(IDS_PARAMETERS), - (LPARAM)this, - (TheMtl->GetFlag(GAMEMTL_ROLLUP1_OPEN) ? 0:APPENDROLL_CLOSED) - ); - - HwndPsx = IParams->AddRollupPage( - AppInstance, - MAKEINTRESOURCE(IDD_GAMEMTL_PSX_PANEL), - PsxDlgProc, - Get_String(IDS_PSX_OPTIONS), - (LPARAM)this, - (TheMtl->GetFlag(GAMEMTL_ROLLUP2_OPEN) ? 0:APPENDROLL_CLOSED) - ); - - HwndHints = IParams->AddRollupPage( - AppInstance, - MAKEINTRESOURCE(IDD_GAMEMTL_HINTS_PANEL), - HintsDlgProc, - Get_String(IDS_MATERIAL_HINTS), - (LPARAM)this, - (TheMtl->GetFlag(GAMEMTL_ROLLUP3_OPEN) ? 0:APPENDROLL_CLOSED) - ); - - HwndNotes = IParams->AddRollupPage( - AppInstance, - MAKEINTRESOURCE(IDD_MATERIAL_NOTES_PANEL), - NotesDlgProc, - Get_String(IDS_NOTES), - (LPARAM)this, - (TheMtl->GetFlag(GAMEMTL_ROLLUP4_OPEN) ? 0:APPENDROLL_CLOSED) - ); - - IParams->SetRollupScrollPos(TheMtl->RollScroll); -} - -/*********************************************************************************************** - * GameMtlDlg::UpdateTexmapDisplay -- Updates the texture map buttons * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/1997 GH : Created. * - *=============================================================================================*/ -void GameMtlDlg::UpdateTexmapDisplay(int i) -{ - TSTR nm = Get_String(IDS_NONE); - Texmap *texmap = (*TheMtl->Maps)[i].Map; - if (texmap) nm = texmap->GetFullName(); - - // Diffuse Map -> Surrender Diffuse Color Channel - if (i == ID_DI) { - SetCheckBox(HwndPanel, IDC_MAPON_DCT, TheMtl->IsMapEnabled(i)); - SetDlgItemText(HwndPanel, IDC_DCT_BUTTON, nm.data()); - } - - // Self Illumination Map -> Surrender Diffuse Illumination Channel - if (i == ID_SI) { - SetCheckBox(HwndPanel, IDC_MAPON_DIT, TheMtl->IsMapEnabled(i)); - SetDlgItemText(HwndPanel, IDC_DIT_BUTTON, nm.data()); - } - - // Specular Map -> Surrender Specular Color Channel - if (i == ID_SP) { - SetCheckBox(HwndPanel, IDC_MAPON_SCT, TheMtl->IsMapEnabled(i)); - SetDlgItemText(HwndPanel, IDC_SCT_BUTTON, nm.data()); - } - - // Reflection Map -> Surrender Specular Illumination Channel - if (i == ID_RL) { - SetCheckBox(HwndPanel, IDC_MAPON_SIT, TheMtl->IsMapEnabled(i)); - SetDlgItemText(HwndPanel, IDC_SIT_BUTTON, nm.data()); - } - -} - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/gridsnapmodifier.cpp b/Generals/Code/Tools/WW3D/max2w3d/gridsnapmodifier.cpp deleted file mode 100644 index 5905ff1e565..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/gridsnapmodifier.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/gridsnapmodifier.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 5/01/01 8:29p $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - -#include "max.h" -#include "resource.h" -#include "simpmod.h" -#include "dllmain.h" -#include "iparamb2.h" - - -/* - - WARNING WARNING WARNING PLEASE READ - This modifier was an experiment to see if we could - solve cracks in adjacent meshes by snapping to a world-space grid. It didn't work for a - few reasons: - - I couldn't implement the world space snapping; the SimpleMod code seems to always force - you to work relative to each object. - - Snapping to a grid won't always snap vertices to the same grid. The probability that - it will work is a function of the distance between the points and the grid spacing - -*/ - - - -#define GRIDSNAPMOD_CLASSID Class_ID(0x7a2d399b, 0x1e3d2004) - - -/** -** GridSnapModifierClass -** This modifier will snap all vertices in the geometry being modified to a grid. Its motivation is to -** try to help solve the problem of cracks between adjacent meshes in Renegade levels. This will work -** a lot better if the objects have reset-transforms prior to being processed by this modifier. -*/ -class GridSnapModifierClass : public SimpleMod2 -{ -public: - - GridSnapModifierClass(); - - // From Animatable - void DeleteThis() { delete this; } - void GetClassName(TSTR& s) { s = Get_String(IDS_GRIDSNAPMODIFIER); } - virtual Class_ID ClassID() { return GRIDSNAPMOD_CLASSID; } - void BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev); - void EndEditParams( IObjParam *ip,ULONG flags,Animatable *next); - RefTargetHandle Clone(RemapDir& remap = NoRemap()); - TCHAR *GetObjectName() { return Get_String(IDS_GRIDSNAPMODIFIER);} - IOResult Load(ILoad *iload); - - // Direct paramblock access - int NumParamBlocks() { return 1; } - IParamBlock2* GetParamBlock(int i) { return pblock2; } - IParamBlock2* GetParamBlockByID(BlockID id) { return (pblock2->ID() == id) ? pblock2 : NULL; } - - // From simple mod - Deformer& GetDeformer(TimeValue t,ModContext &mc,Matrix3& mat,Matrix3& invmat); - Interval GetValidity(TimeValue t); - - //RefTargetHandle GetReference(int i) - //void SetReference(int i,RefTargetHandle rtar) - //Animatable * SubAnim(int i) -}; - -/** -** GridSnapDeformerClass -** This is the callback object used by GridSnapModifierClass to implement the actual geometry changes. This -** architecture is required by the SimpleMod base-class. This Deformer simply snaps vertex positions -** to the grid defined by its parameters. -*/ -class GridSnapDeformerClass : public Deformer -{ -public: - GridSnapDeformerClass(void) : GridDimension(0.001f) {} - - void Set_Grid_Dimension(float grid_dim) { GridDimension = grid_dim; } - float Get_Grid_Dimension(void) { return GridDimension; } - - void Set_Matrices(const Matrix3 & tm,const Matrix3 & invtm) { Transform = tm; InvTransform = invtm; } - - virtual Point3 Map(int i,Point3 p) - { - p = p*Transform; - p.x = floor(p.x / GridDimension) * GridDimension; - p.y = floor(p.y / GridDimension) * GridDimension; - p.z = floor(p.z / GridDimension) * GridDimension; - p = p*InvTransform; - - return p; - } - -private: - float GridDimension; - Matrix3 Transform; - Matrix3 InvTransform; -}; - - -/** -** GridSnapModifier Class Descriptor -** This object "links" the plugin into Max's plugin system. It links the Class-ID to a virtual construction -** method. The function Get_Grid_Snap_Modifier_Desc is the only hook to external code. -*/ -class GridSnapModifierClassDesc:public ClassDesc2 -{ -public: - int IsPublic() { return 1; } - void * Create(BOOL loading = FALSE) { return new GridSnapModifierClass; } - const TCHAR * ClassName() { return _T("Grid Snap Modifier"); } - SClass_ID SuperClassID() { return OSM_CLASS_ID; } - Class_ID ClassID() { return GRIDSNAPMOD_CLASSID; } - const TCHAR* Category() { return _T("Westwood Modifiers");} - HINSTANCE HInstance() { return AppInstance; } - const TCHAR * InternalName() { return _T("Westwood GridSnap"); } -}; - -static GridSnapModifierClassDesc _GridSnapModifierDesc; - -ClassDesc* Get_Grid_Snap_Modifier_Desc(void) -{ - return &_GridSnapModifierDesc; -} - - -/* -** ParamBlock2 Setup -*/ -enum -{ - GSM_PARAMS = 0, -}; - -enum -{ - GSM_PARAM_GRIDDIMENSION = 0, -}; - -static ParamBlockDesc2 _GridSnapParamBlockDesc -( - // parameter block settings - GSM_PARAMS,_T("GridSnap Parameters"), 0, &_GridSnapModifierDesc, P_AUTO_CONSTRUCT + P_AUTO_UI, SIMPMOD_PBLOCKREF, - - // dialog box - IDD_GRIDSNAP_PARAMS, IDS_GRIDSNAP_TITLE, 0, 0, NULL, - - // parameters - GSM_PARAM_GRIDDIMENSION, _T("Grid Dimension"), TYPE_FLOAT, P_RESET_DEFAULT, IDS_GRID_DIMENSION, - p_default, 0.001f, - p_range, 0.0001f, 10.0f, - p_ui, TYPE_SPINNER, EDITTYPE_FLOAT, IDC_GRIDDIM_EDIT, IDC_GRIDDIM_SPIN, 0.0001f, - end, - - end -); - - -/******************************************************************************************** -** -** GridSnapModifierClass Implementation -** -********************************************************************************************/ - -GridSnapModifierClass::GridSnapModifierClass() -{ - // create the parameter block, storing in the base-class's pblock variable - _GridSnapModifierDesc.MakeAutoParamBlocks(this); - assert(pblock2); -} - -void GridSnapModifierClass::BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev) -{ - this->ip = ip; - - SimpleMod2::BeginEditParams(ip,flags,prev); - _GridSnapModifierDesc.BeginEditParams(ip, this, flags, prev); -} - -void GridSnapModifierClass::EndEditParams( IObjParam *ip,ULONG flags,Animatable *next) -{ - SimpleMod2::EndEditParams(ip,flags,next); - _GridSnapModifierDesc.EndEditParams(ip, this, flags, next); - - this->ip = NULL; -} - -RefTargetHandle GridSnapModifierClass::Clone(RemapDir& remap) -{ - GridSnapModifierClass * newmod = new GridSnapModifierClass(); - newmod->ReplaceReference(SIMPMOD_PBLOCKREF,pblock2->Clone(remap)); - newmod->SimpleModClone(this); - return(newmod); -} - -IOResult GridSnapModifierClass::Load(ILoad *iload) -{ - Modifier::Load(iload); - return IO_OK; -} - -Deformer& GridSnapModifierClass::GetDeformer(TimeValue t,ModContext &mc,Matrix3& mat,Matrix3& invmat) -{ - float dimension = 0.0f; Interval valid = FOREVER; - pblock2->GetValue(GSM_PARAM_GRIDDIMENSION, t, dimension, FOREVER); - - static GridSnapDeformerClass deformer; - deformer.Set_Grid_Dimension(dimension); - deformer.Set_Matrices(mat,invmat); - return deformer; -} - -Interval GridSnapModifierClass::GetValidity(TimeValue t) -{ - float f; - Interval valid = FOREVER; - pblock2->GetValue(GSM_PARAM_GRIDDIMENSION, t, f, valid); - return valid; -} - -RefTargetHandle SimpleMod2::GetReference(int i) -{ - switch (i) { - case 0: return tmControl; - case 1: return posControl; - case 2: return pblock2; - default: return NULL; - } -} - -void SimpleMod2::SetReference(int i,RefTargetHandle rtarg) -{ - switch (i) { - case 0: tmControl = (Control*)rtarg; break; - case 1: posControl = (Control*)rtarg; break; - case 2: pblock2 = (IParamBlock2*)rtarg; break; - } -} - -Animatable * SimpleMod2::SubAnim(int i) -{ - switch (i) { - case 0: return posControl; - case 1: return tmControl; - case 2: return pblock2; - default: return NULL; - } -} \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/gridsnapmodifier.h b/Generals/Code/Tools/WW3D/max2w3d/gridsnapmodifier.h deleted file mode 100644 index 559bea7ee20..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/gridsnapmodifier.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/gridsnapmodifier.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 5/01/01 5:56p $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef GRIDSNAPMODIFIER_H -#define GRIDSNAPMODIFIER_H - -class ClassDesc; - -ClassDesc * Get_Grid_Snap_Modifier_Desc(void); - - -#endif //GRIDSNAPMODIFIER_H \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/hiersave.cpp b/Generals/Code/Tools/WW3D/max2w3d/hiersave.cpp deleted file mode 100644 index b894244e2e2..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/hiersave.cpp +++ /dev/null @@ -1,1009 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/hiersave.cpp 56 10/30/00 6:58p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Engine * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/hiersave.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/30/00 6:14p $* - * * - * $Revision:: 56 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * HierarchySaveClass::HierarchySaveClass -- constructor * - * HierarchySaveClass::HierarchySaveClass -- constructor * - * HierarchySaveClass::HierarchySaveClass -- constructor * - * HierarchySaveClass::~HierarchySaveClass -- destructor * - * HierarchySaveClass::Free -- releases all allocated memory * - * HierarchySaveClass::Get_Node_Transform -- returns the transformation matrix of specified n* - * HierarchySaveClass::get_relative_transform -- retruns tm between this node and its parent * - * HierarchySaveClass::Get_Name -- returns the name of this hierarchy * - * HierarchySaveClass::Get_Node -- Get the Max INode * - * HierarchySaveClass::Get_Node_Name -- returns name of this hierarchy node * - * HierarchySaveClass::Find_Named_Node -- returns index of a named node * - * HierarchySaveClass::Get_Export_Coordinate_System - find the bone and coordinate system * - * HierarchySaveClass::Save -- write the hierarchy into a W3D file * - * HierarchySaveClass::Load -- read the hierarchy from a W3D file * - * HierarchySaveClass::add_tree -- adds a node and all of its children * - * HierarchySaveClass::add_node -- adds a single node to the tree * - * HierarchySaveClass::Get_Fixup_Transform -- gets the "fixup" transform for a node * - * HierarchySaveClass::fixup_matrix -- conditions a matrix * - * HierarchySaveClass::save_header -- writes the header into a W3D file * - * HierarchySaveClass::save_pivots -- writes the pivots into a W3D file * - * HierarchySaveClass::save_fixups -- writes the fixup transforms into a W3D file * - * HierarchySaveClass::load_header -- reads the header from a W3D file * - * HierarchySaveClass::load_pivots -- reads the pivots from a W3D file * - * HierarchySaveClass::load_fixups -- reads the fixup transforms from a W3D file * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "hiersave.h" -#include "w3d_file.h" -#include "nodefilt.h" -#include "EULER.H" -#include "util.h" -#include "w3dappdata.h" -#include "errclass.h" -#include "exportlog.h" - - -bool HierarchySaveClass::TerrainModeEnabled = false; - - -/*********************************************************************************************** - * HierarchySaveClass::HierarchySaveClass -- constructor * - * * - * INPUT: * - * root - root INode to construct the HTree from * - * time - current time in Max, transforms at this time will be used * - * treemeter - progress meter * - * hname - name for the hierarchy tree * - * fixup_type - can be used to force all transforms to be translation only * - * fixuptree - htree loaded from a previous export * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -HierarchySaveClass::HierarchySaveClass -( - INode * root, - TimeValue time, - Progress_Meter_Class & treemeter, - char * hname, - int fixuptype, - HierarchySaveClass * fixuptree -) : - Node(DEFAULT_NODE_ARRAY_SIZE), - CurNode(0), - FixupType(fixuptype), - FixupTree(fixuptree) -{ - CurNode = 0; - CurTime = time; - - /* - ** This code-path is activated when the user has created a custom origin. In this case, we - ** need to compute the transform which will make all bones relative to this origin. - */ - OriginOffsetTransform = Inverse(root->GetNodeTM(CurTime)); - - /* - ** Build our tree from the given tree of nodes - */ - int rootidx = add_node(NULL,-1); - assert(rootidx == 0); - add_tree(root,rootidx); - - HierarchyHeader.Version = W3D_CURRENT_HTREE_VERSION; - Set_W3D_Name(HierarchyHeader.Name,hname); - HierarchyHeader.NumPivots = CurNode; - HierarchyHeader.Center.X = 0.0f; - HierarchyHeader.Center.Y = 0.0f; - HierarchyHeader.Center.Z = 0.0f; -} - -/*********************************************************************************************** - * HierarchySaveClass::HierarchySaveClass -- constructor * - * * - * INPUT: * - * * - * rootlist - list of root nodes to add to the htree * - * time - current time in Max, transforms at this time will be used * - * treemeter - progress meter * - * hname - name for the hierarchy tree * - * fixup_type - can be used to force all transforms to be translation only * - * fixuptree - htree loaded from a previous export * - * origin_offset - origin offset transform * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -HierarchySaveClass::HierarchySaveClass -( - INodeListClass * rootlist, - TimeValue time, - Progress_Meter_Class & treemeter, - char * hname, - int fixuptype, - HierarchySaveClass * fixuptree, - const Matrix3 & origin_offset -) : - Node(DEFAULT_NODE_ARRAY_SIZE), - CurNode(0), - FixupType(fixuptype), - FixupTree(fixuptree), - OriginOffsetTransform(origin_offset) -{ - CurNode = 0; - CurTime = time; - - /* - ** Build the tree with all leaves of all of the nodes given - */ - int rootidx = add_node(NULL,-1); - assert(rootidx == 0); - - for (unsigned int i = 0; i < rootlist->Num_Nodes(); i++) { - add_tree((*rootlist)[i],rootidx); - } - - HierarchyHeader.Version = W3D_CURRENT_HTREE_VERSION; - Set_W3D_Name(HierarchyHeader.Name,hname); - HierarchyHeader.NumPivots = CurNode; - HierarchyHeader.Center.X = 0.0f; - HierarchyHeader.Center.Y = 0.0f; - HierarchyHeader.Center.Z = 0.0f; - -} - -/*********************************************************************************************** - * HierarchySaveClass::HierarchySaveClass -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -HierarchySaveClass::HierarchySaveClass(): - Node(NULL), - CurNode(0), - CurTime(0) -{ -} - -/*********************************************************************************************** - * HierarchySaveClass::~HierarchySaveClass -- destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -HierarchySaveClass::~HierarchySaveClass(void) -{ - Free(); -} - -/*********************************************************************************************** - * HierarchySaveClass::Free -- releases all allocated memory * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -void HierarchySaveClass::Free(void) -{ - Node.Clear(); -} - - -/*********************************************************************************************** - * HierarchySaveClass::Get_Node_Transform -- returns the transformation matrix of specified no * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -Matrix3 HierarchySaveClass::Get_Node_Transform(int nodeidx) const -{ - Matrix3 tm(1); - - int idx = nodeidx; - - while (idx != -1) { - tm = tm * get_relative_transform(idx); - idx = Node[idx].Pivot.ParentIdx; - } - - return tm; -} - - -/*********************************************************************************************** - * HierarchySaveClass::get_relative_transform -- retruns tm between this node and its parent * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -Matrix3 HierarchySaveClass::get_relative_transform(int nodeidx) const -{ - assert(nodeidx >= 0); - assert(nodeidx < CurNode); - - Point3 trans; - Quat rot; - Matrix3 tm(true); - Matrix3 rtm(true); - - trans.x = Node[nodeidx].Pivot.Translation.X; - trans.y = Node[nodeidx].Pivot.Translation.Y; - trans.z = Node[nodeidx].Pivot.Translation.Z; - - // WARNING! I had to fudge the orientation - // quaternion (Max's representation seems to - // rotate in the opposite sense as mine...) - rot[0] = -Node[nodeidx].Pivot.Rotation.Q[0]; - rot[1] = -Node[nodeidx].Pivot.Rotation.Q[1]; - rot[2] = -Node[nodeidx].Pivot.Rotation.Q[2]; - rot[3] = Node[nodeidx].Pivot.Rotation.Q[3]; - - tm.Translate(trans); - rot.MakeMatrix(rtm); - tm = rtm * tm; - - return tm; -} - - -/*********************************************************************************************** - * HierarchySaveClass::Get_Name -- returns the name of this hierarchy * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -const char * HierarchySaveClass::Get_Name(void) const -{ - return HierarchyHeader.Name; -} - - -/*********************************************************************************************** - * HierarchySaveClass::Get_Node -- Get the Max INode * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/15/98 GTH : Created. * - *=============================================================================================*/ -INode * HierarchySaveClass::Get_Node(int node) const -{ - assert(node >= 0); - assert(node < CurNode); - - return Node[node].MaxNode; -} - -/*********************************************************************************************** - * HierarchySaveClass::Get_Node_Name -- returns name of this hierarchy node * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -const char * HierarchySaveClass::Get_Node_Name(int node) const -{ - assert(node >= 0); - assert(node < CurNode); - - return Node[node].Pivot.Name; -} - - -/*********************************************************************************************** - * HierarchySaveClass::Find_Named_Node -- returns index of a named node * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -int HierarchySaveClass::Find_Named_Node(const char * name) const -{ - int match = -1; - for (int index=0; indexGetName()); - - boneidx = Find_Named_Node(name); - - if (boneidx != -1) { - - /* - ** We found the parent bone! - */ - done = true; - - } else if (Is_Origin(pbone)) { - - /* - ** Don't go up past our origin, use this as our bone. - */ - boneidx = 0; - done = true; - - } else { - - /* - ** Nope, try the next parent - */ - pbone = pbone->GetParentNode(); - assert(pbone != NULL); - -#if 0 - if (pbone == NULL) { - - /* - ** mesh isn't connected to a bone, use the root - */ - boneidx = 0; - pbone = node; - done = true; - } -#endif - } - } - - if (set_bone_index != NULL) { - *set_bone_index = boneidx; - } - if (set_bone_node != NULL) { - *set_bone_node = pbone; - } - if (set_transform != NULL) { - *set_transform = Get_Fixup_Transform(boneidx) * pbone->GetNodeTM(CurTime); - } -} - -/*********************************************************************************************** - * HierarchySaveClass::Save -- write the hierarchy into a W3D file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -bool HierarchySaveClass::Save(ChunkSaveClass & csave) -{ - ExportLog::printf("\nSaving Hierarchy Tree %s.\n",HierarchyHeader.Name); - ExportLog::printf("Node Count: %d\n",CurNode); - ExportLog::printf("Nodes: \n"); - for (int inode = 0; inode < CurNode; inode++) { - ExportLog::printf(" %s\n",Node[inode].Pivot.Name); - } - - if (!csave.Begin_Chunk(W3D_CHUNK_HIERARCHY)) { - return false; - } - - if (!save_header(csave)) { - return false; - } - - if (!save_pivots(csave)) { - return false; - } - - if (!save_fixups(csave)) { - return false; - } - - if (!csave.End_Chunk()) { - return false; - } - - return true; -} - - -/*********************************************************************************************** - * HierarchySaveClass::Load -- read the hierarchy from a W3D file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -bool HierarchySaveClass::Load(ChunkLoadClass & cload) -{ - Free(); - bool error = false; - - while (cload.Open_Chunk()) { - switch (cload.Cur_Chunk_ID()) { - case W3D_CHUNK_HIERARCHY_HEADER: - if (!load_header(cload)) error = true; - break; - case W3D_CHUNK_PIVOTS: - if (!load_pivots(cload)) error = true; - break; - case W3D_CHUNK_PIVOT_FIXUPS: - if (!load_fixups(cload)) error = true; - break; - default: - break; - } - - if (!cload.Close_Chunk() || error) { - return false; - } - } - - CurNode = HierarchyHeader.NumPivots; - - return true; -} - - -/*********************************************************************************************** - * HierarchySaveClass::add_tree -- adds a node and all of its children * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -void HierarchySaveClass::add_tree(INode * node,int pidx) -{ - int nextparent; - - if (node->IsHidden ()) { - - // if the node is hidden, do not add it but add its children to the current parent. - nextparent = pidx; - - } else if (TerrainModeEnabled && (Is_Normal_Mesh(node) || Is_Null_Object(node))) { - - // terrain optimization, normal meshes are not allowed to have transforms - nextparent = pidx; - - } else if (!Is_Bone(node)) { - - // This node isn't a bone, don't add it - nextparent = pidx; - - } else { - - // Add new pivot! it will be parent of all below it. - nextparent = add_node(node,pidx); - - } - - // Add all of this nodes children - for (int i=0; i < node->NumberOfChildren(); i++) { - add_tree(node->GetChildNode(i),nextparent); - } -} - - -/*********************************************************************************************** - * HierarchySaveClass::add_node -- adds a single node to the tree * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -int HierarchySaveClass::add_node(INode * node,int pidx) -{ - /* - ** 'grow' the node array if necessary - */ - if (CurNode >= Node.Length ()) { - Node.Resize (Node.Length () + NODE_ARRAY_GROWTH_SIZE); - } - - /* - ** setup the pivot - */ - Node[CurNode].MaxNode = node; - Node[CurNode].Pivot.ParentIdx = pidx; - - if (node) { - Set_W3D_Name(Node[CurNode].Pivot.Name,node->GetName()); - } else { - Set_W3D_Name(Node[CurNode].Pivot.Name,"RootTransform"); - } - - /* - ** Now, check if there is a bone with this W3D name already - ** if there is, scold the user and bail out - */ - if (Find_Named_Node(Node[CurNode].Pivot.Name) != -1) { - char buf[128]; - sprintf(buf,"Bones with duplicate names found!\nDuplicated Name: %s\n",Node[CurNode].Pivot.Name); - throw ErrorClass(buf); - } - - /* - ** Compute the transformation for this node - */ - Matrix3 maxnodeTM(1); - Matrix3 ournodeTM(1); - Matrix3 fixupTM(1); - Point3 trans(0,0,0); - Quat rot(1); - Point3 scale(1,1,1); - - if (node) { - maxnodeTM = node->GetNodeTM(CurTime) * OriginOffsetTransform; - } else { - maxnodeTM = Matrix3(1); - } - - /* - ** If this tree is being "fixed up" the first thing we do - ** is to transform Max's nodeTM by the fixup transform. - ** This is done when a base pose was created using our own - ** types of transforms and we want to apply the same - ** changes to this tree. - ** - ** Note that if FixupType is not "NONE", FixupTree must be NULL, - */ - assert(!((FixupTree != NULL) && (FixupType != MATRIX_FIXUP_NONE))); - - if (FixupTree != NULL) { - int fi = FixupTree->Find_Named_Node(Node[CurNode].Pivot.Name); - if (fi == -1) { - char buf[128]; - sprintf(buf,"Incompatible Base Pose!\nMissing Bone: %s\n",Node[CurNode].Pivot.Name); - throw ErrorClass(buf); - } - - Matrix3 fixup = FixupTree->Get_Fixup_Transform(fi); - - maxnodeTM = fixup * maxnodeTM; - } - - - ournodeTM = fixup_matrix(maxnodeTM); - fixupTM = ournodeTM * Inverse(maxnodeTM); - - /* - ** Now, make ournodeTM relative to its parent transform. We - ** will always store relative transformations. (Also, note - ** that it is relative to our version of the parent transform - ** which is not necessarily the same as the MAX version...) - */ - if (pidx != -1) { - Matrix3 parentTM = Get_Node_Transform(pidx); - Matrix3 pinv = Inverse(parentTM); - ournodeTM = ournodeTM * pinv; - } - - - /* - ** Break the matrix down into a rotation and translation. - */ - DecomposeMatrix(ournodeTM,trans,rot,scale); - - /* - ** Save the "fixup" matrix - */ - for (int j=0;j<4;j++) { - Point3 row = fixupTM.GetRow(j); - Node[CurNode].Fixup.TM[j][0] = row.x; - Node[CurNode].Fixup.TM[j][1] = row.y; - Node[CurNode].Fixup.TM[j][2] = row.z; - } - - /* - ** Set the translation and rotation for this pivot. - */ - Node[CurNode].Pivot.Translation.X = trans.x; - Node[CurNode].Pivot.Translation.Y = trans.y; - Node[CurNode].Pivot.Translation.Z = trans.z; - - Node[CurNode].Pivot.Rotation.Q[0] = -rot[0]; - Node[CurNode].Pivot.Rotation.Q[1] = -rot[1]; - Node[CurNode].Pivot.Rotation.Q[2] = -rot[2]; - Node[CurNode].Pivot.Rotation.Q[3] = rot[3]; - - /* - ** Compute the Euler angles and set them. - */ - Matrix3 rotmat; - rot.MakeMatrix(rotmat); - EulerAnglesClass eangs(rotmat,EulerOrderXYZr); - - Node[CurNode].Pivot.EulerAngles.X = eangs.Get_Angle(0); - Node[CurNode].Pivot.EulerAngles.Y = eangs.Get_Angle(1); - Node[CurNode].Pivot.EulerAngles.Z = eangs.Get_Angle(2); - - return CurNode++; -} - -/*********************************************************************************************** - * HierarchySaveClass::Get_Fixup_Transform -- gets the "fixup" transform for a node * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -Matrix3 HierarchySaveClass::Get_Fixup_Transform(int node) const -{ - assert(node >= 0); - assert(node < CurNode); - - Matrix3 m; - - for (int j=0;j<4;j++) { - m.SetRow(j,Point3(Node[node].Fixup.TM[j][0],Node[node].Fixup.TM[j][1],Node[node].Fixup.TM[j][2])); - } - - return m; -} - -/*********************************************************************************************** - * HierarchySaveClass::fixup_matrix -- conditions a matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -Matrix3 HierarchySaveClass::fixup_matrix(const Matrix3 & csrc) const -{ - Matrix3 src = csrc; // the GetTrans function is not const correct... - Matrix3 newtm(1); - Point3 trans; - Quat rot; - Point3 scale; - - switch (FixupType) { - case MATRIX_FIXUP_NONE: - newtm = src; - break; - - case MATRIX_FIXUP_TRANS: - newtm.SetTrans(src.GetTrans()); - newtm = Cleanup_Orthogonal_Matrix(newtm); - break; - - case MATRIX_FIXUP_TRANS_ROT: - DecomposeMatrix(src,trans,rot,scale); - rot.MakeMatrix(newtm); - newtm.SetTrans(trans); - newtm = Cleanup_Orthogonal_Matrix(newtm); - break; - }; - - return newtm; -} - - -/*********************************************************************************************** - * HierarchySaveClass::save_header -- writes the header into a W3D file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -bool HierarchySaveClass::save_header(ChunkSaveClass & csave) -{ - if (!csave.Begin_Chunk(W3D_CHUNK_HIERARCHY_HEADER)) { - return false; - } - - if (csave.Write(&HierarchyHeader,sizeof(HierarchyHeader)) != sizeof(HierarchyHeader)) { - return false; - } - - if (!csave.End_Chunk()) { - return false; - } - - return true; -} - - -/*********************************************************************************************** - * HierarchySaveClass::save_pivots -- writes the pivots into a W3D file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -bool HierarchySaveClass::save_pivots(ChunkSaveClass & csave) -{ - if (!csave.Begin_Chunk(W3D_CHUNK_PIVOTS)) { - return false; - } - - for (uint32 i=0; i. -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/hiersave.h 29 10/26/00 5:59p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Engine * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/hiersave.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/26/00 5:09p $* - * * - * $Revision:: 29 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef HIERSAVE_H -#define HIERSAVE_H - -#include "always.h" - -#include -#include - -#ifndef W3D_FILE_H -#include "w3d_file.h" -#endif - -#ifndef PROGRESS_H -#include "PROGRESS.H" -#endif - -#ifndef CHUNKIO_H -#include "chunkio.h" -#endif - -#ifndef NODELIST_H -#include "nodelist.h" -#endif - -#ifndef VECTOR_H -#include "Vector.H" -#endif - - - -struct HierarchyNodeStruct -{ - INode * MaxNode; - W3dPivotStruct Pivot; - W3dPivotFixupStruct Fixup; - - bool operator == (const HierarchyNodeStruct & that) { return false; } - bool operator != (const HierarchyNodeStruct & that) { return !(*this == that); } -}; - - -class HierarchySaveClass -{ - -public: - - enum { - MATRIX_FIXUP_NONE = 0, - MATRIX_FIXUP_TRANS = 1, - MATRIX_FIXUP_TRANS_ROT = 2 - }; - - HierarchySaveClass(); - - HierarchySaveClass( - INode * root, - TimeValue time, - Progress_Meter_Class & treemeter, - char * hname, - int fixup_type = MATRIX_FIXUP_NONE, - HierarchySaveClass * fixuptree = NULL); - - HierarchySaveClass( - INodeListClass * rootlist, - TimeValue time, - Progress_Meter_Class & treemeter, - char * hname, - int fixup_type = MATRIX_FIXUP_NONE, - HierarchySaveClass * fixuptree = NULL, - const Matrix3 & origin_offset = Matrix3(1)); - - ~HierarchySaveClass(); - - bool Save(ChunkSaveClass & csave); - bool Load(ChunkLoadClass & cload); - int Num_Nodes(void) const { return CurNode; } - const char * Get_Name(void) const; - const char * Get_Node_Name(int node) const; - - // get ahold of the max inode - INode * Get_Node(int node) const; - - // Returns the node's transform from object to world space - Matrix3 Get_Node_Transform(int node) const; - - // Returns the node's transform relative to its parent - Matrix3 Get_Node_Relative_Transform(int node) const { return get_relative_transform(node); } - - // Get the fixup matrix for the given pivot (always applied to the *relative* transform) - Matrix3 Get_Fixup_Transform(int node) const; - - // Finds a node by name - int Find_Named_Node(const char * name) const; - - // Get the coordinate system to use when exporting the given INode. Note that this - // function takes into account the multiple skeletons present when exporting LOD models. - void Get_Export_Coordinate_System(INode * node,int * set_bone_index,INode ** set_bone_node,Matrix3 * set_transform); - - // Turning on terrian mode will cause all HTrees to force all normal meshes to be - // attached to the RootTransform regardless of the status of their 'Export_Transform' flag - static void Enable_Terrain_Optimization(bool onoff) { TerrainModeEnabled = onoff; } - -private: - - enum { MAX_PIVOTS = 4096, DEFAULT_NODE_ARRAY_SIZE = 512, NODE_ARRAY_GROWTH_SIZE = 32 }; - - TimeValue CurTime; - W3dHierarchyStruct HierarchyHeader; - DynamicVectorClass Node; - int CurNode; - int FixupType; - Matrix3 OriginOffsetTransform; // this transform makes a node relative to the origin - HierarchySaveClass * FixupTree; - - static bool TerrainModeEnabled; - - void add_tree(INode * node,int pidx); - int add_node(INode * node,int pidx); - - bool save_header(ChunkSaveClass & csave); - bool save_pivots(ChunkSaveClass & csave); - bool save_fixups(ChunkSaveClass & csave); - - bool load_header(ChunkLoadClass & cload); - bool load_pivots(ChunkLoadClass & cload); - bool load_fixups(ChunkLoadClass & cload); - - Matrix3 get_relative_transform(int nodeidx) const; - Matrix3 fixup_matrix(const Matrix3 & src) const; - void Free(void); -}; - -#endif /*HIERSAVE_H*/ \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/hlodsave.cpp b/Generals/Code/Tools/WW3D/max2w3d/hlodsave.cpp deleted file mode 100644 index 065ab1e228d..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/hlodsave.cpp +++ /dev/null @@ -1,426 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Renegade / G * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/hlodsave.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 11/07/00 5:24p $* - * * - * $Revision:: 9 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * -- The constructor builds the whole HLOD tree in a * - * -- Destructor blows away the dynamic memory we used. * - * -- Method called when saving to a W3D file. Saves the chunks * - * -- Write the header * - * -- Writes each LOD * - * -- Writes the mesh to bone connectivity info for each mesh in an LOD. * - * HLodSaveClass::save_aggregate_array -- save the aggregates (if any) * - * HLodSaveClass::save_proxy_array -- save the array of proxies (if any) * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "hlodsave.h" -#include "meshcon.h" -#include "errclass.h" -#include "util.h" -#include "w3dappdata.h" -#include "wwmath.h" // NO_MAX_SCREEN_SIZE -#include "exportlog.h" - - - -/* Behold, the applicable snippets of code from w3d_file.h that are applicable to this module! - - W3D_CHUNK_HLOD =0x00000700, // description of an HLod object (see HLodClass) - W3D_CHUNK_HLOD_HEADER, // general information such as name and version - W3D_CHUNK_HLOD_LOD_ARRAY, // wrapper around the array of objects for each level of detail - W3D_CHUNK_HLOD_LOD_ARRAY_HEADER, // info on the objects in this level of detail array - W3D_CHUNK_HLOD_SUB_OBJECT, // an object in this level of detail array - -struct W3dHLodHeaderStruct -{ - uint32 Version; - uint32 LodCount; - char Name[W3D_NAME_LEN]; - char HierarchyName[W3D_NAME_LEN]; // name of the hierarchy tree to use (\0 if none) -}; - -struct W3dHLodArrayHeaderStruct -{ - uint32 ModelCount; - float32 MaxScreenSize; // if model is bigger than this, switch to higher lod. -}; - -struct W3dHLodSubObjectStruct -{ - uint32 BoneIndex; - char Name[W3D_NAME_LEN*2]; -}; -*/ - - -/*********************************************************************************************** - * HLodSaveClass -- The constructor builds the whole HLOD tree in a form suitable for saving * - * to a W3D file. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/14/1999 AJA : Created. * - *=============================================================================================*/ -HLodSaveClass::HLodSaveClass (MeshConnectionsClass **connections, int lod_count, TimeValue CurTime, - char *name, const char *htree_name, Progress_Meter_Class &meter, - INodeListClass *origin_list) -: lod_array(NULL) -{ - /* - ** Fill in the W3dHLodHeaderStruct - */ - header.Version = W3D_CURRENT_HLOD_VERSION; - header.LodCount = lod_count; - Set_W3D_Name(header.Name, name); - Set_W3D_Name(header.HierarchyName, htree_name); - ExportLog::printf("\nExporting HLOD object: %s\n",header.Name); - ExportLog::printf(" lod count: %d\n",header.LodCount); - - /* - ** Create the array of stuff for each LOD. - */ - lod_array = new HLodArrayEntry[lod_count]; - if (!lod_array) - throw ErrorClass("Out Of Memory!"); - - int i; - for (i = 0; i < lod_count; i++) - { - - ExportLog::printf(" Exporting LOD Array %d\n",i); - - INode *origin = connections[i]->Get_Origin(); - int sub_obj_count = connections[i]->Get_Sub_Object_Count(); - lod_array[i].Allocate_Sub_Objects(sub_obj_count); - lod_array[i].header.ModelCount = sub_obj_count; - - float screen_size = NO_MAX_SCREEN_SIZE; - if (origin) - origin->GetUserPropFloat("MaxScreenSize", screen_size); - lod_array[i].header.MaxScreenSize = screen_size; - - /* - ** Create the info per mesh in this LOD. - */ - int j; - W3dHLodSubObjectStruct *sub_obj = lod_array[i].sub_obj; - ExportLog::printf(" sub-object count: %d\n",sub_obj_count); - for (j = 0; j < sub_obj_count; j++) - { - char *mesh_name; - int bone_index; - INode *mesh_node; - if (!connections[i]->Get_Sub_Object_Data(j, &mesh_name, &bone_index, &mesh_node)) - throw ErrorClass("Model %s is missing connection data!", name); - - strcpy(sub_obj[j].Name, mesh_name); - sub_obj[j].BoneIndex = bone_index; - - ExportLog::printf(" Sub Object: %s Bone: %d\n",mesh_name,bone_index); - } - } - - /* - ** Copy aggregates from the Top-Level LOD - */ - int agg_count = connections[lod_count-1]->Get_Aggregate_Count(); - aggregate_array.Allocate_Sub_Objects(agg_count); - aggregate_array.header.ModelCount = agg_count; - aggregate_array.header.MaxScreenSize = 0.0f; - - ExportLog::printf(" Exporting Aggregates:\n"); - ExportLog::printf(" aggregate count: %d\n",agg_count); - - for (i=0; iGet_Aggregate_Data(i, &mesh_name, &bone_index, &mesh_node); - - W3dHLodSubObjectStruct & sub_obj = aggregate_array.sub_obj[i]; - strcpy(sub_obj.Name, mesh_name); - sub_obj.BoneIndex = bone_index; - - ExportLog::printf(" Aggregate object: %s Bone: %d\n",mesh_name,bone_index); - - } - - /* - ** Copy the proxy objects from the Top-Level LOD - */ - int proxy_count = connections[lod_count-1]->Get_Proxy_Count(); - proxy_array.Allocate_Sub_Objects(proxy_count); - proxy_array.header.ModelCount = proxy_count; - proxy_array.header.MaxScreenSize = 0.0f; - - ExportLog::printf(" Exporting Proxies\n"); - ExportLog::printf(" proxy count: %d\n",proxy_count); - for (i=0; iGet_Proxy_Data(i, &mesh_name, &bone_index, &mesh_node); - - W3dHLodSubObjectStruct & sub_obj = proxy_array.sub_obj[i]; - strcpy(sub_obj.Name, mesh_name); - sub_obj.BoneIndex = bone_index; - - ExportLog::printf(" Proxy object: %s Bone: %d\n",mesh_name,bone_index); - } - -} - - -/*********************************************************************************************** - * ~HLodSaveClass -- Destructor blows away the dynamic memory we used. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/14/1999 AJA : Created. * - *=============================================================================================*/ -HLodSaveClass::~HLodSaveClass (void) -{ - if (lod_array) - { - delete []lod_array; - lod_array = NULL; - } -} - - -/*********************************************************************************************** - * HLodSaveClass::Save -- Method called when saving to a W3D file. Saves the chunks that * - * define a HLOD. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/14/1999 AJA : Created. * - *=============================================================================================*/ -bool HLodSaveClass::Save(ChunkSaveClass &csave) -{ - if (!lod_array) - return false; - - if (!csave.Begin_Chunk(W3D_CHUNK_HLOD)) - return false; - - if (!save_header(csave)) - return false; - - if (!save_lod_arrays(csave)) - return false; - - if (!save_aggregate_array(csave)) - return false; - - if (!save_proxy_array(csave)) - return false; - - if (!csave.End_Chunk()) - return false; - - return true; -} - - -/*********************************************************************************************** - * HLodSaveClass::save_header -- Write the header * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/14/1999 AJA : Created. * - *=============================================================================================*/ -bool HLodSaveClass::save_header (ChunkSaveClass &csave) -{ - if (!csave.Begin_Chunk(W3D_CHUNK_HLOD_HEADER)) - return false; - - if (csave.Write(&header, sizeof(header)) != sizeof(header)) - return false; - - if (!csave.End_Chunk()) - return false; - - return true; -} - - -/*********************************************************************************************** - * HLodSaveClass::save_lod_arrays -- Writes each LOD * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/14/1999 AJA : Created. * - *=============================================================================================*/ -bool HLodSaveClass::save_lod_arrays(ChunkSaveClass &csave) -{ - for (int i = 0; i < header.LodCount; i++) - { - if (!csave.Begin_Chunk(W3D_CHUNK_HLOD_LOD_ARRAY)) - return false; - - if (!save_sub_object_array(csave, lod_array[i])) - return false; - - if (!csave.End_Chunk()) - return false; - } - - return true; -} - - - -/*********************************************************************************************** - * HLodSaveClass::save_aggregate_array -- save the aggregates (if any) * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/25/2000 gth : Created. * - *=============================================================================================*/ -bool HLodSaveClass::save_aggregate_array(ChunkSaveClass & csave) -{ - if (aggregate_array.num_sub_objects > 0) { - if (!csave.Begin_Chunk(W3D_CHUNK_HLOD_AGGREGATE_ARRAY)) - return false; - - if (!save_sub_object_array(csave, aggregate_array)) - return false; - - if (!csave.End_Chunk()) - return false; - } - return true; -} - - -/*********************************************************************************************** - * HLodSaveClass::save_proxy_array -- save the array of proxies (if any) * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/27/2000 gth : Created. * - *=============================================================================================*/ -bool HLodSaveClass::save_proxy_array(ChunkSaveClass & csave) -{ - if (proxy_array.num_sub_objects > 0) { - if (!csave.Begin_Chunk(W3D_CHUNK_HLOD_PROXY_ARRAY)) - return false; - - if (!save_sub_object_array(csave, proxy_array)) - return false; - - if (!csave.End_Chunk()) - return false; - } - return true; -} - - -/*********************************************************************************************** - * HLodSaveClass::save_sub_object_array -- Writes the mesh to bone connectivity info for each * - * mesh in an LOD. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/14/1999 AJA : Created. * - *=============================================================================================*/ -bool HLodSaveClass::save_sub_object_array(ChunkSaveClass &csave, const HLodArrayEntry & array) -{ - if (!csave.Begin_Chunk(W3D_CHUNK_HLOD_SUB_OBJECT_ARRAY_HEADER)) - return false; - - if (csave.Write(&(array.header), sizeof(array.header)) != sizeof(array.header)) - return false; - - if (!csave.End_Chunk()) - return false; - - for (int j = 0; j < array.num_sub_objects; j++) - { - if (!csave.Begin_Chunk(W3D_CHUNK_HLOD_SUB_OBJECT)) - return false; - - if (csave.Write(&(array.sub_obj[j]), sizeof(array.sub_obj[j])) != sizeof(array.sub_obj[j])) - return false; - - if (!csave.End_Chunk()) - return false; - } - - return true; -} - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/hlodsave.h b/Generals/Code/Tools/WW3D/max2w3d/hlodsave.h deleted file mode 100644 index a74189285be..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/hlodsave.h +++ /dev/null @@ -1,129 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Renegade / G * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/hlodsave.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/27/00 10:22a $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef HLODSAVE_H -#define HLODSAVE_H - -#include "always.h" - -#include -#include - -#include "w3d_file.h" -#include "PROGRESS.H" -#include "chunkio.h" -#include "meshcon.h" - - -class INodeListClass; -class MeshConnectionsClass; - - -/** -** HLodSaveClass -** This object takes an array of mesh-connections objects and exports an LOD model -** constructed from them. -*/ -class HLodSaveClass -{ -public: - HLodSaveClass (MeshConnectionsClass **connections, int lod_count, TimeValue CurTime, - char *name, const char *htree_name, Progress_Meter_Class &meter, - INodeListClass *origin_list); - ~HLodSaveClass (void); - - bool Save (ChunkSaveClass &csave); - - -protected: - - /* - ** class HLodArrayEntry hold the HLOD tree that we will save out in the Save() method. - */ - class HLodArrayEntry - { - public: - W3dHLodArrayHeaderStruct header; - W3dHLodSubObjectStruct *sub_obj; - int num_sub_objects; - - HLodArrayEntry (int num_sub_objs = 0) - { - sub_obj = NULL; - num_sub_objects = 0; - Allocate_Sub_Objects(num_sub_objs); - } - - ~HLodArrayEntry (void) - { - if (sub_obj) - { - delete sub_obj; - sub_obj = NULL; - num_sub_objects = 0; - } - } - - bool Allocate_Sub_Objects (int num) - { - if (num <= 0) return false; - num_sub_objects = 0; - sub_obj = new W3dHLodSubObjectStruct[num]; - if (!sub_obj) return false; - num_sub_objects = num; - return true; - } - - bool operator == (const HLodArrayEntry & that) { return false; } - bool operator != (const HLodArrayEntry & that) { return !(*this == that); } - }; - - bool save_header (ChunkSaveClass &csave); - bool save_lod_arrays (ChunkSaveClass &csave); - bool save_aggregate_array (ChunkSaveClass & csave); - bool save_proxy_array(ChunkSaveClass & csave); - bool save_sub_object_array(ChunkSaveClass & csave, const HLodArrayEntry & array); - - W3dHLodHeaderStruct header; - HLodArrayEntry * lod_array; - HLodArrayEntry aggregate_array; - HLodArrayEntry proxy_array; -}; - - - -#endif diff --git a/Generals/Code/Tools/WW3D/max2w3d/logdlg.cpp b/Generals/Code/Tools/WW3D/max2w3d/logdlg.cpp deleted file mode 100644 index d5d26567fce..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/logdlg.cpp +++ /dev/null @@ -1,388 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/logdlg.cpp 5 11/07/00 5:40p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/logdlg.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 11/07/00 4:24p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "logdlg.h" -#include "resource.h" -#include "dllmain.h" -#include "w3dexp.h" -#include "util.h" -#include "rawfile.h" -#include "units.h" - - -/* -** Static functions -*/ -static BOOL CALLBACK _logdata_dialog_proc(HWND Hwnd,UINT message,WPARAM wParam,LPARAM lParam); -static DWORD WINAPI _logdata_thread_function(LPVOID log_obj_ptr); - - -/*********************************************************************************************** - * LogDataDialogClass::LogDataDialogClass -- constructor for the options dialog object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/09/2000 JGA : Created. * - *=============================================================================================*/ -LogDataDialogClass::LogDataDialogClass(HWND parent): - Hwnd(NULL), - ParentHwnd(parent), - buffer_index(0), - last_buffer_index(0), - status(0) -{ - ThreadHandle = CreateThread(NULL, 0, _logdata_thread_function, (LPVOID)this, 0, &ThreadID); - - if (ThreadHandle) { - while (status == 0) { - // sync, wait for init - } - } -} - -LogDataDialogClass::~LogDataDialogClass(void) -{ - status = 3; - if (::IsWindow(Hwnd)) { - SendMessage( Hwnd, WM_CLOSE, 0, 0 ); - } -} - - -/*********************************************************************************************** - * LogDataDialogClass::printf -- handles doing printfs into the current log window * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/11/2000 JGA : Created. * - *=============================================================================================*/ -void LogDataDialogClass::printf(const char *text, ...) -{ - va_list arguments; - va_start(arguments, text); -} // printf - -void LogDataDialogClass::printf(const char * text, va_list args) -{ - static char string_buffer[256]; - - vsprintf(string_buffer, text, args); - - HWND ctrlHwnd = GetDlgItem(Hwnd, IDC_ANIM_LOG_RICHEDIT); - - SendMessage(ctrlHwnd, EM_SETSEL, -1, -1 ); - SendMessage(ctrlHwnd, EM_REPLACESEL, FALSE, (long)string_buffer); - - last_buffer_index = buffer_index; - buffer_index+=strlen(string_buffer); - - //int min,max,pos; - //GetScrollRange(ctrlHwnd, SB_VERT, &min, &max); - //pos = GetScrollPos(ctrlHwnd, SB_VERT); - - //if (pos == max) { - SendMessage(GetDlgItem(Hwnd,IDC_ANIM_LOG_RICHEDIT), EM_SCROLLCARET, 0, 0); - //} - - -} - -/*********************************************************************************************** - * LogDataDialogClass::rprintf -- replace last printf, with this new printf * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/14/2000 JGA : Created. * - *=============================================================================================*/ -void LogDataDialogClass::rprintf(const char *text, ...) -{ - va_list arguments; - va_start(arguments, text); - - rprintf(text,arguments); -} - -void LogDataDialogClass::rprintf(const char *text, va_list args) -{ - static char string_buffer[256]; - vsprintf(string_buffer, text, args); - - HWND ctrlHwnd = GetDlgItem(Hwnd, IDC_ANIM_LOG_RICHEDIT); - - SendMessage(ctrlHwnd, EM_SETSEL, last_buffer_index, buffer_index ); - SendMessage(ctrlHwnd, EM_REPLACESEL, FALSE, (long)string_buffer); - - buffer_index = strlen(string_buffer) + last_buffer_index; - - //int min,max,pos; - //GetScrollRange(ctrlHwnd, SB_VERT, &min, &max); - //pos = GetScrollPos(ctrlHwnd, SB_VERT); - - //SendMessage(GetDlgItem(Hwnd,IDC_ANIM_LOG_RICHEDIT), EM_SCROLLCARET, 0, 0); - -} // rprintf - - -/*********************************************************************************************** - * LogDataDialogClass::updatebar - send message to progress meter * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/14/2000 JGA : Created. * - *=============================================================================================*/ -void LogDataDialogClass::updatebar(float position, float total) -{ - int pos; - - pos = ((position / total) * 100.0f); - - HWND ctrlHwnd = GetDlgItem(Hwnd, IDC_ANIM_COMPRESS_PROGRESS); - - SendMessage(ctrlHwnd, PBM_SETPOS, pos, 0 ); - -} // updatebar - - -/*********************************************************************************************** - * LogDataDialogClass::Wait_OK - Give user a chance to review log, then hit ok * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/14/2000 JGA : Created. * - *=============================================================================================*/ -void LogDataDialogClass::Wait_OK() -{ - ::EnableWindow(GetDlgItem(Hwnd,IDOK),TRUE); - ::SetForegroundWindow(Hwnd); - - while (status < 2) { - // wait for the OK - } - -} // Wait_OK - - - -/*********************************************************************************************** - * LogDataDialogClass::Dialog_Proc -- Handles the windows message for the options dialog * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/24/1997 GH : Created. * - *=============================================================================================*/ -bool LogDataDialogClass::Dialog_Proc -( - HWND hwnd, - UINT message, - WPARAM wParam, - LPARAM -) -{ - int code = HIWORD(wParam); - - switch (message ) { - - /******************************************************************* - * WM_INITDIALOG - * - * Initialize all of the custom controls for the dialog box - * - *******************************************************************/ - case WM_INITDIALOG: - - Dialog_Init(); - return TRUE; - - - /******************************************************************* - * WM_COMMAND - * - * - *******************************************************************/ - case WM_COMMAND: - - switch (LOWORD(wParam)) - { - case IDOK: - - status = 2; - - EndDialog(Hwnd, 1); - Hwnd = NULL; - return TRUE; - break; - - } - break; - - //case WM_VSCROLL: - // return TRUE; - // break; - - case WM_CLOSE: - - if (status >= 2) { - EndDialog(Hwnd, 1); - Hwnd = NULL; - } - - return TRUE; - break; - - } - return FALSE; - -} // Dialog_Proc - -void LogDataDialogClass::Dialog_Init() -{ - - SetCursor(LoadCursor (NULL, IDC_ARROW)); - - RECT desktop; - RECT ourwin; - - GetWindowRect(GetDesktopWindow(), &desktop); - GetWindowRect(Hwnd, &ourwin); - - int sx,sy,cx,cy; - - sx = ourwin.right - ourwin.left; - sy = ourwin.bottom - ourwin.top; - - cx = (((desktop.right - desktop.left) - sx)/2) + desktop.left; - cy = (((desktop.bottom - desktop.top) - sy)/2) + desktop.top; - - //SetWindowPos(Hwnd, HWND_TOPMOST, cx, cy, 0, 0, SWP_NOSIZE); - SetWindowPos(Hwnd, HWND_TOP, cx, cy, 0, 0, SWP_NOSIZE); - - EnableWindow(GetDlgItem(Hwnd,IDOK),FALSE); - - status = 1; // signal init - - -} // Dialog_Init - - - -/*********************************************************************************************** - * _logdata_dialog_proc -- thunks into the logdata dialog class's windows message handler * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/09/2000 JGA : Created. * - *=============================================================================================*/ -BOOL CALLBACK _logdata_dialog_proc -( - HWND hwnd, - UINT message, - WPARAM wParam, - LPARAM lParam -) -{ - if (message == WM_INITDIALOG) { - LogDataDialogClass * log = (LogDataDialogClass *)lParam; - log->Hwnd = hwnd; - ::SetProp(hwnd,"LogDataDialogClass",(HANDLE)log); - } - - LogDataDialogClass * log = (LogDataDialogClass *)::GetProp(hwnd,"LogDataDialogClass"); - - if (message == WM_DESTROY) { - ::RemoveProp(hwnd,"LogDataDialogClass"); - } - - if (log) { - return log->Dialog_Proc(hwnd,message,wParam,lParam); - } else { - return FALSE; - } - -} // _logdata_dialog_proc - - -DWORD WINAPI _logdata_thread_function(LPVOID log_obj_ptr) -{ - // put logdata dialog box (lpParameter is the "this" pointer of the object) - DialogBoxParam( AppInstance, - MAKEINTRESOURCE(IDD_W3D_LOG), - ((LogDataDialogClass*)log_obj_ptr)->ParentHwnd, - (DLGPROC) _logdata_dialog_proc, - (LPARAM) log_obj_ptr); - - - // When this exits it should terminate the thread - return(0); -} - - -// EOF - logdlg.cpp diff --git a/Generals/Code/Tools/WW3D/max2w3d/logdlg.h b/Generals/Code/Tools/WW3D/max2w3d/logdlg.h deleted file mode 100644 index 23e0a12336f..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/logdlg.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/logdlg.h 4 11/07/00 5:40p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/logdlg.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 11/07/00 3:15p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef LOGDLG_H -#define LOGDLG_H - -#include - - -class LogDataDialogClass -{ -public: - - LogDataDialogClass(HWND parent); - ~LogDataDialogClass(); - - void Wait_OK(); // wait for user to hit OK - - void printf(const char *, ...); - void printf(const char * text, va_list args); - void rprintf(const char *, ...); - void rprintf(const char *text, va_list args); - - void updatebar(float position, float total); - - bool Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM); - -public: -// public variables - HWND Hwnd; - HWND ParentHwnd; - -private: - - void Dialog_Init(); - -private: - - HANDLE ThreadHandle; - DWORD ThreadID; - - int last_buffer_index; - int buffer_index; - -volatile int status; - -}; - - -#endif - -// EOF - logdlg.h diff --git a/Generals/Code/Tools/WW3D/max2w3d/maxworldinfo.cpp b/Generals/Code/Tools/WW3D/max2w3d/maxworldinfo.cpp deleted file mode 100644 index f37b8b59baf..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/maxworldinfo.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/maxworldinfo.cpp $* - * * - * Original Author:: Patrick Smith * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/27/00 7:11p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "maxworldinfo.h" -#include "geometryexporttask.h" - -/* -** Get_Shared_Vertex_Normal -** Loops through all the other meshes in the world and builds a vertex normal for -** the verticies that share the same space and are part of the same smoothing group. -*/ -Vector3 MaxWorldInfoClass::Get_Shared_Vertex_Normal (Vector3 pos, int smgroup) -{ - Point3 normal(0,0,0); - Point3 world_pos = ExportTrans * Point3(pos.X,pos.Y,pos.Z); - - // - // Loop through all the meshes in the world and see which ones contain - // verticies that share the same space and are part of the same smoothing group. - // - for(unsigned int index = 0; index < MeshList.Count(); index ++) { - GeometryExportTaskClass * task = MeshList[index]; - if (task != CurrentTask) { - normal += task->Get_Shared_Vertex_Normal(world_pos,smgroup); - } - } - - return Vector3(normal.x,normal.y,normal.z); -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/maxworldinfo.h b/Generals/Code/Tools/WW3D/max2w3d/maxworldinfo.h deleted file mode 100644 index d8b34590800..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/maxworldinfo.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/maxworldinfo.h $* - * * - * Original Author:: Patrick Smith * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/27/00 6:55p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef MAXWORLDINFO_H -#define MAXWORLDINFO_H - - -#include -#include "meshbuild.h" -#include "nodelist.h" -#include "Vector.H" - - -class GeometryExportTaskClass; - - -/** -** MaxWorldInfoClass - Provides information about the max 'world' (or scene) -** This class is used by the plugin to cause the MeshBuilder to smooth normals -** across adjacent meshes. -*/ -class MaxWorldInfoClass : public WorldInfoClass -{ - public: - MaxWorldInfoClass(DynamicVectorClass & mesh_list) - : MeshList (mesh_list), - SmoothBetweenMeshes (true), - CurrentTask(NULL), - CurrentTime(0) { } - virtual ~MaxWorldInfoClass(void) { } - - // Public methods - virtual Vector3 Get_Shared_Vertex_Normal(Vector3 pos, int smgroup); - - virtual GeometryExportTaskClass * Get_Current_Task(void) const { return CurrentTask; } - virtual void Set_Current_Task(GeometryExportTaskClass * task) { CurrentTask = task; } - - virtual TimeValue Get_Current_Time(void) const { return CurrentTime; } - virtual void Set_Current_Time(TimeValue &time) { CurrentTime = time; } - - virtual Matrix3 Get_Export_Transform(void) const { return ExportTrans; } - virtual void Set_Export_Transform(const Matrix3 &matrix) { ExportTrans = matrix; } - - virtual void Allow_Mesh_Smoothing (bool onoff) { SmoothBetweenMeshes = onoff; } - virtual bool Are_Meshes_Smoothed (void) const { return SmoothBetweenMeshes; } - - private: - - DynamicVectorClass & MeshList; - GeometryExportTaskClass * CurrentTask; - TimeValue CurrentTime; - Matrix3 ExportTrans; - bool SmoothBetweenMeshes; -}; - - - -#endif \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/meshbuild.cpp b/Generals/Code/Tools/WW3D/max2w3d/meshbuild.cpp deleted file mode 100644 index 654a626df84..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/meshbuild.cpp +++ /dev/null @@ -1,1835 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/meshbuild.cpp $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 11/02/00 6:28p $* - * * - * $Revision:: 15 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * MeshBuilderClass::VertClass::Reset -- reset this vertex * - * MeshBuilderClass::FaceClass::Reset -- rest this face * - * MeshBuilderClass::FaceClass::Compute_Plane -- compute the plane for this face * - * MeshBuilderClass::FaceClass::Is_Degenerate -- check if a face is degenerate * - * MeshBuilderClass::MeshStatsStruct::Reset -- reset the stats to all false * - * MeshBuilderClass::MeshBuilderClass -- constructor * - * MeshBuilderClass::~MeshBuilderClass -- destructor * - * MeshBuilderClass::Free -- release all memory in use * - * MeshBuilderClass::Reset -- Get the builder ready to process a mesh * - * MeshBuilderClass::Add_Face -- Add a face to the mesh * - * MeshBuilderClass::Build_Mesh -- process the mesh * - * MeshBuilderClass::Compute_Face_Normals -- computes all of the face normals from the index * - * MeshBuilderClass::Verify_Face_Normals -- checks if any faces have flipped * - * MeshBuilderClass::Compute_Vertex_Normals -- Computes the vertex normals for the mesh * - * MeshBuilderClass::Remove_Degenerate_Faces -- discard invalid or duplicated faces * - * MeshBuilderClass::Compute_Mesh_Stats -- compute some stats about the mesh * - * MeshBuilderClass::Compute_Bounding_Box -- computes an axis-aligned bounding box for the m * - * MeshBuilderClass::Compute_Bounding_Sphere -- computes a bounding sphere for the mesh * - * MeshBuilderClass::Optimize_Mesh -- "optimize" the mesh * - * MeshBuilderClass::Strip_Optimize_Mesh -- optimize the mesh for triangle strips * - * MeshBuilderClass::Grow_Face_Array -- increases the size of the face array * - * MeshBuilderClass::Sort_Vertices -- Sorts vertices according to the given key array * - * MeshBuilderClass::Sort_Vertices_By_Bone_Index -- sorts verts by bone index * - * MeshBuilderClass::Sort_Vertices_By_Vertex_Material -- sorts verts by vertex mtl in pass0 * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "meshbuild.h" -#include "uarray.h" -#include -#include -#include - - -const float EPSILON = 0.0001f; - -/* -** qsort compare functions -*/ -static int face_material_compare(const void *elem1, const void *elem2); -static int pass0_stage0_compare(const void *elem1, const void *elem2); -static int pass0_stage1_compare(const void *elem1, const void *elem2); -static int pass1_stage0_compare(const void *elem1, const void *elem2); -static int pass1_stage1_compare(const void *elem1, const void *elem2); -static int pass2_stage0_compare(const void *elem1, const void *elem2); -static int pass2_stage1_compare(const void *elem1, const void *elem2); -static int pass3_stage0_compare(const void *elem1, const void *elem2); -static int pass3_stage1_compare(const void *elem1, const void *elem2); -static int vertex_compare(const void *elem1, const void *elem2); - -typedef int (*COMPARE_FUNC_TYPE)(const void * elem1,const void * elem2); - -COMPARE_FUNC_TYPE Texture_Compare_Funcs[MeshBuilderClass::MAX_PASSES][MeshBuilderClass::MAX_STAGES] = -{ - { pass0_stage0_compare, pass0_stage1_compare }, - { pass1_stage0_compare, pass1_stage1_compare }, - { pass2_stage0_compare, pass2_stage1_compare }, - { pass3_stage0_compare, pass3_stage1_compare }, -}; - - -/************************************************************************************ -** -** FaceHasherClass, support class for the unique faces hash table. The unique -** faces table is going to detect exactly duplicated faces and discard them. It -** appears that the artists occasionally accidentally duplicate a face which causes -** problems in the stripping algorithm... -** -************************************************************************************/ -class FaceHasherClass : public HashCalculatorClass -{ -public: - - virtual bool Items_Match(const MeshBuilderClass::FaceClass & a, const MeshBuilderClass::FaceClass & b) - { - // Note: if we want this to detect duplicates that are "rotated", must change - // both this function and the Compute_Hash function... - return - ( - (a.VertIdx[0] == b.VertIdx[0]) && - (a.VertIdx[1] == b.VertIdx[1]) && - (a.VertIdx[2] == b.VertIdx[2]) - ); - } - - virtual void Compute_Hash(const MeshBuilderClass::FaceClass & item) - { - HashVal = (int)(item.VertIdx[0]*12345.6f + item.VertIdx[1]*1714.38484f + item.VertIdx[2]*27561.3f)&1023; - } - - virtual int Num_Hash_Bits(void) - { - return 10; - } - - virtual int Num_Hash_Values(void) - { - return 1; - } - - virtual int Get_Hash_Value(int /*index*/) - { - return HashVal; - } - -private: - - int HashVal; - -}; - - -/************************************************************************************ -** -** VertexArray, build an array of unique vertices. Can't use the UniqueArray -** template due to the special considerations needed to properly handle smoothing -** groups... (DAMN!!! this was the reason I *WROTE* UniqueArray, oh well :-) -** -************************************************************************************/ -class VertexArrayClass -{ -public: - - enum - { - HASH_TABLE_SIZE = 4096, - }; - - VertexArrayClass(int maxsize,int match_normals = 0) - { - Verts = NULL; - assert(maxsize > 0); - Verts = new MeshBuilderClass::VertClass[maxsize]; - assert(Verts); - VertCount = 0; - UVSplits = 0; - - HashTable = new MeshBuilderClass::VertClass * [HASH_TABLE_SIZE]; - memset(HashTable,0,sizeof(MeshBuilderClass::VertClass *) * HASH_TABLE_SIZE); - - MatchNormals = match_normals; - - // initialize the center and extent to do nothing to the points input - Center.Set(0.0f,0.0f,0.0f); - Extent.Set(1.0f,1.0f,1.0f); - } - - ~VertexArrayClass(void) - { - delete[] Verts; - delete[] HashTable; - } - - void Set_Bounds(const Vector3 & minv,const Vector3 & maxv) - { - Extent = (maxv - minv) / 2.0f; - Center = (maxv + minv) / 2.0f; - } - - int Submit_Vertex(const MeshBuilderClass::VertClass & vert) - { - // 2D floating point hashing... - unsigned int lasthash = 0xFFFFFFFF; - unsigned int hash; - unsigned int shadeindex = 0xFFFFFFFF; - - // transform the position of the point into the range - // -1 < p < 1 as defined by the center and extent. - // aja/ehc 19991005 - Handle the case where an extent is zero. - Vector3 position = (vert.Position - Center); - double xstart; - if(fabs(Extent.X) > EPSILON) - xstart = (vert.Position.X - Center.X) / Extent.X; - else - xstart = Center.X; - - double ystart; - if(fabs(Extent.Y) > EPSILON) - ystart = (vert.Position.Y - Center.Y) / Extent.Y; - else - ystart = Center.Y; - - double x,y; - - for (x = xstart - EPSILON; x <= xstart + EPSILON + 0.0000001; x+= EPSILON) { - for (y = ystart - EPSILON; y <= ystart + EPSILON + 0.000001; y+= EPSILON) { - - hash = compute_hash((float)x,(float)y); - - if (hash != lasthash) { - MeshBuilderClass::VertClass * test_vert = HashTable[hash]; - while (test_vert) { - - if (Verts_Shading_Match(vert,*test_vert)) { - if (shadeindex == 0xFFFFFFFF) { - shadeindex = test_vert->UniqueIndex; - - // mask the "master" smoothed vertex's smoothing group with our - // face's smoothing group since we are going to be smoothed with it. - Verts[shadeindex].SharedSmGroup &= vert.SmGroup; - } - } - - if (Verts_Match(vert,*test_vert)) { - return test_vert->UniqueIndex; - } - test_vert = test_vert->NextHash; - } - } - - lasthash = hash; - } - } - - // Not found, add to the end of the array - int newindex = VertCount; - VertCount++; - - Verts[newindex] = vert; - Verts[newindex].UniqueIndex = newindex; - if (shadeindex == 0xFFFFFFFF) { - - Verts[newindex].ShadeIndex = newindex; - - // This is a new vertex,so store the face's smoothing group into SharedSmGroup - Verts[newindex].SharedSmGroup = Verts[newindex].SmGroup; - - } else { - - Verts[newindex].ShadeIndex = shadeindex; - - } - - // This is a new vertex, store the face's smoothing group with it - //Verts[newindex].SmoothingGroup = face_smooth_group; - - // And add to the hash table - x = (vert.Position.X - Center.X) / Extent.X; - y = (vert.Position.Y - Center.Y) / Extent.Y; - hash = compute_hash((float)x,(float)y); - Verts[newindex].NextHash = HashTable[hash]; - HashTable[hash] = &Verts[newindex]; - - return newindex; - } - - int Verts_Match(const MeshBuilderClass::VertClass & v0,const MeshBuilderClass::VertClass & v1) - { - // if user is specifying unique id's, they must match: - if (v0.Id != v1.Id) return 0; - - // position must match: - float dp = (v0.Position - v1.Position).Length(); - if (dp > EPSILON) return 0; - - // normal or smoothing group must match: - if (MatchNormals == 0) { - int smgroup_match = ((v0.SmGroup & v1.SmGroup) || (v0.SmGroup == v1.SmGroup)); - if (!smgroup_match) - return 0; - } else { - float dn = (v0.Normal - v1.Normal).Length(); - if (dn > EPSILON) return 0; - } - - // colors, and material id's must match for all passes - int pass=0; - for (; pass < MeshBuilderClass::MAX_PASSES; pass++) { - - if (v0.DiffuseColor[pass] != v1.DiffuseColor[pass]) - return 0; - if (v0.SpecularColor[pass] != v1.SpecularColor[pass]) - return 0; - if (v0.DiffuseIllumination[pass] != v1.DiffuseIllumination[pass]) - return 0; - if (v0.Alpha[pass] != v1.Alpha[pass]) - return 0; - if (v0.VertexMaterialIndex[pass] != v1.VertexMaterialIndex[pass]) - return 0; - - } - - // texcoords must match for all passes and stages - // Note: I'm checking them separately and last so that I can keep track - // of how many splits are caused solely by u-v discontinuities... - for (pass=0; pass 0.0000001f) { - ok = false; - } - } - return ok; -} - -/*********************************************************************************************** - * MeshBuilderClass::Compute_Vertex_Normals -- Computes the vertex normals for the mesh * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * This function should only be called after the mesh has been "optimized". The algorithm * - * relies on non-smooth vertices having been split... * - * * - * HISTORY: * - * 5/15/98 GTH : Created. * - *=============================================================================================*/ -void MeshBuilderClass::Compute_Vertex_Normals(void) -{ - int vertidx; - int faceidx; - int facevertidx; - - /* - ** First, zero all vertex normals - */ - for (vertidx = 0; vertidx < VertCount; vertidx++) { - Verts[vertidx].Normal.Set(0,0,0); - } - - /* - ** Now, go through all of the faces, accumulating the face normals into the - ** "first" vertices containing the appropriate vertex normal for each vertex. - */ - for (faceidx = 0; faceidx < FaceCount; faceidx++) { - for (facevertidx = 0; facevertidx < 3; facevertidx++) { - int vertindex = Faces[faceidx].VertIdx[facevertidx]; - int shadeindex = Verts[vertindex].ShadeIndex; - Verts[shadeindex].Normal += Faces[faceidx].Normal; - } - } - - /* - ** Smooth this mesh with neighboring meshes! - */ - if (WorldInfo != NULL && WorldInfo->Are_Meshes_Smoothed ()) { - for (vertidx = 0; vertidx < VertCount; vertidx++) { - if (Verts[vertidx].ShadeIndex == vertidx) { - Verts[vertidx].Normal += WorldInfo->Get_Shared_Vertex_Normal(Verts[vertidx].Position, Verts[vertidx].SharedSmGroup); - } - } - } - - /* - ** Propogate the accumulated normals to all of the other verts which share them - */ - for (vertidx = 0; vertidx < VertCount; vertidx++) { - int shadeindex = Verts[vertidx].ShadeIndex; - Verts[vertidx].Normal = Verts[shadeindex].Normal; - Verts[vertidx].Normal.Normalize(); - } -} - -/*********************************************************************************************** - * MeshBuilderClass::Remove_Degenerate_Faces -- discard invalid or duplicated faces * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 7/10/98 GTH : Created. * - *=============================================================================================*/ -void MeshBuilderClass::Remove_Degenerate_Faces(void) -{ - int faceidx; - FaceHasherClass facehasher; - UniqueArrayClass uniquefaces(FaceCount,FaceCount/4,&facehasher); - - for (faceidx = 0; faceidx < FaceCount; faceidx++) { - if (!Faces[faceidx].Is_Degenerate()) { - uniquefaces.Add(Faces[faceidx]); - } - } - - FaceCount = uniquefaces.Count(); - AllocFaceCount = uniquefaces.Count(); - CurFace = FaceCount; - - delete[] Faces; - Faces = new FaceClass[AllocFaceCount]; - - for (faceidx = 0; faceidx < FaceCount; faceidx++) { - Faces[faceidx] = uniquefaces.Get(faceidx); - } -} - - - -/*********************************************************************************************** - * MeshBuilderClass::Compute_Mesh_Stats -- compute some stats about the mesh * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/19/98 GTH : Created. * - *=============================================================================================*/ -void MeshBuilderClass::Compute_Mesh_Stats(void) -{ - int pass; - int stage; - int face_index; - int vert_index; - - int tex_index[MAX_PASSES][MAX_STAGES]; - int shader_index[MAX_PASSES]; - int vmat_index[MAX_PASSES]; - - Stats.Reset(); - - for (pass = 0; passX = Verts[0].Position.X; - set_min->Y = Verts[0].Position.Y; - set_min->Z = Verts[0].Position.Z; - set_max->X = Verts[0].Position.X; - set_max->Y = Verts[0].Position.Y; - set_max->Z = Verts[0].Position.Z; - - for (i=0; iX) set_min->X = Verts[i].Position.X; - if (Verts[i].Position.Y < set_min->Y) set_min->Y = Verts[i].Position.Y; - if (Verts[i].Position.Z < set_min->Z) set_min->Z = Verts[i].Position.Z; - - if (Verts[i].Position.X > set_max->X) set_max->X = Verts[i].Position.X; - if (Verts[i].Position.Y > set_max->Y) set_max->Y = Verts[i].Position.Y; - if (Verts[i].Position.Z > set_max->Z) set_max->Z = Verts[i].Position.Z; - } -} - - -/*********************************************************************************************** - * MeshBuilderClass::Compute_Bounding_Sphere -- computes a bounding sphere for the mesh * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/29/98 GTH : Created. * - *=============================================================================================*/ -void MeshBuilderClass::Compute_Bounding_Sphere(Vector3 * set_center,float * set_radius) -{ - int i; - double dx,dy,dz; - - // bounding sphere - // Using the algorithm described in Graphics Gems I page 301. - // This algorithm supposedly generates a bounding sphere within - // 5% of the optimal one but is much faster and simpler to implement. - Vector3 xmin(Verts[0].Position.X,Verts[0].Position.Y,Verts[0].Position.Z); - Vector3 xmax(Verts[0].Position.X,Verts[0].Position.Y,Verts[0].Position.Z); - Vector3 ymin(Verts[0].Position.X,Verts[0].Position.Y,Verts[0].Position.Z); - Vector3 ymax(Verts[0].Position.X,Verts[0].Position.Y,Verts[0].Position.Z); - Vector3 zmin(Verts[0].Position.X,Verts[0].Position.Y,Verts[0].Position.Z); - Vector3 zmax(Verts[0].Position.X,Verts[0].Position.Y,Verts[0].Position.Z); - - - // FIRST PASS: - // finding the 6 minima and maxima points - for (i=1; i xmax.X) { - xmax.X = Verts[i].Position.X; xmax.Y = Verts[i].Position.Y; xmax.Z = Verts[i].Position.Z; - } - if (Verts[i].Position.Y < ymin.Y) { - ymin.X = Verts[i].Position.X; ymin.Y = Verts[i].Position.Y; ymin.Z = Verts[i].Position.Z; - } - if (Verts[i].Position.Y > ymax.Y) { - ymax.X = Verts[i].Position.X; ymax.Y = Verts[i].Position.Y; ymax.Z = Verts[i].Position.Z; - } - if (Verts[i].Position.Z < zmin.Z) { - zmin.X = Verts[i].Position.X; zmin.Y = Verts[i].Position.Y; zmin.Z = Verts[i].Position.Z; - } - if (Verts[i].Position.Z > zmax.Z) { - zmax.X = Verts[i].Position.X; zmax.Y = Verts[i].Position.Y; zmax.Z = Verts[i].Position.Z; - } - } - - // xspan = distance between the 2 points xmin and xmax squared. - // same goes for yspan and zspan. - dx = xmax.X - xmin.X; - dy = xmax.Y - xmin.Y; - dz = xmax.Z - xmin.Z; - double xspan = dx*dx + dy*dy + dz*dz; - - dx = ymax.X - ymin.X; - dy = ymax.Y - ymin.Y; - dz = ymax.Z - ymin.Z; - double yspan = dx*dx + dy*dy + dz*dz; - - dx = zmax.X - zmin.X; - dy = zmax.Y - zmin.Y; - dz = zmax.Z - zmin.Z; - double zspan = dx*dx + dy*dy + dz*dz; - - - // Set points dia1 and dia2 to the maximally separated pair - // This will be the diameter of the initial sphere - Vector3 dia1 = xmin; - Vector3 dia2 = xmax; - double maxspan = xspan; - - if (yspan > maxspan) { - maxspan = yspan; - dia1 = ymin; - dia2 = ymax; - } - if (zspan > maxspan) { - maxspan = zspan; - dia1 = zmin; - dia2 = zmax; - } - - - // Compute initial center and radius and radius squared - Vector3 center; - center.X = (dia1.X + dia2.X) / 2.0f; - center.Y = (dia1.Y + dia2.Y) / 2.0f; - center.Z = (dia1.Z + dia2.Z) / 2.0f; - - dx = dia2.X - center.X; - dy = dia2.Y - center.Y; - dz = dia2.Z - center.Z; - - double radsqr = dx*dx + dy*dy + dz*dz; - double radius = sqrt(radsqr); - - - // SECOND PASS: - // Increment current sphere if any points fall outside of it. - for (i=0; i radsqr) { - - // this point was outside the old sphere, compute a new - // center point and radius which contains this point - double testrad = sqrt(testrad2); - - // adjust center and radius - radius = (radius + testrad) / 2.0; - radsqr = radius * radius; - - double oldtonew = testrad - radius; - center.X = (radius * center.X + oldtonew * Verts[i].Position.X) / testrad; - center.Y = (radius * center.Y + oldtonew * Verts[i].Position.Y) / testrad; - center.Z = (radius * center.Z + oldtonew * Verts[i].Position.Z) / testrad; - } - } - - *set_center = center; - *set_radius = radius; -} - -/*********************************************************************************************** - * MeshBuilderClass::Optimize_Mesh -- "optimize" the mesh * - * * - * Generates the array of unique vertices and sets the vertex indices in each face. Then * - * all of the faces are sorted by material and then into stripping order. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/15/98 GTH : Created. * - *=============================================================================================*/ -void MeshBuilderClass::Optimize_Mesh(bool compute_normals) -{ - int faceidx; - int vertidx; - int facevertidx; - - int match_normals = 0; - if (!compute_normals) { - match_normals = 1; - } - - VertexArrayClass unique_verts(FaceCount * 3,match_normals); - - /* - ** Find the min and max of the array of vertices - */ - Vector3 minv = Faces[0].Verts[0].Position; - Vector3 maxv = Faces[0].Verts[0].Position; - - for (faceidx = 0; faceidx < FaceCount; faceidx++) { - for (facevertidx = 0; facevertidx < 3; facevertidx++) { - - minv.Update_Min(Faces[faceidx].Verts[facevertidx].Position); - maxv.Update_Max(Faces[faceidx].Verts[facevertidx].Position); - } - } - - /* - ** Tell the vertex array the bounds so that it can do better hashing. - */ - unique_verts.Set_Bounds(minv,maxv); - - /* - ** Build the array of unique vertices - */ - for (faceidx = 0; faceidx < FaceCount; faceidx++) { - for (facevertidx = 0; facevertidx < 3; facevertidx++) { - Faces[faceidx].VertIdx[facevertidx] = - unique_verts.Submit_Vertex(Faces[faceidx].Verts[facevertidx]); - } - } - - /* - ** Assign the shared smoothing groups from each 'master' vertex - ** to each referring vertex. - */ - unique_verts.Propogate_Shared_Smooth_Groups(); - - /* - ** Replace the vertex array with the new unique vertex array - */ - VertCount = unique_verts.VertCount; - Verts = new VertClass[VertCount]; - - for (vertidx=0; vertidx v1) { int tmp = v0; v0 = v1; v1 = tmp; } - - // hash value for the edge - hash = (v0 + v1*119)&511; - - // seek edge from hash table - for (edge = edgehash[hash]; edge; edge = edge->Next) { - if (edge->Vertex[0] == v0 && edge->Vertex[1] == v1 && edge->MaterialIdx == mat) - break; - } - - if (edge) { - - // found the edge - edge->Poly[1] = i; - - } else { - - // create new edge and link it to hash table - edge = edgetab + edgecount++; - edge->Next = edgehash[hash]; - edgehash[hash] = edge; - edge->Vertex[0] = v0; - edge->Vertex[1] = v1; - edge->Poly[0] = i; - edge->Poly[1] = -1; - edge->MaterialIdx = mat; - } - - pedges[i].Edge[j] = edge; - } - } - - // the following loop inserts polygons into a new polygon list until - // all polygons have been inserted. Internally it attempts to create - // as long strips as possible while minimizing material switches - // and maintaining vertex reusage coherency to optimize geometry - // engine performance. - while (polysinserted < FaceCount) { - - int startpoly = -1; // best polygon found so far - int bestc = (1<<29); // best polygon weight value found so far - int startpass = 0; // should we start from pass 0 or 1? - int findpass; // 0 = same material only, 1 = any polygon - int c; // c = number of shared edges - - // first attempt to minimize material switches by choosing a polygon with same material - // as the starting poly. Basically what we want is the poly with same material with - // least shared edges and most recent vertices (as we'd like to start the strip from - // a 'corner polygon'). This pass is done only if mesh has multiple materials. - // The second pass scans through all polygons. - - // this loop is O(N*N) -> might turn a bit nasty on larger meshes. Try - // to figure out a way to solve the problem... - - for (findpass = startpass; findpass < 2; findpass++) - { - // loop through all polygons - for (i = 0; i < FaceCount; i++) { - - // if polygon not picked yet - if (premap[i]==-1) { - - // if material mismatch, cannot choose poly (except in pass 1) - if (findpass == 0 && Faces[i].TextureIndex[PolyOrderPass][PolyOrderStage] != lastmat) - continue; - - // calculate number of shared edges - for (c = 0, j = 0; j < 3; j++) { - - // if edge j is shared by two tris, - // use a weight factor of vCount for each edge - if (pedges[i].Edge[j]->Poly[1] >= 0) { - c += (vcount+1); - } - } - - // calculate delta vertex timestamp - for (j = 0; j < 3; j++) { - c += (vcount-vtimestamp[Faces[i].VertIdx[j]]); - } - - // if better than current best pick - if (c < bestc) { - bestc = c; - startpoly = i; - } - } - } - - // if we managed to find a suitable starting poly - if (startpoly != -1) - break; - } - - // track the fact that we created a new strip: - Stats.StripCount++; - - // update the material index - lastmat = Faces[startpoly].TextureIndex[PolyOrderPass][PolyOrderStage]; - newmat[polysinserted] = Faces[startpoly].TextureIndex[PolyOrderPass][PolyOrderStage]; - - // Add the selected polygon to the new polygon list. - // for each edge of start poly, see if the "other" polygon using that edge - // is untaken, if so, store the new polygon such that that edge index is last - - bool found_shared_edge = false; - newpolys[polysinserted] = Faces[startpoly]; - FaceClass * newpoly = &(newpolys[polysinserted]); - - for (int edge_index = 0; (edge_index < 3) && !found_shared_edge; edge_index++) { - - for (int side_index = 0; (side_index < 2) && !found_shared_edge; side_index++) { - - // if this polygon is not the startpoly and it is not "taken", then this edge is ok! - int poly = pedges[startpoly].Edge[edge_index]->Poly[side_index]; - if ((poly != -1) && (poly != startpoly) && (premap[poly] == -1)) { - - // find vert which is not on the final edge - int first_vert = -1; - for (int vidx=0; vidx<3; vidx++) { - if ( (newpoly->VertIdx[vidx] != pedges[startpoly].Edge[edge_index]->Vertex[0]) && - (newpoly->VertIdx[vidx] != pedges[startpoly].Edge[edge_index]->Vertex[1])) { - - first_vert = newpoly->VertIdx[vidx]; - break; - } - } - assert(first_vert != -1); - - // rotate the vertex indices until first_vert is the index of VertIdx[0] - while (newpoly->VertIdx[0] != first_vert) { - int tmp = newpoly->VertIdx[0]; - newpoly->VertIdx[0] = newpoly->VertIdx[1]; - newpoly->VertIdx[1] = newpoly->VertIdx[2]; - newpoly->VertIdx[2] = tmp; - } - - // ok, we found a shareable edge and adjusted our poly so the strip - // will start with it. Now break out of this loop... - found_shared_edge = true; - break; - } - } - } - - // if a shared edge wasn't found, just copy the poly - if (!found_shared_edge) { - newpolys[polysinserted] = Faces[startpoly]; - } - - // Increment the count. Mark the vertices as used (i.e. update their timestamps) - premap[startpoly] = polysinserted; - polysinserted++; - - for (i = 0; i < 3; i++) { - if (vtimestamp[Faces[startpoly].VertIdx[i]]==-1) { - vtimestamp[Faces[startpoly].VertIdx[i]] = vcount++; - } - } - - // If we have no shared edges, this is a lone poly, start another strip - if (pedges[startpoly].Edge[0]->Poly[1] == -1 && - pedges[startpoly].Edge[1]->Poly[1] == -1 && - pedges[startpoly].Edge[2]->Poly[1] == -1) - continue; - - // Build the strip starting from the polygon chosen in the previous loop - int vFIFO[2]; // vertex fifo - int scnt = 0; // strip index count (for poly order flipping) - int nextpoly = startpoly; - - vFIFO[0] = newpoly->VertIdx[1]; // setup the vFIFO - vFIFO[1] = newpoly->VertIdx[2]; - - while (nextpoly != -1) - { - startpoly = nextpoly; - nextpoly = -1; - - for (i = 0; i < 3; i++) { - - // if edge 'i' of startpoly matches the vertices in the fifo - if ((pedges[startpoly].Edge[i]->Vertex[0] == vFIFO[0] && pedges[startpoly].Edge[i]->Vertex[1] == vFIFO[1]) || - (pedges[startpoly].Edge[i]->Vertex[1] == vFIFO[0] && pedges[startpoly].Edge[i]->Vertex[0] == vFIFO[1])) - { - - for (j = 0; j < 2; j++) { - - // if poly 'j' attached to this edge has not been used already, use it! - if (pedges[startpoly].Edge[i]->Poly[j] > -1 && - premap[pedges[startpoly].Edge[i]->Poly[j]] == -1) - { - nextpoly = pedges[startpoly].Edge[i]->Poly[j]; - goto found; - } - } - } - } - - // couldn't find another poly, break from loop - break; - - found:; - - // now, find the new vertex (two verts are on the edge, find the third) - int nw = -1; - for (i = 0; i < 3; i++) { - if (Faces[nextpoly].VertIdx[i] != vFIFO[0] && Faces[nextpoly].VertIdx[i] != vFIFO[1]) { - nw = i; - break; - } - } - assert(nw != -1); - - int new_vindex = Faces[nextpoly].VertIdx[nw]; - - newmat[polysinserted] = Faces[nextpoly].TextureIndex[PolyOrderPass][PolyOrderStage]; - - // add the poly to the newpolys array. - newpolys[polysinserted].VertIdx[0] = vFIFO[0]; - newpolys[polysinserted].VertIdx[1] = vFIFO[1]; - newpolys[polysinserted].VertIdx[2] = new_vindex; - - // if we are on an even triangle, swap the vertex ordering - if (!(scnt&1)) { - int tmp = newpolys[polysinserted].VertIdx[0]; - newpolys[polysinserted].VertIdx[0] = newpolys[polysinserted].VertIdx[1]; - newpolys[polysinserted].VertIdx[1] = tmp; - } - - // push the new vertex into the fifo - vFIFO[0] = vFIFO[1]; - vFIFO[1] = new_vindex; - - if (vtimestamp[new_vindex]==-1) { - vtimestamp[new_vindex] = vcount++; - } - - premap[nextpoly] = polysinserted++; - scnt++; - } - - // scnt+1 is the number of polys that were added to the strip - Stats.AvgStripLength += scnt+1; - if (scnt+1 > Stats.MaxStripLength) { - Stats.MaxStripLength = scnt+1; - } - } - - // Use the premap array to get the rest of the info into the new face table, - for (i=0; iTextureIndex[0][0] < f1->TextureIndex[0][0]) return -1; - if (f0->TextureIndex[0][0] > f1->TextureIndex[0][0]) return 1; - return 0; -} - -inline int tex_compare(const void * elem1,const void * elem2,int pass,int stage) -{ - MeshBuilderClass::FaceClass * f0 = (MeshBuilderClass::FaceClass *)elem1; - MeshBuilderClass::FaceClass * f1 = (MeshBuilderClass::FaceClass *)elem2; - - /* - ** Primarily, sort by texture - */ - if (f0->TextureIndex[pass][stage] < f1->TextureIndex[pass][stage]) return -1; - if (f0->TextureIndex[pass][stage] > f1->TextureIndex[pass][stage]) return 1; - - /* - ** Secondarily, sort by vertex material index - */ - if (f0->Verts[0].VertexMaterialIndex[pass] < f1->Verts[0].VertexMaterialIndex[pass]) return -1; - if (f0->Verts[0].VertexMaterialIndex[pass] > f1->Verts[0].VertexMaterialIndex[pass]) return 1; - - return 0; -} - -int pass0_stage0_compare(const void *elem1, const void *elem2) -{ - return tex_compare(elem1,elem2,0,0); -} - -int pass0_stage1_compare(const void *elem1, const void *elem2) -{ - return tex_compare(elem1,elem2,0,1); -} - -int pass1_stage0_compare(const void *elem1, const void *elem2) -{ - return tex_compare(elem1,elem2,1,0); -} - -int pass1_stage1_compare(const void *elem1, const void *elem2) -{ - return tex_compare(elem1,elem2,1,1); -} - -int pass2_stage0_compare(const void *elem1, const void *elem2) -{ - return tex_compare(elem1,elem2,2,0); -} - -int pass2_stage1_compare(const void *elem1, const void *elem2) -{ - return tex_compare(elem1,elem2,2,1); -} - -int pass3_stage0_compare(const void *elem1, const void *elem2) -{ - return tex_compare(elem1,elem2,3,0); -} - -int pass3_stage1_compare(const void *elem1, const void *elem2) -{ - return tex_compare(elem1,elem2,3,1); -} - -int vertex_compare(const void *elem1, const void *elem2) -{ - MeshBuilderClass::VertClass * v0 = (MeshBuilderClass::VertClass *)elem1; - MeshBuilderClass::VertClass * v1 = (MeshBuilderClass::VertClass *)elem2; - - /* - ** Sort first by bone index, then by vertex material in pass0 - */ - if (v0->BoneIndex < v1->BoneIndex) return -1; - if (v0->BoneIndex > v1->BoneIndex) return 1; - - if (v0->VertexMaterialIndex[0] < v1->VertexMaterialIndex[0]) return -1; - if (v0->VertexMaterialIndex[0] > v1->VertexMaterialIndex[0]) return 1; - - return 0; -} - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/meshbuild.h b/Generals/Code/Tools/WW3D/max2w3d/meshbuild.h deleted file mode 100644 index 3173b7e6e20..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/meshbuild.h +++ /dev/null @@ -1,379 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/meshbuild.h $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 5/22/00 3:17p $* - * * - * $Revision:: 12 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef MESHBUILD_H -#define MESHBUILD_H - -#include "always.h" -#include "vector2.h" -#include "vector3.h" -#include "BITTYPE.H" - -#include - -/* -** WorldInfoClass -** Abstract base class that defines an interface for 'world information'. -** This class provides the mesh builder with information about the world -** outside of its mesh. -*/ -class WorldInfoClass -{ - public: - WorldInfoClass(void) { } - virtual ~WorldInfoClass(void) { } - - // Public methods - virtual Vector3 Get_Shared_Vertex_Normal (Vector3 pos, int smgroup) = 0; - virtual bool Are_Meshes_Smoothed (void) const { return true; } -}; - -/* -** MeshBuilderClass -** This class will process meshes for you, splitting all vertices which do not -** share all parameters (such as texture coordinates), sort the polygons by -** material, and put them into strip order. -** -** To "build" a mesh: -** 1. Reset the builder with the number of polys you're going to sumbit -** 2. Enable the vertex channels that you want -** 3. Submit each face in the form of a FaceClass -** 4. Call Build_Mesh -** -** To use the results: -** 1. Call Get_Vertex_Count and Get_Face_Count to get the counts -** 2. Loop through the verts, looking at each one using Get_Vertex -** 3. Loop through the faces, looking at each one using Get_Face -** -** *NOTE* This class is meant to be relatively self-sufficient. It is used in a -** variety of different applications which are built on completely different -** code-bases. Do not introduce dependencies into this module lightly! :-) -*/ -class MeshBuilderClass -{ - -public: - - enum { - STATE_ACCEPTING_INPUT = 0, // mesh builder is accepting input triangles - STATE_MESH_PROCESSED, // mesh builder has processed the mesh - - MAX_PASSES = 4, // maximum number of material passes supported - MAX_STAGES = 2, // maximum number of texture stages supported in a single pass - }; - - /* - ** Constructor, Destructor - */ - MeshBuilderClass(int pass_count=1,int face_count_guess=255,int face_count_growth_rate=64); - ~MeshBuilderClass(void); - - /* - ** VertClass. The MeshBuilder deals with vertices in this format. - */ - class VertClass - { - public: - VertClass(void) { Reset(); } - void Reset(void); - - public: - - Vector3 Position; // position of the vertex - Vector3 Normal; // vertex normal (can be calculated by mesh builder) - int SmGroup; // smoothing group of the face this vertex was submitted with - int Id; // id of the vertex, must match for vert to be welded, ok at zero if you don't care - int BoneIndex; // bone influence if the mesh is a skin - - int MaxVertColIndex; // Index into the Max mesh.vertCol array of this vertex. - - Vector2 TexCoord[MAX_PASSES][MAX_STAGES]; - Vector3 DiffuseColor[MAX_PASSES]; // diffuse color - Vector3 SpecularColor[MAX_PASSES]; // specular color - Vector3 DiffuseIllumination[MAX_PASSES]; // pre-calced diffuse illum - float Alpha[MAX_PASSES]; // alpha - int VertexMaterialIndex[MAX_PASSES]; // vertex material index - - int Attribute0; // user-set attributes (passed on through...) - int Attribute1; // user-set attributes - - // These values are set up by the mesh builder: - - int SharedSmGroup; // smooth bits that were on in all faces that contributed to this final vertex - int UniqueIndex; // used internally! - int ShadeIndex; // used internally! - VertClass * NextHash; // used internally! - - }; - - /* - ** FaceClass. The MeshBuilder deals faces in this format. When inputing faces, set the - ** top half of the struct and the builder will fill in the bottom (vertex indices, normal, - ** and distance). - */ - class FaceClass - { - public: - FaceClass(void) { Reset(); } - void Reset(void); // reset this face - - public: - VertClass Verts[3]; // array of 3 verts - int SmGroup; // smoothing group - int Index; // user-set index of the face - int Attributes; // user-set attributes - int TextureIndex[MAX_PASSES][MAX_STAGES]; // texture to use for each pass - int ShaderIndex[MAX_PASSES]; // shader for each pass - uint32 SurfaceType; // surface type identifier - - int AddIndex; // set by builder: index of addition - int VertIdx[3]; // set by builder: "optimized" vertex indices - Vector3 Normal; // set by builder: Face normal - float32 Dist; // set by builder: Plane distance - - void Compute_Plane(void); - bool operator != (const FaceClass & that) { return !(*this == that); } - bool operator == (const FaceClass & /*that*/) { return false; } - bool Is_Degenerate(void); - - friend class MeshBuilderClass; - }; - - /* - ** To "build" a mesh: - ** 1. Reset the builder with the approximate number of polys you're going to sumbit, etc. - ** 3. Submit each face in the form of a FaceClass, set only the fields you need (leave others at default) - ** 4. Call Build_Mesh - */ - void Reset(int pass_count,int face_count_guess,int face_count_growth_rate); - int Add_Face(const FaceClass & face); - void Build_Mesh(bool compute_normals); - - /* - ** Optional controls: - ** If one of your passes has more textures than another, you may wish to do the - ** stripping and sorting based on that channel. By default, everything will - ** be stripped and sorted based on pass 0, stage 0 - ** Sort_Vertices can be used to order the vertices arbitrarily. I use it to - ** sort them according to the bone they are attached for skin meshes. - */ - void Set_Polygon_Ordering_Channel(int pass,int texstage); - - /* - ** To use the results: - ** 1. Call Get_Vertex_Count and Get_Face_Count to get the counts - ** 2. Loop through the verts, looking at each one using Get_Vertex - ** 3. Loop through the faces, looking at each one using Get_Face - */ - int Get_Pass_Count(void) const; - int Get_Vertex_Count(void) const; - int Get_Face_Count(void) const; - const VertClass & Get_Vertex(int index) const; - const FaceClass & Get_Face(int index) const; - - /* - ** Access to the Vertices and Faces for modifications. This is used by - ** the max plugin when generating a skin mesh for example. Be careful - ** what you do to them. (I haven't thought through all of the - ** possible things you might do to mess up my nice clean mesh...). - */ - VertClass & Get_Vertex(int index); - FaceClass & Get_Face(int index); - - /* - ** Bounding volume information about the mesh. These functions can compute - ** various types of bounding volumes for the mesh you just processed... - */ - void Compute_Bounding_Box(Vector3 * set_min,Vector3 * set_max); - void Compute_Bounding_Sphere(Vector3 * set_center,float * set_radius); - - /* - ** World information managment. Used to give the mesh builder information - ** about the world outside of its mesh. - */ - WorldInfoClass * Peek_World_Info(void) const { return WorldInfo; } - void Set_World_Info(WorldInfoClass *world_info) { WorldInfo = world_info; } - - /* - ** Mesh Stats, mainly lots of flags for whether this mesh has various - ** channels of information. - */ - struct MeshStatsStruct - { - void Reset(void); - - bool HasTexture[MAX_PASSES][MAX_STAGES]; // has at least one texture in given pass/stage - bool HasShader[MAX_PASSES]; // has at least one shader in given pass - bool HasVertexMaterial[MAX_PASSES]; // has at least one vert material in given pass - - bool HasPerPolyTexture[MAX_PASSES][MAX_STAGES]; // has 2+ textures in given pass/stage - bool HasPerPolyShader[MAX_PASSES]; // has 2+ shaders in given pass - bool HasPerVertexMaterial[MAX_PASSES]; // has 2+ vertex materials in given pass - - bool HasDiffuseColor[MAX_PASSES]; // has diffuse colors in given pass - bool HasSpecularColor[MAX_PASSES]; // has specular colors in given pass - bool HasDiffuseIllumination[MAX_PASSES]; // has diffuse illum in given pass - - bool HasTexCoords[MAX_PASSES][MAX_STAGES]; // has texture coords in given pass - - int UVSplitCount; // how many vertices were split due solely to UV discontinuities - int StripCount; // number of strips that were created - int MaxStripLength; // longest strip created - float AvgStripLength; // average strip length - }; - - const MeshStatsStruct & Get_Mesh_Stats(void) const; - -private: - - void Free(void); - void Compute_Mesh_Stats(void); - void Optimize_Mesh(bool compute_normals); - void Strip_Optimize_Mesh(void); - void Remove_Degenerate_Faces(void); - void Compute_Face_Normals(void); - bool Verify_Face_Normals(void); - void Compute_Vertex_Normals(void); - void Grow_Face_Array(void); - void Sort_Vertices(void); - - /* - ** Winged edge stuff is used by the strip optimize function - */ - struct WingedEdgeStruct - { - int MaterialIdx; - WingedEdgeStruct * Next; - int Vertex[2]; - int Poly[2]; - }; - - struct WingedEdgePolyStruct - { - WingedEdgeStruct * Edge[3]; - }; - - - int State; // is the builder accepting input or already processed the mesh. - int PassCount; // number of render passes for this mesh - int FaceCount; // number of faces - FaceClass * Faces; // array of faces - int InputVertCount; // number of input verts; - int VertCount; // number of verts; - VertClass * Verts; // array of verts; - int CurFace; // current face being added - - WorldInfoClass * WorldInfo; // obj containing info about other meshes in the world - - MeshStatsStruct Stats; // internally useful junk about the mesh being processed. - int PolyOrderPass; // order the polys using the texture indices in this pass - int PolyOrderStage; // order the polys using the texture indices in this stage - - int AllocFaceCount; // number of faces allocated - int AllocFaceGrowth; // growth rate of face array -}; - -inline void MeshBuilderClass::Set_Polygon_Ordering_Channel(int pass,int texstage) -{ - assert(pass >= 0); - assert(pass < MAX_PASSES); - assert(texstage >= 0); - assert(texstage < MAX_STAGES); - - PolyOrderPass = pass; - PolyOrderStage = texstage; -} - -inline int MeshBuilderClass::Get_Pass_Count(void) const -{ - return PassCount; -} - -inline int MeshBuilderClass::Get_Vertex_Count(void) const -{ - assert(State == STATE_MESH_PROCESSED); - return VertCount; -} - -inline int MeshBuilderClass::Get_Face_Count(void) const -{ - assert(State == STATE_MESH_PROCESSED); - return FaceCount; -} - -inline const MeshBuilderClass::VertClass & MeshBuilderClass::Get_Vertex(int index) const -{ - assert(State == STATE_MESH_PROCESSED); - assert(index >= 0); - assert(index < VertCount); - return Verts[index]; -} - -inline const MeshBuilderClass::FaceClass & MeshBuilderClass::Get_Face(int index) const -{ - assert(State == STATE_MESH_PROCESSED); - assert(index >= 0); - assert(index < FaceCount); - return Faces[index]; -} - -inline MeshBuilderClass::VertClass & MeshBuilderClass::Get_Vertex(int index) -{ - assert(State == STATE_MESH_PROCESSED); - assert(index >= 0); - assert(index < VertCount); - return Verts[index]; -} - -inline MeshBuilderClass::FaceClass & MeshBuilderClass::Get_Face(int index) -{ - assert(State == STATE_MESH_PROCESSED); - assert(index >= 0); - assert(index < FaceCount); - return Faces[index]; -} - -inline const MeshBuilderClass::MeshStatsStruct & MeshBuilderClass::Get_Mesh_Stats(void) const -{ - assert(State == STATE_MESH_PROCESSED); - return Stats; -} - -#endif diff --git a/Generals/Code/Tools/WW3D/max2w3d/meshcon.cpp b/Generals/Code/Tools/WW3D/max2w3d/meshcon.cpp deleted file mode 100644 index 7fc479a334e..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/meshcon.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/meshcon.cpp 34 10/27/00 4:12p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G Math Library * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/meshcon.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/27/00 10:39a $* - * * - * $Revision:: 34 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * MeshConnectionsClass::MeshConnectionsClass -- Constructor * - * MeshConnectionsClass::~MeshConnectionsClass -- Destructor * - * MeshConnectionsClass::Get_Aggregate_Data -- name and bone for the given aggregate * - * MeshConnectionsClass::Get_Proxy_Data -- name and transform for the specified proxy object * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "meshcon.h" -#include "util.h" -#include "SnapPoints.h" -#include "w3dappdata.h" -#include "geometryexporttask.h" -#include "geometryexportcontext.h" - - -/*********************************************************************************************** - * MeshConnectionsClass::MeshConnectionsClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/19/2000 gth : New version which uses the GeometryExportTasks * - *=============================================================================================*/ -MeshConnectionsClass::MeshConnectionsClass -( - DynamicVectorClass sub_object_list, - GeometryExportContextClass & context -) : - CurTime(context.CurTime), - Origin(context.Origin) -{ - unsigned int i; - assert(Origin != NULL); - - /* - ** Set the name, count the sub-objects and aggregates - */ - Set_W3D_Name(Name,context.ModelName); - - /* - ** For each sub-object, record the bone it is attached to and its name - */ - int count = sub_object_list.Count(); - for (i=0; iGet_Full_Name(con.ObjectName,sizeof(con.ObjectName)); - con.BoneIndex = sub_object_list[i]->Get_Bone_Index(); - con.MeshINode = sub_object_list[i]->Get_Object_Node(); - - if (sub_object_list[i]->Is_Aggregate()) { - Aggregates.Add(con); - } else if (sub_object_list[i]->Is_Proxy()) { - ProxyObjects.Add(con); - } else { - SubObjects.Add(con); - } - } -} - - -/*********************************************************************************************** - * MeshConnectionsClass::~MeshConnectionsClass -- Destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/24/1997 GH : Created. * - *=============================================================================================*/ -MeshConnectionsClass::~MeshConnectionsClass(void) -{ -} - - -/*********************************************************************************************** - * MeshConnectionsClass::Get_Sub_Object_Data -- Returns the name and bone index for a given obj* - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/14/1999 AJA : Created. * - *=============================================================================================*/ -bool MeshConnectionsClass::Get_Sub_Object_Data (int mesh_idx, char **out_name, int *out_boneindex, - INode **out_inode) -{ - if (mesh_idx >= SubObjects.Count()) return false; - - if (out_name) - *out_name = SubObjects[mesh_idx].ObjectName; - if (out_boneindex) - *out_boneindex = SubObjects[mesh_idx].BoneIndex; - if (out_inode) - *out_inode = SubObjects[mesh_idx].MeshINode; - - return true; -} - - -/*********************************************************************************************** - * MeshConnectionsClass::Get_Aggregate_Data -- name and bone for the given aggregate * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/25/2000 gth : Created. * - *=============================================================================================*/ -bool MeshConnectionsClass::Get_Aggregate_Data(int mesh_idx, char **out_name, int *out_boneindex, - INode **out_inode) -{ - if (mesh_idx >= Aggregates.Count()) return false; - - if (out_name) - *out_name = Aggregates[mesh_idx].ObjectName; - if (out_boneindex) - *out_boneindex = Aggregates[mesh_idx].BoneIndex; - if (out_inode) - *out_inode = Aggregates[mesh_idx].MeshINode; - - return true; -} - - -/*********************************************************************************************** - * MeshConnectionsClass::Get_Proxy_Data -- name and transform for the specified proxy object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/2000 gth : Created. * - *=============================================================================================*/ -bool MeshConnectionsClass::Get_Proxy_Data(int index, char **out_name, int *out_boneindex, - INode **out_inode) -{ - if (index >= ProxyObjects.Count()) return false; - - if (out_name) - *out_name = ProxyObjects[index].ObjectName; - if (out_boneindex) - *out_boneindex = ProxyObjects[index].BoneIndex; - if (out_inode) - *out_inode = ProxyObjects[index].MeshINode; - - return true; -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/meshcon.h b/Generals/Code/Tools/WW3D/max2w3d/meshcon.h deleted file mode 100644 index 848e1fe0743..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/meshcon.h +++ /dev/null @@ -1,149 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/meshcon.h 26 10/27/00 4:11p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G Tools * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/meshcon.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/27/00 10:31a $* - * * - * $Revision:: 26 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef MESHCON_H -#define MESHCON_H - - -#ifndef ALWAYS_H -#include "always.h" -#endif - -#ifndef CHUNKIO_H -#include "chunkio.h" -#endif - -#ifndef NODELIST_H -#include "nodelist.h" -#endif - -#ifndef HIERSAVE_H -#include "hiersave.h" -#endif - -#ifndef W3D_FILE -#include "w3d_file.h" -#endif - -#ifndef VECTOR_H -#include "Vector.H" -#endif - - -class GeometryExportTaskClass; -class GeometryExportContextClass; - - -struct ConnectionStruct -{ - ConnectionStruct(void) : BoneIndex(0),MeshINode(NULL) - { - memset(ObjectName,0,sizeof(ObjectName)); - } - - int BoneIndex; - char ObjectName[2*W3D_NAME_LEN]; - INode * MeshINode; - - // required by DynamicVectorClass... - operator == (const ConnectionStruct & that) { return false; } - operator != (const ConnectionStruct & that) { return !(*this==that); } -}; - - -/** -** MeshConnectionsClass -** This class is the description of a hierarchical model. It contains an array of "ConnectionStructs" which -** associate pieces of geometry with nodes in a hierarchy tree. -*/ -class MeshConnectionsClass -{ -public: - - MeshConnectionsClass( DynamicVectorClass sub_objects, - GeometryExportContextClass & context ); - - ~MeshConnectionsClass(void); - - /* - ** Get the name of the mesh connections object (will be - ** the name of the runtime HierarchyModel that this - ** object is describing. - */ - const char * Get_Name(void) const { return Name; } - - /* - ** Get the total number of meshes (of all types). - */ - int Get_Sub_Object_Count (void) const { return SubObjects.Count(); } - int Get_Aggregate_Count(void) const { return Aggregates.Count(); } - int Get_Proxy_Count(void) const { return ProxyObjects.Count(); } - - /* - ** Retrieve data about the mesh of the given index. - ** out_name - name of the mesh is passed back by setting the char* pointed to by this value. - ** out_boneindex - the index of the bone used is passed back by setting the int pointed to by this value. - ** out_inode - mesh INode is passed by setting the INode* pointed to by this value. If this - ** parameter is NULL, the value is not passed back. - */ - bool Get_Sub_Object_Data(int index, char **out_name, int *out_boneindex, INode **out_inode = NULL); - bool Get_Aggregate_Data(int index, char **out_name, int *out_boneindex, INode **out_inode = NULL); - bool Get_Proxy_Data(int index, char **out_name, int *out_boneindex, INode **out_inode = NULL); - - /* - ** Returns the origin node used by this model. - */ - INode * Get_Origin (void) const { return Origin; } - -private: - - TimeValue CurTime; - INode * Origin; - - char Name[W3D_NAME_LEN]; - - // array of SubObjects - DynamicVectorClass SubObjects; - DynamicVectorClass Aggregates; - DynamicVectorClass ProxyObjects; - - -}; - - -#endif /*MESHCON_H*/ \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/meshsave.cpp b/Generals/Code/Tools/WW3D/max2w3d/meshsave.cpp deleted file mode 100644 index 49955e87d15..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/meshsave.cpp +++ /dev/null @@ -1,2246 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/meshsave.cpp 107 8/21/01 10:28a Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G * - * * - * File Name : MESHSAVE.CPP * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 06/10/97 * - * * - * Last Update : 10/20/1999997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * MeshSaveClass::MeshSaveClass -- constructor, processes a Max mesh * - * MeshSaveClass::~MeshSaveClass -- destructor, frees all allocated memory * - * MeshSaveClass::write_verts -- write the vertex chunk into a wtm file * - * MeshSaveClass::write_header -- write a mesh header chunk into a wtm file * - * MeshSaveClass::Write_To_File -- Append the mesh to an open wtm file * - * MeshSaveClass::write_normals -- writes the vertex normals chunk into a wtm file * - * MeshSaveClass::write_vert_normals -- Writes the surrender normal chunk into a wtm file * - * MeshSaveClass::write_triangles -- Write the triangles chunk into a wtm file. * - * MeshSaveClass::write_sr_triangles -- writes the triangles in surrender friendly format * - * MeshSaveClass::write_triangles -- write the triangles chunk * - * MeshSaveClass::compute_surrender_vertex -- Compute the surrender vertex normals * - * MeshSaveClass::setup_material -- Gets the texture names and base colors for a material * - * MeshSaveClass::compute_bounding_volumes -- computes a bounding box and bounding sphere for* - * MeshSaveClass::set_transform -- set the default transformation matrix for the mesh * - * MeshSaveClass::compute_physical_properties -- computes the volume and moment of inertia * - * MeshSaveClass::prep_mesh -- pre-transform the MAX mesh by a specified matrix * - * MeshSaveClass::write_user_text -- write the user text chunk * - * MeshSaveClass::get_htree_bone_index_for_inode -- searches the htree for the given INode * - * MeshSaveClass::get_skin_modifier_objects -- Searches for the WWSkin modifier for this mes * - * MeshSaveClass::inv_deform_mesh -- preprocess the mesh for skinning * - * MeshSaveClass::create_materials -- create the materials for this mesh * - * MeshSaveClass::write_ps2_shaders -- Write shaders specific to the PS2 in their own chunk. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "meshsave.h" -#include -#include -#include -#include "gamemtl.h" -#include "errclass.h" -#include "vxl.h" -#include "vxldbg.h" -#include "nodelist.h" -#include "hiersave.h" -#include "util.h" -#include "w3dappdata.h" -#include "skin.h" -#include "skindata.h" -#include "meshbuild.h" -#include "AlphaModifier.h" -#include "aabtreebuilder.h" -#include "exportlog.h" - - -static char _string1[512]; -const int VOXEL_RESOLUTION = 64; // resolution to use when computing I, V and CM - -#define DEBUG_VOXELS 0 -#define MIN_AABTREE_POLYGONS 8 -#define DIFFUSE_HOUSECOLOR_TEXTURE_PREFIX 0x4443485A //'ZHCD' prefix put on all code generated textures -#define DIFFUSE_COLOR_TEXTURE_PREFIX 0x44434d5A //'ZMCD' prefix put on all code generated textures -#define DIFFUSE_COLOR_TEXTURE_MASK 0x4443005A - -/************************************************************************************ -** -** Compute the determinant of the 3x3 portion of the given matrix -** -************************************************************************************/ -float Compute_3x3_Determinant(const Matrix3 & tm) -{ - float det = tm[0][0] * (tm[1][1]*tm[2][2] - tm[1][2]*tm[2][1]); - det -= tm[0][1] * (tm[1][0]*tm[2][2] - tm[1][2]*tm[2][0]); - det += tm[0][2] * (tm[1][0]*tm[2][1] - tm[1][1]*tm[2][0]); - - return det; -} - -/************************************************************************************ -** -** check if this is a mesh which should use a simple rendering method. I don't -** compute vertex normals or store u-v's in that case (prevents vertex splitting) -** -************************************************************************************/ -bool use_simple_rendering(int geo_type) -{ - geo_type &= W3D_MESH_FLAG_GEOMETRY_TYPE_MASK; - - if ( (geo_type == OBSOLETE_W3D_MESH_FLAG_GEOMETRY_TYPE_SHADOW) || - (geo_type == W3D_MESH_FLAG_GEOMETRY_TYPE_AABOX) || - (geo_type == W3D_MESH_FLAG_GEOMETRY_TYPE_OBBOX) ) - { - return true; - } else { - return false; - } -} - -/************************************************************************************ -** -** build the bitfield of W3D mesh attributes for the given node -** -************************************************************************************/ -uint32 setup_mesh_attributes(INode * node) -{ - uint32 attributes = W3D_MESH_FLAG_NONE; - - /* - ** Mesh will be one of: - ** W3D_MESH_FLAG_NONE, - ** W3D_MESH_FLAG_COLLISION_BOX, - ** W3D_MESH_FLAG_SKIN, - ** W3D_MESH_FLAG_ALIGNED - ** W3D_MESH_FLAG_ORIENTED - */ - if (Is_Collision_AABox(node)) { - attributes = W3D_MESH_FLAG_GEOMETRY_TYPE_AABOX; - } else if (Is_Collision_OBBox(node)) { - attributes = W3D_MESH_FLAG_GEOMETRY_TYPE_OBBOX; - } else if (Is_Skin(node)) { - attributes = W3D_MESH_FLAG_GEOMETRY_TYPE_SKIN; - } else if (Is_Camera_Aligned_Mesh(node)) { - attributes = W3D_MESH_FLAG_GEOMETRY_TYPE_CAMERA_ALIGNED; - } else if (Is_Camera_Oriented_Mesh(node)) { - attributes = W3D_MESH_FLAG_GEOMETRY_TYPE_CAMERA_ORIENTED; - } - - /* - ** And, a mesh may have one or more types of collision detection enabled. - ** W3D_MESH_FLAG_COLLISION_TYPE_PHYSICAL - ** W3D_MESH_FLAG_COLLISION_TYPE_PROJECTILE - ** However, if the mesh is SKIN, SHADOW, ALIGNED, ORIENTED or NULL, don't let - ** the collision bits get set... - */ - if ( attributes != W3D_MESH_FLAG_GEOMETRY_TYPE_SKIN && - attributes != W3D_MESH_FLAG_GEOMETRY_TYPE_CAMERA_ALIGNED && - attributes != W3D_MESH_FLAG_GEOMETRY_TYPE_CAMERA_ORIENTED ) - { - - if (Is_Physical_Collision(node)) { - attributes |= W3D_MESH_FLAG_COLLISION_TYPE_PHYSICAL; - } - - if (Is_Projectile_Collision(node)) { - attributes |= W3D_MESH_FLAG_COLLISION_TYPE_PROJECTILE; - } - - if (Is_Vis_Collision(node)) { - attributes |= W3D_MESH_FLAG_COLLISION_TYPE_VIS; - } - - if (Is_Camera_Collision(node)) { - attributes |= W3D_MESH_FLAG_COLLISION_TYPE_CAMERA; - } - - if (Is_Vehicle_Collision(node)) { - attributes |= W3D_MESH_FLAG_COLLISION_TYPE_VEHICLE; - } - - } - - /* - ** A mesh may have one of the following bits set as well - */ - if (Is_Hidden(node)) { - attributes |= W3D_MESH_FLAG_HIDDEN; - } - if (Is_Two_Sided(node)) { - attributes |= W3D_MESH_FLAG_TWO_SIDED; - } - if (Is_Shadow(node)) { - attributes |= W3D_MESH_FLAG_CAST_SHADOW; - } - if (Is_Shatterable(node)) { - attributes |= W3D_MESH_FLAG_SHATTERABLE; - } - if (Is_NPatchable(node)) { - attributes |= W3D_MESH_FLAG_NPATCHABLE; - } - - return attributes; -} - - - -/*********************************************************************************************** - * MeshSaveClass::MeshSaveClass -- constructor, processes a Max mesh * - * * - * This class takes a MAX mesh and computes the information for a W3D mesh or skin. * - * * - * INPUT: * - * * - * inode - the max INode containing the mesh/skin to export * - * exportspace - matrix defining the desired coordinate system for the mesh * - * htree - hierarchy tree that this mesh is being connected to * - * curtime - current time in Max. * - * meter - progress meter * - * mesh_name - name to use for the mesh * - * container_name - name of the container * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/10/1997 GH : Created. * - *=============================================================================================*/ -MeshSaveClass::MeshSaveClass -( - char * mesh_name, - char * container_name, - INode * inode, - const Mesh * input_mesh, - Matrix3 & exportspace, - W3DAppData2Struct & exportoptions, - HierarchySaveClass * htree, - TimeValue curtime, - Progress_Meter_Class & meter, - unsigned int * materialColors, - int &numMaterialColors, - int &numHouseColors, - char *materialColorTexture, - WorldInfoClass * world_info -) : - MaxINode(inode), - ExportOptions(exportoptions), - CurTime(curtime), - ExportSpace(exportspace), - HTree(htree), - UserText(NULL), - VertInfluences(NULL), - MaterialRemapTable(NULL) -{ - Mesh mesh = *input_mesh; // copy the mesh so we can modify it - Mtl * nodemtl = inode->GetMtl(); - DWORD wirecolor = inode->GetWireColor(); - - PS2Material = FALSE; - - // Check to see if the mesh uses PS2 game materials. If so, set a flag so - // that write_shaders will know to make a PS2 shader chunk. - if (nodemtl) { - if (nodemtl->ClassID() == PS2GameMaterialClassID) { - PS2Material = TRUE; - } else if (nodemtl->IsMultiMtl()) { - for (int i = 0; i < nodemtl->NumSubMtls(); i++) { - Mtl *sub = nodemtl->GetSubMtl(i); - if (sub->ClassID() == PS2GameMaterialClassID) { - PS2Material = TRUE; - } - } - } - } - - ////////////////////////////////////////////////////////////////////// - // Check if the mesh is being inverted by its transform. If this - // is the case, then we will need to reverse the winding of all - // polygons later. - ////////////////////////////////////////////////////////////////////// - Matrix3 objtm = MaxINode->GetObjectTM(curtime); - MeshInverted = (Compute_3x3_Determinant(objtm) < 0.0f); - - ////////////////////////////////////////////////////////////////////// - // Prep the mesh by transforming it by the delta between exportspace - // and this INodes current space - // (this is the delta between the bone and the mesh if one exists...) - ////////////////////////////////////////////////////////////////////// - MeshToExportSpace = objtm * Inverse(ExportSpace); - prep_mesh(mesh,MeshToExportSpace); - - ////////////////////////////////////////////////////////////////////// - // Prepare the mesh header. - ////////////////////////////////////////////////////////////////////// - assert(mesh_name != NULL); - assert(container_name != NULL); - - memset(&Header,0,sizeof(Header)); - Set_W3D_Name(Header.MeshName,mesh_name); - Set_W3D_Name(Header.ContainerName,container_name); - - Header.Version = W3D_CURRENT_MESH_VERSION; - Header.Attributes = setup_mesh_attributes(MaxINode); - - meter.Finish_In_Steps( - 3*Header.NumTris + // normals - Header.NumVertices + // surrender normals - 64 // voxelization - ); - - ExportLog::printf("\nProcessing Mesh: %s\n",Header.MeshName); - - ////////////////////////////////////////////////////////////////////// - // Enforce that we have enough data to actually make a mesh - ////////////////////////////////////////////////////////////////////// - if (mesh.getNumFaces() <= 0) { - throw ErrorClass("No Triangles in Mesh: %s",Header.MeshName); - } - - if (mesh.getNumVerts() <= 0) { - throw ErrorClass("No Vertices in Mesh: %s",Header.MeshName); - } - - ////////////////////////////////////////////////////////////////////// - // process the materials - ////////////////////////////////////////////////////////////////////// - DebugPrint("processing materials\n"); - scan_used_materials(mesh,nodemtl); - create_materials(nodemtl,wirecolor,materialColorTexture); - - ////////////////////////////////////////////////////////////////////// - // what face and vertex attributes are we going to export? - ////////////////////////////////////////////////////////////////////// - Header.FaceChannels = W3D_FACE_CHANNEL_FACE; - Header.VertexChannels = W3D_VERTEX_CHANNEL_LOCATION; - - if (!use_simple_rendering(Header.Attributes)) { - Header.VertexChannels |= W3D_VERTEX_CHANNEL_NORMAL; - } - - if (((Header.Attributes & W3D_MESH_FLAG_GEOMETRY_TYPE_MASK) == W3D_MESH_FLAG_GEOMETRY_TYPE_SKIN) && (HTree != NULL)) { - Header.VertexChannels |= W3D_VERTEX_CHANNEL_BONEID; - } - - ////////////////////////////////////////////////////////////////////// - // Process the mesh - ////////////////////////////////////////////////////////////////////// - Builder.Set_World_Info (world_info); - Build_Mesh(mesh, nodemtl, materialColors, numMaterialColors, numHouseColors); - - if (materialColorTexture) - { //diffuse color materials are replaced by textures - //set diffuse to 255,255,255 so it has no effect. - fix_diffuse_materials(numHouseColors != 0); - } - - ////////////////////////////////////////////////////////////////////// - // Create damage (deform) information for the mesh - ////////////////////////////////////////////////////////////////////// - Object *ref_obj = MaxINode->GetObjectRef (); - DeformSave.Initialize(Builder, ref_obj, mesh, &MeshToExportSpace); - - ////////////////////////////////////////////////////////////////////// - // Determine if the deformer should use alpha or v-color info - ////////////////////////////////////////////////////////////////////// - if (ExportOptions.Is_Vertex_Alpha_Enabled()) { - unsigned int alpha_passes = 0; - for (int pass=0; pass < MaterialDesc.Pass_Count(); pass++) { - if (MaterialDesc.Pass_Uses_Vertex_Alpha(pass)) { - alpha_passes |= (1 << pass); - } - } - DeformSave.Set_Alpha_Passes(alpha_passes); - } - - ////////////////////////////////////////////////////////////////////// - // Set the counts in the mesh header - ////////////////////////////////////////////////////////////////////// - Header.NumTris = Builder.Get_Face_Count(); - Header.NumVertices = Builder.Get_Vertex_Count(); - - ////////////////////////////////////////////////////////////////////// - // Compute the mesh's bounding box and sphere. This must be done - // before we pre-deform the mesh (if its a skin). - ////////////////////////////////////////////////////////////////////// - compute_bounding_volumes(); - - ////////////////////////////////////////////////////////////////////// - // Voxelize the mesh and compute the Moment of Inertia and - // Center of Mass. This must come after we compute the bounding - // volumes and before we pre-deform the mesh. - ////////////////////////////////////////////////////////////////////// - Progress_Meter_Class voxelmeter(meter, 64.0f * meter.Increment); - compute_physical_constants(MaxINode,voxelmeter,false /*usevoxelizer*/); - - ////////////////////////////////////////////////////////////////////// - // If this is a skin, pre-deform the mesh. - ////////////////////////////////////////////////////////////////////// - if (((Header.Attributes & W3D_MESH_FLAG_GEOMETRY_TYPE_MASK) == W3D_MESH_FLAG_GEOMETRY_TYPE_SKIN) && (HTree != NULL)) { - inv_deform_mesh(); - } - - ////////////////////////////////////////////////////////////////////// - // Get the user text from MAX's properties window. - ////////////////////////////////////////////////////////////////////// - TSTR usertext; - MaxINode->GetUserPropBuffer(usertext); - CStr usertext8 = usertext; - - if (usertext8.Length() > 0) { - UserText = new char[usertext8.Length() + 1]; - memset(UserText,0,usertext8.Length() + 1); - memcpy(UserText,usertext8.data(),usertext8.Length()); - } -} - -/*********************************************************************************************** - * MeshSaveClass::~MeshSaveClass -- destructor, frees all allocated memory * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/10/1997 GH : Created. * - *=============================================================================================*/ -MeshSaveClass::~MeshSaveClass(void) -{ - if (UserText) { - delete[] UserText; - UserText = NULL; - } - - if (VertInfluences) { - delete[] VertInfluences; - VertInfluences = NULL; - } - - if (MaterialRemapTable) { - delete[] MaterialRemapTable; - MaterialRemapTable = NULL; - } -} - -//search through previously found material colors and return index. house colors are always placed in top row. -void getMaterialUV(UVVert &tvert,unsigned int diffuse, unsigned int *materialColors, int &numMaterialColors, int &numHouseColors, bool house) -{ - int i; - - if (house) - { //this material is a house color, place it in first row. - for (i=0; i<16; i++) - { - if (materialColors[i]==diffuse) - { - tvert.x=((double)(i%16)+0.5)/16.0; ///@todo: MW: Remove hard-coded texture size - tvert.y=1.0-((double)(i/16)+0.5)/16.0; - numHouseColors=16; - return; - } - } - - ExportLog::printf("\nUndefined House Color %d,%d,%d",(diffuse>>16)&0xff,(diffuse>>8)&0xff,diffuse&0xff); - assert(0); //all house colors must be from a predefined range of reds - } - - for (i=16; i<(16+numMaterialColors); i++) - { - if (materialColors[i]==diffuse) - { - tvert.x=((double)(i%16)+0.5)/16.0; ///@todo: MW: Remove hard-coded texture size - tvert.y=1.0-((double)(i/16)+0.5)/16.0; - return; - } - } - - //new color found - tvert.x=((double)(i%16)+0.5)/16.0; ///@todo: MW: Remove hard-coded texture size - tvert.y=1.0-((double)(i/16)+0.5)/16.0; - - materialColors[i]=diffuse; - numMaterialColors++; -} - -void MeshSaveClass::Build_Mesh(Mesh & mesh, Mtl *node_mtl, unsigned int *materialColors, int &numMaterialColors, int &numHouseColors) -{ - int vert_counter; - int face_index; - int pass; - int stage; - float *vdata = NULL; - int firstSolidColoredMaterial=-1; - - Builder.Reset(true,mesh.getNumFaces(),mesh.getNumFaces()/3); - - // Get a pointer to the channel that has alpha values entered by the artist. - // This pointer will be NULL if they didn't use the channel. - vdata = mesh.vertexFloat(ALPHA_VERTEX_CHANNEL); - - /* - ** Get the skin info - */ - bool is_skin = false; - SkinDataClass * skindata = NULL; - SkinWSMObjectClass * skinobj = NULL; - - get_skin_modifier_objects(&skindata,&skinobj); - - if ( ((Header.Attributes & W3D_MESH_FLAG_GEOMETRY_TYPE_MASK) == W3D_MESH_FLAG_GEOMETRY_TYPE_SKIN) && - (HTree != NULL) ) - { - is_skin = ((skindata != NULL) && (skinobj != NULL)); - } - - /* - ** Submit all of the faces - */ - MeshBuilderClass::FaceClass face; - for (face_index = 0; face_index < mesh.getNumFaces(); face_index++) { - - Face maxface = mesh.faces[face_index]; - - int mat_index = 0; - if (Header.NumMaterials > 0) { - mat_index = MaterialRemapTable[(maxface.getMatID() % Header.NumMaterials)]; - } - assert(mat_index != -1); - - for (pass=0; passNumSubMtls() > 1)) { - mtl_to_use = node_mtl->GetSubMtl (maxface.getMatID() % node_mtl->NumSubMtls()); - } - - if ((mtl_to_use != NULL) && ((mtl_to_use->ClassID() == GameMaterialClassID) || - (mtl_to_use->ClassID() == PS2GameMaterialClassID))) { - face.SurfaceType = ((GameMtl *)mtl_to_use)->Get_Surface_Type (); - } - - for (vert_counter = 0; vert_counter < 3; vert_counter++) { - - /* - ** if this mesh is being inverted, we need to insert the verts in - ** the opposite order. max_vert_counter will count backwards - ** in this case; causing all vertex data to be entered in the - ** reverse winding. - */ - int max_vert_counter; - - if (MeshInverted) { - max_vert_counter = 2 - vert_counter; - } else { - max_vert_counter = vert_counter; - } - - int max_vert_index = maxface.v[max_vert_counter]; - - /* - ** Vertex Id, to prevent unwanted welding! - */ - face.Verts[vert_counter].Id = max_vert_index; - - /* - ** Vertex Position - */ - face.Verts[vert_counter].Position.X = mesh.verts[max_vert_index].x; - face.Verts[vert_counter].Position.Y = mesh.verts[max_vert_index].y; - face.Verts[vert_counter].Position.Z = mesh.verts[max_vert_index].z; - - if (vdata) { - - // If an alpha channel has been created, use its value. - for (int pass=0; pass < MaterialDesc.Pass_Count(); pass++) { - if (MaterialDesc.Pass_Uses_Vertex_Alpha(pass)) { - // Mulitiply by .01 to change from percentage. - face.Verts[vert_counter].Alpha[pass] = vdata[max_vert_index] * .01; - } - } - } - - - /* - ** Texture coordinate. Apply uv coords if the mesh has them and is not being - ** instructed to ignore them. - ** - check if the mesh needs them (uses_simple_rendering() == false) - ** - for each pass and stage, look up what map channel this face's material is using - ** - ask Max for the tfaces and tverts for that map channel - ** - copy the values into each vertex - */ - for (pass=0; passFilename && *((unsigned int *)map3d->Filename) == DIFFUSE_COLOR_TEXTURE_PREFIX) //check for prefix - { - double Diffuse = vmat->Diffuse.Get_Color() >> 8; //get material color - - //MW: Encode the material color into the u texture coordinate - tvert.x=Diffuse; - tvert.y=Diffuse; - - //find out material color location within texture page - if (strnicmp(MaterialDesc.Get_Vertex_Material_Name(mat_index,pass),"HouseColor",10)==0) - getMaterialUV(tvert,vmat->Diffuse.Get_Color() >> 8, materialColors, numMaterialColors, numHouseColors, true); - else - getMaterialUV(tvert,vmat->Diffuse.Get_Color() >> 8, materialColors, numMaterialColors, numHouseColors, false); - - //Keep track of first vertex material converted, so we can remap all other non-textured - //materials to use the same material. - if (firstSolidColoredMaterial == -1) - firstSolidColoredMaterial=MaterialDesc.Get_Vertex_Material_Index(mat_index,pass); - } - - /* - ** If the mesh needs uv coords and they are present, copy the uv into tvert - */ - else - if (!use_simple_rendering(Header.Attributes)) { - - int channel = MaterialDesc.Get_Map_Channel(mat_index,pass,stage); - - UVVert * uvarray = mesh.mapVerts(channel); - TVFace * tvfacearray = mesh.mapFaces(channel); - - ///@todo: MW: Forced ingoring of uv coordinates if no texture! Is this ok? - W3dMapClass *map3d=MaterialDesc.Get_Texture(mat_index,pass,stage); - - if (map3d && (uvarray != NULL) && (tvfacearray != NULL)) { - - int tvert_index = tvfacearray[face_index].t[max_vert_counter]; - tvert = uvarray[tvert_index]; - } - } - - /* - ** Copy the texture coordinate into the vertex structure - */ - face.Verts[vert_counter].TexCoord[pass][stage].X = tvert.x; - face.Verts[vert_counter].TexCoord[pass][stage].Y = tvert.y; - - } - } - - /* - ** Vertex Color - */ - if (mesh.vcFace) { - - /* - ** If the mesh is being mirrored, remap the index - */ - int max_cvert_index = mesh.vcFace[face_index].t[max_vert_counter]; - - VertColor vc; - vc = mesh.vertCol[max_cvert_index]; - - /* - ** If Vertex Alpha is specified, the vertex color is converted - ** to alpha. If the (obsolete) Node-flag for vertex alpha is enabled, - ** the alpha is put into each pass which has alpha enabled. Otherwise, - ** we check the material settings for which passes should get the alpha - ** values. If neither alpha options are enabled, we put the color - ** value into the first pass. - */ - if (ExportOptions.Is_Vertex_Alpha_Enabled()) { - - float alpha = (vc.x + vc.y + vc.z) / 3.0f; - for (int pass=0; pass < MaterialDesc.Pass_Count(); pass++) { - if (MaterialDesc.Pass_Uses_Vertex_Alpha(pass)) { - face.Verts[vert_counter].Alpha[pass] = alpha; - } - } - } else { - face.Verts[vert_counter].DiffuseColor[0].X = vc.x; - face.Verts[vert_counter].DiffuseColor[0].Y = vc.y; - face.Verts[vert_counter].DiffuseColor[0].Z = vc.z; - } - - face.Verts[vert_counter].MaxVertColIndex = max_cvert_index; - - } else { - face.Verts[vert_counter].MaxVertColIndex = 0; - } - - /* - ** Vertex materials (get's index of sub-material) - */ - for (pass = 0; passFilename && *((unsigned int *)map3d->Filename) == DIFFUSE_COLOR_TEXTURE_PREFIX) //check for prefix - face.Verts[vert_counter].VertexMaterialIndex[pass]=firstSolidColoredMaterial; - else - face.Verts[vert_counter].VertexMaterialIndex[pass] = MaterialDesc.Get_Vertex_Material_Index(mat_index,pass); - } - - face.Verts[vert_counter].Attribute0 = max_vert_index; - face.Verts[vert_counter].Attribute1 = face_index; - - /* - ** Skin attachment - */ - face.Verts[vert_counter].BoneIndex = 0; - if (is_skin) { - - int skin_bone_index = skindata->VertData[max_vert_index].BoneIdx[0]; - - // If this is a valid bone, try to find the corresponding bone index in the HTree - if ( (skin_bone_index != -1) && - (skin_bone_index < skinobj->Num_Bones()) && - (skinobj->BoneTab[skin_bone_index] != NULL) ) - { - face.Verts[vert_counter].BoneIndex = get_htree_bone_index_for_inode(skinobj->BoneTab[skin_bone_index]); - } - } - } - - Builder.Add_Face(face); - } - - /* - ** Process the mesh - */ - Builder.Build_Mesh(true); - - const MeshBuilderClass::MeshStatsStruct & stats = Builder.Get_Mesh_Stats(); - int vcount = Builder.Get_Vertex_Count(); - int pcount = mesh.numFaces; - float vert_poly_ratio = (float)vcount / (float)pcount; - - ExportLog::printf(" triangle count: %d\n",pcount); - ExportLog::printf(" final vertex count: %d\n",vcount); - ExportLog::printf(" vertex/triangle ratio: %f\n",vert_poly_ratio); - ExportLog::printf(" strip count: %d\n",stats.StripCount); - ExportLog::printf(" average strip length: %f\n",stats.AvgStripLength); - ExportLog::printf(" longest strip: %d\n",stats.MaxStripLength); -} - - -/*********************************************************************************************** - * MeshSaveClass::get_skin_modifier_objects -- Searches for the WWSkin modifier for this mesh * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -void MeshSaveClass::get_skin_modifier_objects(SkinDataClass ** skin_data_ptr,SkinWSMObjectClass ** skin_obj_ptr) -{ - *skin_data_ptr = NULL; - *skin_obj_ptr = NULL; - - // loop through the references that our node has - for (int i = 0; i < MaxINode->NumRefs(); i++) { - - ReferenceTarget *refTarg = MaxINode->GetReference(i); - - // if the reference is a WSM Derived Object. - if (refTarg != NULL && refTarg->ClassID() == Class_ID(WSM_DERIVOB_CLASS_ID,0)) { - - IDerivedObject * wsm_der_obj = (IDerivedObject *)refTarg; - - // loop through the WSM's attached to this WSM Derived object - for (int j = 0; j < wsm_der_obj->NumModifiers(); j++) { - Modifier * mod = wsm_der_obj->GetModifier(j); - if (mod->ClassID() == SKIN_MOD_CLASS_ID) { - - // This is our modifier! Get the data from it! - SkinModifierClass * skinmod = (SkinModifierClass *)mod; - ModContext * mc = wsm_der_obj->GetModContext(j); - *skin_data_ptr = (SkinDataClass *)(mc->localData); - *skin_obj_ptr = (SkinWSMObjectClass *)skinmod->GetReference(SkinModifierClass::OBJ_REF); - } - } - } - } -} - - -/*********************************************************************************************** - * MeshSaveClass::get_htree_bone_index_for_inode -- searches the htree for the given INode * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/1/2000 gth : Created. * - *=============================================================================================*/ -int MeshSaveClass::get_htree_bone_index_for_inode(INode * node) -{ - // index of this INode in the hierarchy tree (it better be there :-) - char w3dname[W3D_NAME_LEN]; - Set_W3D_Name(w3dname,node->GetName()); - int bindex = HTree->Find_Named_Node(w3dname); - - // If the desired bone isn't being exported, export the point - // relative to the root. - if (bindex == -1) { - bindex = 0; - } - - return bindex; -} - -/*********************************************************************************************** - * MeshSaveClass::inv_deform_mesh -- preprocess the mesh for skinning * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - * 5/1/2000 gth : Created. * - *=============================================================================================*/ -void MeshSaveClass::inv_deform_mesh() -{ - // Got the skinning info, now pre-deform each vertex and - // create an array of vertex influence indexes. - VertInfluences = new W3dVertInfStruct[Builder.Get_Vertex_Count()]; - memset(VertInfluences,0,sizeof(W3dVertInfStruct) * Builder.Get_Vertex_Count()); - Header.VertexChannels |= W3D_VERTEX_CHANNEL_BONEID; - - for (int vert_index = 0; vert_index < Builder.Get_Vertex_Count(); vert_index++) { - - MeshBuilderClass::VertClass & vert = Builder.Get_Vertex(vert_index); - - if (vert.BoneIndex == 0) { - - // set the influence to 0 (root node) and leave the vert and normal unchanged - // (gth) 07/11/2000: Note that in this case, the mesh coordinates have already been - // transformed relative to the user or scene origin and do not need to be further modified. - VertInfluences[vert_index].BoneIdx = 0; - - } else { - - // here we go! get the matrix from the hierarchy tree and transform - // the point into the bone's coordinate system. - // (gth) 07/11/2000: The origin_offset_tm is no longer needed because - // skin meshes are transformed into the origin coordinate system before - // we get to this code. - Matrix3 bonetm = HTree->Get_Node_Transform(vert.BoneIndex); - Matrix3 invbonetm = Inverse(bonetm); - Point3 pos; - - pos.x = vert.Position.X; - pos.y = vert.Position.Y; - pos.z = vert.Position.Z; - - pos = pos * invbonetm; - - vert.Position.X = pos.x; - vert.Position.Y = pos.y; - vert.Position.Z = pos.z; - - // Now, transform the normal into the bone's coordinate system. - invbonetm.NoTrans(); - Point3 norm; - - norm.x = vert.Normal.X; - norm.y = vert.Normal.Y; - norm.z = vert.Normal.Z; - - norm = norm * invbonetm; - - vert.Normal.X = norm.x; - vert.Normal.Y = norm.y; - vert.Normal.Z = norm.z; - - VertInfluences[vert_index].BoneIdx = vert.BoneIndex; - } - } -} - - -/*********************************************************************************************** - * MeshSaveClass::Write_To_File -- Append the mesh to an open wtm file * - * * - * INPUT: * - * csave - ChunkSaveClass object to handle writing the chunk-based file * - * export_aabtree - should we generate an aabtree for this mesh * - * * - * OUTPUT: * - * 0 if nothing went wrong, Non-Zero otherwise * - * * - * WARNINGS: * - * * - * * - * HISTORY: * - * 06/10/1997 GH : Created. * - *=============================================================================================*/ -int MeshSaveClass::Write_To_File(ChunkSaveClass & csave,bool export_aabtree) -{ - if (!csave.Begin_Chunk(W3D_CHUNK_MESH)) { - return 1; - } - - if (write_header(csave) != 0) { - return 1; - } - - if (write_user_text(csave) != 0) { - return 1; - } - - if (write_verts(csave) != 0) { - return 1; - } - - if (write_vert_normals(csave) != 0) { - return 1; - } - - if (write_triangles(csave) != 0) { - return 1; - } - - if (write_vert_influences(csave) != 0) { - return 1; - } - - if (write_vert_shade_indices(csave) != 0) { - return 1; - } - - if (write_material_info(csave) != 0) { - return 1; - } - - if (write_vertex_materials(csave) != 0) { - return 1; - } - - if (PS2Material == TRUE) { - - // The ps2 shaders must be written out first. - if (write_ps2_shaders(csave) != 0) { - return 1; - } - } - - if (write_shaders(csave) != 0) { - return 1; - } - - - if (write_textures(csave) != 0) { - return 1; - } - - for (int pass=0; pass 0); - assert(Builder.Get_Vertex_Count() == (int)Header.NumVertices); - - for (int i=0; i= Header.Min.X); - assert(vert.Position.Y >= Header.Min.Y); - assert(vert.Position.Z >= Header.Min.Z); - - } - - W3dVectorStruct w3dvert; - w3dvert.X = vert.Position.X; - w3dvert.Y = vert.Position.Y; - w3dvert.Z = vert.Position.Z; - - if (csave.Write(&(w3dvert),sizeof(W3dVectorStruct)) != sizeof(W3dVectorStruct)) { - return 1; - } - } - - if (!csave.End_Chunk()) { - return 1; - } - return 0; -} - - -/*********************************************************************************************** - * MeshSaveClass::write_vert_normals -- Writes the surrender normal chunk into a wtm file * - * * - * INPUT: * - * csave - chunk save object * - * * - * OUTPUT: * - * 0 if nothing went wrong, Non-Zero otherwise * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/10/1997 GH : Created. * - *=============================================================================================*/ -int MeshSaveClass::write_vert_normals(ChunkSaveClass & csave) -{ - if (!(Header.VertexChannels & W3D_VERTEX_CHANNEL_NORMAL)) return 0; - - if (!csave.Begin_Chunk(W3D_CHUNK_VERTEX_NORMALS)) { - return 1; - } - - for (int i=0; i < Builder.Get_Vertex_Count(); i++) { - - const MeshBuilderClass::VertClass & vert = Builder.Get_Vertex(i); - - W3dVectorStruct norm; - - if (ExportOptions.Is_ZNormals_Enabled()) { - norm.X = 0.0f; - norm.Y = 0.0f; - norm.Z = 1.0f; - } else { - norm.X = vert.Normal.X; - norm.Y = vert.Normal.Y; - norm.Z = vert.Normal.Z; - } - - if (csave.Write(&(norm),sizeof(W3dVectorStruct)) != sizeof(W3dVectorStruct)) { - return 1; - } - } - - if (!csave.End_Chunk()) { - return 1; - } - - return 0; -} - -/*********************************************************************************************** - * MeshSaveClass::write_vert_influences -- skins will have this chunk that binds verts to bones* - * * - * INPUT: * - * csave - chunk save object * - * * - * OUTPUT: * - * 0 if nothing went wrong, Non-Zero otherwise * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/10/1997 GH : Created. * - *=============================================================================================*/ -int MeshSaveClass::write_vert_influences(ChunkSaveClass & csave) -{ - if (((Header.Attributes & W3D_MESH_FLAG_GEOMETRY_TYPE_MASK) != W3D_MESH_FLAG_GEOMETRY_TYPE_SKIN) || - !(Header.VertexChannels & W3D_VERTEX_CHANNEL_BONEID) || - (VertInfluences == NULL)) { - return 0; - } - - if (!csave.Begin_Chunk(W3D_CHUNK_VERTEX_INFLUENCES)) { - return 1; - } - - int count = Builder.Get_Vertex_Count(); - if (csave.Write(VertInfluences,count * sizeof(W3dVertInfStruct)) != count * sizeof(W3dVertInfStruct)) { - return 1; - } - - if (!csave.End_Chunk()) { - return 1; - } - - return 0; -} - - -/*********************************************************************************************** - * MeshSaveClass::write_triangles -- write the triangles chunk * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/7/98 GTH : Created. * - *=============================================================================================*/ -int MeshSaveClass::write_triangles(ChunkSaveClass & csave) -{ - if (!csave.Begin_Chunk(W3D_CHUNK_TRIANGLES)) { - return 1; - } - - assert(Builder.Get_Face_Count() == (int)Header.NumTris); - for (int i=0; i 0); - - if (PS2Material == TRUE) { - - // Make the PC shader as close to the PS2 shader as possible. - // This will allow for viewing in W3D View. - setup_PC_shaders_from_PS2_shaders(); - } - - if (!csave.Begin_Chunk(W3D_CHUNK_SHADERS)) { - return 1; - } - - W3dShaderStruct * shader; - - for (int i=0; iFilename,strlen(map->Filename) + 1) != strlen(map->Filename) + 1) return 1; - csave.End_Chunk(); - - // optionally write an animation info chunk - if (map->AnimInfo != NULL) { - csave.Begin_Chunk(W3D_CHUNK_TEXTURE_INFO); - if (csave.Write(map->AnimInfo,sizeof(W3dTextureInfoStruct)) != sizeof(W3dTextureInfoStruct)) return 1; - csave.End_Chunk(); - } - - csave.End_Chunk(); - } - - if (!csave.End_Chunk()) { - return 1; - } - return 0; -} - -int MeshSaveClass::write_pass(ChunkSaveClass & csave,int pass) -{ - assert(pass >= 0); - assert(pass < MaterialDesc.Pass_Count()); - - if (!csave.Begin_Chunk(W3D_CHUNK_MATERIAL_PASS)) { - return 1; - } - - const MeshBuilderClass::MeshStatsStruct & stats = Builder.Get_Mesh_Stats(); - - if (stats.HasVertexMaterial[pass]) { - write_vertex_material_ids(csave,pass); - } - - if (stats.HasShader[pass]) { - write_shader_ids(csave,pass); - } - - if (stats.HasDiffuseColor[pass] || DeformSave.Does_Deformer_Modify_DCG ()) { - write_dcg(csave,pass); - } - - for (int stage = 0; stage < MeshBuilderClass::MAX_STAGES; stage++) { - write_texture_stage(csave,pass,stage); - } - - if (!csave.End_Chunk()) { - return 1; - } - return 0; -} - -int MeshSaveClass::write_vertex_material_ids(ChunkSaveClass & csave,int pass) -{ - const MeshBuilderClass::MeshStatsStruct & stats = Builder.Get_Mesh_Stats(); - - if (!csave.Begin_Chunk(W3D_CHUNK_VERTEX_MATERIAL_IDS)) { - return 1; - } - - uint32 matid; - - if (stats.HasPerVertexMaterial[pass]) { - for (int i=0; i= MIN_AABTREE_POLYGONS) && - ((Header.Attributes & W3D_MESH_FLAG_GEOMETRY_TYPE_MASK) == W3D_MESH_FLAG_GEOMETRY_TYPE_NORMAL) - ) - { - - /* - ** Build temporary array representations of the mesh - */ - int vertcount = Builder.Get_Vertex_Count(); - int polycount = Builder.Get_Face_Count(); - Vector3 * verts = new Vector3[vertcount]; - Vector3i * polys = new Vector3i[polycount]; - - for (int vi=0; viNumSubMtls() <= 1)) { - - MaterialRemapTable = new int[1]; - MaterialRemapTable[0] = 0; - return 1; - - } else { - - int sub_mtl_count = nodemtl->NumSubMtls(); - MaterialRemapTable = new int[sub_mtl_count]; - - // Initialize each remap to -1 (indicates that the material is un-used) - for (mat_index=0; mat_index 0); - return matcount; - } -} - -//Check if material is solid, non-textured. -int isTexturedMaterial(Mtl * mtl) -{ - Texmap * tmap; - - tmap = mtl->GetSubTexmap(ID_DI); - if (mtl->ClassID() == GameMaterialClassID) - { - GameMtl * gamemtl=(GameMtl *)mtl; - - for (int pass=0;passGet_Pass_Count(); pass++) - { - for (int stage=0; stage < W3dMaterialClass::MAX_STAGES; stage++) - { if (gamemtl->Get_Texture_Enable(pass,stage) && gamemtl->Get_Texture(pass,stage)) - return 1; //using a texture - } - } - return 0; - } - else - { - return (tmap && tmap->ClassID() == Class_ID(BMTEX_CLASS_ID,0)); - } -} - -//count number of used solid materials (no texture) -int MeshSaveClass::getNumSolidMaterials(Mtl * nodemtl) -{ - int mat_index; - int numSolid=0; - - if ((nodemtl == NULL) || (nodemtl->NumSubMtls() <= 1)) - { //Check if diffuse texture present - if (isTexturedMaterial(nodemtl)) - return 00; - return 1; - } - else - { - int sub_mtl_count = nodemtl->NumSubMtls(); - - for (mat_index=0; mat_indexGetSubMtl(mat_index))) - continue; - numSolid++; - } - } - return numSolid; - } -} - -//Cancels out the material colors by setting them to white. -//Also changes prefix on texture names to use DIFFUSE_HOUSECOLOR_TEXTURE_PREFIX -//if house color is used. -void MeshSaveClass::fix_diffuse_materials(bool isHouseColor) -{ - uint8 color=255; - char materialColorFilename[_MAX_FNAME + 1]; - - for (int mat_index=0; mat_indexFilename && (*((unsigned int *)map3d->Filename) & 0xffff00ff) == DIFFUSE_COLOR_TEXTURE_MASK) //check for 'TXC^' prefix - { //found a material which had its material color replaced by a texture - //set the material color to white so it's not being used. - vmat->Diffuse.Set(color,color,color); - vmat->Ambient.Set(color,color,color); - - if (isHouseColor && *(map3d->Filename+1) != 'H') - { //our material texture contains house colors, adjust the name - //by adding H prefix. - sprintf(materialColorFilename,"%s%s","ZHCD",map3d->Filename+4); - map3d->Set_Filename(materialColorFilename); - } - } - } - } - } -} - -/*********************************************************************************************** - * MeshSaveClass::create_materials -- create the materials for this mesh * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - * 2/8/99 GTH : modified to use the MaterialRemapTable * - *=============================================================================================*/ -void MeshSaveClass::create_materials(Mtl * nodemtl,DWORD wirecolor, char *materialColorTexture) -{ - bool domaps = !use_simple_rendering(Header.Attributes); - - ////////////////////////////////////////////////////////////////////// - // Create materials - // Four cases: - // - Creating a collision object: use a hard-coded material - // - The material is null: use wire color - // - The material is a simple material: create one material - // - The material is a multi-material: create n materials - ////////////////////////////////////////////////////////////////////// - int geo_type = Header.Attributes & W3D_MESH_FLAG_GEOMETRY_TYPE_MASK; - if ((geo_type == W3D_MESH_FLAG_GEOMETRY_TYPE_AABOX) || - (geo_type == W3D_MESH_FLAG_GEOMETRY_TYPE_OBBOX)) - { - Header.NumMaterials = 1; - - W3dVertexMaterialStruct vmat; - W3dShaderStruct shader; - W3dMaterialClass material; - - Color diffuse; - if (Header.Attributes & W3D_MESH_FLAG_COLLISION_TYPE_PHYSICAL) { - diffuse.r = 0.0f; - diffuse.g = 0.0f; - diffuse.b = 1.0f; - } else { - diffuse.r = 0.4f; - diffuse.g = 1.0f; - diffuse.b = 0.4f; - } - - W3d_Shader_Reset(&shader); - W3d_Shader_Set_Dest_Blend_Func(&shader,W3DSHADER_DESTBLENDFUNC_ONE_MINUS_SRC_ALPHA); - W3d_Shader_Set_Src_Blend_Func(&shader,W3DSHADER_SRCBLENDFUNC_SRC_ALPHA); - - W3d_Vertex_Material_Reset(&vmat); - vmat.Opacity = 0.5f; - - // add material 0 - vmat.Diffuse.R = (uint8)(diffuse.r * 255.0f); - vmat.Diffuse.G = (uint8)(diffuse.g * 255.0f); - vmat.Diffuse.B = (uint8)(diffuse.b * 255.0f); - material.Set_Pass_Count(1); - material.Set_Vertex_Material(vmat,0); - material.Set_Shader(shader,0); - MaterialDesc.Add_Material(material); - - assert(MaterialDesc.Material_Count() == 1); - - } else if (!nodemtl) { - - // Create a single material using the wire color - Header.NumMaterials = 1; - - W3dVertexMaterialStruct vmat; - W3dShaderStruct shader; - W3dMaterialClass material; - - W3d_Vertex_Material_Reset(&vmat); - W3d_Shader_Reset(&shader); - - vmat.Diffuse.R = GetRValue(wirecolor); - vmat.Diffuse.G = GetGValue(wirecolor); - vmat.Diffuse.B = GetBValue(wirecolor); - - material.Set_Pass_Count(1); - material.Set_Vertex_Material(vmat,0); - material.Set_Shader(shader,0); - - MaterialDesc.Add_Material(material,"WireColor"); - assert(MaterialDesc.Material_Count() == 1); - - } else if (!nodemtl->IsMultiMtl()) { - - Header.NumMaterials = 1; - W3dMaterialClass mat; - - if (isTexturedMaterial(nodemtl) == 0) - mat.Init(nodemtl,materialColorTexture); - else - mat.Init(nodemtl,NULL); - - W3dMaterialDescClass::ErrorType err; - err = MaterialDesc.Add_Material(mat,nodemtl->GetName()); - if (err == W3dMaterialDescClass::MULTIPASS_TRANSPARENT) { - sprintf(_string1,"Exporting Materials for Mesh: %s\nMaterial %s is multi-pass and transparent\nMulti-pass transparent materials are not allowed.\n", - Header.MeshName, - nodemtl->GetName()); - ExportLog::printf(_string1); - throw ErrorClass(_string1); - } - assert(MaterialDesc.Material_Count() == 1); - - } else { - - Header.NumMaterials = nodemtl->NumSubMtls(); - W3dMaterialClass mat; - - for (unsigned mi = 0; mi < Header.NumMaterials; mi++) { - - // only process materials that were found to be used in the scan_used_materials call - if (MaterialRemapTable[mi] != -1) { - - if (isTexturedMaterial(nodemtl->GetSubMtl(mi)) == 0) - mat.Init(nodemtl->GetSubMtl(mi),materialColorTexture); - else - mat.Init(nodemtl->GetSubMtl(mi),NULL); - - char * name; - W3dMaterialDescClass::ErrorType err; - - name = nodemtl->GetSubMtl(mi)->GetName(); - err = MaterialDesc.Add_Material(mat,name); - - if (err == W3dMaterialDescClass::INCONSISTENT_PASSES) { - sprintf(_string1,"Exporting Materials for Mesh: %s\nMaterial %s has %d passes.\nThe other materials have %d passes.\nAll Materials must have the same number of passes.\n", - Header.MeshName, - nodemtl->GetSubMtl(mi)->GetName(), - mat.Get_Pass_Count(), - MaterialDesc.Pass_Count()); - ExportLog::printf(_string1); - throw ErrorClass(_string1); - } - if (err == W3dMaterialDescClass::MULTIPASS_TRANSPARENT) { - sprintf(_string1,"Exporting Materials for Mesh: %s\nMaterial %s is multi-pass and transparent\nMulti-pass transparent materials are not allowed.\n", - Header.MeshName, - nodemtl->GetSubMtl(mi)->GetName()); - throw ErrorClass(_string1); - } - if (err == W3dMaterialDescClass::INCONSISTENT_SORT_LEVEL) { - sprintf(_string1,"Exporting Materials for Mesh: %s\nMaterial %s does not have the same Static Sort Level as other materials used on the mesh.\nAll materials for a mesh must use the same Static Sort Level value.\n", - Header.MeshName, - nodemtl->GetSubMtl(mi)->GetName()); - ExportLog::printf(_string1); - throw ErrorClass(_string1); - } - } - } - } - - // Store the material's sort level in the mesh header. - Header.SortLevel = MaterialDesc.Get_Sort_Level(); -} - -/*********************************************************************************************** - * MeshSaveClass::compute_bounding_volumes -- computes a bounding box and bounding sphere for * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/01/1997 GH : Created. * - *=============================================================================================*/ -void MeshSaveClass::compute_bounding_volumes(void) -{ - Vector3 min,max,center; - float radius; - - Builder.Compute_Bounding_Box(&min,&max); - Builder.Compute_Bounding_Sphere(¢er,&radius); - - Header.SphCenter.X = center.X; - Header.SphCenter.Y = center.Y; - Header.SphCenter.Z = center.Z; - Header.SphRadius = radius; - - Header.Min.X = min.X; - Header.Min.Y = min.Y; - Header.Min.Z = min.Z; - Header.Max.X = max.X; - Header.Max.Y = max.Y; - Header.Max.Z = max.Z; -} - - -/*********************************************************************************************** - * MeshSaveClass::compute_physical_properties -- computes the volume and moment of inertia * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/01/1997 GH : Created. * - *=============================================================================================*/ -void MeshSaveClass::compute_physical_constants -( - INode * inode, - Progress_Meter_Class & meter, - bool voxelize -) -{ - -#if 0 // IF we need this again, move the data to a physics chunk (header doesn't have it anymore) - - if (voxelize) { - - // Create an INodeList object for this mesh - AnyINodeFilter nodefilt; - INodeListClass meshlist(CurTime,&nodefilt); - meshlist.Insert(inode); - - // Create a Voxel object for this mesh - VoxelClass * voxel = new VoxelClass - ( - meshlist, - VOXEL_RESOLUTION, - ExportSpace, - CurTime, - meter - ); - -#if DEBUG_VOXELS - VoxelDebugWindowClass dbgwin(voxel); - dbgwin.Display_Window(); -#endif - - double vol[1]; - double cm[3]; - double inertia[9]; - - voxel->Compute_Physical_Properties(vol,cm,inertia); - - Header.Volume = (float)vol[0]; - - Header.MassCenter.X = (float)cm[0]; - Header.MassCenter.Y = (float)cm[1]; - Header.MassCenter.Z = (float)cm[2]; - - Header.Inertia[0] = (float)inertia[0]; - Header.Inertia[1] = (float)inertia[1]; - Header.Inertia[2] = (float)inertia[2]; - Header.Inertia[3] = (float)inertia[3]; - Header.Inertia[4] = (float)inertia[4]; - Header.Inertia[5] = (float)inertia[5]; - Header.Inertia[6] = (float)inertia[6]; - Header.Inertia[7] = (float)inertia[7]; - Header.Inertia[8] = (float)inertia[8]; - - } else { - - // Set mass center to the center of the bounding box - Header.MassCenter.X = (Header.Max.X + Header.Min.X) / 2.0f; - Header.MassCenter.Y = (Header.Max.Y + Header.Min.Y) / 2.0f; - Header.MassCenter.Z = (Header.Max.Z + Header.Min.Z) / 2.0f; - - // Set inertia tensor to inertia tensor of the bounding box - // (gth) !!!! DO THIS !!!! - Header.Inertia[0] = 1.0f; - Header.Inertia[1] = 0.0f; - Header.Inertia[2] = 0.0f; - Header.Inertia[3] = 0.0f; - Header.Inertia[4] = 1.0f; - Header.Inertia[5] = 0.0f; - Header.Inertia[6] = 0.0f; - Header.Inertia[7] = 0.0f; - Header.Inertia[8] = 1.0f; - - Header.Volume = (Header.Max.X - Header.Min.X) * (Header.Max.Y - Header.Min.Y) * (Header.Max.Z - Header.Min.Z); - } - -#endif -} - - -/*********************************************************************************************** - * MeshSaveClass::prep_mesh -- pre-transform the MAX mesh by a specified matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/01/1997 GH : Created. * - *=============================================================================================*/ -void MeshSaveClass::prep_mesh(Mesh & mesh,Matrix3 & objoff) -{ - int vert_index; - - // Transform the mesh's vertices so that they are relative to the coordinate - // system that we want to use with the mesh - for (vert_index = 0; vert_index < mesh.getNumVerts (); vert_index++) { - mesh.verts[vert_index] = mesh.verts[vert_index] * objoff; - } - - // Re-Build the normals. - mesh.buildNormals(); -} - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/meshsave.h b/Generals/Code/Tools/WW3D/max2w3d/meshsave.h deleted file mode 100644 index 48c9b6681d5..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/meshsave.h +++ /dev/null @@ -1,226 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/meshsave.h 44 10/30/00 1:12p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G * - * * - * File Name : MESHSAVE.H * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 06/10/97 * - * * - * Last Update : June 10, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef MESHSAVE_H -#define MESHSAVE_H - -#include "rawfile.h" // have to include this before Max.h -#include -#include "BITTYPE.H" -#include "w3d_file.h" -#include "chunkio.h" -#include "PROGRESS.H" -#include "nodelist.h" -#include "util.h" -#include "w3dmtl.h" -#include "meshbuild.h" -#include "MeshDeformSave.h" -#include "w3dappdata.h" - -class HierarchySaveClass; -class MeshConnectionsClass; -class MeshSaveClass; -class SkinDataClass; - - -/******************************************************************************************* -** -** VertStruct -** -*******************************************************************************************/ -struct VertStruct -{ - Point3 Vertex; - Point3 Normal; - Point2 TexCoord; - Color Color; - - uint32 MaxVertIdx; // index of the MAX vertex that this vert came from - uint32 MaxFaceIdx; // index of the MAX face that this vert came from - VertStruct * Next; // used by the hash table... -}; - -/******************************************************************************************* -** -** FaceStruct -** -*******************************************************************************************/ -struct FaceStruct -{ - uint32 MaxVidx[3]; // original 3ds-MAX vertex index (for smoothing computations) - uint32 OurVidx[3]; // vertex, vertex normal, and texture coord indices - uint32 MaterialIdx; // material index - uint32 SmGroup; // smoothing group (not really needed, normals pre-calced) - Point3 Normal; // Face normal - float32 Dist; // Plane distance - uint32 Attributes; // collision flags, sort method, etc -}; - -/******************************************************************************************* -** -** MeshSaveClass - this is the big one, create meshes and skins from a MAX mesh. -** -*******************************************************************************************/ -class MeshSaveClass -{ -public: - - enum { - EX_UNKNOWN = 0, // exception error codes - EX_CANCEL = 1 - }; - - MeshSaveClass( - char * mesh_name, - char * container_name, - INode * inode, - const Mesh * input_mesh, - Matrix3 & exportspace, - W3DAppData2Struct & exportoptions, - HierarchySaveClass * htree, - TimeValue curtime, - Progress_Meter_Class & meter, - unsigned int * materialColors, - int &numMaterialColors, - int &numHouseColors, - char * materialColorTexture, - WorldInfoClass * world_info = NULL - ); - - ~MeshSaveClass(void); - - int Write_To_File(ChunkSaveClass & csave,bool export_aabtrees = false); - -private: - - INode * MaxINode; - W3DAppData2Struct & ExportOptions; - - W3dMeshHeader3Struct Header; - W3dMaterialDescClass MaterialDesc; - MeshBuilderClass Builder; - MeshDeformSaveClass DeformSave; - TimeValue CurTime; - Matrix3 ExportSpace; - Matrix3 MeshToExportSpace; - Matrix3 PivotSpace; - HierarchySaveClass * HTree; - char * UserText; - bool MeshInverted; // this flag indicates that the transform is inverting this mesh - W3dVertInfStruct * VertInfluences; - - int * MaterialRemapTable; // reindexes mtl_idx after un-used mtls are removed - - // Flag set if the mesh uses a PS2 material. - int PS2Material; - -private: - - // Use a MeshBuilderClass to process the mesh - void Build_Mesh(Mesh & mesh, Mtl *node_mtl, unsigned int *materialColors, int &numMaterialColors, int &numHouseColors); - - // compute properties for the mesh - void compute_bounding_volumes(void); - void compute_physical_constants(INode * inode,Progress_Meter_Class & meter,bool voxelize); - - // create the materials - int scan_used_materials(Mesh & mesh, Mtl * nodemtl); - void create_materials(Mtl * nodemtl,DWORD wirecolor, char *materialColorTexture); - void fix_diffuse_materials(bool isHouseColor); - - // count number of used solid materials (no texture) - int getNumSolidMaterials(Mtl * nodemtl); - - // creating damage stages - void add_damage_stage(MeshSaveClass * damage_mesh); - - // methods used in building the wtm file - int write_header(ChunkSaveClass & csave); - int write_user_text(ChunkSaveClass & csave); - - int write_verts(ChunkSaveClass & csave); - int write_vert_normals(ChunkSaveClass & csave); - int write_vert_influences(ChunkSaveClass & csave); - int write_vert_shade_indices(ChunkSaveClass & csave); - - int write_triangles(ChunkSaveClass & csave); - - int write_material_info(ChunkSaveClass & csave); - int write_shaders(ChunkSaveClass & csave); - int write_vertex_materials(ChunkSaveClass & csave); - int write_textures(ChunkSaveClass & csave); - - int write_pass(ChunkSaveClass & csave,int pass); - int write_vertex_material_ids(ChunkSaveClass & csave,int pass); - int write_shader_ids(ChunkSaveClass & csave,int pass); - int write_dcg(ChunkSaveClass & csave,int pass); - - int write_texture_stage(ChunkSaveClass & csave,int pass,int stage); - int write_texture_ids(ChunkSaveClass & csave,int pass,int stage); - int write_texture_coords(ChunkSaveClass & csave,int pass,int stage); - - int write_aabtree(ChunkSaveClass & csave); - - // transforms mesh so that it uses the desired coordinate system - void prep_mesh(Mesh & mesh,Matrix3 & objoff); - - // inverse deform the mesh so that its ready to be used as a skin! - void get_skin_modifier_objects(SkinDataClass ** skin_data_ptr,SkinWSMObjectClass ** skin_obj_ptr); - int get_htree_bone_index_for_inode(INode * node); - void inv_deform_mesh(void); - - // get rendering settings for the materials - void customize_materials(void); - - // Write the ps2 shaders and approximate them as close as possible in the W3D shaders. - int write_ps2_shaders(ChunkSaveClass & csave); - - // Make the PC shader emulate the PS2 shader. - void setup_PC_shaders_from_PS2_shaders(); - - friend class DamageClass; -}; - - - - - -#endif /*MESHSAVE_H*/ \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/motion.cpp b/Generals/Code/Tools/WW3D/max2w3d/motion.cpp deleted file mode 100644 index f2c883ba053..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/motion.cpp +++ /dev/null @@ -1,1027 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/motion.cpp 26 10/30/00 6:56p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/motion.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/30/00 5:25p $* - * * - * $Revision:: 26 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * MotionClass::MotionClass -- constructor * - * MotionClass::MotionClass -- constructor * - * MotionClass::init -- initialize * - * MotionClass::~MotionClass -- destructor * - * MotionClass::compute_frame_motion -- compute the motion for a specified frame * - * MotionClass::set_motion_matrix -- save a motin matrix * - * MotionClass::get_motion_matrix -- retrieve a motion matrix * - * MotionClass::set_eulers -- store euler angles * - * MotionClass::get_eulers -- retrieve euler angles * - * MotionClass::Save -- save the motion to a W3D file * - * MotionClass::save_header -- save the header * - * MotionClass::save_channels -- save the motion channels * - * MotionClass::set_visibility -- store a visibility bit * - * MotionClass::get_visibility -- retrieve the visibility bit for this node:frame * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "motion.h" -#include "w3d_file.h" -#include "vchannel.h" -#include "bchannel.h" -#include "EULER.H" -#include "util.h" -#include "errclass.h" -#include "w3dutil.h" -#include "exportlog.h" - - - -/*********************************************************************************************** - * MotionClass::MotionClass -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -MotionClass::MotionClass -( - IScene * scene, - INode * rootnode, - HierarchySaveClass * basepose, - W3dExportOptionsStruct & options, - int framerate, - Progress_Meter_Class * meter, - HWND MaxHwnd, - char * name, - Matrix3 & offset -): - BasePose(basepose), - Scene(scene), - RootNode(rootnode), - RootList(NULL), - StartFrame(options.StartFrame), - EndFrame(options.EndFrame), - ReduceAnimation(options.ReduceAnimation), - ReduceAnimationPercent(options.ReduceAnimationPercent), - CompressAnimation(options.CompressAnimation), - CompressAnimationFlavor(options.CompressAnimationFlavor), - CompressAnimationTranslationError(options.CompressAnimationTranslationError), - CompressAnimationRotationError(options.CompressAnimationRotationError), - FrameRate(framerate), - Meter(meter), - Offset(offset) -{ - - ExportLog::printf("Initializing Capture....\n"); - - init(); - - Set_W3D_Name(Name,name); -} - -/*********************************************************************************************** - * MotionClass::MotionClass -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -MotionClass::MotionClass -( - IScene * scene, - INodeListClass * rootlist, - HierarchySaveClass * basepose, - W3dExportOptionsStruct & options, - int framerate, - Progress_Meter_Class * meter, - HWND MaxHwnd, - char * name, - Matrix3 & offset -): - BasePose(basepose), - Scene(scene), - RootNode(NULL), - RootList(rootlist), - StartFrame(options.StartFrame), - EndFrame(options.EndFrame), - ReduceAnimation(options.ReduceAnimation), - ReduceAnimationPercent(options.ReduceAnimationPercent), - CompressAnimation(options.CompressAnimation), - CompressAnimationFlavor(options.CompressAnimationFlavor), - CompressAnimationTranslationError(options.CompressAnimationTranslationError), - CompressAnimationRotationError(options.CompressAnimationRotationError), - FrameRate(framerate), - Meter(meter), - Offset(offset) -{ - - ExportLog::printf("Initializing Capture....\n"); - - init(); - - Set_W3D_Name(Name,name); -} - -/*********************************************************************************************** - * MotionClass::init -- initialize * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -void MotionClass::init(void) -{ - int i,j; - - NumFrames = (EndFrame - StartFrame + 1); - - ExportLog::printf("Extracting %d frames of animation from Max\n", NumFrames); - ExportLog::printf("\n"); - - /* - ** Allocate space for a matrix per frame per node - ** and an XYZEulers per frame per node. - */ - MotionMatrix = new Matrix3 * [BasePose->Num_Nodes()]; - if (MotionMatrix == NULL) { - throw (ErrorClass("Out of Memory")); - } - - EulerDelta = new Point3 * [BasePose->Num_Nodes()]; - if (EulerDelta == NULL) { - throw (ErrorClass("Out of Memory")); - } - - for (i=0; iNum_Nodes(); i++) { - MotionMatrix[i] = new Matrix3[NumFrames]; - if (MotionMatrix[i] == NULL) { - throw (ErrorClass("Out of Memory")); - } - - /* - ** Initialize all of the matrices to identity. - */ - for (j=0; jNum_Nodes(); i++) { - EulerDelta[i] = new Point3[NumFrames]; - if (EulerDelta[i] == NULL) { - throw (ErrorClass("Out of Memory")); - } - - /* - ** Initialize all of the Euler angles to 0,0,0 - */ - for (j=0; jNum_Nodes()]; - - for (i=0; iNum_Nodes(); i++) { - VisData[i].Resize(NumFrames); - - /* - ** initialize to always visible - */ - for (j=0; jNum_Nodes()]; - - for (i=0; iNum_Nodes(); i++) { - BinMoveData[i].Resize(NumFrames); - - /* - ** initialize to always interpolate - */ - for (j=0; jNum_Nodes()); - - for (i=0; iNum_Nodes(); i++) { - NodeValidFlags[i] = 0; - } - - /* - ** Compute motion data for each frame - */ - for (i=0; i < NumFrames; i++) { - ExportLog::rprintf("( %d ) ", i); - ExportLog::updatebar(i, NumFrames); - compute_frame_motion(i); - } - - ExportLog::updatebar(1, 1); // 100% - ExportLog::rprintf("Extraction Complete.\n"); -} - - - -/*********************************************************************************************** - * MotionClass::~MotionClass -- destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -MotionClass::~MotionClass(void) -{ - int i; - - for (i=0; iNum_Nodes(); i++) { - if (MotionMatrix[i]) delete[] MotionMatrix[i]; - } - if (MotionMatrix) { - delete[] MotionMatrix; - } - - for (i=0; iNum_Nodes(); i++) { - if (EulerDelta[i]) delete[] EulerDelta[i]; - } - if (EulerDelta) { - delete[] EulerDelta; - } - - if (VisData) { - delete[] VisData; - } - - if (BinMoveData) { - delete[] BinMoveData; - } - - ExportLog::printf("Destroy Log..%d,%d,%d,%d, %s..\n",1,2,3,4,"go"); - -} - - -/*********************************************************************************************** - * MotionClass::compute_frame_motion -- compute the motion for a specified frame * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -void MotionClass::compute_frame_motion(int frame) -{ - /* - ** Compute MAX's time value for this frame - ** NOTE: the frame index passed in is the offset from StartFrame - ** to get the original MAX frame number, we add StartFrame. - */ - TimeValue frametime = (StartFrame + frame) * GetTicksPerFrame(); - - /* - ** Create a hierarchy tree object for the scene at this frame - */ - HierarchySaveClass * tree; - - if (RootNode != NULL) { - tree = new HierarchySaveClass(RootNode,frametime,*Meter,"NoName",false,BasePose); - } else { - tree = new HierarchySaveClass(RootList,frametime,*Meter,"NoName",false,BasePose,Offset); - } - - if (tree == NULL) { - throw (ErrorClass("Out of memory!")); - } - - /* - ** Loop over each node in this frame's tree - */ - for (int tindex=0; tindexNum_Nodes(); tindex++) { - - /* - ** Find the node in the Base Pose corresponding to this node. - ** If this node is not in the base pose, skip - */ - int bindex = BasePose->Find_Named_Node(tree->Get_Node_Name(tindex)); - - if (bindex != -1) { - - /* - ** Get the relative transform from the base and from - ** this frame's tree. Assume that both have already been "fixed"; - ** obviously the base pose has... However, the current tree - ** needs to be built by passing the basepose in as the "fixup tree" - ** - ** What are the "fixup" matrices? These are the transforms which - ** were applied to the base pose when the user wanted to force the - ** base pose to use only matrices with certain properties. For - ** example, if we wanted the base pose to use translations only, - ** the fixup transform for each node is a transform which when - ** multiplied by the real node's world transform, yeilds a pure - ** translation matrix. Fixup matrices also show up in the mesh - ** exporter since all vertices must be transformed by their inverses - ** in order to make things work... - */ - Matrix3 basetm = BasePose->Get_Node_Relative_Transform(bindex); - Matrix3 thistm = tree->Get_Node_Relative_Transform(tindex); - INode *tree_node = tree->Get_Node(tindex); - - Matrix3 motion = thistm * Inverse(basetm); - - motion = Cleanup_Orthogonal_Matrix(motion); - - set_motion_matrix(bindex,frame,motion); - - /* - ** Also, store the Euler angles for this node - */ - EulerAnglesClass my_eulers(motion,EulerOrderXYZr); - float ex = my_eulers.Get_Angle(0); - float ey = my_eulers.Get_Angle(1); - float ez = my_eulers.Get_Angle(2); - - set_eulers(bindex,frame,ex,ey,ez); - - /* - ** Store the visibility bit for this node - */ - INode * node = tree->Get_Node(tindex); - bool vis; - if (node) { - vis = (node->GetVisibility(frametime) > 0.0f); - } else { - vis = 1; - } - set_visibility(bindex,frame,vis); - - // - // Store out binary move or not - // - bool binary_move = false; - - if ((node)&&(vis)) { - - if (frame != 0) { - // sample previous frame, and an inbetween time - // to determine if there's a binary movement - - TimeValue frametime_prev = frametime - GetTicksPerFrame(); - TimeValue frametime_mid = (frametime + frametime_prev) / 2; - - // if data at frametime_prev == data at frametime_mid and != data at frametime - // then we have a binary movement! - - Control *c; - - c = node->GetTMController()->GetPositionController(); - - if (c) { - - Interval iValid; - - Matrix3 smat1; // sample matrix 1 - Matrix3 smat2; // sample matrix 2 - Matrix3 smat3; // sample matrix 3 - - iValid = FOREVER; - smat1 = node->GetParentTM(frametime_prev); - c->GetValue(frametime_prev, &smat1, iValid, CTRL_RELATIVE); - - iValid = FOREVER; - smat2 = node->GetParentTM(frametime_mid); - c->GetValue(frametime_mid, &smat2, iValid, CTRL_RELATIVE); - - iValid = FOREVER; - smat3 = node->GetParentTM(frametime); - c->GetValue(frametime, &smat3, iValid, CTRL_RELATIVE); - - if ((smat1 == smat2) && (!(smat2 == smat3))) { - binary_move = true; - DebugPrint(_T("Binary Move on Translation\n")); - } - - if (false == binary_move) { - c = node->GetTMController()->GetRotationController(); - - if (c) { - - iValid = FOREVER; - smat1 = node->GetParentTM(frametime_prev); - c->GetValue(frametime_prev, &smat1, iValid, CTRL_RELATIVE); - - iValid = FOREVER; - smat2 = node->GetParentTM(frametime_mid); - c->GetValue(frametime_mid, &smat2, iValid, CTRL_RELATIVE); - - iValid = FOREVER; - smat3 = node->GetParentTM(frametime); - c->GetValue(frametime, &smat3, iValid, CTRL_RELATIVE); - - if ((smat1 == smat2) && (!(smat2 == smat3))) { - binary_move = true; - DebugPrint(_T("Binary Move on Rotation\n")); - } - } - } - } - } - } - - - set_binary_movement(bindex, frame, binary_move); - - } // if(bindex!=-1) - } - - /* - ** release allocated memory - */ - delete tree; -} - - -/*********************************************************************************************** - * MotionClass::set_motion_matrix -- store a motion matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -void MotionClass::set_motion_matrix(int node,int frame,const Matrix3 & motion) -{ - assert(node >= 0); - assert(frame >= 0); - assert(node < BasePose->Num_Nodes()); - assert(frame < NumFrames); - - MotionMatrix[node][frame] = motion; - NodeValidFlags[node] = 1; -} - - -/*********************************************************************************************** - * MotionClass::get_motion_matrix -- retrieve a motion matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -Matrix3 MotionClass::get_motion_matrix(int node,int frame) -{ - assert(node >= 0); - assert(frame >= 0); - assert(node < BasePose->Num_Nodes()); - assert(frame < NumFrames); - - return MotionMatrix[node][frame]; -} - - -/*********************************************************************************************** - * MotionClass::set_eulers -- store euler angles * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -void MotionClass::set_eulers(int node,int frame, float x, float y, float z) -{ - /* - ** if we're past the first frame, massage the euler angles to the - ** representation closest to the previous frame. - */ - if (frame > 0) { - - /* - ** First, compute equivalent euler angles - */ - double x2 = PI + x; - double y2 = PI - y; - double z2 = PI + z; - - if (x2 > PI) { - x2 = x2 - 2*PI; - } - - if (y2 > PI) { - y2 = y2 - 2*PI; - } - - if (z2 > PI) { - z2 = z2 - 2*PI; - } - - /* - ** load up the previous frame eulers - */ - double px,py,pz; - px = get_eulers(node,frame - 1)[0]; - py = get_eulers(node,frame - 1)[1]; - pz = get_eulers(node,frame - 1)[2]; - - // now, pick between the two - double mag0 = (x - px) * (x - px) + (y - py) * (y - py) + (z - pz) * (z - pz); - double mag1 = (x2 - px) * (x2 - px) + (y2 - py) * (y2 - py) + (z2 - pz) * (z2 - pz); - - if (mag1 < mag0) { - x = x2; - y = y2; - z = z2; - } - } - - EulerDelta[node][frame].x = x; - EulerDelta[node][frame].y = y; - EulerDelta[node][frame].z = z; - NodeValidFlags[node] = 1; -} - - -/*********************************************************************************************** - * MotionClass::get_eulers -- retrieve euler angles * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -Point3 MotionClass::get_eulers(int node,int frame) -{ - return Point3( - EulerDelta[node][frame].x, - EulerDelta[node][frame].y, - EulerDelta[node][frame].z - ); -} - - -/*********************************************************************************************** - * MotionClass::set_visibility -- store a visibility bit * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/15/98 GTH : Created. * - *=============================================================================================*/ -void MotionClass::set_visibility(int node,int frame,bool visible) -{ - VisData[node][frame] = visible; - NodeValidFlags[node] = 1; -} - - -/*********************************************************************************************** - * MotionClass::get_visibility -- retrieve the visibility bit for this node:frame * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/15/98 GTH : Created. * - *=============================================================================================*/ -bool MotionClass::get_visibility(int node,int frame) -{ - return VisData[node][frame]; -} - - -/*********************************************************************************************** - * MotionClass::set_binary_movement -- store a binary movement bit * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/15/98 GTH : Created. * - *=============================================================================================*/ -void MotionClass::set_binary_movement(int node,int frame,bool visible) -{ - BinMoveData[node][frame] = visible; - //NodeValidFlags[node] = 1; -} - - -/*********************************************************************************************** - * MotionClass::get_visibility -- retrieve the movement bit for this node:frame * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/15/98 GTH : Created. * - *=============================================================================================*/ -bool MotionClass::get_binary_movement(int node,int frame) -{ - return BinMoveData[node][frame]; -} - - - -/*********************************************************************************************** - * MotionClass::Save -- save the motion to a W3D file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -bool MotionClass::Save(ChunkSaveClass & csave) -{ - uint32 chunk_anim_type = W3D_CHUNK_ANIMATION; - - ExportLog::printf("\nBegin Save Motion Data\n"); - - if (CompressAnimation) { - chunk_anim_type = W3D_CHUNK_COMPRESSED_ANIMATION; - } - - if (!csave.Begin_Chunk( chunk_anim_type )) { - return false; - } - - if (!save_header(csave)) { - return false; - } - - if (!save_channels(csave)) { - return false; - } - - if (!csave.End_Chunk()) { - return false; - } - - return true; -} - - -/*********************************************************************************************** - * MotionClass::save_header -- save the header * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -bool MotionClass::save_header(ChunkSaveClass & csave) -{ - - ExportLog::printf("Save Header Type: "); - - if (CompressAnimation) { - // New Compressed Style - if (!csave.Begin_Chunk(W3D_CHUNK_COMPRESSED_ANIMATION_HEADER)) { - return false; - } - - W3dCompressedAnimHeaderStruct aheader; - aheader.Version = W3D_CURRENT_COMPRESSED_HANIM_VERSION; - Set_W3D_Name(aheader.Name,Name); - Set_W3D_Name(aheader.HierarchyName,BasePose->Get_Name()); - aheader.NumFrames = NumFrames; - aheader.FrameRate = FrameRate; - aheader.Flavor = CompressAnimationFlavor; // for future expansion - - switch (CompressAnimationFlavor) { - - case ANIM_FLAVOR_TIMECODED: - ExportLog::printf("TimeCoded\n"); - break; - case ANIM_FLAVOR_ADAPTIVE_DELTA: - ExportLog::printf("Adaptive Delta\n"); - break; - default: - ExportLog::printf("UNKNOWN\n"); - break; - } - - if (csave.Write(&aheader,sizeof(aheader)) != sizeof(aheader)) { - return false; - } - - if (!csave.End_Chunk()) { - return false; - } - } - else { - - ExportLog::printf("Non-Compressed.\n"); - - // Classic Non-Compressed Style - if (!csave.Begin_Chunk(W3D_CHUNK_ANIMATION_HEADER)) { - return false; - } - - W3dAnimHeaderStruct aheader; - aheader.Version = W3D_CURRENT_HANIM_VERSION; - Set_W3D_Name(aheader.Name,Name); - Set_W3D_Name(aheader.HierarchyName,BasePose->Get_Name()); - aheader.NumFrames = NumFrames; - aheader.FrameRate = FrameRate; - - if (csave.Write(&aheader,sizeof(aheader)) != sizeof(aheader)) { - return false; - } - - if (!csave.End_Chunk()) { - return false; - } - } - - - return true; -} - -/*********************************************************************************************** - * MotionClass::save_channels -- save the motion channels * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -bool MotionClass::save_channels(ChunkSaveClass & csave) -{ - - int NumNodes = BasePose->Num_Nodes(); - - ExportLog::printf("\nSaving Channel Data for %d Nodes\n", NumNodes); - - for (int nodeidx = 0; nodeidx < BasePose->Num_Nodes(); nodeidx++) { - - ExportLog::printf("\nnode: %d ", nodeidx); - - /* - ** Just ignore this node if it didn't appear in the max scene. - */ - if (NodeValidFlags[nodeidx]) { - - float identity[] = { 0.0f,0.0f,0.0f,1.0f }; - - VectorChannelClass xchan (nodeidx, NumFrames, ANIM_CHANNEL_X, 1, identity); - VectorChannelClass ychan (nodeidx, NumFrames, ANIM_CHANNEL_Y, 1, identity); - VectorChannelClass zchan (nodeidx, NumFrames, ANIM_CHANNEL_Z, 1, identity); - VectorChannelClass xrchan(nodeidx, NumFrames, ANIM_CHANNEL_XR, 1, identity); - VectorChannelClass yrchan(nodeidx, NumFrames, ANIM_CHANNEL_YR, 1, identity); - VectorChannelClass zrchan(nodeidx, NumFrames, ANIM_CHANNEL_ZR, 1, identity); - VectorChannelClass qchan (nodeidx, NumFrames, ANIM_CHANNEL_Q, 4, identity); - - xchan.SetSaveOptions(CompressAnimation, CompressAnimationFlavor, CompressAnimationTranslationError, CompressAnimationRotationError, ReduceAnimation, ReduceAnimationPercent); - ychan.SetSaveOptions(CompressAnimation, CompressAnimationFlavor, CompressAnimationTranslationError, CompressAnimationRotationError, ReduceAnimation, ReduceAnimationPercent); - zchan.SetSaveOptions(CompressAnimation, CompressAnimationFlavor, CompressAnimationTranslationError, CompressAnimationRotationError, ReduceAnimation, ReduceAnimationPercent); - xrchan.SetSaveOptions(CompressAnimation, CompressAnimationFlavor, CompressAnimationTranslationError, CompressAnimationRotationError, ReduceAnimation, ReduceAnimationPercent); - yrchan.SetSaveOptions(CompressAnimation, CompressAnimationFlavor, CompressAnimationTranslationError, CompressAnimationRotationError, ReduceAnimation, ReduceAnimationPercent); - zrchan.SetSaveOptions(CompressAnimation, CompressAnimationFlavor, CompressAnimationTranslationError, CompressAnimationRotationError, ReduceAnimation, ReduceAnimationPercent); - qchan.SetSaveOptions(CompressAnimation, CompressAnimationFlavor, CompressAnimationTranslationError, CompressAnimationRotationError, ReduceAnimation, ReduceAnimationPercent); - - BitChannelClass vischan(nodeidx, NumFrames, BIT_CHANNEL_VIS, 1); - vischan.Set_Bits(VisData[nodeidx]); - - BitChannelClass binmovechan(nodeidx, NumFrames, 0, 0); - binmovechan.Set_Bits(BinMoveData[nodeidx]); - - for (int frameidx = 0; frameidx < NumFrames; frameidx++) { - - float vec[4]; - Matrix3 tm = get_motion_matrix(nodeidx,frameidx); - Point3 eulers = get_eulers(nodeidx,frameidx); - - - Point3 old_tran = tm.GetTrans(); - Quat old_rot(tm); - - Point3 tran; - Point3 scale; - Quat rot; - - DecomposeMatrix(tm,tran,rot,scale); - - /* - ** fixup the quaternion - max's quaternions are different than mine(?) - */ - rot[0] = -rot[0]; - rot[1] = -rot[1]; - rot[2] = -rot[2]; - rot[3] = rot[3]; - - /* - ** Build the x translation channel - */ - vec[0] = tran.x; - xchan.Set_Vector(frameidx,vec); - - /* - ** Build the y translation channel - */ - vec[0] = tran.y; - ychan.Set_Vector(frameidx,vec); - - /* - ** Build the z translation channel - */ - vec[0] = tran.z; - zchan.Set_Vector(frameidx,vec); - - /* - ** Build the x rotation channel - */ - vec[0] = eulers.x; - xrchan.Set_Vector(frameidx,vec); - - /* - ** Build the y rotation channel - */ - vec[0] = eulers.y; - yrchan.Set_Vector(frameidx,vec); - - /* - ** Build the z rotation channel - */ - vec[0] = eulers.z; - zrchan.Set_Vector(frameidx,vec); - - /* - ** Build the quaternion rotation channel - */ - vec[0] = rot[0]; - vec[1] = rot[1]; - vec[2] = rot[2]; - vec[3] = rot[3]; - - qchan.Set_Vector(frameidx,vec); - - /* - ** build the visibility channel - */ - vischan.Set_Bit(frameidx,get_visibility(nodeidx,frameidx)); - // - // build binarymovement channel - // - binmovechan.Set_Bit(frameidx, get_binary_movement(nodeidx, frameidx)); - } - - // If objects arn't visible, then the channel data may as well be empty - - if (!vischan.Is_Empty()) { - - if (!xchan.Is_Empty()) xchan.ClearInvisibleData(&vischan); - if (!ychan.Is_Empty()) ychan.ClearInvisibleData(&vischan); - if (!zchan.Is_Empty()) zchan.ClearInvisibleData(&vischan); - if (!qchan.Is_Empty()) qchan.ClearInvisibleData(&vischan); - - } - - if (!xchan.Is_Empty()) { - ExportLog::printf("x"); - xchan.Save(csave, &binmovechan ); - } - if (!ychan.Is_Empty()) { - ExportLog::printf("y"); - ychan.Save(csave, &binmovechan ); - } - if (!zchan.Is_Empty()) { - ExportLog::printf("z"); - zchan.Save(csave, &binmovechan ); - } - - - // (gth) not saving Euler angles any more since we don't use them -// if (!xrchan.Is_Empty()) xrchan.Save(csave); -// if (!yrchan.Is_Empty()) yrchan.Save(csave); -// if (!zrchan.Is_Empty()) zrchan.Save(csave); - - if (!qchan.Is_Empty()) { - ExportLog::printf("q"); - qchan.Save(csave, &binmovechan); - } - - if (!vischan.Is_Empty()) { - ExportLog::printf("v"); - vischan.Save(csave, CompressAnimation); - } - } - - ExportLog::updatebar(nodeidx ,NumNodes); - - } - - ExportLog::updatebar(1,1); - - ExportLog::printf("\n\nSave Channel Data Complete.\n"); - - return true; -} - -// EOF - motion.cpp - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/motion.h b/Generals/Code/Tools/WW3D/max2w3d/motion.h deleted file mode 100644 index 1caade3ffec..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/motion.h +++ /dev/null @@ -1,164 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/motion.h 13 10/30/00 6:56p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/motion.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/30/00 5:25p $* - * * - * $Revision:: 13 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef MOTION_H -#define MOTION_H - - -#ifndef ALWAYS_H -#include "always.h" -#endif - -#include - -#ifndef HIERSAVE_H -#include "hiersave.h" -#endif - -#ifndef PROGRESS_H -#include "PROGRESS.H" -#endif - -#ifndef CHUNKIO_H -#include "chunkio.h" -#endif - -#ifndef VECTOR_H -#include "Vector.H" -#endif - -#ifndef LOGDLG_H -#include "logdlg.h" -#endif - -struct W3dExportOptionsStruct; - - -class MotionClass -{ -public: - - MotionClass ( - IScene * scene, - INode * rootnode, - HierarchySaveClass * basepose, - W3dExportOptionsStruct & options, - int framerate, - Progress_Meter_Class * meter, - HWND MaxHwnd, - char * name, - Matrix3 & offset = Matrix3(1) // matrix to bring current object space into - // base object space (for damage animations) - ); - - MotionClass ( - IScene * scene, - INodeListClass * rootlist, - HierarchySaveClass * basepose, - W3dExportOptionsStruct & options, - int framerate, - Progress_Meter_Class * meter, - HWND MaxHwnd, - char * name, - Matrix3 & offset = Matrix3(1) // matrix to bring current object space into - // base object space (for damage animations) - ); - - ~MotionClass(void); - - bool Save(ChunkSaveClass & csave); - -private: - - IScene * Scene; - INode * RootNode; - INodeListClass * RootList; - HierarchySaveClass * BasePose; - int StartFrame; - int EndFrame; - int NumFrames; - int FrameRate; - - bool ReduceAnimation; - int ReduceAnimationPercent; - - bool CompressAnimation; - int CompressAnimationFlavor; - float CompressAnimationTranslationError; - float CompressAnimationRotationError; - - Progress_Meter_Class * Meter; - char Name[W3D_NAME_LEN]; - Matrix3 Offset; - - // 2D array of matrices, one per node per frame - Matrix3 * * MotionMatrix; - - // 2D array of euler angles, one per node per frame - Point3 * * EulerDelta; - - // Visibility bits, one bit per node per frame - BooleanVectorClass * VisData; - - // Movement bits, one bit per node per frame, to designate a movement as interpolated, or not - BooleanVectorClass * BinMoveData; - - // flag for each node in the base pose, indicating - // whether the node actually appeard in the max scene - // being exported. - BooleanVectorClass NodeValidFlags; - - void compute_frame_motion(int frame); - void set_motion_matrix(int node,int frame,const Matrix3 & motion); - Matrix3 get_motion_matrix(int node,int frame); - void set_eulers(int node,int frame,float x,float y,float z); - Point3 get_eulers(int node,int frame); - void set_visibility(int node,int frame,bool visible); - bool get_visibility(int node,int frame); - void set_binary_movement(int node,int frame,bool visible); - bool get_binary_movement(int node,int frame); - - bool save_header(ChunkSaveClass & csave); - bool save_channels(ChunkSaveClass & csave); - - void init(void); - -}; - - -#endif /*MOTION_H*/ \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/namedsel.cpp b/Generals/Code/Tools/WW3D/max2w3d/namedsel.cpp deleted file mode 100644 index 42acab32b7b..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/namedsel.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/namedsel.cpp 4 10/28/97 6:08p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - WWSkin * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/namedsel.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/26/97 1:29p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "namedsel.h" - - -NamedSelSetList::~NamedSelSetList() -{ - for (int i=0; i= 0) Delete_Set(i); -} - -void NamedSelSetList::Reset(void) -{ - while (Sets.Count() > 0) { - Delete_Set(0); - } -} - -void NamedSelSetList::Set_Size(int size) -{ - for (int i=0; iSetSize(size,TRUE); - } -} - -NamedSelSetList& NamedSelSetList::operator=(NamedSelSetList& from) -{ - for (int i=0; iBeginChunk(NAMED_SEL_SET_CHUNK); - - isave->BeginChunk(NAMED_SEL_NAME_CHUNK); - isave->WriteWString(*Names[i]); - isave->EndChunk(); - - isave->BeginChunk(NAMED_SEL_BITS_CHUNK); - Sets[i]->Save(isave); - isave->EndChunk(); - - isave->EndChunk(); - - } - return IO_OK; -} - - -IOResult NamedSelSetList::Load(ILoad *iload) -{ - IOResult res; - - while (IO_OK==(res=iload->OpenChunk())) { - - switch (iload->CurChunkID()) { - - case NAMED_SEL_SET_CHUNK: - res = Load_Set(iload); - break; - - default: - assert(0); - break; - } - - iload->CloseChunk(); - if (res!=IO_OK) return res; - } - return IO_OK; -} - -IOResult NamedSelSetList::Load_Set(ILoad * iload) -{ - IOResult res; - BitArray set; - TCHAR * name; - - BOOL gotset = FALSE; - BOOL gotname = FALSE; - - res = iload->OpenChunk(); - - while (IO_OK==(res=iload->OpenChunk())) { - - switch (iload->CurChunkID()) { - - case NAMED_SEL_BITS_CHUNK: - { - res = set.Load(iload); - gotset = TRUE; - break; - } - - case NAMED_SEL_NAME_CHUNK: - { - res = iload->ReadWStringChunk(&name); - gotname = TRUE; - break; - } - } - iload->CloseChunk(); - if (res != IO_OK) return res; - } - - assert(gotset && gotname); - Append_Set(set,TSTR(name)); - - return IO_OK; -} \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/namedsel.h b/Generals/Code/Tools/WW3D/max2w3d/namedsel.h deleted file mode 100644 index bc03d3b653a..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/namedsel.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/namedsel.h 4 10/28/97 6:08p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - WWSkin * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/namedsel.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/21/97 2:05p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef NAMEDSEL_H -#define NAMEDSEL_H - - -#include "max.h" - -/* -** This is a class for containing bit arrays for -** the named selection sets. I stole it from -** the Edit Mesh modifier code... -** It is basically a dynamically sized array -** of bitarrays. -*/ -class NamedSelSetList -{ -public: - Tab Sets; - Tab Names; - - ~NamedSelSetList(); - - BitArray & operator[](int i) { return *Sets[i]; } - int Count() { return Sets.Count(); } - - int Find_Set(TSTR & setname); - void Delete_Set(int i); - void Delete_Set(TSTR & setname); - void Reset(void); - void Append_Set(BitArray & nset,TSTR & setname); - - IOResult Load(ILoad * iload); - IOResult Save(ISave * isave); - IOResult Load_Set(ILoad * iload); - - void Set_Size(int size); - NamedSelSetList & operator=(NamedSelSetList & from); - - enum { - NAMED_SEL_SET_CHUNK = 0x0021, - NAMED_SEL_BITS_CHUNK = 0x0022, - NAMED_SEL_NAME_CHUNK = 0x0023 - }; -}; - - -#endif /*NAMEDSEL_H*/ diff --git a/Generals/Code/Tools/WW3D/max2w3d/nullsave.cpp b/Generals/Code/Tools/WW3D/max2w3d/nullsave.cpp deleted file mode 100644 index 008d3656740..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/nullsave.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/nullsave.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 8/05/99 3:14p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "nullsave.h" - - -NullSaveClass::NullSaveClass -( - char * mesh_name, - char * container_name, - Progress_Meter_Class & meter -) -{ - ////////////////////////////////////////////////////////////////////// - // Set up the NullObject description - ////////////////////////////////////////////////////////////////////// - memset(&NullData,0,sizeof(NullData)); - - NullData.Version = W3D_NULL_OBJECT_CURRENT_VERSION; - if ((container_name != NULL) && (strlen(container_name) > 0)) { - strcpy(NullData.Name,container_name); - strcat(NullData.Name,"."); - } - strcat(NullData.Name,mesh_name); -} - - - -int NullSaveClass::Write_To_File(ChunkSaveClass & csave) -{ - csave.Begin_Chunk(W3D_CHUNK_NULL_OBJECT); - csave.Write(&NullData,sizeof(NullData)); - csave.End_Chunk(); - return 0; -} - - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/nullsave.h b/Generals/Code/Tools/WW3D/max2w3d/nullsave.h deleted file mode 100644 index a7ce19de370..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/nullsave.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/nullsave.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 8/05/99 3:05p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef NULLSAVE_H -#define NULLSAVE_H - - -#include -#include "w3d_file.h" -#include "chunkio.h" -#include "PROGRESS.H" - - -/******************************************************************************************* -** -** NullSaveClass - Create a Null object. -** -*******************************************************************************************/ -class NullSaveClass -{ -public: - - enum { - EX_UNKNOWN = 0, // exception error codes - EX_CANCEL = 1 - }; - - NullSaveClass( char * mesh_name, - char * container_name, - Progress_Meter_Class & meter); - - int Write_To_File(ChunkSaveClass & csave); - -private: - - W3dNullObjectStruct NullData; - -}; - - - - -#endif //NULLSAVE_H diff --git a/Generals/Code/Tools/WW3D/max2w3d/presetexportoptionsdialog.cpp b/Generals/Code/Tools/WW3D/max2w3d/presetexportoptionsdialog.cpp deleted file mode 100644 index c4f31e2fd10..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/presetexportoptionsdialog.cpp +++ /dev/null @@ -1,914 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/presetexportoptionsdialog.cpp $* - * * - * Original Author:: Patrick Smith * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 11/10/00 2:26p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "presetexportoptionsdialog.h" -#include "dllmain.h" -#include "resource.h" -#include "w3dexp.h" -#include "animationcompressionsettings.h" - - -//////////////////////////////////////////////////////////////////////////////////////// -// Constants -//////////////////////////////////////////////////////////////////////////////////////// - -static const char *BROWSE_FILTER = "W3D Files (*.W3D)\0*.W3D\0WHT Files (*.WHT)\0*.WHT\0\0"; - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// PresetExportOptionsDialogClass -// -//////////////////////////////////////////////////////////////////////////////////////// -PresetExportOptionsDialogClass::PresetExportOptionsDialogClass (Interface *maxinterface, HWND parent_wnd) : - MaxInterface (maxinterface), - Options (NULL), - Wnd (NULL), - ParentWnd (parent_wnd), - CurrentPane (-1) -{ - ::memset (PaneWnds, 0, sizeof (PaneWnds)); - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// ~PresetExportOptionsDialogClass -// -//////////////////////////////////////////////////////////////////////////////////////// -PresetExportOptionsDialogClass::~PresetExportOptionsDialogClass (void) -{ - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Do_Modal -// -//////////////////////////////////////////////////////////////////////////////////////// -int -PresetExportOptionsDialogClass::Do_Modal (void) -{ - int retval = ::DialogBoxParam (AppInstance, MAKEINTRESOURCE (IDD_W3D_PRESET_EXPORT_OPTIONS), - ParentWnd, Real_Message_Proc, (LPARAM)this); - return retval; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Real_Message_Proc -// -//////////////////////////////////////////////////////////////////////////////////////// -BOOL CALLBACK -PresetExportOptionsDialogClass::Real_Message_Proc -( - HWND wnd, - UINT message, - WPARAM wparam, - LPARAM lparam -) -{ - PresetExportOptionsDialogClass *dialog_obj = NULL; - - // - // Setup the framework we need so that the instance - // can process the messages instead of this static callback. - // - if (message == WM_INITDIALOG) { - dialog_obj = (PresetExportOptionsDialogClass *)lparam; - dialog_obj->Wnd = wnd; - ::SetProp (wnd, "DIALOG_OBJ", (HANDLE)dialog_obj); - } else { - dialog_obj = (PresetExportOptionsDialogClass *)::GetProp (wnd, "DIALOG_OBJ"); - } - - // - // Allow the instance to handle the call - // - BOOL retval = FALSE; - if (dialog_obj != NULL) { - retval = dialog_obj->Message_Proc (message, wparam, lparam); - } - - // - // Cleanup the framework - // - if (message == WM_DESTROY) { - ::RemoveProp (wnd, "DIALOG_OBJ"); - } - - return retval; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Settings_Pane_Message_Proc -// -//////////////////////////////////////////////////////////////////////////////////////// -BOOL CALLBACK -PresetExportOptionsDialogClass::Settings_Pane_Message_Proc -( - HWND wnd, - UINT message, - WPARAM wparam, - LPARAM lparam -) -{ - PresetExportOptionsDialogClass *dialog_obj = NULL; - - // - // Setup the framework we need so that the instance - // can process the messages instead of this static callback. - // - if (message == WM_INITDIALOG) { - dialog_obj = (PresetExportOptionsDialogClass *)lparam; - ::SetProp (wnd, "DIALOG_OBJ", (HANDLE)dialog_obj); - } else { - dialog_obj = (PresetExportOptionsDialogClass *)::GetProp (wnd, "DIALOG_OBJ"); - } - - // - // Allow the instance to handle the call - // - BOOL retval = FALSE; - if (dialog_obj != NULL) { - retval = dialog_obj->Pane_Message_Proc (message, wparam, lparam); - } - - // - // Cleanup the framework - // - if (message == WM_DESTROY) { - ::RemoveProp (wnd, "DIALOG_OBJ"); - } - - return retval; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Pane_Message_Proc -// -//////////////////////////////////////////////////////////////////////////////////////// -BOOL -PresetExportOptionsDialogClass::Pane_Message_Proc -( - UINT message, - WPARAM wparam, - LPARAM lparam -) -{ - BOOL retval = FALSE; - - switch (message) - { - case WM_CUSTEDIT_ENTER: - - switch (wparam) - { - case IDC_RANGE_LOW_EDIT: - { - // - // Update the start frame - // - ICustEdit *edit_ctrl = GetICustEdit ((HWND)lparam); - if (edit_ctrl != NULL) { - Options->StartFrame = edit_ctrl->GetInt (); - - // - // Bounds check the value - // - if (Options->StartFrame > Options->EndFrame) { - Options->StartFrame = Options->EndFrame; - } - - Update_Controls (); - } - } - break; - - case IDC_RANGE_HIGH_EDIT: - { - // - // Update the end frame - // - ICustEdit *edit_ctrl = GetICustEdit ((HWND)lparam); - if (edit_ctrl != NULL) { - Options->EndFrame = edit_ctrl->GetInt (); - - // - // Bounds check the value - // - if (Options->EndFrame < Options->StartFrame) { - Options->EndFrame = Options->StartFrame; - } - - Update_Controls (); - } - } - break; - } - - break; - - case CC_SPINNER_BUTTONUP: - { - ISpinnerControl *spin_ctrl = (ISpinnerControl *)lparam; - if (spin_ctrl != NULL) { - - switch (LOWORD (wparam)) - { - // - // Update the start frame - // - case IDC_RANGE_LOW_SPIN: - Options->StartFrame = spin_ctrl->GetIVal (); - - // - // Bounds check the value - // - if (Options->StartFrame > Options->EndFrame) { - Options->StartFrame = Options->EndFrame; - } - Update_Controls (); - break; - - // - // Update the end frame - // - case IDC_RANGE_HIGH_SPIN: - Options->EndFrame = spin_ctrl->GetIVal (); - - // - // Bounds check the value - // - if (Options->EndFrame < Options->StartFrame) { - Options->EndFrame = Options->StartFrame; - } - - Update_Controls (); - break; - } - } - } - break; - - case WM_COMMAND: - { - HWND control_wnd = reinterpret_cast (lparam); - bool update_controls = true; - - switch (LOWORD (wparam)) - { - case IDC_EXPORT_MESH_SMOOTH_CHECK: - Options->SmoothBetweenMeshes = (SendMessage (control_wnd, BM_GETCHECK, 0, 0L) == 1); - break; - - case IDC_EXPORT_MESH_AABTREES: - Options->DisableExportAABTrees = (SendMessage (control_wnd, BM_GETCHECK, 0, 0L) != 1); - break; - -#if 0 - case IDC_EXPORT_MESH_OPTIMIZE: - Options->EnableOptimizeMeshData = (SendMessage (control_wnd, BM_GETCHECK, 0, 0L) == 1); - break; -#endif - - case IDC_USE_SKELETON_CHECK: - Options->LoadHierarchy = (SendMessage (control_wnd, BM_GETCHECK, 0, 0L) == 1); - break; - - case IDC_COMPRESS_ANIMATION_CHECK: - Options->CompressAnimation = (SendMessage (control_wnd, BM_GETCHECK, 0, 0L) == 1); - break; - - case IDC_WHT_BROWSE_BUTTON: - { - OPENFILENAME ofn = { sizeof (OPENFILENAME), 0 }; - ofn.lpstrFilter = BROWSE_FILTER; - ofn.nMaxFile = _MAX_PATH; - ofn.nMaxFileTitle = _MAX_FNAME + _MAX_EXT; - ofn.Flags = OFN_HIDEREADONLY | OFN_CREATEPROMPT; - ofn.lpstrDefExt = "wht"; - ofn.hwndOwner = Wnd; - ofn.lpstrFile = Options->HierarchyFilename; - - if (::GetOpenFileName (&ofn)) { - - // - // Get the relative path between the current export path - // and the full file path to the hierarchy file: - // - Create_Relative_Path (Options->RelativeHierarchyFilename, - W3dExportClass::CurrentExportPath, - ofn.lpstrFile); - } - } - break; - - case IDC_COMPRESSION_SETTINGS: - { - // - // Display the compression options dialog - // - AnimationCompressionSettingsDialogClass dialog (MaxInterface, Wnd); - dialog.Set_Options (Options); - dialog.Do_Modal (); - } - break; - - case IDC_EXPORT_MESH_MAT_TO_TEXTURE: - Options->EnableMaterialColorToTextureConversion = (SendMessage (control_wnd, BM_GETCHECK, 0, 0L) == 1); - break; - - default: - update_controls = false; - break; - } - - if (update_controls) { - Update_Controls (); - } - } - break; - } - - return retval; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Message_Proc -// -//////////////////////////////////////////////////////////////////////////////////////// -BOOL -PresetExportOptionsDialogClass::Message_Proc -( - UINT message, - WPARAM wparam, - LPARAM lparam -) -{ - BOOL retval = FALSE; - - switch (message) - { - case WM_INITDIALOG: - { - // - // Center the dialog - // - RECT parent_rect = { 0 }; - RECT rect = { 0 }; - ::GetWindowRect (ParentWnd, &parent_rect); - ::GetWindowRect (Wnd, &rect); - int width = parent_rect.right - parent_rect.left; - int height = parent_rect.bottom - parent_rect.top; - ::SetWindowPos ( Wnd, NULL, - parent_rect.left + (width / 2) - ((rect.right - rect.left) / 2), - parent_rect.top + (height / 2) - ((rect.bottom - rect.top) / 2), - 0, 0, SWP_NOZORDER | SWP_NOSIZE); - - // - // Initialize the controls - // - Create_Settings_Panes (); - Initialize_Controls (); - Update_Controls (); - Determine_Preset_Type (); - retval = TRUE; - } - break; - - case WM_COMMAND: - retval = On_Command (wparam, lparam); - break; - } - - return retval; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// On_Command -// -//////////////////////////////////////////////////////////////////////////////////////// -BOOL -PresetExportOptionsDialogClass::On_Command (WPARAM wparam, LPARAM lparam) -{ - BOOL retval = FALSE; - - switch (LOWORD (wparam)) - { - case IDC_HLOD_RADIO: - Show_Settings_Pane (PANE_HLOD); - break; - - case IDC_ANIM_HLOD_RADIO: - Show_Settings_Pane (PANE_ANIM_HLOD); - break; - - case IDC_ANIM_RADIO: - Show_Settings_Pane (PANE_ANIM); - break; - - case IDC_TERRAIN_RADIO: - Show_Settings_Pane (PANE_TERRAIN); - break; - - case IDC_SKELETON_RADIO: - Show_Settings_Pane (PANE_SKELETON); - break; - - case IDC_MESH_RADIO: - Show_Settings_Pane (PANE_MESH); - break; - - case IDCANCEL: - ::memcpy (Options, &OrigOptions, sizeof (OrigOptions)); - EndDialog (Wnd, IDCANCEL); - break; - - case IDOK: - Save_Settings (); - EndDialog (Wnd, IDOK); - break; - } - - return retval; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Show_Settings_Pane -// -//////////////////////////////////////////////////////////////////////////////////////// -void -PresetExportOptionsDialogClass::Show_Settings_Pane (int pane_id) -{ - if (pane_id != CurrentPane) { - - // - // Show the new pane and hide the old pane - // - ::ShowWindow (PaneWnds[pane_id], SW_SHOW); - if (CurrentPane >= 0) { - ::ShowWindow (PaneWnds[CurrentPane], SW_HIDE); - } - CurrentPane = pane_id; - } - - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Create_Settings_Panes -// -//////////////////////////////////////////////////////////////////////////////////////// -void -PresetExportOptionsDialogClass::Create_Settings_Panes (void) -{ - PaneWnds[PANE_HLOD] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_HLOD), - Wnd, Settings_Pane_Message_Proc, (LPARAM)this); - - PaneWnds[PANE_ANIM_HLOD] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_ANIMATED_HLOD), - Wnd, Settings_Pane_Message_Proc, (LPARAM)this); - - PaneWnds[PANE_ANIM] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_ANIMATION), - Wnd, Settings_Pane_Message_Proc, (LPARAM)this); - - PaneWnds[PANE_TERRAIN] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_TERRAIN), - Wnd, Settings_Pane_Message_Proc, (LPARAM)this); - - PaneWnds[PANE_SKELETON] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_SKELETON), - Wnd, Settings_Pane_Message_Proc, (LPARAM)this); - - PaneWnds[PANE_MESH] = ::CreateDialogParam (AppInstance, MAKEINTRESOURCE (IDD_EXPORT_PANE_MESH), - Wnd, Settings_Pane_Message_Proc, (LPARAM)this); - - - // - // Get the position and size of the group box the settings panes will be - // displayed inside - // - RECT group_rect = { 0 }; - ::GetWindowRect (::GetDlgItem (Wnd, IDC_GROUP_BOX), &group_rect); - ::ScreenToClient (Wnd, (LPPOINT)&group_rect); - ::ScreenToClient (Wnd, ((LPPOINT)&group_rect) + 1); - int width = group_rect.right - group_rect.left; - int height = group_rect.bottom - group_rect.top; - - // - // Loop over all the panes and make sure they are in the proper location - // - for (int index = 0; index < PANE_MAX; index ++) { - HWND pane_wnd = PaneWnds[index]; - - // - // Get the size of this pane - // - RECT rect = { 0 }; - ::GetWindowRect (pane_wnd, &rect); - - // - // Center the pane inside of the group box - // - ::SetWindowPos ( pane_wnd, ::GetDlgItem (Wnd, IDC_GROUP_BOX), - group_rect.left + (width / 2) - ((rect.right - rect.left) / 2), - group_rect.top + (height / 2) - ((rect.bottom - rect.top) / 2), - 0, 0, SWP_NOSIZE); - } - - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Destroy_Settings_Panes -// -//////////////////////////////////////////////////////////////////////////////////////// -void -PresetExportOptionsDialogClass::Destroy_Settings_Panes (void) -{ - // - // Loop over all the panes and destroy them - // - for (int index = 0; index < PANE_MAX; index ++) { - ::DestroyWindow (PaneWnds[index]); - PaneWnds[index] = NULL; - } - - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Determine_Preset_Type -// -//////////////////////////////////////////////////////////////////////////////////////// -void -PresetExportOptionsDialogClass::Determine_Preset_Type (void) -{ - // - // Examine the current options and try to determine which - // preset best matches this configuration. - // - - if (Options->EnableTerrainMode) { - - // - // Select the terrain UI - // - Show_Settings_Pane (PANE_TERRAIN); - SendDlgItemMessage (Wnd, IDC_TERRAIN_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L); - - } else if (Options->ExportGeometry == false) { - - if (Options->ExportAnimation == false) { - - // - // Select the skeleton UI - // - Show_Settings_Pane (PANE_SKELETON); - SendDlgItemMessage (Wnd, IDC_SKELETON_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L); - } else { - - // - // Select the anim UI - // - Show_Settings_Pane (PANE_ANIM); - SendDlgItemMessage (Wnd, IDC_ANIM_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L); - } - - } else if (Options->ExportHierarchy == false && Options->LoadHierarchy == false) { - - // - // Select the mesh UI - // - Show_Settings_Pane (PANE_MESH); - SendDlgItemMessage (Wnd, IDC_MESH_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L); - - } else if (Options->ExportAnimation == false) { - - // - // Select the HLOD UI - // - Show_Settings_Pane (PANE_HLOD); - SendDlgItemMessage (Wnd, IDC_HLOD_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L); - - } else { - - // - // Select the HLOD anim UI - // - Show_Settings_Pane (PANE_ANIM_HLOD); - SendDlgItemMessage (Wnd, IDC_ANIM_HLOD_RADIO, BM_SETCHECK, (WPARAM)TRUE, 0L); - } - - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Initialize_Controls -// -//////////////////////////////////////////////////////////////////////////////////////// -void -PresetExportOptionsDialogClass::Initialize_Controls (void) -{ - // - // Check the review log file button if necessary - // - CheckDlgButton (Wnd, IDC_REVIEW_LOG, Options->ReviewLog); - - // - // Precompute some of the animation data - // - int ticksperframe = ::GetTicksPerFrame(); - int startframe = MaxInterface->GetAnimRange ().Start () / ticksperframe; - int endframe = MaxInterface->GetAnimRange ().End () / ticksperframe; - - // - // Clamp the real options the same way the displayed values are clamped - // - if (startframe > Options->StartFrame) { - Options->StartFrame = startframe; - } - if (endframe < Options->EndFrame) { - Options->EndFrame = endframe; - } - - // - // Loop over all the panes and update any of the controls therein - // - for (int index = 0; index < PANE_MAX; index ++) { - HWND pane_wnd = PaneWnds[index]; - - // - // Are there any animation controls on this pane to initialize? - // - if (::GetDlgItem (pane_wnd, IDC_RANGE_LOW_SPIN) != NULL) { - - ISpinnerControl *low_spin = NULL; - ISpinnerControl *high_spin = NULL; - - low_spin = ::SetupIntSpinner (pane_wnd, IDC_RANGE_LOW_SPIN, IDC_RANGE_LOW_EDIT, - startframe, endframe, 0); - - high_spin = ::SetupIntSpinner (pane_wnd, IDC_RANGE_HIGH_SPIN, IDC_RANGE_HIGH_EDIT, - startframe, endframe, 0); - - ::SetProp (::GetDlgItem (pane_wnd, IDC_RANGE_LOW_SPIN), "ISpinnerControl", (HANDLE)low_spin); - ::SetProp (::GetDlgItem (pane_wnd, IDC_RANGE_HIGH_SPIN), "ISpinnerControl", (HANDLE)high_spin); - } - } - - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Update_Controls -// -//////////////////////////////////////////////////////////////////////////////////////// -void -PresetExportOptionsDialogClass::Update_Controls (void) -{ - // - // Loop over all the panes and update any of the controls therein - // - for (int index = 0; index < PANE_MAX; index ++) { - HWND pane_wnd = PaneWnds[index]; - - // - // Handle the check boxes - // - CheckDlgButton (pane_wnd, IDC_EXPORT_MESH_SMOOTH_CHECK, Options->SmoothBetweenMeshes); - CheckDlgButton (pane_wnd, IDC_EXPORT_MESH_AABTREES, !Options->DisableExportAABTrees); -#if ENABLE_MESH_OPTIMIZING - CheckDlgButton (pane_wnd, IDC_EXPORT_MESH_OPTIMIZE, Options->EnableOptimizeMeshData); -#endif - CheckDlgButton (pane_wnd, IDC_USE_SKELETON_CHECK, Options->LoadHierarchy); - CheckDlgButton (pane_wnd, IDC_COMPRESS_ANIMATION_CHECK, Options->CompressAnimation); - CheckDlgButton (pane_wnd, IDC_EXPORT_MESH_MAT_TO_TEXTURE, Options->EnableMaterialColorToTextureConversion); - - // - // Enable/disable the compression settings button - // - HWND compress_settings_btn = ::GetDlgItem (pane_wnd, IDC_COMPRESSION_SETTINGS); - if (compress_settings_btn != NULL) { - ::EnableWindow (compress_settings_btn, Options->CompressAnimation); - } - - // - // Setup the skeleton browse button - // - HWND skeleten_browse_btn = ::GetDlgItem (pane_wnd, IDC_WHT_BROWSE_BUTTON); - if (skeleten_browse_btn != NULL) { - - // - // Honor the relative path if it is present - // - if (Options->RelativeHierarchyFilename[0] != 0) { - SetWindowText (skeleten_browse_btn, Options->RelativeHierarchyFilename); - ::Create_Full_Path (Options->HierarchyFilename, - W3dExportClass::CurrentExportPath, - Options->RelativeHierarchyFilename); - - } else if (Options->HierarchyFilename[0] != 0) { - SetWindowText (skeleten_browse_btn, Options->HierarchyFilename); - ::Create_Relative_Path (Options->RelativeHierarchyFilename, - W3dExportClass::CurrentExportPath, - Options->HierarchyFilename); - } - - // - // Set the enable state of the window - // - ::EnableWindow (skeleten_browse_btn, Options->LoadHierarchy); - } - - // - // Are there any animation controls on this pane to update? - // - HWND low_spin_wnd = ::GetDlgItem (pane_wnd, IDC_RANGE_LOW_SPIN); - HWND high_spin_wnd = ::GetDlgItem (pane_wnd, IDC_RANGE_HIGH_SPIN); - if (low_spin_wnd != NULL && high_spin_wnd != NULL) { - - // - // Peek at the spinner control objects - // - ISpinnerControl *low_spin = NULL; - ISpinnerControl *high_spin = NULL; - low_spin = (ISpinnerControl *)::GetProp (low_spin_wnd, "ISpinnerControl"); - high_spin = (ISpinnerControl *)::GetProp (high_spin_wnd, "ISpinnerControl"); - - // - // Update the spin controls - // - low_spin->SetValue (Options->StartFrame, FALSE); - high_spin->SetValue (Options->EndFrame, FALSE); - } - } - - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// Save_Settings -// -//////////////////////////////////////////////////////////////////////////////////////// -void -PresetExportOptionsDialogClass::Save_Settings (void) -{ - // - // Force settings that certain preset types need - // - if (::IsDlgButtonChecked (Wnd, IDC_TERRAIN_RADIO)) { - - // - // Force some settings for the "Renegade Terrain" preset - // - Options->ExportHierarchy = true; - Options->LoadHierarchy = false; - Options->ExportAnimation = false; - Options->ExportGeometry = true; - Options->CompressAnimation = false; - Options->ReduceAnimation = false; - Options->EnableTerrainMode = true; - Options->DisableExportAABTrees = false; - Options->EnableMaterialColorToTextureConversion = false; - } else if (::IsDlgButtonChecked (Wnd, IDC_SKELETON_RADIO)) { - - // - // Force some settings for the "Skeleton" preset - // - Options->ExportHierarchy = true; - Options->LoadHierarchy = false; - Options->ExportAnimation = false; - Options->ExportGeometry = false; - Options->CompressAnimation = false; - Options->ReduceAnimation = false; - Options->EnableTerrainMode = false; - Options->EnableOptimizeMeshData = false; - Options->DisableExportAABTrees = true; - Options->SmoothBetweenMeshes = false; - Options->EnableTerrainMode = false; - Options->EnableMaterialColorToTextureConversion = false; - } else if (::IsDlgButtonChecked (Wnd, IDC_MESH_RADIO)) { - - // - // Force some settings for the "Simple Mesh" preset - // - Options->ExportHierarchy = false; - Options->LoadHierarchy = false; - Options->ExportAnimation = false; - Options->ExportGeometry = true; - Options->CompressAnimation = false; - Options->ReduceAnimation = false; - Options->EnableTerrainMode = false; - Options->EnableOptimizeMeshData = false; - Options->SmoothBetweenMeshes = false; - Options->EnableTerrainMode = false; - } else if (::IsDlgButtonChecked (Wnd, IDC_HLOD_RADIO)) { - - // - // Force some settings for the "Hierarchical Model" preset - // - Options->ExportHierarchy = !Options->LoadHierarchy; - Options->ExportAnimation = false; - Options->ExportGeometry = true; - Options->CompressAnimation = false; - Options->ReduceAnimation = false; - Options->EnableTerrainMode = false; - } else if (::IsDlgButtonChecked (Wnd, IDC_ANIM_HLOD_RADIO)) { - - // - // Force some settings for the "Hierarchical Animated Model" preset - // - Options->ExportHierarchy = !Options->LoadHierarchy; - Options->ExportAnimation = true; - Options->ExportGeometry = true; - Options->EnableTerrainMode = false; - } else if (::IsDlgButtonChecked (Wnd, IDC_ANIM_RADIO)) { - - // - // Force some settings for the "Pure Animation" preset - // - Options->ExportHierarchy = !Options->LoadHierarchy; - Options->ExportAnimation = true; - Options->ExportGeometry = false; - Options->EnableTerrainMode = false; - Options->EnableOptimizeMeshData = false; - Options->DisableExportAABTrees = true; - Options->SmoothBetweenMeshes = false; - Options->EnableMaterialColorToTextureConversion = false; - } - - // - // Record the "Review Log File" option - // - Options->ReviewLog = (::IsDlgButtonChecked (Wnd, IDC_REVIEW_LOG) == 1); - - // - // Check to see if anything has changed - // - if (::memcmp (Options, &OrigOptions, sizeof (OrigOptions)) != 0) { - SetSaveRequiredFlag (true); - } - - return ; -} - diff --git a/Generals/Code/Tools/WW3D/max2w3d/presetexportoptionsdialog.h b/Generals/Code/Tools/WW3D/max2w3d/presetexportoptionsdialog.h deleted file mode 100644 index 66b8c529120..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/presetexportoptionsdialog.h +++ /dev/null @@ -1,124 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/presetexportoptionsdialog.h $* - * * - * Original Author:: Patrick Smith * - * * - * $Author:: Patrick $* - * * - * $Modtime:: 10/30/00 2:45p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef __PRESET_EXPORT_OPTIONS_DIALOG_H -#define __PRESET_EXPORT_OPTIONS_DIALOG_H - -#include -#include -#include "w3dutil.h" - - -//////////////////////////////////////////////////////////////////////////////////////// -// -// PresetExportOptionsDialogClass -// -//////////////////////////////////////////////////////////////////////////////////////// -class PresetExportOptionsDialogClass -{ -public: - - ////////////////////////////////////////////////////////////////// - // Public constructors/destructors - ////////////////////////////////////////////////////////////////// - PresetExportOptionsDialogClass (Interface *maxinterface, HWND parent_wnd = NULL); - ~PresetExportOptionsDialogClass (void); - - - ////////////////////////////////////////////////////////////////// - // Public methods - ////////////////////////////////////////////////////////////////// - - void Set_Options (W3dExportOptionsStruct *options) { Options = options; ::memcpy (&OrigOptions, Options, sizeof (OrigOptions)); } - int Do_Modal (void); - -private: - - ////////////////////////////////////////////////////////////////// - // Private data types - ////////////////////////////////////////////////////////////////// - - enum - { - PANE_HLOD = 0, - PANE_ANIM_HLOD, - PANE_ANIM, - PANE_TERRAIN, - PANE_SKELETON, - PANE_MESH, - PANE_MAX - }; - - - ////////////////////////////////////////////////////////////////// - // Static methods - ////////////////////////////////////////////////////////////////// - static BOOL CALLBACK Real_Message_Proc (HWND wnd, UINT message, WPARAM wparam, LPARAM lparam); - static BOOL CALLBACK Settings_Pane_Message_Proc (HWND wnd, UINT message, WPARAM wparam, LPARAM lparam); - - ////////////////////////////////////////////////////////////////// - // Private methods - ////////////////////////////////////////////////////////////////// - BOOL Message_Proc (UINT message, WPARAM wparam, LPARAM lparam); - BOOL Pane_Message_Proc (UINT message, WPARAM wparam, LPARAM lparam); - BOOL Settings_Message_Proc (UINT message, WPARAM wparam, LPARAM lparam); - BOOL On_Command (WPARAM wparam, LPARAM lparam); - void Show_Settings_Pane (int pane_id); - void Create_Settings_Panes (void); - void Destroy_Settings_Panes (void); - void Determine_Preset_Type (void); - void Initialize_Controls (void); - void Update_Controls (void); - void Save_Settings (void); - - ////////////////////////////////////////////////////////////////// - // Private member data - ////////////////////////////////////////////////////////////////// - W3dExportOptionsStruct * Options; - W3dExportOptionsStruct OrigOptions; - Interface * MaxInterface; - HWND Wnd; - HWND ParentWnd; - HWND PaneWnds[PANE_MAX]; - int CurrentPane; -}; - - -#endif //__PRESET_EXPORT_OPTIONS_DIALOG_H - diff --git a/Generals/Code/Tools/WW3D/max2w3d/rcmenu.cpp b/Generals/Code/Tools/WW3D/max2w3d/rcmenu.cpp deleted file mode 100644 index 08ba749ac78..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/rcmenu.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/rcmenu.cpp 6 4/19/00 12:24p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/rcmenu.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 4/18/00 8:26p $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * RCMenuClass::Init -- initialize the "right-click" menu * - * RCMenuClass::Selected -- menu selection callback * - * RCMenuClass::Toggle_Hierarchy -- toggle the "export hierarchy" option * - * RCMenuClass::Toggle_Geometry -- toggle the "export geometry" option * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "rcmenu.h" -#include "w3dutil.h" -#include "util.h" - - -RCMenuClass TheRCMenu; - -/*********************************************************************************************** - * RCMenuClass::Init -- initialize the "right-click" menu * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -void RCMenuClass::Init(RightClickMenuManager* manager, HWND hWnd, IPoint2 m) -{ - Installed=TRUE; - - SelNode = InterfacePtr->PickNode(hWnd,m); - - if (SelNode) { - - UINT menuflags; - W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(SelNode); - - /* - ** Add the menu separator - */ - manager->AddMenu(this, MF_SEPARATOR, MENU_SEPARATOR, NULL); - - /* - ** Add the Name of the object - */ - char string[64]; - sprintf(string,"%s:",SelNode->GetName()); - manager->AddMenu(this, MF_STRING | MF_DISABLED, MENU_NODE_NAME, string); - - /* - ** Add the pointer - */ -// sprintf(string,"0x%X",(unsigned long)SelNode); -// manager->AddMenu(this, MF_STRING | MF_GRAYED, MENU_NODE_POINTER, string); - - /* - ** Add the hierarchy menu option - */ - if (wdata->Is_Bone()) { - menuflags = MF_STRING | MF_CHECKED; - } else { - menuflags = MF_STRING; - } - manager->AddMenu(this, menuflags, MENU_TOGGLE_HIERARCHY, "W3D: Export Hierarchy"); - - /* - ** Add the geometry menu option - */ - if (wdata->Is_Geometry()) { - menuflags = MF_STRING | MF_CHECKED; - } else { - menuflags = MF_STRING; - } - manager->AddMenu(this, menuflags, MENU_TOGGLE_GEOMETRY, "W3D: Export Geometry"); - - } -} - -/*********************************************************************************************** - * RCMenuClass::Selected -- menu selection callback * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -void RCMenuClass::Selected(UINT id) -{ - switch (id) { - - case MENU_TOGGLE_HIERARCHY: - Toggle_Hierarchy(SelNode); - break; - case MENU_TOGGLE_GEOMETRY: - Toggle_Geometry(SelNode); - break; - - } -} - -/*********************************************************************************************** - * RCMenuClass::Toggle_Hierarchy -- toggle the "export hierarchy" option * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -void RCMenuClass::Toggle_Hierarchy(INode * node) -{ - - W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(SelNode); - assert(wdata); - - if (wdata->Is_Bone()) { - wdata->Enable_Export_Transform(false); - } else { - wdata->Enable_Export_Transform(true); - } -} - -/*********************************************************************************************** - * RCMenuClass::Toggle_Geometry -- toggle the "export geometry" option * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -void RCMenuClass::Toggle_Geometry(INode * node) -{ - W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(SelNode); - assert(wdata); - - if (wdata->Is_Geometry()) { - wdata->Enable_Export_Geometry(false); - } else { - wdata->Enable_Export_Geometry(true); - } -} - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/rcmenu.h b/Generals/Code/Tools/WW3D/max2w3d/rcmenu.h deleted file mode 100644 index 024c8878c67..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/rcmenu.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/rcmenu.h 3 1/14/98 10:23a Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/rcmenu.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 1/13/98 3:44p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef RCMENU_H -#define RCMENU_H - -#include "max.h" -#include "dllmain.h" -#include "resource.h" -#include "istdplug.h" - -class W3DUtilityClass; - -/********************************************************************************************** -** -** RCMenuClass - W3D Utility's right-click menu. -** -**********************************************************************************************/ -class RCMenuClass : public RightClickMenu -{ - -public: - - RCMenuClass() {Installed=FALSE;} - ~RCMenuClass() {} - - void Bind(Interface * ipi, W3DUtilityClass * eni) { InterfacePtr = ipi; UtilityPtr = eni; } - - void Init(RightClickMenuManager* manager, HWND hWnd, IPoint2 m); - void Selected(UINT id); - void Toggle_Hierarchy(INode * node); - void Toggle_Geometry(INode * node); - -public: - - BOOL Installed; - -private: - - Interface * InterfacePtr; - W3DUtilityClass * UtilityPtr; - INode * SelNode; - - enum { - MENU_SEPARATOR = 0, - MENU_TOGGLE_HIERARCHY, - MENU_TOGGLE_GEOMETRY, - MENU_NODE_NAME, - MENU_NODE_POINTER - }; -}; - -extern RCMenuClass TheRCMenu; - -#endif diff --git a/Generals/Code/Tools/WW3D/max2w3d/resource.h b/Generals/Code/Tools/WW3D/max2w3d/resource.h deleted file mode 100644 index 06a6e74f004..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/resource.h +++ /dev/null @@ -1,422 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by max2w3d.rc -// -#define IDS_COPYRIGHT_NOTICE 1 -#define IDS_AUTHOR_NAME 2 -#define IDS_GAMEMTL 3 -#define IDS_MAP_TEXTURE 4 -#define IDS_ENVMAP 5 -#define IDS_SCENE_EXPORT 6 -#define IDS_LIB_DESCRIPTION 7 -#define IDS_FILE_OPEN_ERROR 8 -#define IDS_DLL_NAME 9 -#define IDS_WTM_SHORT_DESCRIPTION 10 -#define IDS_WTM_LONG_DESCRIPTION 11 -#define IDS_WHT_SHORT_DESCRIPTION 12 -#define IDS_WHT_LONG_DESCRIPTION 13 -#define IDS_WHA_SHORT_DESCRIPTION 14 -#define IDS_WHA_LONG_DESCRIPTION 15 -#define IDS_WTM_FILE_EXTEN 16 -#define IDS_WHT_FILE_EXTEN 17 -#define IDS_WHA_FILE_EXTEN 18 -#define IDS_W3D_FILE_EXTEN 19 -#define IDS_W3D_LONG_DESCRIPTION 20 -#define IDS_W3D_SHORT_DESCRIPTION 21 -#define IDS_W3D_UTILITY_CLASS_NAME 22 -#define IDS_W3DMENU_CATEGORY 23 -#define IDS_W3DMENU_TITLE 24 -#define IDS_SOT 25 -#define IDS_DIFFUSE_COLOR 26 -#define IDS_PARAMETERS 27 -#define IDS_TEXTURE_MAP 28 -#define IDS_ENVIRONMENT_MAP 29 -#define IDS_TEXMAPS 30 -#define IDS_AM 31 -#define IDS_DI 32 -#define IDS_SP 33 -#define IDS_SH 34 -#define IDS_SS 35 -#define IDS_SI 36 -#define IDS_OP 37 -#define IDS_FI 38 -#define IDS_BU 39 -#define IDS_RL 40 -#define IDS_RR 41 -#define IDS_NONE 42 -#define IDS_NOTES 43 -#define IDD_GAMEMTL_PASS_COUNT 101 -#define IDD_VOXEL_DEBUG_DIALOG 103 -#define IDD_W3D_EXPORT_OPTIONS 106 -#define IDD_W3D_UTILITY_DIALOG 107 -#define IDD_BONE_INFLUENCE_PARAMS 108 -#define IDD_SKELETON_PARAMETERS 109 -#define IDD_SKIN_SOT 110 -#define IDD_GAMEMTL_PANEL 111 -#define IDD_GAMEMTL_NOTES_PANEL 112 -#define IDD_GAMEMTL_HINTS_PANEL 114 -#define IDD_GAMEMTL_PSX_PANEL 115 -#define IDD_GAMEMTL_PASS 118 -#define IDD_GAMEMTL_VERTEX_MATERIAL 119 -#define IDD_GAMEMTL_SHADER 120 -#define IDD_GAMEMTL_TEXTURES 121 -#define IDD_GAMEMTL_PASS_COUNT_DIALOG 122 -#define IDD_GENERATE_NAMES_DIALOG 126 -#define IDD_MESH_DEFORM_PANEL 127 -#define IDI_ORIG 127 -#define IDI_DEFORMED 128 -#define IDD_GAMEMTL_SURFACE_TYPE 128 -#define IDD_GAMEMTL_DISPLACEMENT_MAP 129 -#define IDB_NORM 130 -#define IDB_DEFORM 131 -#define IDD_GENERATE_MTL_NAMES_DIALOG 133 -#define IDD_GENERATE_LOD_EXTENSION_DIALOG 135 -#define IDD_EXPORT_ALL 136 -#define IDD_SCENE_SETUP 137 -#define IDD_GAMEMTL_PS2_SHADER 138 -#define IDD_GAMEMTL_PS2_TEXTURES 139 -#define IDD_ALPHA_MODIFIER 140 -#define IDD_W3D_LOG 142 -#define IDD_INPUT_DIALOG 143 -#define IDD_W3DUTILITY_FLOATER_DIALOG 145 -#define IDD_W3DUTILITY_SETTINGS_DIALOG 147 -#define IDD_W3DUTILITY_TOOLS_DIALOG 148 -#define IDD_W3D_EXPORT_OPTIONS1 149 -#define IDD_W3D_PRESET_EXPORT_OPTIONS 149 -#define IDD_EXPORT_PANE_HLOD 150 -#define IDD_EXPORT_PANE_ANIMATED_HLOD 151 -#define IDD_EXPORT_PANE_ANIMATION 152 -#define IDD_EXPORT_PANE_MESH 153 -#define IDD_EXPORT_PANE_SKELETON 154 -#define IDD_EXPORT_PANE_TERRAIN 155 -#define IDD_ANIMATION_COMPRESSION 156 -#define IDI_DISK 157 -#define IDB_WW3D 158 -#define IDD_GRIDSNAP_PARAMS 159 -#define IDC_TRANSLATION_ONLY_CHECK 1000 -#define IDC_TERRAIN_MODE_CHECK 1001 -#define IDC_SETPASSCOUNT 1014 -#define IDC_PASSCOUNT_SPIN 1016 -#define IDC_PASSCOUNT_EDIT 1017 -#define IDC_MAPON_DCT 1018 -#define IDC_MAX_SETS_SPIN 1018 -#define IDC_GAMEMTL_PASSCOUNT_STATIC 1019 -#define IDC_MAX_SETS_EDIT 1019 -#define IDC_MAPON_SCT 1020 -#define IDC_STAGE0_DISPLAY_BUTTON 1020 -#define IDC_VOXEL_VIEWPORT 1021 -#define IDC_MAPON_DIT 1021 -#define IDC_STAGE0_PUBLISH_BUTTON 1021 -#define IDC_MAPON_SIT 1022 -#define IDC_STAGE1_DISPLAY_BUTTON 1022 -#define IDC_WHT_EXPORT_RADIO 1023 -#define IDC_STAGE1_PUBLISH_BUTTON 1023 -#define IDC_WHT_LOAD_RADIO 1024 -#define IDC_STAGE0_RESIZE_BUTTON 1024 -#define IDC_WHA_EXPORT_RADIO 1025 -#define IDC_STAGE0_NO_MIPMAP_BUTTON 1025 -#define IDC_WHT_BROWSE_BUTTON 1026 -#define IDC_STAGE0_CLAMP_U_BUTTON 1026 -#define IDC_WHA_NO_EXPORT_RADIO 1027 -#define IDC_STAGE0_CLAMP_V_BUTTON 1027 -#define IDC_WTM_EXPORT_RADIO 1028 -#define IDC_STAGE1_RESIZE_BUTTON 1028 -#define IDC_WTM_NO_EXPORT_RADIO 1029 -#define IDC_STAGE1_NO_MIPMAP_BUTTON 1029 -#define IDC_STAGE1_CLAMP_U_BUTTON 1030 -#define IDC_WHT_NO_EXPORT_RADIO 1031 -#define IDC_STAGE1_CLAMP_V_BUTTON 1031 -#define IDC_STAGE0_ALPHA_BITMAP_BUTTON 1032 -#define IDC_LAYER_EDIT 1033 -#define IDC_RANGE_LOW_EDIT 1033 -#define IDC_STAGE1_ALPHA_BITMAP_BUTTON 1033 -#define IDC_RANGE_HIGH_EDIT 1034 -#define IDC_NAME_INDEX_EDIT 1034 -#define IDC_STAGE0_NOLOD_BUTTON 1034 -#define IDC_DCT_FRAMES_EDIT 1035 -#define IDC_STAGE1_NOLOD_BUTTON 1035 -#define IDC_DCT_FRAMES_SPIN 1036 -#define IDC_OPACITY_EDIT 1037 -#define IDC_HIERARCHY_CHECK 1038 -#define IDC_OPACITY_SPIN 1038 -#define IDC_UNHIDE_GEOMETRY 1039 -#define IDC_SCT_FRAMES_EDIT 1039 -#define IDC_SELECT_ALPHA_MESHES 1039 -#define IDC_LINK_BY_NAME_BUTTON 1040 -#define IDC_BASE_POSE_EDIT 1040 -#define IDC_UNHIDE_HIERARCHY 1040 -#define IDC_SCT_FRAMES_SPIN 1040 -#define IDC_SELECT_GEOMETRY 1040 -#define IDC_AUTO_LINK_BUTTON 1041 -#define IDC_BASE_POSE_SPIN 1041 -#define IDC_HIDE_ALL 1041 -#define IDC_FOG_EDIT 1041 -#define IDC_SELECT_HIERARCHY 1041 -#define IDC_ADD_BONES_BUTTON 1042 -#define IDC_GEOMETRY_CHECK 1042 -#define IDC_FOG_SPIN 1042 -#define IDC_LINK_BUTTON 1042 -#define IDC_REMOVE_BONES_BUTTON 1043 -#define IDC_TRANSULCENCY_EDIT 1043 -#define IDC_COLLECTION_NAMES_GENERATE 1043 -#define IDC_UNLINK_BUTTON 1043 -#define IDC_BONE_LIST 1044 -#define IDC_TRANSLUCENCY_SPIN 1044 -#define IDC_COLLECTION_NAMES_INCREMENT_LOD 1044 -#define IDC_SELECT_PHYSICAL 1044 -#define IDC_SIT_FRAMES_EDIT 1045 -#define IDC_GEOMETRY_CAMERA_ALIGNED 1045 -#define IDC_SIT_FRAMES_SPIN 1046 -#define IDC_GEOMETRY_CAMERA_ORIENTED 1046 -#define IDC_SHININESS_EDIT 1047 -#define IDC_GEOMETRY_NORMAL 1047 -#define IDC_SHININESS_SPIN 1048 -#define IDC_GEOMETRY_AABOX 1048 -#define IDC_SELECT_PROJECTILE 1049 -#define IDC_COLLISION_PHYSICAL 1050 -#define IDC_DCT_RATE_EDIT 1051 -#define IDC_SELECT_VIS 1051 -#define IDC_DCT_RATE_SPIN 1052 -#define IDC_GEOMETRY_OBBOX 1052 -#define IDC_LAYER_SPIN 1053 -#define IDC_RANGE_LOW_SPIN 1053 -#define IDC_OBJ_NAME 1053 -#define IDC_DIT_FRAMES_EDIT 1053 -#define IDC_RANGE_HIGH_SPIN 1054 -#define IDC_DIT_FRAMES_SPIN 1054 -#define IDC_NAME_INDEX_SPIN 1054 -#define IDC_MATERIAL_NAMES_GENERATE 1054 -#define IDC_DIT_RATE_EDIT 1055 -#define IDC_GEOMETRY_SHADOW 1055 -#define IDC_DIT_RATE_SPIN 1056 -#define IDC_GEOMETRY_NULL 1056 -#define IDC_SCT_RATE_EDIT 1057 -#define IDC_LOD_EXTENSION_GENERATE 1057 -#define IDC_GEOMETRY_AGGREGATE 1057 -#define IDC_DCT_MAPPING_COMBO 1058 -#define IDC_GEOMETRY_LIGHTGLARE 1058 -#define IDC_GEOMETRY_DAZZLE 1058 -#define IDC_DIT_MAPPING_COMBO 1059 -#define IDC_MAPPING_COMBO 1059 -#define IDC_MAPPING0_COMBO 1059 -#define IDC_SCT_MAPPING_COMBO 1060 -#define IDC_MAPPING1_COMBO 1060 -#define IDC_SCT_RATE_SPIN 1061 -#define IDC_USE_ALPHA_CHECK 1062 -#define IDC_SIT_MAPPING_COMBO 1063 -#define IDC_SIT_RATE_EDIT 1064 -#define IDC_SIT_RATE_SPIN 1065 -#define IDC_DIT_OVER_DCT_CHECK 1067 -#define IDC_SIT_OVER_SCT_CHECK 1068 -#define IDC_USE_SORTING_CHECK 1068 -#define IDC_DIT_OVER_DIG_CHECK 1069 -#define IDC_NO_TRANS 1069 -#define IDC_SIT_OVER_SIG_CHECK 1070 -#define IDC_100_TRANS 1070 -#define IDC_FAST_SPECULAR_AFTER_ALPHA_CHECK 1071 -#define IDC_50_TRANS 1071 -#define IDC_25_TRANS 1072 -#define IDC_MINUS_100_TRANS 1073 -#define IDC_NO_RT_LIGHTING 1074 -#define IDC_VIEWPORT_DISPLAY_CHECK 1075 -#define IDC_COLORMASK_CHECK 1081 -#define IDC_DEPTHMASK_CHECK 1082 -#define IDC_ALPHATEST_CHECK 1083 -#define IDC_DEPTHCOMPARE_COMBO 1085 -#define IDC_DESTBLEND_COMBO 1086 -#define IDC_FOG_COMBO 1087 -#define IDC_PRIGRADIENT_COMBO 1088 -#define IDC_SRCBLEND_COMBO 1089 -#define IDC_DETAILCOLOR_COMBO 1090 -#define IDC_DETAILALPHA_COMBO 1091 -#define IDC_STAGE0_HINT_COMBO 1092 -#define IDC_SECGRADIENT_COMBO 1093 -#define IDC_STAGE1_HINT_COMBO 1095 -#define IDC_STAGE0_FRAMES_EDIT 1096 -#define IDC_STAGE0_FRAMES_SPIN 1097 -#define IDC_STAGE0_RATE_EDIT 1098 -#define IDC_STAGE0_RATE_SPIN 1099 -#define IDC_DCT_BUTTON 1100 -#define IDC_GAMEMTL_TAB 1100 -#define IDC_STAGE0_BUTTON 1101 -#define IDC_SCT_BUTTON 1102 -#define IDC_STAGE1_BUTTON 1102 -#define IDC_DIT_BUTTON 1103 -#define IDC_AMBIENT_COLOR 1103 -#define IDC_SIT_BUTTON 1104 -#define IDC_EMISSIVE_COLOR 1104 -#define IDC_SHADEMODEL_COMBO 1105 -#define IDC_STAGE1_FRAMES_EDIT 1106 -#define IDC_STAGE1_FRAMES_SPIN 1107 -#define IDC_STAGE1_RATE_EDIT 1108 -#define IDC_STAGE1_RATE_SPIN 1109 -#define IDC_DITHERMASK_COMBO 1110 -#define IDC_DIFFUSE_COLOR 1113 -#define IDC_STAGE0_ENABLE 1113 -#define IDC_SPECULAR_COLOR 1114 -#define IDC_STAGE1_ENABLE 1114 -#define IDC_AMBIENT_COEFF 1115 -#define IDC_STAGE1_ANIM_COMBO 1115 -#define IDC_DIFFUSE_COEFF 1116 -#define IDC_PRESET_COMBO 1116 -#define IDC_EMISSIVE_COEFF 1117 -#define IDC_STAGE0_ANIM_COMBO 1117 -#define IDC_SPECULAR_COEFF 1118 -#define IDC_GEOMETRY_TWO_SIDED 1119 -#define IDC_COLLISION_VIS 1120 -#define IDC_GEOMETRY_HIDE 1121 -#define IDC_GEOMETRY_ZNORMALS 1122 -#define IDC_GEOMETRY_VERTEX_ALPHA 1123 -#define IDC_BASE_NAME_EDIT 1124 -#define IDC_GEOMETRY_CAST_SHADOW 1124 -#define IDC_PREFIX_EDIT 1125 -#define IDC_COLLISION_CAMERA 1125 -#define IDC_GEOMETRY_SHATTERABLE 1126 -#define IDC_SUFFIX_EDIT 1126 -#define IDC_GEOMETRY_NPATCH 1127 -#define IDC_AFFECT_ALL_RADIO 1131 -#define IDC_AFFECT_SELECTED_RADIO 1132 -#define IDC_LOD_INDEX_EDIT 1133 -#define IDC_LOD_INDEX_SPIN 1134 -#define IDC_ASSIGN_COLLISION_BITS_CHECK 1135 -#define IDC_ASSIGN_NAMES_CHECK 1137 -#define IDC_COLLISION_PROJECTILE 1138 -#define IDC_COPY_SPECULAR_DIFFUSE 1139 -#define IDC_ASSIGN_PREFIX_CHECK 1139 -#define IDC_COLLISION_VEHICLE 1139 -#define IDC_MAPPING_ARGS_EDIT 1140 -#define IDC_ASSIGN_SUFFIX_CHECK 1140 -#define IDC_MAPPING0_ARGS_EDIT 1140 -#define IDC_MAPPING1_ARGS_EDIT 1141 -#define IDC_SHADER_DEFAULTS_BUTTON 1143 -#define IDC_STATE_SLIDER 1145 -#define IDC_CURRENT_SET_SLIDER 1146 -#define IDC_CURRENT_SET_STATIC 1147 -#define IDC_VERTEX_COLOR 1149 -#define IDC_RESTORE_BUTTON 1150 -#define IDC_MANUALAPPLY 1151 -#define IDC_SURFACE_TYPE_COMBO 1152 -#define IDC_EXPORT_MESH_SMOOTH_CHECK 1153 -#define IDC_LOCK_SETS 1154 -#define IDC_EXPORT_MESH_AABTREES 1154 -#define IDC_TEXTURE_BUTTON 1155 -#define IDC_EXPORT_MESH_MAT_TO_TEXTURE 1155 -#define IDC_AMOUNT_EDIT 1156 -#define IDC_EXPORT_MESH_OPTIMIZE 1156 -#define IDC_AMOUNT_SPIN 1157 -#define IDC_DAMREG_INDEX_EDIT 1161 -#define IDC_DAMREG_INDEX_SPIN 1162 -#define IDC_DIRECTORY 1163 -#define IDC_STAGE0UVCHAN_EDIT 1163 -#define IDC_BROWSE 1164 -#define IDC_STAGE0UVCHAN_SPIN 1164 -#define IDC_RECURSIVE 1165 -#define IDC_STAGE1UVCHAN_EDIT 1165 -#define IDC_LOD_COUNT 1166 -#define IDC_STAGE1UVCHAN_SPIN 1166 -#define IDC_LOD_OFFSET 1167 -#define IDC_LOD_AS_COPY 1168 -#define IDC_LOD_AS_INSTANCE 1169 -#define IDC_LOD_AS_REFERENCE 1170 -#define IDC_DAMAGE_COUNT 1171 -#define IDC_DAMAGE_OFFSET 1172 -#define IDC_DAMAGE_AS_COPY 1173 -#define IDC_PS2_PRESET_COMBO 1173 -#define IDC_DAMAGE_AS_INSTANCE 1174 -#define IDC_COMPATIBLE 1174 -#define IDC_DAMAGE_AS_REFERENCE 1175 -#define IDC_ALPHA_EDIT 1175 -#define IDC_A_COMBO 1176 -#define IDC_B_COMBO 1177 -#define IDC_EXPORT_STANDARD_MATERIALS 1177 -#define IDC_C_COMBO 1178 -#define IDC_EXPORT_UTILITIES_GROUP 1178 -#define IDC_D_COMBO 1179 -#define IDC_COMPRESS_ANIMATION_CHECK 1179 -#define IDC_ALPHA_SPIN 1180 -#define IDC_ALPHA_SPIN2 1181 -#define IDC_REDUCE_ANIMATION_CHECK 1188 -#define IDC_REDUCE_ANIMATION_COMBO 1190 -#define IDC_ANIMATION_FPS_STATIC 1191 -#define IDC_COMPRESS_ANIMATION_FLAVOR_COMBO 1192 -#define IDC_MAX_TRANS_ERROR_EDIT 1193 -#define IDC_MAX_ROT_ERROR_EDIT 1194 -#define IDC_ANIM_COMPRESS_PROGRESS 1196 -#define IDC_ANIM_LOG_RICHEDIT 1198 -#define IDC_VIEWLOG_CHECK 1199 -#define IDC_VALUE 1200 -#define IDC_LABEL 1201 -#define IDC_ALPHA_CHECKBOX 1204 -#define IDC_DAZZLE_COMBO 1205 -#define IDC_CREATE_SETTINGS_FLOATER 1208 -#define IDC_RADIO1 1212 -#define IDC_HLOD_RADIO 1212 -#define IDC_RADIO2 1213 -#define IDC_COMPRESSION_SETTINGS 1213 -#define IDC_ANIM_RADIO 1213 -#define IDC_RADIO3 1214 -#define IDC_MESH_RADIO 1214 -#define IDC_RADIO4 1215 -#define IDC_SKELETON_RADIO 1215 -#define IDC_GROUP_BOX 1216 -#define IDC_RADIO5 1217 -#define IDC_TERRAIN_RADIO 1217 -#define IDC_USE_SKELETON_CHECK 1217 -#define IDC_RADIO6 1218 -#define IDC_ANIM_HLOD_RADIO 1218 -#define IDC_REVIEW_LOG 1219 -#define IDC_ENABLE_SORT_LEVEL 1220 -#define IDC_SORT_LEVEL 1221 -#define IDC_SORT_LEVEL_SPIN 1222 -#define IDC_GRIDDIM_EDIT 1223 -#define IDC_GRIDDIM_SPIN 1224 -#define IDS_SKIN_CLASS_NAME 60011 -#define IDS_SKIN_OBJECT_NAME 60012 -#define IDS_SKIN 60013 -#define IDS_SKIN_PARAMETERS 60014 -#define IDS_SKIN_INFO 60015 -#define IDS_BONE_INFLUENCE_PARAMS 60016 -#define IDS_SOT2 60017 -#define IDS_SKELETON_PARAMETERS 60018 -#define IDS_PICK_BONE_DIALOG_TITLE 60019 -#define IDS_PICK_BONE_BUTTON_TEXT 60020 -#define IDS_MULTIPLE_OBJECTS 60021 -#define IDS_NO_OBJECT 60022 -#define IDS_SPECULAR_COLOR 60023 -#define IDS_AMBIENT_COLOR 60024 -#define IDS_EMISSIVE_COLOR 60027 -#define IDS_MATERIAL_HINTS 60028 -#define IDS_PSX_OPTIONS 60029 -#define IDS_UV_MAPPING 60030 -#define IDS_ENVIRONMENT_MAPPING 60031 -#define IDS_PASS_COUNT 60032 -#define IDS_PASS_SETTINGS 60033 -#define IDS_PUBLISH 60034 -#define IDS_DISPLAY 60035 -#define IDS_RESIZE 60036 -#define IDS_NO_MIPMAP 60037 -#define IDS_CLAMP_U 60038 -#define IDS_CLAMP_V 60039 -#define IDS_ALPHA_BITMAP 60040 -#define IDS_SURFACE_TYPE 60041 -#define IDS_DISPLACEMENT_MAP 60042 -#define IDS_ALPHA_MODIFIER_CLASS 60043 -#define IDS_PS2_GAMEMTL 60044 -#define IDS_PC_TO_PS2_MAT_CONVERTER 60045 -#define IDS_NO_LOD 60046 -#define IDS_W3DUTILITY_SETTINGS 60047 -#define IDS_W3DUTILITY_TOOLS 60048 -#define IDS_GRIDSNAPMODIFIER 60049 -#define IDS_GRIDSNAP_TITLE 60050 -#define IDS_GRID_DIMENSION 60051 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 160 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1225 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/Generals/Code/Tools/WW3D/max2w3d/simpdib.cpp b/Generals/Code/Tools/WW3D/max2w3d/simpdib.cpp deleted file mode 100644 index 4558c9a9f02..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/simpdib.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/simpdib.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/14/97 3:07p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "simpdib.h" - - -SimpleDIBClass::SimpleDIBClass(HWND hwnd,int width,int height,PaletteClass & pal): - IsZombie(false), - Info(NULL), - Handle(0), - Pixels(NULL), - Width(width), - Height(height), - PixelBase(NULL), - Pitch(NULL) -{ - // Allocate a BITMAPINFO structure - Info = (BITMAPINFO *) new char [sizeof(BITMAPINFO) + 256*sizeof(RGBQUAD)]; - - if (Info == NULL) { - IsZombie = true; - return; - } - - // Describe the type of DIB we want. - Info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - Info->bmiHeader.biWidth = width; - Info->bmiHeader.biHeight = -height; //ask for a top-down dib. - Info->bmiHeader.biPlanes = 1; - Info->bmiHeader.biBitCount = 8; - Info->bmiHeader.biCompression = BI_RGB; - Info->bmiHeader.biSizeImage = 0; - Info->bmiHeader.biXPelsPerMeter = 0; - Info->bmiHeader.biYPelsPerMeter = 0; - Info->bmiHeader.biClrUsed = 256; - Info->bmiHeader.biClrImportant = 256; - - // Fill in the DIB's palette. - for (int i=0; i<256; i++) { - Info->bmiColors[i].rgbBlue = (unsigned char)pal[i].Get_Blue(); - Info->bmiColors[i].rgbGreen = (unsigned char)pal[i].Get_Green(); - Info->bmiColors[i].rgbRed = (unsigned char)pal[i].Get_Red(); - Info->bmiColors[i].rgbReserved = 0; - } - - // Create the DIB. - HDC hdc = GetDC(hwnd); - Handle = CreateDIBSection(hdc, Info, DIB_RGB_COLORS,(void**)&Pixels, NULL, 0); - ReleaseDC(hwnd, hdc); - - if (!Handle) { - IsZombie = true; - return; - } - - Width = Info->bmiHeader.biWidth; - Height = abs(Info->bmiHeader.biHeight); - Pitch = (Width + 3) & 0xfffffffC; - - // Check if the DIB is bottom-up or top-down. - // (it better be top-down, thats what I'm asking for!!!) - if (Info->bmiHeader.biHeight > 0) { - - // bottom-up DIB - PixelBase = (Pixels + (Height - 1) * Width); - Pitch = -Pitch; - - } else { - - // top-down DIB - PixelBase = Pixels; - Pitch = Pitch; - } -} - -SimpleDIBClass::~SimpleDIBClass(void) -{ - if (Info) delete [] Info; - if (Handle) DeleteObject(Handle); -} - - -void SimpleDIBClass::Clear(unsigned char color) -{ - if (Pixels) { - memset(Pixels, color, abs(Pitch)*Height); - } -} - -void SimpleDIBClass::Set_Pixel(int i,int j,unsigned char color) -{ - if ((i < 0) || (j < 0) || (i >= Width) || (j >= Height)) { - return; - } - - *(PixelBase + j*Pitch + i) = color; -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/simpdib.h b/Generals/Code/Tools/WW3D/max2w3d/simpdib.h deleted file mode 100644 index ceb44c6e3b2..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/simpdib.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/simpdib.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/14/97 3:07p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SIMPDIB_H -#define SIMPDIB_H - -#ifndef ALWAYS_H -#include "always.h" -#endif - -#include - -#ifndef WIN_H -#include "win.h" -#endif - -#ifndef PALETTE_H -#include "palette.h" -#endif - -class SimpleDIBClass -{ -public: - - SimpleDIBClass(HWND hwnd,int width, int height,PaletteClass & pal); - ~SimpleDIBClass(void); - - HBITMAP Get_Handle() { return Handle; } - int Get_Width(void) { return Width; } - int Get_Height(void) { return Height; } - - void Clear(unsigned char color); - void Set_Pixel(int i,int j,unsigned char color); - -private: - - bool IsZombie; // object constructor failed, its a living-dead object! - BITMAPINFO * Info; // info used in creating the dib + the palette. - HBITMAP Handle; // handle to the actual dib - unsigned char * Pixels; // address of memory containing the pixel data - int Width; // width of the dib - int Height; // height of the dib - unsigned char * PixelBase; // address of upper left pixel (this and DIBPitch abstract up/down DIBS) - int Pitch; // offset from DIBPixelBase to next row (can be negative for bottom-up DIBS) - -}; - - -#endif /*SIMPDIB_H*/ \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/skin.cpp b/Generals/Code/Tools/WW3D/max2w3d/skin.cpp deleted file mode 100644 index 65a1f251aa7..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/skin.cpp +++ /dev/null @@ -1,1916 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - WWSkin * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/skin.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 4/24/01 5:15p $* - * * - * $Revision:: 13 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "skin.h" -#include "dllmain.h" -#include "max.h" -#include "simpmod.h" -#include "simpobj.h" -#include "resource.h" - -#include "skindata.h" -#include "bpick.h" -#include "namedsel.h" -#include "boneicon.h" - -#if defined W3D_MAX4 //defined as in the project (.dsp) -static GenSubObjType _SubObjectTypeVertex(1); -#endif - -/* -** Static functions -*/ -static BOOL CALLBACK _sot_dialog_proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam); -static BOOL CALLBACK _skeleton_dialog_thunk(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam); -static BOOL CALLBACK _bone_influence_dialog_thunk(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam); -static TriObject * Get_Tri_Object(TimeValue t,ObjectState & os,Interval & valid,BOOL & needsdel); -static float Bone_Distance(INode * bone,TimeValue time,const Point3 & vertex); - -/* -** Static variables -*/ -HWND SkinWSMObjectClass::SotHWND = NULL; -HWND SkinWSMObjectClass::SkeletonHWND = NULL; -HWND SkinWSMObjectClass::BoneListHWND = NULL; -IObjParam * SkinWSMObjectClass::InterfacePtr = NULL; -ICustButton * SkinWSMObjectClass::AddBonesButton = NULL; -ICustButton * SkinWSMObjectClass::RemoveBonesButton = NULL; -ISpinnerControl * SkinWSMObjectClass::BasePoseSpin = NULL; - - -/******************************************************************************* -** -** Class Descriptor for SkinWSMObjectClass -** -*******************************************************************************/ -class SkinWSMObjectClassDesc:public ClassDesc -{ -public: - - int IsPublic() { return 1; } - void * Create(BOOL loading = FALSE) { return new SkinWSMObjectClass; } - const TCHAR * ClassName() { return _T("WWSkin"); } - SClass_ID SuperClassID() { return WSM_OBJECT_CLASS_ID; } - Class_ID ClassID() { return SKIN_OBJ_CLASS_ID; } - const TCHAR* Category() { return _T("Westwood Space Warps"); } -}; - -static SkinWSMObjectClassDesc _SkinWSMObjectDesc; -ClassDesc * Get_Skin_Obj_Desc() { return &_SkinWSMObjectDesc; } - - -/******************************************************************************* -** -** Class Descriptor for the SkinModifier -** -*******************************************************************************/ -class SkinModClassDesc:public ClassDesc -{ -public: - - int IsPublic() { return 0; } - void * Create(BOOL loading = FALSE) { return new SkinModifierClass; } - const TCHAR * ClassName() { return _T("WWSkin"); } - SClass_ID SuperClassID() { return WSM_CLASS_ID; } - Class_ID ClassID() { return SKIN_MOD_CLASS_ID; } - const TCHAR * Category() { return _T("Westwood Space Warps"); } -}; - -static SkinModClassDesc _SkinModDesc; -ClassDesc * Get_Skin_Mod_Desc() { return &_SkinModDesc; } - - - -/******************************************************************************* -** -** SkinWSMObjectCreateCallback -** A class derived from CreateMouseCallBack to handle -** the user input during the creation phase of the SkinWSMObject. -** -*******************************************************************************/ -class SkinWSMObjectCreateCallBack : public CreateMouseCallBack -{ -public: - int proc( ViewExp * vpt,int msg, int point, int flags, IPoint2 m, Matrix3 & mat) - { - if (msg == MOUSE_POINT) { - Point3 pos = vpt->GetPointOnCP(m); - mat.IdentityMatrix(); - mat.SetTrans(pos); - return CREATE_STOP; - } - return TRUE; - } -}; - -static SkinWSMObjectCreateCallBack _SkinCreateCB; - -/******************************************************************************* -** -** SkinWSMObjectClass -** -*******************************************************************************/ -SkinWSMObjectClass::SkinWSMObjectClass() -{ - /* - ** Initialize class variables to default state! - */ - MeshBuilt = FALSE; - BoneSelectionMode = BONE_SEL_MODE_NONE; - BoneTab.SetCount(0); - BasePoseFrame = 0; - - pblock = NULL; -} - -SkinWSMObjectClass::~SkinWSMObjectClass(void) -{ - assert(!((InterfacePtr == NULL) && (SotHWND != NULL))); - if (SotHWND != NULL) { - InterfacePtr->UnRegisterDlgWnd(SotHWND); - InterfacePtr->DeleteRollupPage(SotHWND); - SotHWND = NULL; - } - - assert(!((InterfacePtr == NULL) && (SkeletonHWND != NULL))); - if (SkeletonHWND != NULL) { - InterfacePtr->UnRegisterDlgWnd(SkeletonHWND); - InterfacePtr->DeleteRollupPage(SkeletonHWND); - SkeletonHWND = NULL; - } -} - -void SkinWSMObjectClass::BeginEditParams(IObjParam *ip, ULONG flags,Animatable *prev) -{ - SimpleWSMObject::BeginEditParams(ip,flags,prev); - - /* - ** save off a copy of the interface pointer - */ - InterfacePtr = ip; - - /* - ** Install the "supports objects of type" rollup - */ - if (SotHWND == NULL) { - SotHWND = ip->AddRollupPage( - AppInstance, - MAKEINTRESOURCE(IDD_SKIN_SOT), - _sot_dialog_proc, - Get_String(IDS_SOT), - (LPARAM)InterfacePtr, - APPENDROLL_CLOSED); - } else { - SetWindowLong(SotHWND,GWL_USERDATA,(LPARAM)ip); - } - - /* - ** Install the skeleton rollup - */ - if (SkeletonHWND == NULL) { - SkeletonHWND = InterfacePtr->AddRollupPage( - AppInstance, - MAKEINTRESOURCE(IDD_SKELETON_PARAMETERS), - _skeleton_dialog_thunk, - Get_String(IDS_SKELETON_PARAMETERS), - (LPARAM)this, - 0); - } else { - SetWindowLong(SkeletonHWND,GWL_USERDATA,(LPARAM)this); - } - - Update_Bone_List(); -} - -void SkinWSMObjectClass::EndEditParams(IObjParam *ip, ULONG flags,Animatable *next) -{ - SimpleWSMObject::EndEditParams(ip,flags,next); - - if (flags & END_EDIT_REMOVEUI) { - /* - ** Remove the Sot rollup - */ - if (SotHWND != NULL) { - InterfacePtr->UnRegisterDlgWnd(SotHWND); - InterfacePtr->DeleteRollupPage(SotHWND); - SotHWND = NULL; - } - - /* - ** Remove the info rollup - */ - if (SkeletonHWND != NULL) { - InterfacePtr->UnRegisterDlgWnd(SkeletonHWND); - InterfacePtr->DeleteRollupPage(SkeletonHWND); - SkeletonHWND = NULL; - } - } - - /* - ** get rid of our copy of the interface pointer - */ - InterfacePtr = NULL; -} - -RefTargetHandle SkinWSMObjectClass::Clone(RemapDir & remap) -{ - /* - ** create another SkinWSMObject and return it. - */ - SkinWSMObjectClass * sobj = new SkinWSMObjectClass(); - return(sobj); -} - -RefTargetHandle SkinWSMObjectClass::GetReference(int i) -{ - /* - ** return reference "i". If i==0, the reference belongs - ** to SimpleWSMObject so thunk down to it. - */ - if (i < SimpleWSMObject::NumRefs()) { - return SimpleWSMObject::GetReference(i); - } - - /* - ** The rest of the references are ours. - */ - int boneidx = To_Bone_Index(i); - return BoneTab[boneidx]; -} - -void SkinWSMObjectClass::SetReference(int i, RefTargetHandle rtarg) -{ - if (i < SimpleWSMObject::NumRefs()) { - SimpleWSMObject::SetReference(i,rtarg); - } else { - int boneidx = To_Bone_Index(i); - assert(boneidx >= 0); - assert(boneidx < BoneTab.Count()); - BoneTab[boneidx] = (INode *)rtarg; - } -} - -RefResult SkinWSMObjectClass::NotifyRefChanged(Interval changeInt,RefTargetHandle hTarget,PartID& partID, RefMessage message) -{ - int i; - switch (message) { - - case REFMSG_TARGET_DELETED: - for (i=0; isetVerts(a, b, c); - f->setSmGroup(0); - f->setEdgeVisFlags(1,1,1); -} - -void SkinWSMObjectClass::User_Picked_Bone(INode * node) -{ - // TODO: Undo/Redo! - switch (BoneSelectionMode) { - case BONE_SEL_MODE_ADD: - Add_Bone(node); - break; - - case BONE_SEL_MODE_REMOVE: - Remove_Bone(node); - break; - - default: - assert(0); - } - - Set_Bone_Selection_Mode(BONE_SEL_MODE_NONE); - Update_Bone_List(); -} - -void SkinWSMObjectClass::User_Picked_Bones(INodeTab & nodetab) -{ - // TODO: Undo/Redo! - switch (BoneSelectionMode) { - case BONE_SEL_MODE_ADD_MANY: - Add_Bones(nodetab); - break; - - case BONE_SEL_MODE_REMOVE_MANY: - Remove_Bones(nodetab); - break; - - default: - assert(0); - } - - Set_Bone_Selection_Mode(BONE_SEL_MODE_NONE); - Update_Bone_List(); -} - -void SkinWSMObjectClass::Set_Bone_Selection_Mode(int mode) -{ - assert(mode >= BONE_SEL_MODE_NONE); - assert(mode <= BONE_SEL_MODE_REMOVE_MANY); - - /* - ** store the selection mode - */ - BoneSelectionMode = mode; - - /* - ** update the dialog box buttons - */ - AddBonesButton->SetCheck(mode == BONE_SEL_MODE_ADD_MANY); - RemoveBonesButton->SetCheck(mode == BONE_SEL_MODE_REMOVE_MANY); -} - -int SkinWSMObjectClass::Add_Bone(INode * node) -{ - int refidx; - int boneidx; - - /* - ** If we already have this bone, just return - */ - boneidx = Find_Bone(node); - if (boneidx != -1) { - return boneidx; - } - - /* - ** Otherwise, look for a NULL bone and we'll re-use - ** its slot. This happens when a user removes a bone or - ** a bone in the scene is deleted. - */ - boneidx = Find_Bone(NULL); - if (boneidx != -1) { - refidx = To_Ref_Index(boneidx); - MakeRefByID(FOREVER,refidx,node); - return boneidx; - } - - /* - ** If we made it here, add the bone to the end of the - ** reference array. - */ - BoneTab.Append(1,&node); - boneidx = BoneTab.Count() - 1; - refidx = To_Ref_Index(boneidx); - MakeRefByID(FOREVER,refidx,node); - return boneidx; -} - -void SkinWSMObjectClass::Add_Bones(INodeTab & nodetab) -{ - /* - ** Add each bone individually - */ - for (int i=0; iGetName()); - } - } -} - -int SkinWSMObjectClass::Find_Bone(INode * node) -{ - for (int i=0; i 0) { - isave->BeginChunk(NUM_BONES_CHUNK); - isave->Write(&numbones,sizeof(ULONG),&nb); - isave->EndChunk(); - } - return IO_OK; -} - -IOResult SkinWSMObjectClass::Load(ILoad * iload) -{ - SimpleWSMObject::Load(iload); - - IOResult res; - ULONG nb; - int level = -1; - - while (IO_OK==(res=iload->OpenChunk())) { - - switch (iload->CurChunkID()) { - - case NUM_BONES_CHUNK: { - ULONG numbones; - res = iload->Read(&numbones,sizeof(numbones),&nb); - BoneTab.SetCount(numbones); - for (int i=0; iCloseChunk(); - - if (res!=IO_OK) { - return res; - } - } - return IO_OK; -} - - -int SkinWSMObjectClass::Find_Closest_Bone(const Point3 & vertex) -{ - float mindist = 10000.0f; - int minindex = -1; - TimeValue basetime = Get_Base_Pose_Time(); - - for (int boneidx = 0; boneidx < BoneTab.Count(); boneidx++) { - - if (BoneTab[boneidx] == NULL) continue; - - float bonedist = Bone_Distance(BoneTab[boneidx],basetime,vertex); - if (bonedist < mindist) { - mindist = bonedist; - minindex = boneidx; - } - } - - return minindex; -} - - - -/******************************************************************************* -** -** SkinModifierClass -** -*******************************************************************************/ - -SkinModifierClass::SkinModifierClass(void) -{ - Default_Init(); -} - -SkinModifierClass::SkinModifierClass(INode * node,SkinWSMObjectClass * skin_obj) -{ - Default_Init(); - - /* - ** Make the reference to the space warp node. - */ - MakeRefByID(FOREVER,NODE_REF,node); - - /* - ** Make reference to the WSMObject - */ - MakeRefByID(FOREVER,OBJ_REF,skin_obj); - -} - -void SkinModifierClass::Default_Init(void) -{ - SubObjSelLevel = VERTEX_SEL_LEVEL; - WSMObjectRef = NULL; - WSMNodeRef = NULL; - InterfacePtr = NULL; - - BoneInfluenceHWND = NULL; - LinkButton = NULL; - LinkByNameButton = NULL; - AutoLinkButton = NULL; - UnLinkButton = NULL; -} - - -RefTargetHandle SkinModifierClass::Clone(RemapDir & remap) -{ - SkinModifierClass * newmod = new SkinModifierClass(WSMNodeRef,(SkinWSMObjectClass *)WSMObjectRef); - return newmod; -} - - -void SkinModifierClass::BeginEditParams(IObjParam * ip, ULONG flags,Animatable * prev) -{ - static int i=0; - - i++; - - /* - ** Grab a copy of the interface pointer - */ - InterfacePtr = ip; - - /* - ** allocate the selection command mode for use in vertex selection - */ - SelectMode = new SelectModBoxCMode(this,InterfacePtr); - - /* - ** register the desired sub-object selection types. - */ - const TCHAR * ptype[] = { "Vertices" }; -#if defined W3D_MAX4 //defined as in the project (.dsp) - InterfacePtr->SetSubObjectLevel(1); -#else - //---This call is obsolete from version 4. - InterfacePtr->RegisterSubObjectTypes( ptype, 1); -#endif - /* - ** Restore the selection level. - */ - ip->SetSubObjectLevel(SubObjSelLevel); - -} - - -void SkinModifierClass::EndEditParams(IObjParam *ip, ULONG flags,Animatable *next) -{ - /* - ** just checking... - */ - assert(ip == InterfacePtr); - - /* - ** Make sure we clear out the pick mode - */ - InterfacePtr->ClearPickMode(); - - /* - ** remove and deallocate the selection command mode - */ - InterfacePtr->DeleteMode(SelectMode); - if (SelectMode ) delete SelectMode; - SelectMode = NULL; - - /* - ** Remove the rollup window(s) if needed - */ - if (flags & END_EDIT_REMOVEUI) { - Remove_Bone_Influence_Dialog(); - } - - /* - ** Make sure we don't hang onto an invalid interface - */ - InterfacePtr = NULL; -} - -Interval SkinModifierClass::Get_Validity(TimeValue t) -{ - /* - ** Start with an infinite interval and chop it down - ** using the validity intervals of each of the controlling bones - */ - Interval valid = FOREVER; - - /* - ** Now intersect the validity with the validities of all of - ** the controlling bones. - */ - SkinWSMObjectClass * obj = (SkinWSMObjectClass *)Get_WSMObject(); - -// for (int i=0; iNum_Bones(); i++) { -// valid &= obj->Get_Bone(i)->tmValid(); //TODO: is this right? -// } - -// return valid; - return Interval(t,t+1); //KLUDGE - only valid for this frame -} - -RefTargetHandle SkinModifierClass::GetReference(int i) -{ - switch (i) { - case OBJ_REF: return WSMObjectRef; - case NODE_REF: return WSMNodeRef; - default: return NULL; - } -} - -void SkinModifierClass::SetReference(int i, RefTargetHandle rtarg) -{ - switch (i) { - case OBJ_REF: WSMObjectRef = (SkinWSMObjectClass *)rtarg; break; - case NODE_REF: WSMNodeRef = (INode *)rtarg; break; - } -} - -RefResult SkinModifierClass::NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) -{ - switch (message) { - - case REFMSG_TARGET_DELETED: - - /* - ** This means the WSM node is being deleted. As a result, - ** we must delete ourselves. - */ - DeleteMe(); // also deletes all refs and - // sends REFMSG_TARGET_DELETED to all Dependents - return REF_STOP; - } - - return(REF_SUCCEED); - -} - -void SkinModifierClass::ModifyObject(TimeValue t, ModContext & mc, ObjectState * os, INode * node) -{ - /* - ** Get a TriObject from the object state - */ - assert(os->obj->IsSubClassOf(triObjectClassID)); - TriObject *triobj = (TriObject *)os->obj; - - /* - ** Get the skin data from the ModContext. - */ - SkinDataClass * skindata = (SkinDataClass *)mc.localData; - - /* - ** If there is no skin data, allocate it - ** Also, do an initial auto attach. - */ - if (skindata == NULL) { - mc.localData = skindata = new SkinDataClass(&triobj->mesh); - } - - if (!skindata->IsValid()) { - skindata->Validate(&triobj->mesh); - } - - /* - ** If in vertex selection mode, tell the mesh to display the - ** selected vertices and turn on vertex tick marks. Otherwise - ** make sure vertex tick marks are off. - */ - if (SubObjSelLevel == VERTEX_SEL_LEVEL) { - triobj->mesh.vertSel = skindata->VertSel; - triobj->mesh.SetDispFlag(DISP_VERTTICKS|DISP_SELVERTS); - - if (triobj->mesh.selLevel != MESH_VERTEX) { - triobj->mesh.selLevel = MESH_VERTEX; - } - } else { - triobj->mesh.selLevel = MESH_OBJECT; - triobj->mesh.ClearDispFlag(DISP_VERTTICKS|DISP_SELVERTS); - } - - /* - ** Loop through the points in the deformable object - */ - for (int vidx = 0; vidx < triobj->NumPoints(); vidx++) { - - - // TODO: Allow multiple bone influences here... - // issues - UI to set the weights, rebalance weights whenever - // a bone is deleted, should also then never get NULL bones - // and remove the need to check for NULL bones in this routine... - - /* - ** Get a pointer to the bone that this vertex is attached to - */ - InfluenceStruct * inf = &(skindata->VertData[vidx]); - - int boneidx = inf->BoneIdx[0]; - if ((boneidx != -1) && (boneidx < WSMObjectRef->Num_Bones())) { - - INode * bone = WSMObjectRef->Get_Bone(inf->BoneIdx[0]); - - if (bone == NULL) { - /* - ** this bone has gone away for some reason so - ** clear this vert's bone influence index - */ - inf->BoneIdx[0] = -1; - - } else { - - /* - ** Ok, got the bone, now transform the point and - ** give it back to the mesh - */ - Point3 pnew; - Matrix3 tm; - - pnew = triobj->GetPoint(vidx); - - if (os->GetTM()) { - tm = *(os->GetTM()); - } else { - tm.IdentityMatrix(); - } - - pnew = tm * pnew; - - TimeValue basetime = WSMObjectRef->Get_Base_Pose_Time(); - Matrix3 basetm = bone->GetObjectTM(basetime); - Matrix3 curtm = bone->GetObjectTM(t); - pnew = (pnew * Inverse(basetm)) * curtm; - - pnew = Inverse(tm) * pnew; - - triobj->SetPoint(vidx,pnew); - } - } - } - - /* - ** Tell the object that points were changed - */ - triobj->PointsWereChanged(); - - /* - ** Set the validity of the updated geometry data - */ - triobj->UpdateValidity(GEOM_CHAN_NUM,Get_Validity(t)); -} - -IOResult SkinModifierClass::Save(ISave * isave) -{ - ULONG nb; - Modifier::Save(isave); - - /* - ** Save the sub object selection level - */ - short sl = SubObjSelLevel; - isave->BeginChunk(SEL_LEVEL_CHUNK); - isave->Write(&sl,sizeof(short),&nb); - isave->EndChunk(); - - return IO_OK; -} - -IOResult SkinModifierClass::Load(ILoad * iload) -{ - Modifier::Load(iload); - - IOResult res; - ULONG nb; - int level = -1; - - while (IO_OK==(res=iload->OpenChunk())) { - - switch (iload->CurChunkID()) { - - case SEL_LEVEL_CHUNK: { - short sl; - res = iload->Read(&sl,sizeof(short),&nb); - SubObjSelLevel = sl; - } - break; - } - - iload->CloseChunk(); - - if (res!=IO_OK) { - return res; - } - } - return IO_OK; -} - -IOResult SkinModifierClass::SaveLocalData(ISave *isave, LocalModData *ld) -{ - SkinDataClass * skindata = (SkinDataClass *)ld; - - return skindata->Save(isave); -} - -IOResult SkinModifierClass::LoadLocalData(ILoad *iload, LocalModData **pld) -{ - /* - ** Create a new SkinDataClass - */ - if (*pld==NULL) { - *pld = (SkinDataClass *) new SkinDataClass(); - } - SkinDataClass * newskin = (SkinDataClass *)*pld; - - /* - ** Initialize it from ILoad... - */ - return newskin->Load(iload); -} - - -void SkinModifierClass::ActivateSubobjSel(int level, XFormModes & modes) -{ - /* - ** Storing the current sub-object selection level - */ - SubObjSelLevel = level; - - /* - ** Set the appropriate command mode. We only want selection. - */ - switch (SubObjSelLevel) - { - case OBJECT_SEL_LEVEL: - Remove_Bone_Influence_Dialog(); - break; - - case VERTEX_SEL_LEVEL: // Modifying Vertices - modes = XFormModes(NULL,NULL,NULL,NULL,NULL,SelectMode); - Install_Bone_Influence_Dialog(); - break; - } - - /* - ** Put our named subobject selection sets into the drop down list - */ - Create_Named_Selection_Sets(); - - /* - ** Notify our dependents that the subselection type, - ** and the display have changed - */ - NotifyDependents(FOREVER, PART_SUBSEL_TYPE|PART_DISPLAY, REFMSG_CHANGE); - - /* - ** Notify the pipeline that the selection level has changed. - */ - InterfacePtr->PipeSelLevelChanged(); - - /* - ** Notify our dependents that the selection channel, - ** display attributes, and subselection type channels have changed - */ - NotifyDependents(FOREVER, SELECT_CHANNEL|DISP_ATTRIB_CHANNEL|SUBSEL_TYPE_CHANNEL, REFMSG_CHANGE); -} - -int SkinModifierClass::HitTest -( - TimeValue t, - INode * inode, - int type, - int crossing, - int flags, - IPoint2 * p, - ViewExp * vpt, - ModContext * mc -) -{ - Interval valid = FOREVER; - int needsdel; - int savedLimits; - int res = 0; - HitRegion hr; - Matrix3 mat; - - MakeHitRegion(hr,type, crossing,4,p); - mat = inode->GetObjectTM(t); - - /* - ** Set up the graphics window to do the hit test - */ - GraphicsWindow *gw = vpt->getGW(); - gw->setHitRegion(&hr); - gw->setTransform(mat); - gw->setRndLimits(((savedLimits = gw->getRndLimits()) | GW_PICK) & ~GW_ILLUM); - - if (1 /*IgnoreBackfaces*/) { - gw->setRndLimits(gw->getRndLimits() | GW_BACKCULL); - } else { - gw->setRndLimits(gw->getRndLimits() & ~GW_BACKCULL); - } - - gw->clearHitCode(); - - /* - ** Do the hit test! - */ - SubObjHitList hitlist; - MeshSubHitRec * rec; - - ObjectState os = inode->EvalWorldState(InterfacePtr->GetTime()); - TriObject * tobj = Get_Tri_Object(InterfacePtr->GetTime(),os,valid,needsdel); - res = tobj->mesh.SubObjectHitTest(gw,gw->getMaterial(),&hr,flags | SUBHIT_VERTS,hitlist); - - /* - ** Record all of the hits - */ - rec = hitlist.First(); - while (rec) - { - /* - ** rec->index is the index of vertex which was hit! - ** Remember that we are always turning on vertex hit testing; - ** if we were testing for edges, index would be the edge index. - */ - vpt->LogHit(inode,mc,rec->dist,rec->index,NULL); - rec = rec->Next(); - } - - /* - ** Cleanup - */ - gw->setRndLimits(savedLimits); - - if (needsdel) { - tobj->DeleteThis(); - } - - return res; -} - -void SkinModifierClass::SelectSubComponent(HitRecord *hitRec, BOOL selected, BOOL all, BOOL invert) -{ - SkinDataClass * skindata = NULL; - int count = 0; - - switch (SubObjSelLevel) { - - case VERTEX_SEL_LEVEL: - - while (hitRec) { - - skindata = (SkinDataClass *)hitRec->modContext->localData; - - /* - ** Undo/Redo functionality - */ -#if 0 - if (theHold.Holding() && !SelData->held) { - theHold.Put(new SubSelRestore(this,SelData)); - } - theHold.Accept(_T("Select Vertex")); -#endif - - BitArray * array = &(skindata->VertSel); - - if (all & invert) { - - /* - ** hitRec->hitInfo is the MeshSubHitRec::index that was stored in the - ** HitTest method through LogHit - */ - if ((*array)[hitRec->hitInfo]) { - array->Clear(hitRec->hitInfo); - } else { - array->Set(hitRec->hitInfo,selected); - } - } else { - array->Set(hitRec->hitInfo,selected); - } - - if (!all) break; - hitRec = hitRec->Next(); - } - break; - } - - NotifyDependents(FOREVER, PART_SELECT, REFMSG_CHANGE); -} - -void SkinModifierClass::ClearSelection(int selLevel) -{ - int needsdel = 0; - Interval valid = FOREVER; - ModContextList mcList; - INodeTab nodes; - - if (!InterfacePtr ) return; - - InterfacePtr->GetModContexts(mcList,nodes); - InterfacePtr->ClearCurNamedSelSet(); - - for (int i = 0; i < mcList.Count(); i++) { - - SkinDataClass * skindata = (SkinDataClass *)mcList[i]->localData; - - if (skindata==NULL) continue; - - ObjectState os = nodes[i]->EvalWorldState(InterfacePtr->GetTime()); - TriObject * tobj = Get_Tri_Object(InterfacePtr->GetTime(),os,valid,needsdel); - - switch (SubObjSelLevel) { -#if 0 - case OBJECT_SEL_LEVEL: - assert(0); - return; -#endif - - case VERTEX_SEL_LEVEL: -#if 0 // undo/redo - if (theHold.Holding()) { - theHold.Put(new VertexSelRestore(meshData,this)); - } -#endif - tobj->mesh.vertSel.ClearAll(); - skindata->VertSel.ClearAll(); - break; - } - - if (needsdel) { - tobj->DeleteThis(); - } - } - - /* - ** Get rid of the temporary copies of the INodes. - */ - nodes.DisposeTemporary(); - - /* - ** Tell our dependents that the selection set has changed - */ - NotifyDependents(FOREVER, PART_SELECT, REFMSG_CHANGE); - -} - -void SkinModifierClass::SelectAll(int selLevel) -{ - int needsdel = 0; - Interval valid = FOREVER; - ModContextList mclist; - INodeTab nodes; - - if (!InterfacePtr) return; - - InterfacePtr->GetModContexts(mclist,nodes); - InterfacePtr->ClearCurNamedSelSet(); - - for (int i = 0; i < mclist.Count(); i++) { - - SkinDataClass * skindata = (SkinDataClass *)mclist[i]->localData; - - if (skindata==NULL) continue; - - ObjectState os = nodes[i]->EvalWorldState(InterfacePtr->GetTime()); - TriObject * tobj = Get_Tri_Object(InterfacePtr->GetTime(),os,valid,needsdel); - - switch (SubObjSelLevel) { - - case OBJECT_SEL_LEVEL: - assert(0); - return; - - case VERTEX_SEL_LEVEL: -#if 0 // undo/redo - if (theHold.Holding()) { - theHold.Put(new VertexSelRestore(meshData,this)); - } -#endif - tobj->mesh.vertSel.SetAll(); - skindata->VertSel.SetAll(); - break; - } - - if (needsdel) { - tobj->DeleteThis(); - } - } - - /* - ** Get rid of the temporary copies of the INodes. - */ - nodes.DisposeTemporary(); - - /* - ** Tell our dependents that the selection set has changed - */ - NotifyDependents(FOREVER, PART_SELECT, REFMSG_CHANGE); -} - -void SkinModifierClass::InvertSelection(int selLevel) -{ - int needsdel = 0; - Interval valid = FOREVER; - ModContextList mclist; - INodeTab nodes; - - if (!InterfacePtr) return; - - InterfacePtr->GetModContexts(mclist,nodes); - InterfacePtr->ClearCurNamedSelSet(); - - for (int i = 0; i < mclist.Count(); i++) { - - SkinDataClass * skindata = (SkinDataClass *)mclist[i]->localData; - - if (skindata==NULL) continue; - - ObjectState os = nodes[i]->EvalWorldState(InterfacePtr->GetTime()); - TriObject * tobj = Get_Tri_Object(InterfacePtr->GetTime(),os,valid,needsdel); - - switch (SubObjSelLevel) { - - case OBJECT_SEL_LEVEL: - assert(0); - return; - - case VERTEX_SEL_LEVEL: -#if 0 // undo/redo - if (theHold.Holding()) { - theHold.Put(new VertexSelRestore(meshData,this)); - } -#endif - for (int j=0; jmesh.vertSel.GetSize(); j++) { - if (tobj->mesh.vertSel[j]) tobj->mesh.vertSel.Clear(j); - else tobj->mesh.vertSel.Set(j); - } - skindata->VertSel = tobj->mesh.vertSel; - break; - } - - if (needsdel) { - tobj->DeleteThis(); - } - } - - /* - ** Get rid of the temporary copies of the INodes. - */ - nodes.DisposeTemporary(); - - /* - ** Tell our dependents that the selection set has changed - */ - NotifyDependents(FOREVER, PART_SELECT, REFMSG_CHANGE); - -} - -void SkinModifierClass::User_Picked_Bone(INode * node) -{ - assert(InterfacePtr != NULL); - - /* - ** Get a pointer to the ModContext and SkinData for - ** the mesh currently being messed with. - */ - ModContext * mc = NULL; - ModContextList mclist; - INodeTab nodelist; - - InterfacePtr->GetModContexts(mclist,nodelist); - - /* - ** This seems wrong... But I always get only one ModContext and - ** it is the one that I want so I'll just use it... - ** I believe that OS Modifiers can get multiple ones but WS modifiers - ** don't - */ - mc = mclist[0]; - assert(mc != NULL); - SkinDataClass * skindata = (SkinDataClass *)(mc->localData); - - /* - ** Add this bone to the influences of all selected vertices - */ - int boneidx = WSMObjectRef->Find_Bone(node); - assert(boneidx != -1); - skindata->Add_Influence(boneidx); - - /* - ** Recreate all of the named selection sets! - */ - Create_Named_Selection_Sets(); - - /* - ** Update dependents and redraw the views. - */ - NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE); - InterfacePtr->RedrawViews(InterfacePtr->GetTime()); -} - -void SkinModifierClass::User_Picked_Bones(INodeTab & nodetab) -{ - /* - ** One by one, add the selected bones to the influences of - ** all selected vertices. - */ - for (int i=0; iGetModContexts(mclist,nodes); - - for (int i = 0; i < mclist.Count(); i++) { - - SkinDataClass * skindata = (SkinDataClass *)mclist[i]->localData; - if (!skindata) continue; - - int index = skindata->VertSelSets.Find_Set(setname); - if (index < 0) continue; - - int needsdel; - Interval valid; - ObjectState os = nodes[i]->EvalWorldState(InterfacePtr->GetTime()); - TriObject * tobj = Get_Tri_Object(InterfacePtr->GetTime(),os,valid,needsdel); - Mesh * mesh = &(tobj->mesh); - - // TODO: undo redo -#if 0 - if (theHold.Holding()) { - theHold.Put(new VertexSelRestore(meshData,this)); - } -#endif - - if (skindata->VertSelSets[index].GetSize() != mesh->getNumVerts()) { - skindata->VertSelSets[index].SetSize(mesh->getNumVerts(),TRUE); - } - mesh->vertSel = skindata->VertSelSets[index]; - skindata->VertSel = mesh->vertSel; - - if (needsdel) { - tobj->DeleteThis(); - } - } - - nodes.DisposeTemporary(); - - NotifyDependents(FOREVER, PART_SELECT, REFMSG_CHANGE); - InterfacePtr->RedrawViews(InterfacePtr->GetTime()); -} - -void SkinModifierClass::NewSetFromCurSel(TSTR &setname) -{ - Install_Named_Selection_Sets(); -} - -void SkinModifierClass::RemoveSubSelSet(TSTR &setname) -{ - Install_Named_Selection_Sets(); -} - -void SkinModifierClass::Create_Named_Selection_Sets(void) -{ - /* - ** This function creates a named selection set of vertices - ** for each bone in the skeleton. - */ - if (InterfacePtr == NULL) return; - - SkinWSMObjectClass * skinobj = WSMObjectRef; - if (skinobj == NULL) return; - - ModContextList mclist; - INodeTab nodes; - InterfacePtr->GetModContexts(mclist,nodes); - SkinDataClass * skindata = (SkinDataClass *)mclist[0]->localData; - if (skindata == NULL) return; - - /* - ** Clear out the old selection sets - */ - skindata->VertSelSets.Reset(); - - /* - ** Create and add a set for each bone - */ - for (int boneidx = 0; boneidx < skinobj->Num_Bones(); boneidx++) { - - if (skinobj->Get_Bone(boneidx) != NULL) { - BitArray boneverts; - boneverts.SetSize(skindata->VertData.Count()); - - for (int vertidx = 0; vertidx < skindata->VertData.Count(); vertidx++) { - if (skindata->VertData[vertidx].BoneIdx[0] == boneidx) boneverts.Set(vertidx); - else boneverts.Clear(vertidx); - } - - TSTR bonename = skinobj->Get_Bone(boneidx)->GetName(); - - skindata->VertSelSets.Append_Set(boneverts,bonename); - } - } - - Install_Named_Selection_Sets(); - - nodes.DisposeTemporary(); -} - -void SkinModifierClass::Install_Named_Selection_Sets(void) -{ - /* - ** If we are in sub-object selection mode add the sets - ** to the drop down box. - */ - if ((SubObjSelLevel == VERTEX_SEL_LEVEL) && (InterfacePtr != NULL)) { - - ModContextList mclist; - INodeTab nodes; - InterfacePtr->GetModContexts(mclist,nodes); - SkinDataClass * skindata = (SkinDataClass *)mclist[0]->localData; - if (skindata == NULL) return; - - InterfacePtr->ClearSubObjectNamedSelSets(); - for (int i=0; i < skindata->VertSelSets.Count(); i++) { - InterfacePtr->AppendSubObjectNamedSelSet(*skindata->VertSelSets.Names[i]); - } - - nodes.DisposeTemporary(); - } -} - -void SkinModifierClass::Auto_Attach_Verts(BOOL all) -{ - assert(InterfacePtr); - - /* - ** Get the skin data. - */ - ModContextList mclist; - INodeTab nodes; - InterfacePtr->GetModContexts(mclist,nodes); - SkinDataClass * skindata = (SkinDataClass *)mclist[0]->localData; - if (skindata == NULL) return; - - /* - ** get the skin WSM object. - */ - SkinWSMObjectClass * skinobj = WSMObjectRef; - if (skinobj == NULL) return; - - /* - ** Get a triobject representing the object state in the base pose. - */ - Interval valid; - BOOL needsdel; - - TimeValue basetime = WSMObjectRef->Get_Base_Pose_Time(); - ObjectState os = nodes[0]->EvalWorldState(basetime); - TriObject * triobj = Get_Tri_Object(basetime,os,valid,needsdel); - - /* - ** Attach each selected vertex (or all of them) to their closest bone. - */ - for (int vertidx = 0; vertidx < skindata->VertData.Count(); vertidx++){ - if (skindata->VertSel[vertidx] || all) { - - Point3 vert = triobj->GetPoint(vertidx); - if (os.GetTM()) vert = vert * (*os.GetTM()); - int boneidx = skinobj->Find_Closest_Bone(vert); - skindata->VertData[vertidx].Set_Influence(boneidx); - } - } - - /* - ** Re-create the named selection sets - */ - Create_Named_Selection_Sets(); - - /* - ** Update dependents and redraw the views. - */ - NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE); - InterfacePtr->RedrawViews(InterfacePtr->GetTime()); - - /* - ** Cleanup... - */ - nodes.DisposeTemporary(); - - if (needsdel) { - triobj->DeleteThis(); - } -} - -void SkinModifierClass::Unlink_Verts(void) -{ - assert(InterfacePtr); - - /* - ** Get the skin data. - */ - ModContextList mclist; - INodeTab nodes; - InterfacePtr->GetModContexts(mclist,nodes); - SkinDataClass * skindata = (SkinDataClass *)mclist[0]->localData; - if (skindata == NULL) return; - - /* - ** Unlink each selected vertex (give them bone index -1) - */ - for (int vertidx = 0; vertidx < skindata->VertData.Count(); vertidx++){ - if (skindata->VertSel[vertidx]) { - skindata->VertData[vertidx].Set_Influence(-1); - } - } - - /* - ** Re-create the named selection sets - */ - Create_Named_Selection_Sets(); - - /* - ** Update dependents and redraw the views. - */ - NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE); - InterfacePtr->RedrawViews(InterfacePtr->GetTime()); - - /* - ** Cleanup... - */ - nodes.DisposeTemporary(); -} - - -/**************************************************************************** -** -** DIALOG BOX JUNK -** -****************************************************************************/ - -void SkinModifierClass::Install_Bone_Influence_Dialog(void) -{ - if (BoneInfluenceHWND != NULL) return; - - /* - ** loading resource string for the name of the dialog - */ - static int loaded = 0; - static TCHAR string[MAX_STRING_LENGTH]; - - if (!loaded) { - LoadString(AppInstance,IDS_BONE_INFLUENCE_PARAMS,string,MAX_STRING_LENGTH); - loaded = 1; - } - - /* - ** Put up the UI that is used to assign vertices to bones - */ - BoneInfluenceHWND = InterfacePtr->AddRollupPage( - AppInstance, - MAKEINTRESOURCE(IDD_BONE_INFLUENCE_PARAMS), - _bone_influence_dialog_thunk, - string, - (LPARAM)this, - 0); -} - -void SkinModifierClass::Remove_Bone_Influence_Dialog(void) -{ - /* - ** If it is currently up, remove the bone influences dialog - */ - if (BoneInfluenceHWND != NULL) { - InterfacePtr->UnRegisterDlgWnd(BoneInfluenceHWND); - InterfacePtr->DeleteRollupPage(BoneInfluenceHWND); - BoneInfluenceHWND = NULL; - } -} - -/********************************************************************************* -* -* _sot_dialog_proc -* -*********************************************************************************/ -static BOOL CALLBACK _sot_dialog_proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) -{ - IObjParam *ip = (IObjParam*)GetWindowLong(hWnd,GWL_USERDATA); - - switch (message) { - case WM_INITDIALOG: - SetWindowLong(hWnd,GWL_USERDATA,lParam); - break; - - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - if (ip) ip->RollupMouseMessage(hWnd,message,wParam,lParam); - return FALSE; - - default: - return FALSE; - } - return TRUE; -} - - -/********************************************************************************* -* -* _skeleton_dialog_proc -* -*********************************************************************************/ -static BOOL CALLBACK _skeleton_dialog_thunk(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) -{ - SkinWSMObjectClass * skinobj = (SkinWSMObjectClass *)GetWindowLong(hWnd,GWL_USERDATA); - if (!skinobj && message != WM_INITDIALOG) return FALSE; - - if (message == WM_INITDIALOG) { - skinobj = (SkinWSMObjectClass *)lParam; - SetWindowLong(hWnd,GWL_USERDATA,(LONG)skinobj); - } - - return skinobj->Skeleton_Dialog_Proc(hWnd,message,wParam,lParam); -} - -BOOL SkinWSMObjectClass::Skeleton_Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) -{ - switch (message) { - - case WM_INITDIALOG: - - BoneListHWND = GetDlgItem(hWnd,IDC_BONE_LIST); - - /* - ** Intitialize the add bone and remove bone check buttons - */ - AddBonesButton = GetICustButton(GetDlgItem(hWnd, IDC_ADD_BONES_BUTTON)); - RemoveBonesButton = GetICustButton(GetDlgItem(hWnd, IDC_REMOVE_BONES_BUTTON)); - - AddBonesButton->SetType(CBT_CHECK); - AddBonesButton->SetHighlightColor(GREEN_WASH); - AddBonesButton->SetTooltip(TRUE, _T("Add bones by name")); - - RemoveBonesButton->SetType(CBT_CHECK); - RemoveBonesButton->SetHighlightColor(GREEN_WASH); - RemoveBonesButton->SetTooltip(TRUE, _T("Remove bones by name")); - - /* - ** Initialize the "Base Pose Frame" spinner - */ - BasePoseSpin = GetISpinner(GetDlgItem(hWnd, IDC_BASE_POSE_SPIN)); - BasePoseSpin->SetLimits(0,9999, FALSE); - BasePoseSpin->SetValue(0,FALSE); - BasePoseSpin->SetResetValue(0); - BasePoseSpin->LinkToEdit(GetDlgItem(hWnd,IDC_BASE_POSE_EDIT),EDITTYPE_INT); - return TRUE; - - case WM_DESTROY: - ReleaseICustButton(AddBonesButton); - ReleaseICustButton(RemoveBonesButton); - ReleaseISpinner(BasePoseSpin); - - AddBonesButton = NULL; - RemoveBonesButton = NULL; - BasePoseSpin = NULL; - BoneListHWND = NULL; - - return FALSE; - - case CC_SPINNER_CHANGE: - switch (LOWORD(wParam)) - { - case IDC_BASE_POSE_SPIN: - BasePoseFrame = BasePoseSpin->GetIVal(); - break; - } - NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE); - InterfacePtr->RedrawViews(InterfacePtr->GetTime(),REDRAW_INTERACTIVE); - return TRUE; - - case CC_SPINNER_BUTTONUP: - NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE); - InterfacePtr->RedrawViews(InterfacePtr->GetTime(),REDRAW_END); - return TRUE; - - - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - InterfacePtr->RollupMouseMessage(hWnd,message,wParam,lParam); - return FALSE; - - case WM_COMMAND: - switch (LOWORD(wParam)) - { - - case IDC_ADD_BONES_BUTTON: - TheBonePicker.Set_User(this); - Set_Bone_Selection_Mode(BONE_SEL_MODE_ADD_MANY); - InterfacePtr->DoHitByNameDialog(&TheBonePicker); - Set_Bone_Selection_Mode(BONE_SEL_MODE_NONE); - break; - - case IDC_REMOVE_BONES_BUTTON: - TheBonePicker.Set_User(this,FALSE,&(BoneTab)); - Set_Bone_Selection_Mode(BONE_SEL_MODE_REMOVE_MANY); - InterfacePtr->DoHitByNameDialog(&TheBonePicker); - Set_Bone_Selection_Mode(BONE_SEL_MODE_NONE); - break; - } - - default: - return FALSE; - } -} - -/********************************************************************************* -* -* Bone_Influence_Dialog_Proc -* -*********************************************************************************/ -static BOOL CALLBACK _bone_influence_dialog_thunk(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) -{ - SkinModifierClass * skinmod = (SkinModifierClass *)GetWindowLong(hWnd,GWL_USERDATA); - if (!skinmod && message != WM_INITDIALOG) return FALSE; - - if (message == WM_INITDIALOG) { - skinmod = (SkinModifierClass *)lParam; - SetWindowLong(hWnd,GWL_USERDATA,(LONG)skinmod); - } - - return skinmod->Bone_Influence_Dialog_Proc(hWnd,message,wParam,lParam); -} - - -BOOL SkinModifierClass::Bone_Influence_Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) -{ - switch (message) { - - case WM_INITDIALOG: - /* - ** Intitialize the bone influence buttons - */ - LinkButton = GetICustButton(GetDlgItem(hWnd, IDC_LINK_BUTTON)); - LinkByNameButton = GetICustButton(GetDlgItem(hWnd, IDC_LINK_BY_NAME_BUTTON)); - AutoLinkButton = GetICustButton(GetDlgItem(hWnd, IDC_AUTO_LINK_BUTTON)); - UnLinkButton = GetICustButton(GetDlgItem(hWnd, IDC_UNLINK_BUTTON)); - - LinkButton->SetType(CBT_PUSH); - LinkButton->SetTooltip(TRUE, _T("Link Vertices to a bone by selecting the bone")); - - LinkByNameButton->SetType(CBT_PUSH); - LinkByNameButton->SetTooltip(TRUE, _T("Link Vertices to a bone by name")); - - AutoLinkButton->SetType(CBT_PUSH); - AutoLinkButton->SetTooltip(TRUE, _T("Link Vertices to nearest bone")); - - UnLinkButton->SetType(CBT_PUSH); - UnLinkButton->SetTooltip(TRUE, _T("Unlink selected vertices")); - - return TRUE; - - case WM_DESTROY: - ReleaseICustButton(LinkButton); - ReleaseICustButton(LinkByNameButton); - ReleaseICustButton(AutoLinkButton); - ReleaseICustButton(UnLinkButton); - - LinkButton = NULL; - LinkByNameButton = NULL; - AutoLinkButton = NULL; - UnLinkButton = NULL; - return FALSE; - - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - InterfacePtr->RollupMouseMessage(hWnd,message,wParam,lParam); - return FALSE; - - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDC_LINK_BUTTON: - { - /* - ** user picks a bone out of the scene to link to. - */ - assert(WSMObjectRef != NULL); - INodeTab * bonetab = &(WSMObjectRef->Get_Bone_List()); - TheBonePicker.Set_User(this,TRUE,bonetab); - InterfacePtr->SetPickMode(&TheBonePicker); - break; - } - - case IDC_LINK_BY_NAME_BUTTON: - { - /* - ** pop up a bone selection dialog - */ - assert(WSMObjectRef != NULL); - INodeTab * bonetab = &(WSMObjectRef->Get_Bone_List()); - TheBonePicker.Set_User(this,TRUE,bonetab); - InterfacePtr->DoHitByNameDialog(&TheBonePicker); - break; - } - - case IDC_AUTO_LINK_BUTTON: - { - Auto_Attach_Verts(); - break; - } - - case IDC_UNLINK_BUTTON: - { - Unlink_Verts(); - break; - } - } - - default: - return FALSE; - } -} - -static TriObject * Get_Tri_Object(TimeValue t,ObjectState & os,Interval & valid,BOOL & needsdel) -{ - needsdel = FALSE; - valid &= os.Validity(t); - - if (os.obj->IsSubClassOf(triObjectClassID)) { - return (TriObject *)os.obj; - } else { - if (os.obj->CanConvertToType(triObjectClassID)) { - Object * oldObj = os.obj; - TriObject * tobj = (TriObject *)os.obj->ConvertToType(t,triObjectClassID); - needsdel = (tobj != oldObj); - return tobj; - } - } - return NULL; -} - - -float Bone_Distance(INode * bone,TimeValue time,const Point3 & vertex) -{ - /* - ** Average the pivot point of this bone with the pivot points of - ** all of its children. - */ - Point3 icenter = bone->GetObjectTM(time).GetTrans(); - - for (int ci=0; ciNumberOfChildren(); ci++) { - icenter += bone->GetChildNode(ci)->GetObjectTM(time).GetTrans(); - } - - icenter = icenter / (float)(bone->NumberOfChildren() + 1); - - return Length(icenter - vertex); -} - -#if defined W3D_MAX4 //defined as in the project (.dsp) - -int SkinModifierClass::NumSubObjTypes() -{ - return 1; -} -//////////////////////////////////////////////////////////////////////////////////////// -ISubObjType *SkinModifierClass::GetSubObjType(int i) -{ - - static bool _initialized = false; - if(!_initialized){ - _initialized = true; - _SubObjectTypeVertex.SetName("Vertices"); - } - if(i == -1){ - if(GetSubObjectLevel() > 0){ - return GetSubObjType(GetSubObjectLevel()-1); - } - } - return &_SubObjectTypeVertex; -} -#endif diff --git a/Generals/Code/Tools/WW3D/max2w3d/skin.h b/Generals/Code/Tools/WW3D/max2w3d/skin.h deleted file mode 100644 index 099881d159f..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/skin.h +++ /dev/null @@ -1,405 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - WWSkin * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/skin.h $* - * * - * $Author:: Moumine_ballo $* - * * - * $Modtime:: 4/18/01 11:31a $* - * * - * $Revision:: 8 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef SKIN_H -#define SKIN_H - -#include -#include "simpmod.h" -#include "simpobj.h" -#include "bpick.h" -#include "namedsel.h" -#include "w3d_file.h" - - -#define SKIN_OBJ_CLASS_ID Class_ID(0x32b37e0c, 0x5a9612e4) -#define SKIN_MOD_CLASS_ID Class_ID(0x6bad4898, 0x0d1d6ced) -extern ClassDesc * Get_Skin_Obj_Desc(); -extern ClassDesc * Get_Skin_Mod_Desc(); - - -/* - - Writing a space warp plug-in involves creating instances of two key classes. - One is derived from class WSMObject. (WSMObject stands for Word Space Modifier Object, - just another name for Space Warp Object). The other class is subclassed off Modifier. - These two classes work together. The space warp object handles the display and management - of its user interface parameters, the display of the space warp node in the scene, and - provides a world space orientation. The space warp modifier handles the actual deformation - of the geometry of nodes bound to the space warp. Each node bound to the space warp - will have a ModContext which we will store data in. - - The following class is the WSMObject for the westwood skin modifier. - -*/ -class SkinWSMObjectClass : public SimpleWSMObject, BonePickerUserClass -{ -public: - - SkinWSMObjectClass(); - virtual ~SkinWSMObjectClass(); - - /* - ** From Animatable - */ - void DeleteThis() { delete this; } - void BeginEditParams(IObjParam *ip, ULONG flags,Animatable *prev); - void EndEditParams(IObjParam *ip, ULONG flags,Animatable *next); - TCHAR * GetObjectName() { return _T("WWSkin"); } - Class_ID ClassID() { return SKIN_OBJ_CLASS_ID; } - - /* - ** From ReferenceTarget - */ - RefTargetHandle Clone(RemapDir& remap = NoRemap()); - - /* - ** From Reference Maker. These three functions give access to the "virtual array" of references. - ** For SkinWSMObjectClass, we have to remember that SimpleWSMObject already has a reference - ** so we are taking ours on after - */ - virtual int NumRefs() { return SimpleWSMObject::NumRefs() + Num_Bones();} - virtual RefTargetHandle GetReference(int i); - virtual void SetReference(int i, RefTargetHandle rtarg); - RefResult NotifyRefChanged(Interval changeInt,RefTargetHandle hTarget,PartID& partID, RefMessage message); - - /* - ** From Object - */ - int DoOwnSelectHilite() { return TRUE; } - CreateMouseCallBack * GetCreateMouseCallBack(); - - /* - ** From WSMObject - */ - Modifier *CreateWSMMod(INode *node); - - /* - ** From SimpleWSMObject - */ - void BuildMesh(TimeValue t); - - /* - ** Setup a triangle - */ - void Build_Tri(Face * f, int a, int b, int c); - - /* - ** Dialog box message processing - */ - BOOL SkinWSMObjectClass::Skeleton_Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam); - - /* - ** Bone picking. - */ - virtual void User_Picked_Bone(INode * node); - virtual void User_Picked_Bones(INodeTab & nodetab); - void Set_Bone_Selection_Mode(int mode); - - int Add_Bone(INode * node); - void Add_Bones(INodeTab & nodetab); - void Remove_Bone(INode * node); - void Remove_Bones(INodeTab & nodetab); - void Update_Bone_List(void); - - /* - ** Converting between bone indexes and reference indexes - ** The bone references are a variable number of references which are - ** added at the end of the reference array. - */ - int To_Bone_Index(int refidx) { return refidx - SimpleWSMObject::NumRefs(); } - int To_Ref_Index(int boneidx) { return SimpleWSMObject::NumRefs() + boneidx; } - - /* - ** External access to the bones - */ - int Num_Bones(void) { return BoneTab.Count(); } - INode * Get_Bone(int idx) { return BoneTab[idx]; } - INodeTab & Get_Bone_List(void) { return BoneTab; } - int Find_Bone(INode * node); - int Get_Base_Pose_Frame(void) { return BasePoseFrame; } - int Get_Base_Pose_Time(void) { return BasePoseFrame * GetTicksPerFrame(); } - int Find_Closest_Bone(const Point3 & vertex); - - /* - ** Saving and loading. - */ - IOResult Save(ISave *isave); - IOResult Load(ILoad *iload); - - /* - ** Static UI variables. These have to be static due to the strange way - ** that MAX behaves during creation of objects. If you create an object - ** then delete it, EndEditParams is not called and its destructor isn't called... - */ - static HWND SotHWND; - static HWND SkeletonHWND; - static HWND BoneListHWND; - static IObjParam * InterfacePtr; - static ICustButton * AddBonesButton; - static ICustButton * RemoveBonesButton; - static ISpinnerControl * BasePoseSpin; - - /* - ** flag for whether we need to build the bones mesh for this object - */ - BOOL MeshBuilt; - - /* - ** Bone Selection! - */ - enum { - BONE_SEL_MODE_NONE = 0, - BONE_SEL_MODE_ADD, - BONE_SEL_MODE_REMOVE, - BONE_SEL_MODE_ADD_MANY, - BONE_SEL_MODE_REMOVE_MANY - }; - - int BoneSelectionMode; - INodeTab BoneTab; - - /* - ** Dialog controls - */ - int BasePoseFrame; - - /* - ** Chunk ID's - */ - enum { - NUM_BONES_CHUNK = 0x0001 - }; - - /* - ** Friend functions - */ - friend BOOL CALLBACK _skeleton_dialog_thunk(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam); -}; - -/* -** SkinModifierClass -*/ -class SkinModifierClass : public Modifier, BonePickerUserClass -{ - -public: - - SkinModifierClass(void); - SkinModifierClass(INode * node,SkinWSMObjectClass * skin_obj); -#if defined W3D_MAX4 //defined as in the project (.dsp) - ISubObjType *GetSubObjType(int i); - int NumSubObjTypes(); -#endif - void Default_Init(void); - - /* - ** From Animatable - */ - void DeleteThis() { delete this; } - void GetClassName(TSTR& s) { s = TSTR(_T("WWSkin")); } - TCHAR * GetObjectName() { return _T("WWSkin Binding"); } - SClass_ID SuperClassID() { return WSM_CLASS_ID; } - Class_ID ClassID() { return SKIN_MOD_CLASS_ID; } - RefTargetHandle Clone(RemapDir& remap = NoRemap()); - RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message); - void BeginEditParams(IObjParam *ip, ULONG flags,Animatable *prev); - void EndEditParams(IObjParam *ip, ULONG flags,Animatable *next); - CreateMouseCallBack * GetCreateMouseCallBack() { return NULL; } - - /* - ** From Reference Maker. These three functions give access to the "virtual array" of references. - */ - int NumRefs() { return 2; } - RefTargetHandle GetReference(int i); - void SetReference(int i, RefTargetHandle rtarg); - - /* - ** Tell MAX what channels we use and what channels we change: - ** Note that if we do not tell max that we use a channel, that channel is not - ** guaranteed to be valid. - */ - virtual ChannelMask ChannelsUsed() { return SELECT_CHANNEL|SUBSEL_TYPE_CHANNEL|GEOM_CHANNEL; } - virtual ChannelMask ChannelsChanged() { return SELECT_CHANNEL|SUBSEL_TYPE_CHANNEL|GEOM_CHANNEL; } - - /* - ** MAX tells us whenever an input changed. If we cache anything, we can use this - ** function to dump the cached data and regenerate it. - */ - virtual void NotifyInputChanged(Interval changeInt, PartID partID, RefMessage message, ModContext *mc) {} - - /* - ** This is where the modifier actually modifies the object! - */ - virtual void ModifyObject(TimeValue t, ModContext & mc, ObjectState * os, INode * node); - - /* - ** Since our modifier will be storing information based on the vertex indices, whenever - ** the topology of its input is changed things will no longer work correctly. Therefore, - ** we tell max that we depend on the topology remaining the same. - */ - virtual BOOL DependOnTopology(ModContext &mc) { return TRUE; } - - /* - ** What types of objects can we modify: The skin modifier will only work with TRIOBJ's - */ - virtual Class_ID InputType() { return Class_ID(TRIOBJ_CLASS_ID,0); } - - /* - ** Saving and loading. Remember to call the base class's save and load functions as well. - */ - IOResult Save(ISave *isave); - IOResult Load(ILoad *iload); - virtual IOResult LoadLocalData(ILoad *iload, LocalModData **pld); - virtual IOResult SaveLocalData(ISave *isave, LocalModData *ld); - - /* - ** For SkinModifierClass, we allow vertex sub-object selection. - ** This function notifies an object being edited that the current sub object - ** selection level has changed. level==0 indicates object level selection. - ** level==1 or greater refer to the types registered by the object in the - ** order they appeared in the list when registered. If level >= 1, the object - ** should specify sub-object xform modes in the modes structure (defined in cmdmode.h). - */ - void ActivateSubobjSel(int level, XFormModes& modes); - - int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt, ModContext* mc); - void SelectSubComponent(HitRecord *hitRec, BOOL selected, BOOL all, BOOL invert=FALSE); - void ClearSelection(int selLevel);// - void SelectAll(int selLevel); - void InvertSelection(int selLevel); - - /* - ** An object that supports sub-object selection can choose to - ** support named sub object selection sets. Methods in the the - ** interface passed to objects allow them to add items to the - ** sub-object selection set drop down. - ** The following methods implement named sub-obj selection sets - */ - virtual BOOL SupportsNamedSubSels() { return TRUE; } - virtual void ActivateSubSelSet(TSTR &setName); - virtual void NewSetFromCurSel(TSTR &setName); - virtual void RemoveSubSelSet(TSTR &setName); - void Create_Named_Selection_Sets(void); - void Install_Named_Selection_Sets(void); - - WSMObject * Get_WSMObject(void) { return (WSMObject*)GetReference(OBJ_REF); } - Interval Get_Validity(TimeValue t); - - /* - ** Bone picking - */ - virtual void User_Picked_Bone(INode * node); - virtual void User_Picked_Bones(INodeTab & nodetab); - - /* - ** Auto-Attach vertices to nearest bone - */ - void Auto_Attach_Verts(BOOL all = FALSE); - - /* - ** Unlink selected verts (links them to the root or origin) - */ - void Unlink_Verts(void); - -private: - - /* - ** Windows dialog management and communication functions - */ - void Install_Bone_Influence_Dialog(void); - void Remove_Bone_Influence_Dialog(void); - - BOOL Bone_Influence_Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam); - -public: - - /* - ** References for SkinModifierClass - */ - enum { - OBJ_REF = 0, - NODE_REF = 1 - }; - - SkinWSMObjectClass * WSMObjectRef; - INode * WSMNodeRef; - - /* - ** Sub-Object Selection variables - */ - enum { - OBJECT_SEL_LEVEL = 0, - VERTEX_SEL_LEVEL = 1 - }; - - int SubObjSelLevel; - - - /* - ** Bone Influence Dialog panel variables - */ - HWND BoneInfluenceHWND; - ICustButton * LinkButton; - ICustButton * LinkByNameButton; - ICustButton * AutoLinkButton; - ICustButton * UnLinkButton; - - /* - ** Cached pointers to some MAX objects - */ - IObjParam * InterfacePtr; - SelectModBoxCMode * SelectMode; - - /* - ** Load/Save Chunk ID's - */ - enum { - SEL_LEVEL_CHUNK = 0xAA01, - }; - - /* - ** Friend "thunking" functions for the dialog handling. - */ - friend BOOL CALLBACK _bone_influence_dialog_thunk(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam); -}; - - - - -#endif - diff --git a/Generals/Code/Tools/WW3D/max2w3d/skindata.cpp b/Generals/Code/Tools/WW3D/max2w3d/skindata.cpp deleted file mode 100644 index 3c690cad082..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/skindata.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/skindata.cpp 7 5/28/98 12:15p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - WWSkin * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/skindata.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 5/28/98 12:15p $* - * * - * $Revision:: 7 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * SkinDataClass::Save -- save the skindata in the MAX file * - * SkinDataClass::Load -- load the skindata from a MAX file * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "skindata.h" - - -/*********************************************************************************************** - * SkinDataClass::Save -- save the skindata in the MAX file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -IOResult SkinDataClass::Save(ISave *isave) -{ - ULONG nb; - - /* - ** save the flags - */ - short flags = 0; - if (Valid) flags |= 0x01; - if (Held) flags |= 0x02; - - isave->BeginChunk(FLAGS_CHUNK); - isave->Write(&flags,sizeof(flags),&nb); - isave->EndChunk(); - - /* - ** Save the bit array of currently selected vertices - */ - if (VertSel.NumberSet() > 0) { - isave->BeginChunk(VERT_SEL_CHUNK); - VertSel.Save(isave); - isave->EndChunk(); - } - - /* - ** Save the named selection sets of vertices - */ -#if 0 - if (VertSelSets.Count() > 0) { - isave->BeginChunk(INFLUENCE_DATA_CHUNK); - VertSelSets.Save(isave); - isave->EndChunk(); - } -#endif - - /* - ** Save the vertex influence data - */ - if (VertData.Count() > 0) { - isave->BeginChunk(INFLUENCE_DATA_CHUNK); - isave->Write(VertData.Addr(0),VertData.Count() * sizeof(InfluenceStruct), &nb); - isave->EndChunk(); - } - - return IO_OK; -} - - -/*********************************************************************************************** - * SkinDataClass::Load -- load the skindata from a MAX file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -IOResult SkinDataClass::Load(ILoad *iload) -{ - ULONG nb; - short flags; - int n; - IOResult res; - - while (IO_OK == (res=iload->OpenChunk())) { - - switch (iload->CurChunkID()) { - - case FLAGS_CHUNK: - res = iload->Read(&flags,sizeof(flags),&nb); - Valid = (flags & 0x01); - Held = (flags & 0x02); - break; - - case VERT_SEL_CHUNK: - res = VertSel.Load(iload); - break; - - case NAMED_SEL_SETS_CHUNK: - res = VertSelSets.Load(iload); - break; - - case INFLUENCE_DATA_CHUNK: - n = iload->CurChunkLength() / sizeof(InfluenceStruct); - VertData.SetCount(n); - res = iload->Read(VertData.Addr(0),n*sizeof(InfluenceStruct),&nb); - break; - } - - iload->CloseChunk(); - - if (res != IO_OK) { - return res; - } - } - - /* - ** ensure that the arrays are sized correctly - */ - Invalidate(); - - return IO_OK; -} - diff --git a/Generals/Code/Tools/WW3D/max2w3d/skindata.h b/Generals/Code/Tools/WW3D/max2w3d/skindata.h deleted file mode 100644 index a7638befc48..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/skindata.h +++ /dev/null @@ -1,162 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/skindata.h 6 10/28/97 6:08p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - WWSkin * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/skindata.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/21/97 2:04p $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef SKINDATA_H -#define SKINDATA_H - -#include "max.h" -#include "namedsel.h" - -/* -** InfluenceStruct - structure which stores the bone -** influence information for a single vertex. -*/ -struct InfluenceStruct -{ - /* - ** vertices can be influenced by up to two bones. - */ - int BoneIdx[2]; - float BoneWeight[2]; - - InfluenceStruct(void) { BoneIdx[0] = -1; BoneIdx[1] = -1; BoneWeight[0] = 1.0f; BoneWeight[1] = 0.0f; } - - void Set_Influence(int boneidx) { - // TODO: make this actually let you set two bones with - // weighting values. Need UI to furnish this info... - BoneIdx[0] = boneidx; - } -}; - - -/* -** SkinDataClass - a class which contains the bone influence data -** for the modifier. One of these will be hung off of the -** ModContext... -*/ -class SkinDataClass : public LocalModData -{ - -public: - - SkinDataClass(void) { Held = FALSE; Valid = FALSE; } - - SkinDataClass(Mesh *mesh) - { - VertSel = mesh->vertSel; - VertData.SetCount(mesh->getNumVerts()); - for (int i=0; ivertSel.GetSize(),1); - VertData.SetCount(mesh->getNumVerts()); - Valid = TRUE; - } - } - - virtual LocalModData * Clone(void) - { - SkinDataClass * newdata = new SkinDataClass(); - newdata->VertSel = VertSel; - newdata->VertData = VertData; - return newdata; - } - - void Add_Influence(int boneidx) - { - /* - ** Make this INode influence all currently selected vertices - */ - for (int i=0; i VertData; - - /* - ** Load/Save chunk ID's - */ - enum { - FLAGS_CHUNK = 0x0000, - VERT_SEL_CHUNK = 0x0010, - NAMED_SEL_SETS_CHUNK = 0x0020, - INFLUENCE_DATA_CHUNK = 0x0030 - }; - -}; - - -#endif diff --git a/Generals/Code/Tools/WW3D/max2w3d/util.cpp b/Generals/Code/Tools/WW3D/max2w3d/util.cpp deleted file mode 100644 index 18136757739..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/util.cpp +++ /dev/null @@ -1,622 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/util.cpp 28 10/27/00 4:12p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/util.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/27/00 1:13p $* - * * - * $Revision:: 28 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Cleanup_Orthogonal_Matrix -- removes very small numbers from the matrix * - * Set_W3D_Name -- set a W3D name * - * Split_Node_Name -- break a node name into the base and extension * - * Is_Max_Tri_Mesh -- Is this node a triangle mesh? * - * -- checks if the node is the origin of a model * - * -- Checks if the node is the origin for the base obect (non-LOD'd). * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "util.h" -#include "w3dutil.h" -#include "skin.h" -#include "skindata.h" -#include "modstack.h" - - -#define MAX_NODE_NAME_LEN 256 // max name size we can handle - -const float EPSILON = 0.00001f; -static char _string[256]; - - - -static int get_geometry_type(INode * node) -{ - assert(node != NULL); - return W3DAppData2Struct::Get_App_Data(node)->Get_Geometry_Type(); - - //return (get_w3d_bits(node) & GEO_TYPE_MASK); -} - - -/*********************************************************************************************** - * Cleanup_Orthogonal_Matrix -- removes very small numbers from the matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -Matrix3 Cleanup_Orthogonal_Matrix(Matrix3 & mat) -{ - Matrix3 newmat = mat; - - for (int j=0; j<3; j++) { - Point3 row = newmat.GetRow(j); - - if (fabs(row.x) < EPSILON) row.x = 0.0f; - if (fabs(row.y) < EPSILON) row.y = 0.0f; - if (fabs(row.z) < EPSILON) row.z = 0.0f; - - row = Normalize(row); - - newmat.SetRow(j,row); - } - - return newmat; -} - -/*********************************************************************************************** - * Set_W3D_Name -- set a W3D name * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - * 9/13/1999 AJA : Strip off the trailing ".digits" since this is a convention we've set in * - * MAX to help artists manage LODs. * - *=============================================================================================*/ -void Set_W3D_Name(char * set_name,const char * src) -{ - memset(set_name,0,W3D_NAME_LEN); - strncpy(set_name,src,W3D_NAME_LEN-1); - char *dot = strrchr(set_name, '.'); - if (dot) - { - // If a number comes after the dot, strip it off - int value; - if (sscanf(dot+1, "%d", &value) == 1) - *dot = 0; - // If nothing comes after the dot, strip it off - else if (*(dot+1) == 0) - *dot = 0; - } - strupr(set_name); -} - -/*********************************************************************************************** - * Split_Node_Name -- break a node name into the base and extension * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -void Split_Node_Name(const char * name,char * set_base,char * set_exten,int * set_exten_index) -{ - // Nodes are assumed to be named in the following way: - // . - // for example: mesh.d1 - - char buf[MAX_NODE_NAME_LEN]; - char * ptr; - - assert(strlen(name) < MAX_NODE_NAME_LEN); - - // Initialize - if (set_base != NULL) set_base[0] = 0; - if (set_exten != NULL) set_exten[0] = 0; - if (set_exten_index != NULL) *set_exten_index = 0; - - // Get the base name - strncpy(buf,name,MAX_NODE_NAME_LEN); - ptr = buf; - while ((*ptr != 0) && (*ptr != '.')) { - ptr++; - } - - if (*ptr == '.') { - - // copy what we have so far into set_base - *ptr = 0; - if (set_base != NULL) strncpy(set_base,buf,MAX_NODE_NAME_LEN); - - // copy the rest back into the extension - ptr++; - if (set_exten != NULL) strncpy(set_exten,ptr,MAX_NODE_NAME_LEN); - - // now get the extension index - ptr++; - if (set_exten_index != NULL) *set_exten_index = atoi(ptr); - - } else { - - // no extension, just copy the base name - if (set_base != NULL) strncpy(set_base,buf,MAX_NODE_NAME_LEN); - return; - } -} - - -bool Append_Lod_Character (char *meshname, int lod_level, INodeListClass *origin_list) -{ - if (meshname == NULL || lod_level < 0) - return false; - - if (!origin_list) - return false; - - int num_lods = origin_list->Num_Nodes(); - - /* - ** Search the other LODs to see if there is a mesh with the same name. - ** If there is, we will append the current LOD level digit to the name. - ** If there is not, the name will not be modified. - */ - INode *conflict = NULL, *cur_origin = NULL; - int i, lod; - for (i = 0; i < num_lods; i++) - { - // Don't bother searching the current LOD. - lod = Get_Lod_Level((*origin_list)[i]); - if (lod == lod_level) - continue; - - // Search this lod for a node of the same name. - conflict = Find_Named_Node(meshname, (*origin_list)[i]); - if (conflict) - { - // Name length is a worry here, because the name plus the number - // must be less than W3D_NAME_LEN (which is fairly small!). - int length = strlen(meshname); - if ( (lod_level < 10) && (length < W3D_NAME_LEN - 1) ) - { - // Append a number corresponding to the LOD level to the mesh name. - // Highest-detail LOD is '0' (convention). - char *insert = meshname + length; - *insert++ = '0' + lod_level; - *insert = '\0'; - } - else if ( (lod_level < 100) && (length < W3D_NAME_LEN - 2) ) - { - // Append a number corresponding to the LOD level to the mesh name. - // Highest-detail LOD is '0' (convention). - char buf[3]; - sprintf(buf, "%d", lod_level); - strcat(meshname, buf); - } - else - { - // Replace the last character of the mesh name with the lod character (as above). - meshname[W3D_NAME_LEN-2] = '0' + lod_level; - } - - // Name mangling finished (conflict with other LODs is solved on their pass). - break; - } - } - - return true; -} - - - -void Create_Full_Path(char *full_path, const char *curr, const char *rel_path) -{ - // Copy current dir to full path. If it doesn't end with a slash, add one. - strcpy(full_path, curr); - int curr_len = strlen(curr); - char *full_p = full_path + curr_len; // Point at the terminating NULL - if (curr_len == 0 ||(*(full_p - 1) != '/' && *(full_p - 1) != '\\')) { - *full_p = '\\'; - *(++full_p) = '\000'; // Point at the terminating NULL - } - - // Scan "..\"s at the beginning of the rel path, scan backwards on the - // full path (current dir): - const char *rel_p; - for ( rel_p = rel_path; - *rel_p == '.' && *(rel_p+1) == '.' && ( *(rel_p+2) == '/' || *(rel_p+2) == '\\' ); - rel_p += 3) - { - full_p--; - for (; full_p > full_path && *(full_p-1) != '/' && *(full_p-1) != '\\'; full_p--); - *full_p = '\000'; - } - - // Copy the remainder of the relative path to the full path: - strcpy(full_p, rel_p); -} - -// This enum is used inside Create_Relative_Path: -enum PathCharType { - NULL_CHAR, - SLASH_CHAR, - PLAIN_CHAR -}; - -void Create_Relative_Path(char *rel_path, const char *curr, const char *full_path) -{ - // Copy both constant strings and convert them to uppercase: - int curr_len = strlen(curr); - char *up_curr = (char *)malloc(curr_len + 1); - strcpy(up_curr, curr); - _strupr(up_curr); - - int full_len = strlen(full_path); - char *up_full = (char *)malloc(full_len + 1); - strcpy(up_full, full_path); - _strupr(up_full); - - char *rel_p = rel_path; - - // Find shared prefix of curr and full path - const char *full_p = up_full; - const char *curr_p = up_curr; - for ( ; - *full_p && *full_p == *curr_p || (*full_p == '/' && *curr_p == '\\') || (*full_p == '\\' && *curr_p == '/'); - full_p++, curr_p++ - ); - - // If no shared prefix at this point set the relative path to 0 - // This will force the code to use the absolute path. - if (full_p == up_full) { - rel_path[0] = 0; - goto end; - } - - // The first different character for each string can be: a NULL, a slash, - // or an ordinary character. - PathCharType full_type, curr_type; - if (*full_p == '\000') { - full_type = NULL_CHAR; - } else { - if (*full_p == '/' || *full_p == '\\') { - full_type = SLASH_CHAR; - } else { - full_type = PLAIN_CHAR; - } - } - if (*curr_p == '\000') { - curr_type = NULL_CHAR; - } else { - if (*curr_p == '/' || *curr_p == '\\') { - curr_type = SLASH_CHAR; - } else { - curr_type = PLAIN_CHAR; - } - } - // If the last fullpath char is a NULL or both are slashes, we have an - // error - return full path - if (full_type == NULL_CHAR || (full_type == SLASH_CHAR && curr_type == SLASH_CHAR)) { - strcpy(rel_path, up_full); - goto end; - } - - // If the current path has ended (last char is a NULL) and the full path's - // last char is a slash, then just copy the remainder of the full path - // (w/o the slash) to the relative path, and exit. - if (curr_type == NULL_CHAR && full_type == SLASH_CHAR) { - full_p++; // skip slash - strcpy(rel_path, full_p); - goto end; - } - - // If one of following holds: - // 1) One of the last chars is a slash and the other is a plain char - // 2) The current path has ended (last char is NULL) and the last char - // of the full path is a plain char - // 3) The last char of both are plain chars and the previous char is not a - // slash - // Then we must backtrack both pointers until the characters before them - // are slashes. If there are no previous slashes, we have an error. - if ( (full_type == SLASH_CHAR && curr_type == PLAIN_CHAR) || - (curr_type == SLASH_CHAR && full_type == PLAIN_CHAR) || - (curr_type == NULL_CHAR && full_type == PLAIN_CHAR) || - (curr_type == PLAIN_CHAR && full_type == PLAIN_CHAR && - *(full_p-1) != '/' && *(full_p-1) != '\\') ) - { - for (; - full_p > up_full && - ( (*(full_p - 1) != '/' && *(full_p - 1) != '\\') || - (*(curr_p - 1) != '/' && *(curr_p - 1) != '\\') ); - full_p--, curr_p--); - } - - // If no shared prefix at this point (not even a drive letter) return the - // full path - if (full_p == up_full) { - strcpy(rel_path, up_full); - goto end; - } - - // Scan all directories levels in current path from shared point to end - - // for each one add a "../" to the relative path. Note that at this point - // we know we have to add at least one. - *rel_p++ = '.'; - *rel_p++ = '.'; - *rel_p++ = '\\'; - // Go over remaining current path, for each slash we find add one "../" to - // the relative path - for (; *curr_p; curr_p++) { - if (*curr_p == '/' || *curr_p == '\\') { - *rel_p++ = '.'; - *rel_p++ = '.'; - *rel_p++ = '\\'; - } - } - - // If the last char of the current path is a slash remove a "../" from the - // relative path. - if (*(curr_p - 1) == '/' || *(curr_p - 1) == '\\') { - rel_p -= 3; - } - - // Copy remaining full path (from shared point to end) to relative path - strcpy(rel_p, full_p); - -end: - free(up_curr); - free(up_full); -} - -bool Is_Full_Path(char * path) -{ - // first scan for a drive letter (scan for a colon) - if (strchr(path,':') != NULL) { - return true; - } - - // now scan for a "network" path (starts with "//") - if ((path[0] == '/') && (path[1] == '/')) { - return true; - } - if ((path[0] == '\\') && (path[1] == '\\')) { - return true; - } - - return false; -} - - -/*********************************************************************************************** - * Is_Max_Tri_Mesh -- Is this node a triangle mesh? * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/2/98 GTH : Created. * - *=============================================================================================*/ -bool Is_Max_Tri_Mesh(INode * node) -{ - Object *obj = node->EvalWorldState(0).obj; - - if (obj && obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0))) { - return true; - } - return false; -} - - - -bool Is_Damage_Root(INode *node) -{ - if (node == NULL) - return false; - - // Is the node's parent the scene root? - INode *parent = node->GetParentNode(); - if (!parent || !parent->IsRootNode()) - return false; - - // Is the node's name in the form "damage.*"? - char *name = node->GetName(); - if (strnicmp(name, "damage.", strlen("damage.")) != 0) - return false; - -/* This won't pick up references to a dummy object for some reason. - // Does the node point to a dummy object? - Object *obj = node->GetObjectRef(); - if (!obj || !obj->CanConvertToType(Class_ID(DUMMY_CLASS_ID, 0))) - return false; -*/ - - return true; -} - - -/*********************************************************************************************** - * Is_Origin -- checks if the node is the origin of a model * - * * - * A node is an origin if its parent is the scene root, it is a dummy object, and its name * - * is of the form "origin.*" (case insensitive). All descendants of the origin will be * - * expressed in coordinates relative to the origin object. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/13/99 AJA : Created. - *=============================================================================================*/ -bool Is_Origin(INode * node) -{ - if (!node) return false; - if (node->IsRootNode()) return true; - if (node->IsHidden()) return false; - - // Is the node's parent the scene root? - INode *parent = node->GetParentNode(); - if (!parent || !parent->IsRootNode()) - return false; - - // Is the node's name in the form "origin.*"? - char *name = node->GetName(); - if (strnicmp(name, "origin.", strlen("origin.")) != 0) - return false; - -/* This won't pick up references to a dummy object for some reason. - // Does the node point to a dummy object? - Object *obj = node->GetObjectRef(); - if (!obj || !obj->CanConvertToType(Class_ID(DUMMY_CLASS_ID, 0))) - return false; -*/ - - // This is an origin. - return true; -} - - -/*********************************************************************************************** - * Is_Base_Origin -- Checks if the node is the origin for the base obect (non-LOD'd). * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/13/1999 AJA : Created. * - *=============================================================================================*/ -bool Is_Base_Origin(INode * node) -{ - if (!node) return false; - - if (node->IsRootNode()) return true; - - if (!Is_Origin(node)) return false; - - // An origin is the base object origin if it's name is "origin." or - // "origin.0" (a numeric value evaluating to zero as scanned by sscanf - // which would include "origin.00" "origin.000", etc.). - bool is_base_origin = false; - char *name = node->GetName(); - if (stricmp(name, "origin.") == 0) - is_base_origin = true; - else if (strlen(name) > strlen("origin.")) - { - // We know the first 7 characters are "origin." because that - // was tested in Is_Origin(). Is it "origin.0"? - int idx; - if ((sscanf(name+strlen("origin."), "%d", &idx) == 1) && (idx == 0)) - is_base_origin = true; - } - - return is_base_origin; -} - - -int Get_Lod_Level(INode *node) -{ - if (node->IsRootNode()) return 0; - if (!Is_Origin(node)) return -1; - - char *name = node->GetName(); - char *dot = strrchr(name, '.'); - assert(dot); - return atoi(dot+1); -} - -int Get_Damage_State(INode *node) -{ - if (!Is_Damage_Root(node)) return -1; - - char *name = node->GetName(); - char *dot = strrchr(name, '.'); - assert(dot); - return atoi(dot+1); -} - -INode *Find_Named_Node(char *nodename, INode *root) -{ - if (!root || !nodename) - return NULL; - - // Perform a breadth-first search of the tree for a node - // of the given name. - INode *child = NULL; - int i; - char cur_name[W3D_NAME_LEN]; - - // Is this the node we're looking for? - Set_W3D_Name(cur_name, root->GetName()); - if (strcmp(cur_name, nodename) == 0) - return root; - - // Check the children against the given name. - for (i = 0; i < root->NumChildren(); i++) - { - // Is it this child? - child = root->GetChildNode(i); - Set_W3D_Name(cur_name, child->GetName()); - if (strcmp(nodename, cur_name) == 0) - return child; - } - - // Wasn't any children. Check each child's descendants. - for (i = 0; i < root->NumChildren(); i++) - { - child = root->GetChildNode(i); - INode *found = Find_Named_Node(nodename, child); - if (found) - return found; - } - - // Didn't find the node anywhere. - return NULL; -} - diff --git a/Generals/Code/Tools/WW3D/max2w3d/util.h b/Generals/Code/Tools/WW3D/max2w3d/util.h deleted file mode 100644 index b2ddd5e4e52..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/util.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/util.h 25 10/27/00 4:11p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/util.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/27/00 10:24a $* - * * - * $Revision:: 25 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef UTIL_H -#define UTIL_H - -#ifndef ALWAYS_H -#include "always.h" -#endif - -#include - -#include "skin.h" -#include "nodelist.h" - - -/* -** Gets rid of very small numbers in the matrix -** (sets them to zero). -*/ -Matrix3 Cleanup_Orthogonal_Matrix(Matrix3 & mat); - -/* -** Naming utility functions -*/ -void Set_W3D_Name(char * set_name,const char * src); -void Split_Node_Name(const char * name,char * set_base,char * set_exten,int * set_exten_index); -bool Append_Lod_Character(char *meshname, int lod_level, INodeListClass *origin_list); - -/* -** File path utility functions -*/ -void Create_Full_Path(char *full_path, const char *cwd, const char *rel_path); -void Create_Relative_Path(char *rel_path, const char *cwd, const char *full_path); -bool Is_Full_Path(char * path); - -/* -** Check if this is some kind of triangle mesh inside of MAX. We will assume -** different default export behavior depending on whether the object is a -** triangle mesh or not. -*/ -bool Is_Max_Tri_Mesh(INode * node); - - -/* -** Origin support. -*/ -bool Is_Origin(INode *node); -bool Is_Base_Origin(INode *node); -INode *Find_Origin(INode *node); - -bool Is_Damage_Root(INode *node); - -/* -** Lod-Level and Damage State settings for an INode -*/ -int Get_Lod_Level(INode *node); -int Get_Damage_State(INode *node); - -/* -** Utility function to find a named node in a hierarchy. -*/ -INode *Find_Named_Node (char *nodename, INode *root); - - -/* -** Macros -*/ -#define SAFE_DELETE(pobject) \ - if (pobject) { \ - delete pobject; \ - pobject = NULL; \ - } \ - -#define SAFE_DELETE_ARRAY(pobject) \ - if (pobject) { \ - delete [] pobject; \ - pobject = NULL; \ - } \ - - -#endif \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/vchannel.cpp b/Generals/Code/Tools/WW3D/max2w3d/vchannel.cpp deleted file mode 100644 index 64d1dd846e6..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/vchannel.cpp +++ /dev/null @@ -1,1396 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/vchannel.cpp 10 10/30/00 6:56p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/vchannel.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/30/00 5:26p $* - * * - * $Revision:: 10 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "vchannel.h" -#include -#include -#include -#include "w3d_file.h" -#include "w3dquat.h" -#include "bchannel.h" -#include "exportlog.h" - - -#define FILTER_TABLE_SIZE (256) -#define FILTER_TABLE_GEN_START (16) -#define FILTER_TABLE_GEN_SIZE (FILTER_TABLE_SIZE - FILTER_TABLE_GEN_START) - -static float filtertable[FILTER_TABLE_SIZE] = { - 0.00000001f, - 0.0000001f, - 0.000001f, - 0.00001f, - 0.0001f, - 0.001f, - 0.01f, - 0.1f, - 1.0f, - 10.0f, - 100.0f, - 1000.0f, - 10000.0f, - 100000.0f, - 1000000.0f, - 10000000.0f, - -}; -static bool table_valid = false; - - -VectorChannelClass::VectorChannelClass -( - uint32 id, - int maxframes, - uint32 flags, - int vectorlength, - float32 * identvect -) : - ID(id), - Flags(flags), - MaxFrames(maxframes), - VectorLen(vectorlength), - IsEmpty(true), - IdentVect(NULL), - Data(NULL), - Begin(0), - End(0), - ReduceAnimation(false), - ReduceAnimationPercent(0), - CompressAnimation(false), - CompressAnimationFlavor(0), - CompressAnimationTranslationError(0.0f), - CompressAnimationRotationError(0.0f) -{ - - assert(VectorLen > 0); - IdentVect = new float32[VectorLen]; - Data = new float32[MaxFrames * VectorLen]; - assert(Data); - assert(IdentVect); - - memcpy(IdentVect,identvect,VectorLen * sizeof(float32)); - memset(Data,0,MaxFrames * VectorLen * sizeof(float32)); - - // start "Begin" at the end of the array, whenever we set a value - // at an index less than "Begin", we push "Begin" back. - Begin = MaxFrames; - End = 0; - - if (false == table_valid) { - // Create Filter Table, used in delta compression - - for (int i=0; i= 0); - assert(frameidx < MaxFrames); - - for (int vi=0; vi= 0); - assert(frameidx < MaxFrames); - - return &(Data[frameidx * VectorLen]); -} - - -bool VectorChannelClass::SaveTimeCoded(ChunkSaveClass & csave, BitChannelClass *binmov) -{ - uint32 channelsize = sizeof(W3dTimeCodedAnimChannelStruct); - uint32 packetsize = (VectorLen * sizeof(float32)) + sizeof(uint32); - channelsize += packetsize * MaxFrames; - channelsize -= sizeof(uint32); - - W3dTimeCodedAnimChannelStruct * chn = (W3dTimeCodedAnimChannelStruct *)malloc(channelsize); - - if (chn == NULL) { - return false; - } - - chn->NumTimeCodes = MaxFrames; - chn->VectorLen = VectorLen; - chn->Pivot = ID; - chn->Flags = Flags; - - // Fetch Channel Data into new format - // tc [data] tc [data] tc [data] .. ... - uint32 fidx = 0; - - for (int fcount=0; fcount < MaxFrames; fcount++, fidx += (VectorLen+1) ) { - - uint32 * pivec; - float32 * pfvec; - - pivec = &chn->Data[ fidx ]; - pfvec = (float32 *) (pivec + 1); - - *pivec = fcount; - - if (binmov) { - - bool binary_move = binmov->Get_Bit( fcount ); - - // check for false binary movement - if (fcount != Begin) { - if (binary_move) { - *pivec |= W3D_TIMECODED_BINARY_MOVEMENT_FLAG; - } - } - else { - //if (log) log->printf("\nFALSE Binary\n"); - } - } - - - // Copy Vector - for (int vidx=0; vidx < VectorLen; vidx++) { - - pfvec[vidx] = get_value(fcount,vidx); - } - } - - // Compress the new structure - - VectorChannelClass::compress( chn ); - - // update the size - - float original_channelsize = channelsize; - - channelsize = sizeof(W3dTimeCodedAnimChannelStruct); - channelsize += packetsize * chn->NumTimeCodes; - channelsize -= sizeof(uint32); - - float percent = (((float)channelsize) / original_channelsize) * 100.0f; - // save - - ExportLog::printf("%.0f", percent); - - if (csave.Write(chn,channelsize) != channelsize) { - return false; - } - - if (chn != NULL) { - free(chn); - } - - if (!csave.End_Chunk()) { - return false; - } - - return true; - -} // SaveTimeCoded - - -/* -struct W3dAdaptiveDeltaAnimChannelStruct -{ - uint32 NumFrames; // number of frames of animation - uint16 Pivot; // pivot effected by this channel - uint8 VectorLen; // num Channels - uint8 Flags; // channel type - float Scale; // Filter Table Scale - - uint32 Data[1]; // OpCode Data Stream - -}; -*/ - -struct -{ - unsigned char filter : 7; - unsigned char flag : 1; - unsigned char d0 : 4; - unsigned char d1 : 4; - unsigned char d2 : 4; - unsigned char d3 : 4; - unsigned char d4 : 4; - unsigned char d5 : 4; - unsigned char d6 : 4; - unsigned char d7 : 4; - unsigned char d8 : 4; - unsigned char d9 : 4; - unsigned char d10 : 4; - unsigned char d11 : 4; - unsigned char d12 : 4; - unsigned char d13 : 4; - unsigned char d14 : 4; - unsigned char d15 : 4; - -} AdaptiveDeltaPacketStruct; - -// -// test compress Adaptive Delta packet -// -// inputs: filter - forced filter to use -// scale (filter table scale) -// value1 (continue compression from this initial value) -// float *indata // 16 values to compress -// float *outdata // 16 decompressed values -// -// output: float error; // aggregate error for packet -// -float VectorChannelClass::test_compress(int filter_index, float scale, float value1, float *indata, float *outdata) -{ - - float error = 0.0f; - - // compute filter - - float filter = filtertable[filter_index] * scale; - - assert(filter_index < FILTER_TABLE_SIZE); - - float last_value = value1; - - for(int data_idx=0; data_idx < 16; data_idx++) { - - // NOTE: DETERMINE best factor via Brute Force - // This helps under/over-flow problems - - // brute - int best_factor = 100; - float least_error = 999999999.9f; - for (float try_factor = -8.0f; try_factor < 8.0f; try_factor+=1.0f) { - float temp = (try_factor * filter) + last_value; // decompress using this filter - temp-=indata[data_idx]; // delta decompressed value, vs original value - temp=fabs(temp); - if (temp < least_error) { - least_error = temp; - best_factor = try_factor; - } - } - assert(best_factor <= 7); - assert(best_factor >=-8); - - float dfactor = best_factor; - - outdata[data_idx] = (dfactor * filter) + last_value; - // END BRUTE FORCE IT - - float delta = outdata[data_idx] - indata[data_idx]; - - //if (delta > error) error = delta; - error+= (delta * delta); - - last_value = outdata[data_idx]; - } - - return( sqrt(error) ); - -} // test_compress - -// -// compress Adaptive Delta packet -// -// inputs: filter - forced filter to use -// scale (filter table scale) -// value1 (continue compression from this initial value) -// float *indata // 16 values to compress -// unsigned char *pPacket -// -// output: float error; // aggregate error for packet -// -float VectorChannelClass::compress(int filter_index, float scale, float value1, float *indata, unsigned char *pPacket, float *outdata) -{ - float error = 0.0f; - - // compute filter - - float filter = filtertable[filter_index] * scale; - - assert(filter_index < FILTER_TABLE_SIZE); - - *pPacket = filter_index; - pPacket++; - - float last_value = value1; - - for(int data_idx=0; data_idx < 16; data_idx++) { - - // NOTE: PLAN TO ADD A LOOP IN HERE, to DETERMINE best factor via Brute Force - // This could help under/over-flow problems - { - // brute - int best_factor = 100; - float least_error = 999999999.9f; - for (float try_factor = -8.0f; try_factor < 8.0f; try_factor+=1.0f) { - float temp = (try_factor * filter) + last_value; // decompress using this filter - temp-=indata[data_idx]; // delta decompressed value, vs original value - temp=fabs(temp); - if (temp < least_error) { - least_error = temp; - best_factor = try_factor; - } - } - assert(best_factor <= 7); - assert(best_factor >=-8); - - float dfactor = best_factor; - - outdata[data_idx] = (dfactor * filter) + last_value; - - int pi = data_idx>>1; - - if (data_idx & 1) { - best_factor<<=4; - pPacket[pi]&=0x0f; - pPacket[pi]|=best_factor; - } - else { - best_factor&=0xf; - pPacket[pi]&=0xf0; - pPacket[pi]|=best_factor; - } - } - - // END BRUTE FORCE IT - - error+=fabs(outdata[data_idx] - indata[data_idx]); - - last_value = outdata[data_idx]; - - } - - return( error ); - -} // compress - - -bool VectorChannelClass::SaveAdaptiveDelta(ChunkSaveClass & csave, BitChannelClass *binmov) -{ - uint32 channelsize = sizeof(W3dAdaptiveDeltaAnimChannelStruct); - int packetsize = sizeof(AdaptiveDeltaPacketStruct); - int numpackets = (MaxFrames + 15) / 16; - channelsize += packetsize * numpackets * VectorLen; - channelsize -= sizeof(char); - channelsize += VectorLen * sizeof(float); - - W3dAdaptiveDeltaAnimChannelStruct * chn = (W3dAdaptiveDeltaAnimChannelStruct *)malloc(channelsize); - - if (chn == NULL) { - return false; - } - -// Brute Force Compressor - - // Initialize Chan Data - chn->NumFrames = MaxFrames; - chn->Pivot = ID; - chn->VectorLen = VectorLen; - chn->Flags = Flags; - chn->Scale = 0.0f; - memset(&chn->Data[0], channelsize - (sizeof(W3dAdaptiveDeltaAnimChannelStruct) - sizeof(char)), 0x00); - - assert(VectorLen <= 4); // otherwise temp vector won't have room - - float *initial = (float *)&chn->Data[0]; - float work[4]; - - // Fetch initial value - int i=0; - for (; i < VectorLen; i++) { - work[i] = initial[i] = get_value(0, i); - } - - float original_packet[16]; - float decompressed_packet[16]; - float scale = 0.0f; - float last_value=0.0f; - int frame = 1; - float delta; - - // Compute Scale - - for (int fidx=1; fidx < MaxFrames; fidx++) { - for (i=0; i scale) scale = delta; - } - } - - scale/=7.0f; // range of the delta encode is +- 7 units, in which ever filter range - // the smaller the scale, the better our precision is going to be - - // End Compute Scale - - for (i=0; i < numpackets; i++) { - for (int vi=0; viprintf("\nvi= %d frames %d to %d : error = %f ",vi, frame, frame+15, least_error); - - // Encode current packet - - unsigned char * pPacket; - - pPacket = (unsigned char *) &chn->Data[0]; // beginning of data struct - pPacket+= (VectorLen * sizeof(float)); // skip over initial values - pPacket+= (sizeof(AdaptiveDeltaPacketStruct) * VectorLen * ((frame-1)>>4)); // skip up to the appropriate packet - pPacket+= sizeof(AdaptiveDeltaPacketStruct) * vi; // skip up the appropriate vector index - - compress(best_filter, scale, last_value, original_packet, pPacket, decompressed_packet); - - // update work[vi]; - work[vi] = decompressed_packet[15]; - - } // for vi - frame+=16; - } // for numpackets - - - // print how big we are vs non-compressed - float rawsize = sizeof(W3dAnimChannelStruct); - rawsize += (VectorLen * sizeof(float32) * (MaxFrames)) - sizeof(float32); - - float percent = ((float)channelsize) / rawsize; - percent*=100.0f; - - ExportLog::printf("%.0f", percent); - - - // update final scale - chn->Scale = scale; - - if (csave.Write(chn,channelsize) != channelsize) { - return false; - } - - if (chn != NULL) { - free(chn); - } - - if (!csave.End_Chunk()) { - return false; - } - - return true; - -} // SaveAdaptiveDelta - - -bool VectorChannelClass::Save(ChunkSaveClass & csave, BitChannelClass *binmov) -{ - if (IsEmpty) return true; - - compute_range(); - if (EndFirstFrame = Begin; - chn->LastFrame = End; - chn->VectorLen = VectorLen; - chn->Pivot = ID; - chn->Flags = Flags; - - for (int fcount=0; fcount < End-Begin+1; fcount++) { - for (int vidx=0; vidx < VectorLen; vidx++) { - - int writeidx = fcount * VectorLen + vidx; - - chn->Data[writeidx] = get_value(Begin + fcount,vidx); - } - } - - if (csave.Write(chn,channelsize) != channelsize) { - return false; - } - - if (chn != NULL) { - free(chn); - } - - if (!csave.End_Chunk()) { - return false; - } - - } - - return true; -} - -void VectorChannelClass::SetSaveOptions(bool compress, int flavor, float Terr, float Rerr, bool reduce, int reduce_percent) -{ - - ReduceAnimation = reduce; - ReduceAnimationPercent = reduce_percent; - CompressAnimation = compress; - CompressAnimationFlavor = flavor; - CompressAnimationTranslationError = Terr; - CompressAnimationRotationError = DEG_TO_RAD(Rerr); - -} // SetSaveOptions - -// -// Set data in motion channel to identity vector -// R2 - set invisible data to repeat last known position, the previous algorthm caused problems with -// the current movie assets -// -void VectorChannelClass::ClearInvisibleData(BitChannelClass *vis) -{ - float *tvec; - - assert(VectorLen <= 8); - - bool prev_state = vis->Get_Bit( 0 ); - - tvec = Get_Vector( 0 ); - - for (int idx=0; idx < MaxFrames; idx++) { - - bool cur_state = vis->Get_Bit( idx ); - - if (cur_state != prev_state) { - prev_state = cur_state; - tvec = Get_Vector( idx ); - } - - if (false == cur_state) { - //Set_Vector( idx, IdentVect ); - Set_Vector( idx, tvec ); - } - } -} // ClearInvisibleData - - -void VectorChannelClass::set_value(int framenum,int vindex,float32 val) -{ - assert(framenum >= 0); - assert(framenum < MaxFrames); - assert(vindex >= 0); - assert(vindex < VectorLen); - - Data[framenum * VectorLen + vindex] = val; -} - -float32 VectorChannelClass::get_value(int framenum,int vindex) -{ - assert(framenum >= 0); - assert(framenum < MaxFrames); - assert(vindex >= 0); - assert(vindex < VectorLen); - - return Data[framenum * VectorLen + vindex]; -} - -bool VectorChannelClass::is_identity(float32 * vec) -{ - const double ERROR_TOLERANCE = 0.00005 * 0.00005; - double dist = 0.0; - - for (int vi=0; vi= 0) && (is_identity(Get_Vector(End)))) { - End--; - } -} // compute_range - - -// -// Remove a packet from a W3dTimeCodedAnimChanelStruct -// -void VectorChannelClass::remove_packet(W3dTimeCodedAnimChannelStruct * c, uint32 packet_idx) -{ - assert( c ); - assert( c->NumTimeCodes > 1 ); - - uint32 packet_size = c->VectorLen + 1; - uint32 packet_len = packet_size * sizeof(uint32); - - uint32 *src, *dst; - - dst = (uint32 *) &c->Data[ packet_size * packet_idx ]; - src = (uint32 *) &c->Data[ packet_size * (packet_idx + 1) ]; - - uint32 copy_length = (c->NumTimeCodes - (packet_idx + 1)) * packet_len; - - if (copy_length) { - - memcpy(dst, src, copy_length); - - } - - // Decrement Packet Count - c->NumTimeCodes--; - -} // remove_packet - -// -// Take a non-compressed TimeCoded Motion Channel -// and compress the packets -// -void VectorChannelClass::compress(W3dTimeCodedAnimChannelStruct * c) -{ - - assert( c ); - - - // Standard Error Threshold Compression - - double Terr = CompressAnimationTranslationError; - double Rerr = CompressAnimationRotationError; - - float TimeCodes_ct = c->NumTimeCodes; - - switch( c->Flags ) - { - case ANIM_CHANNEL_X: - case ANIM_CHANNEL_Y: - case ANIM_CHANNEL_Z: { - - while(1) { - - uint32 idx = find_useless_packet( c, Terr ); - - if (PACKETS_ALL_USEFUL == idx) break; - - remove_packet( c, idx ); - - } - - break; - } - - case ANIM_CHANNEL_XR: - case ANIM_CHANNEL_YR: - case ANIM_CHANNEL_ZR: { - - while(1) { - - uint32 idx = find_useless_packet( c, Rerr ); - - if (PACKETS_ALL_USEFUL == idx) break; - - remove_packet( c, idx ); - - } - - break; - } - - case ANIM_CHANNEL_Q: { - - while(1) { - - uint32 idx = find_useless_packetQ( c, Rerr ); - - if (PACKETS_ALL_USEFUL == idx) break; - - remove_packet( c, idx ); - - } - - break; - } - - default: // undefined channel - assert(0); - break; - } - - // Forced Reduction Phase - - if (ReduceAnimation) { - if (ReduceAnimationPercent) { - - float pct = ReduceAnimationPercent; - - pct *= (0.01f); - - pct = 1.0f - pct; - - // if out of range, don't even try - if (pct <= 0.0f) return; - if (pct >= 1.0f) return; - - pct*=TimeCodes_ct; - - pct+=0.5f; - - uint32 maxFrames = pct; - - if (maxFrames < 2) maxFrames = 2; - - if (maxFrames >= c->NumTimeCodes) return; // desired minimum already attained - - - switch( c->Flags ) - { - case ANIM_CHANNEL_X: - case ANIM_CHANNEL_Y: - case ANIM_CHANNEL_Z: - case ANIM_CHANNEL_XR: - case ANIM_CHANNEL_YR: - case ANIM_CHANNEL_ZR: { - - while(maxFrames < c->NumTimeCodes) { - - uint32 idx = find_least_useful_packet( c ); - if (PACKETS_ALL_USEFUL == idx) break; - remove_packet( c, idx ); - } - - break; - } - - case ANIM_CHANNEL_Q: { - - while(maxFrames < c->NumTimeCodes) { - - uint32 idx = find_least_useful_packetQ( c ); - if (PACKETS_ALL_USEFUL == idx) break; - remove_packet( c, idx ); - } - - break; - } - - default: // undefined channel - assert(0); - break; - } - } // if ReducePercent - - } // if Reduce - -} // compress - - - -// -// find a packet that isn't needed, and return the index -// if all packets are necessary, then return back PACKETS_ALL_USEFUL -// a useless packet is defined, as a packet that can be recreated -// via interpolation -// -// Make Sure we NEVER get rid of binary movement packets -// The rule is, you can't interpolate TOO a binary movement, but you can -// interpolate FROM -//#define W3D_TIMECODED_BINARY_MOVEMENT_FLAG 0x80000000 -// -uint32 VectorChannelClass::find_useless_packet(W3dTimeCodedAnimChannelStruct * c, double tolerance) -{ -#define MAX_VECTOR_SIZE 8 -static float32 tempvec[MAX_VECTOR_SIZE]; - - assert( c ); // make sure pointer exists - assert( c->NumTimeCodes ); // make sure some packets exist - assert( c->VectorLen <= MAX_VECTOR_SIZE ); - - uint32 packet_size = c->VectorLen + 1; - - if (c->NumTimeCodes > 1) { - if (c->NumTimeCodes > 2) { - - float32 *pVecSrc, *pVecDst, *pVecOriginal; - uint32 *pTcSrc, *pTcDst, *pTcOriginal; - - for(uint32 try_idx = 0; try_idx < (c->NumTimeCodes - 2); try_idx++) { - - // Src Pointers - pTcSrc = (uint32 *) &c->Data[ try_idx * packet_size ]; - pVecSrc = (float32 *) pTcSrc+1; - - // Original Vector we're trying to recreate - pTcOriginal = (uint32 *) &c->Data[ (try_idx + 1) * packet_size ]; - pVecOriginal = (float32 *) pTcOriginal+1; - - // Dst Pointers - pTcDst = (uint32 *) &c->Data[ (try_idx + 2 ) * packet_size ]; - pVecDst = (float32 *) pTcDst+1; - - // Skip automagically, if binary movement involved - if (*pTcOriginal & W3D_TIMECODED_BINARY_MOVEMENT_FLAG) { - continue; // can't get rid of this guy - } - if (*pTcDst & W3D_TIMECODED_BINARY_MOVEMENT_FLAG) { - continue; // can't get rid of this guy either - } - - // Linear Interpolate between Src, and Dst, to recreate the - // Original - - float32 tStart = ((*pTcSrc) & ~W3D_TIMECODED_BINARY_MOVEMENT_FLAG); // upgrade to floats - float32 tRecreate = *pTcOriginal; - float32 tEnd = *pTcDst; - float32 tRatio = (tRecreate - tStart) / (tEnd - tStart); - - uint32 idx=0; - for (; idx < c->VectorLen; idx++) { - - tempvec[ idx ] = WWMath::Lerp(pVecSrc[idx], pVecDst[idx], tRatio); - - } - - // Compare Original to our re-creation - - bool close_enough = true; - - for (idx=0; idx < c->VectorLen; idx++) { - - float32 delta; - - delta = fabs(pVecOriginal[idx] - tempvec[idx]); - - if (delta > tolerance) { - close_enough = false; - break; - } - - } - - // If our Recreation is very close to the original, - // then discard the original - - if (true == close_enough) { - return (try_idx + 1); - } - - // else continue - - } // for - - } - else { - // Special Case, when there are only 2 time codes - // Check to see if they are equal, value - // if so, then return the 2nd timecode as useless - - float32 *pVecSrc = (float32 *) &c->Data[ 1 ]; - float32 *pVecDst = (float32 *) &c->Data[ packet_size + 1 ]; - - bool identical = true; - - if ((c->Data[ packet_size ] & W3D_TIMECODED_BINARY_MOVEMENT_FLAG) == 0) { - - for(uint32 idx=0; idx < c->VectorLen; idx++) { - - float32 delta; - - delta = fabs(pVecDst[idx] - pVecSrc[idx]); - - if (delta > tolerance) { - identical = false; - break; - } - - } - - if (identical) return( 1 ); - - } - } - } - - return( PACKETS_ALL_USEFUL ); - -} // find_useless_packet - - -// -// Special Case for Quaternion Packets -// -// Make Sure we NEVER get rid of binary movement packets -// The rule is, you can't interpolate TOO a binary movement, but you can -// interpolate FROM -//#define W3D_TIMECODED_BINARY_MOVEMENT_FLAG 0x80000000 -// -uint32 VectorChannelClass::find_useless_packetQ(W3dTimeCodedAnimChannelStruct * c, double tolerance) -{ - - assert( c ); // make sure pointer exists - assert( c->NumTimeCodes ); // make sure some packets exist - assert( c->VectorLen == 4); - - uint32 packet_size = c->VectorLen + 1; - - if (c->NumTimeCodes > 1) { - if (c->NumTimeCodes > 2) { - - float32 *pVecSrc, *pVecDst, *pVecOrg; - uint32 *pTcSrc, *pTcDst, *pTcOrg; - - for(uint32 try_idx = 0; try_idx < (c->NumTimeCodes - 2); try_idx++) { - - // Src Pointers - pTcSrc = (uint32 *) &c->Data[ try_idx * packet_size ]; - pVecSrc = (float32 *) pTcSrc+1; - - // Original Vector we're trying to recreate - pTcOrg = (uint32 *) &c->Data[ (try_idx + 1) * packet_size ]; - pVecOrg = (float32 *) pTcOrg+1; - - // Dst Pointers - pTcDst = (uint32 *) &c->Data[ (try_idx + 2 ) * packet_size ]; - pVecDst = (float32 *) pTcDst+1; - - // Sphereical Linear Interpolate between Src, and Dst, to recreate the - // Original - - // Skip automagically, if binary movement involved - if (*pTcOrg & W3D_TIMECODED_BINARY_MOVEMENT_FLAG) { - continue; // can't get rid of this guy - } - if (*pTcDst & W3D_TIMECODED_BINARY_MOVEMENT_FLAG) { - continue; // can't get rid of this guy either - } - - float32 tStart = ((*pTcSrc) & ~W3D_TIMECODED_BINARY_MOVEMENT_FLAG); // upgrade to floats - float32 tRecreate = *pTcOrg; - float32 tEnd = *pTcDst; - float32 tRatio = (tRecreate - tStart) / (tEnd - tStart); - - - Quaternion qSrc(1); - qSrc.Set(pVecSrc[0],pVecSrc[1],pVecSrc[2],pVecSrc[3]); - - Quaternion qOrg(1); - qOrg.Set(pVecOrg[0],pVecOrg[1],pVecOrg[2],pVecOrg[3]); - - Quaternion qDst(1); - qDst.Set(pVecDst[0],pVecDst[1],pVecDst[2],pVecDst[3]); - - Quaternion q = Slerp( qSrc, qDst, tRatio ); - - Quaternion Delta(1); - Delta = Inverse(qOrg) * q; - - double angle = acosf( fabs( Delta.W ) ) * 2.0; - - if (angle <= tolerance ) { - return (try_idx + 1); - } - - // else continue - - } // for - - } - - } - else { - // Special Case, when there are only 2 time codes - // Check to see if they are equal, value - // if so, then return the 2nd timecode as useless - - float32 *pVecSrc = (float32 *) &c->Data[ 1 ]; - float32 *pVecDst = (float32 *) &c->Data[ packet_size + 1 ]; - - if ((c->Data[ packet_size ] & W3D_TIMECODED_BINARY_MOVEMENT_FLAG) == 0) { - - Quaternion qSrc(1); - qSrc.Set(pVecSrc[0], pVecSrc[1], pVecSrc[2], pVecSrc[3]); - - Quaternion qDst(1); - qDst.Set(pVecDst[0], pVecDst[1], pVecDst[2], pVecDst[3]); - - Quaternion Delta(1); - Delta = Inverse(qSrc) * qDst; - - double angle = acosf( fabs( Delta.W ) ) * 2.0; - - if (angle <= tolerance ) { - return (1); - } - } - } - - return( PACKETS_ALL_USEFUL ); - -} // find_useless_packetQ - - -// -// Instead of using a fixed error threshold, find the packet -// that generates the least amount of error, via removal -// -// Make Sure we NEVER get rid of binary movement packets -// The rule is, you can't interpolate too a binary movement, but you can -// interpolate FROM -//#define W3D_TIMECODED_BINARY_MOVEMENT_FLAG 0x80000000 -// -uint32 VectorChannelClass::find_least_useful_packet(W3dTimeCodedAnimChannelStruct *c) -{ - -static float32 tempvec[MAX_VECTOR_SIZE]; - - assert( c ); // make sure pointer exists - assert( c->NumTimeCodes ); // make sure some packets exist - assert( c->VectorLen <= MAX_VECTOR_SIZE ); - - uint32 packet_size = c->VectorLen + 1; - - double leasterror = 9999999.0f; - uint32 ret_idx = PACKETS_ALL_USEFUL; - - if (c->NumTimeCodes > 1) { - if (c->NumTimeCodes > 2) { - - float32 *pVecSrc, *pVecDst, *pVecOriginal; - uint32 *pTcSrc, *pTcDst, *pTcOriginal; - - for(uint32 try_idx = 0; try_idx < (c->NumTimeCodes - 2); try_idx++) { - - // Src Pointers - pTcSrc = (uint32 *) &c->Data[ try_idx * packet_size ]; - pVecSrc = (float32 *) pTcSrc+1; - - // Original Vector we're trying to recreate - pTcOriginal = (uint32 *) &c->Data[ (try_idx + 1) * packet_size ]; - pVecOriginal = (float32 *) pTcOriginal+1; - - // Dst Pointers - pTcDst = (uint32 *) &c->Data[ (try_idx + 2 ) * packet_size ]; - pVecDst = (float32 *) pTcDst+1; - - // Skip automagically, if binary movement involved - if (*pTcOriginal & W3D_TIMECODED_BINARY_MOVEMENT_FLAG) { - continue; // can't get rid of this guy - } - if (*pTcDst & W3D_TIMECODED_BINARY_MOVEMENT_FLAG) { - continue; // can't get rid of this guy either - } - - // Linear Interpolate between Src, and Dst, to recreate the - // Original - - float32 tStart = ((*pTcSrc) & ~W3D_TIMECODED_BINARY_MOVEMENT_FLAG); // upgrade to floats - float32 tRecreate = *pTcOriginal; - float32 tEnd = *pTcDst; - float32 tRatio = (tRecreate - tStart) / (tEnd - tStart); - - uint32 idx=0; - for (; idx < c->VectorLen; idx++) { - - tempvec[ idx ] = WWMath::Lerp(pVecSrc[idx], pVecDst[idx], tRatio); - - } - - // Compare Original to our re-creation - - double delta = 0.0; - - - for (idx=0; idx < c->VectorLen; idx++) { - - double tmp; - - tmp = pVecOriginal[idx] - tempvec[idx]; - - delta += (tmp * tmp); - - } - - delta = sqrtf( delta ); - - if (delta < leasterror) - { - - // If our Recreation is very close to the original, - // then discard the original - leasterror = delta; - ret_idx =(try_idx + 1); - } - - // else continue - - } // for - - return( ret_idx ); - - } - else { - - if ((c->Data[ packet_size ] & W3D_TIMECODED_BINARY_MOVEMENT_FLAG) == 0) { - return( 1 ); - } - } - } - - - return( PACKETS_ALL_USEFUL ); - - -} // Find Least useful packet - - -// -// Instead of using a fixed error threshold, find the packet -// that generates the least amount of error, via removal -// special case for Quaternion channel -// -// Make Sure we NEVER get rid of binary movement packets -// The rule is, you can't interpolate FROM a binary movement, but you can -// interpolate TOO -//#define W3D_TIMECODED_BINARY_MOVEMENT_FLAG 0x80000000 -// -uint32 VectorChannelClass::find_least_useful_packetQ(W3dTimeCodedAnimChannelStruct *c) -{ - - assert( c ); // make sure pointer exists - assert( c->NumTimeCodes ); // make sure some packets exist - assert( c->VectorLen == 4); - - uint32 packet_size = c->VectorLen + 1; - - double leasterror = 9999999.0f; - uint32 ret_idx = PACKETS_ALL_USEFUL; - - if (c->NumTimeCodes > 1) { - if (c->NumTimeCodes > 2) { - - float32 *pVecSrc, *pVecDst, *pVecOrg; - uint32 *pTcSrc, *pTcDst, *pTcOrg; - - for(uint32 try_idx = 0; try_idx < (c->NumTimeCodes - 2); try_idx++) { - - // Src Pointers - pTcSrc = (uint32 *) &c->Data[ try_idx * packet_size ]; - pVecSrc = (float32 *) pTcSrc+1; - - // Original Vector we're trying to recreate - pTcOrg = (uint32 *) &c->Data[ (try_idx + 1) * packet_size ]; - pVecOrg = (float32 *) pTcOrg+1; - - // Dst Pointers - pTcDst = (uint32 *) &c->Data[ (try_idx + 2 ) * packet_size ]; - pVecDst = (float32 *) pTcDst+1; - - // Skip automagically, if binary movement involved - if (*pTcOrg & W3D_TIMECODED_BINARY_MOVEMENT_FLAG) { - continue; // can't get rid of this guy - } - if (*pTcDst & W3D_TIMECODED_BINARY_MOVEMENT_FLAG) { - continue; // can't get rid of this guy either - } - - // Spherical Linear Interpolate between Src, and Dst, to recreate the - // Original - - float32 tStart = ((*pTcSrc) & ~W3D_TIMECODED_BINARY_MOVEMENT_FLAG); // upgrade to floats - float32 tRecreate = *pTcOrg; - float32 tEnd = *pTcDst; - float32 tRatio = (tRecreate - tStart) / (tEnd - tStart); - - - Quaternion qSrc(1); - qSrc.Set(pVecSrc[0],pVecSrc[1],pVecSrc[2],pVecSrc[3]); - - Quaternion qOrg(1); - qOrg.Set(pVecOrg[0],pVecOrg[1],pVecOrg[2],pVecOrg[3]); - - Quaternion qDst(1); - qDst.Set(pVecDst[0],pVecDst[1],pVecDst[2],pVecDst[3]); - - Quaternion q = Slerp( qSrc, qDst, tRatio ); - - Quaternion Delta(1); - Delta = Inverse(qOrg) * q; - - double angle = acosf( fabs( Delta.W ) ) * 2; - - if (angle < leasterror ) { - leasterror = angle; - ret_idx = (try_idx + 1); - } - - // else continue - - } // for - - return( ret_idx ); - - } - - } - else { - // Special Case, when there are only 2 time codes - // Check to see if they are equal, value - // if so, then return the 2nd timecode as useless - - if ((c->Data[ packet_size ] & W3D_TIMECODED_BINARY_MOVEMENT_FLAG) == 0) { - return( 1 ); - } - } - - - return( PACKETS_ALL_USEFUL ); - -} // find_least_useful_packetQ - - -// EOF - vchannel.cpp \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/vchannel.h b/Generals/Code/Tools/WW3D/max2w3d/vchannel.h deleted file mode 100644 index 6021f8da57b..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/vchannel.h +++ /dev/null @@ -1,140 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/vchannel.h 8 10/30/00 6:56p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/vchannel.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/30/00 5:25p $* - * * - * $Revision:: 8 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef VCHANNEL_H -#define VCHANNEL_H - -#ifndef ALWAYS_H -#include "always.h" -#endif - -#ifndef BITTYPE_H -#include "BITTYPE.H" -#endif - -#ifndef CHUNKIO_H -#include "chunkio.h" -#endif - -#ifndef W3D_FILE_H -#include "w3d_file.h" -#endif - - -class BitChannelClass; - -/* - - This class is a container for an array of vectors. It will keep - track of whether the entire array of vectors is zero, and if not - where the non-zero vectors begin and end. - - VectorChannelClass is used in exporting motion. Motion data - is broken into separate channels for X, Y, Z, and orientation. - Then if any of the channels are empty, they don't have to be stored. - The X,Y,Z channels all contain one-dimensional vectors and the - orientation channel contains four-dimensional vectors. - -*/ -// for compression -#define DEFAULT_LOSSY_ERROR_TOLERANCE (0.0001) -#define PACKETS_ALL_USEFUL (0xFFFFFFFF) - -class VectorChannelClass -{ -public: - - VectorChannelClass(uint32 id,int maxframes,uint32 flags,int vectorlength,float32 * identvec); - ~VectorChannelClass(void); - - void Set_Vector(int framenumber,float32 * vector); - float * Get_Vector(int frameidx); - bool Is_Empty(void) { return IsEmpty; } - void SetSaveOptions(bool compress, int flavor, float Terr, float Rerr, bool reduce, int reduce_percent); - bool Save(ChunkSaveClass & csave, BitChannelClass *binmov); - void ClearInvisibleData(BitChannelClass *vis); - -private: - - uint32 ID; - uint32 Flags; - int MaxFrames; - int VectorLen; - bool IsEmpty; - - float32 * IdentVect; - float32 * Data; - int Begin; - int End; - - // Save Options - - bool ReduceAnimation; - int ReduceAnimationPercent; - bool CompressAnimation; - int CompressAnimationFlavor; - float CompressAnimationTranslationError; - float CompressAnimationRotationError; - - // Write a single value - void set_value(int framenum,int vindex,float32 val); - - // Read a single value - float32 get_value(int framenum,int vindex); - - // Test a vector against the "identity" vector - bool is_identity(float32 * vec); - - // This function finds the start and end of the "non-identity" data - void compute_range(void); - - // compress functions - void compress(W3dTimeCodedAnimChannelStruct * c); - float compress(int filter_index, float scale, float value1, float *indata, unsigned char *pPacket, float *outdata); - float test_compress(int filter_index, float scale, float value1, float *indata, float *outdata); - uint32 find_useless_packet(W3dTimeCodedAnimChannelStruct * c, double tolerance); - uint32 find_useless_packetQ(W3dTimeCodedAnimChannelStruct * c, double tolerance); - uint32 find_least_useful_packet(W3dTimeCodedAnimChannelStruct *c); - uint32 find_least_useful_packetQ(W3dTimeCodedAnimChannelStruct *c); - void remove_packet(W3dTimeCodedAnimChannelStruct * c, uint32 packet_idx); - bool SaveTimeCoded(ChunkSaveClass & csave, BitChannelClass *binmov); - bool SaveAdaptiveDelta(ChunkSaveClass & csave, BitChannelClass *binmov); - -}; - -#endif /*VCHANNEL_H*/ \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/vxl.cpp b/Generals/Code/Tools/WW3D/max2w3d/vxl.cpp deleted file mode 100644 index 574aee48b38..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/vxl.cpp +++ /dev/null @@ -1,722 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/vxl.cpp 4 10/28/97 6:08p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G Math Library * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/vxl.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/14/97 3:07p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "vxl.h" -#include "errclass.h" - - -/* - - This module will voxelize one or more meshes. It is only used to compute - some things like Moment of Inertia and Center of Mass for the object. - Much of the code which was doing the shading and lighting computations - has been stripped out. - -*/ - -static void compute_dimensions( - INodeListClass & meshlist, - const Matrix3 & parenttm, - TimeValue curtime, - Point3 * min, - Point3 * max - ); - -#define VIS_UNKNOWN 0 -#define VIS_SOLID 1 -#define VIS_VISIBLE 2 - -/************************************************************************ -* VoxelClass Constructor -* -* Voxelize a list of meshes. -* -* INPUTS: -* -* OUTPUS: -* -************************************************************************/ -VoxelClass::VoxelClass -( - INodeListClass & meshlist, - int resolution, - Matrix3 parenttm, - TimeValue time, - Progress_Meter_Class & meter -) -{ - Resolution = resolution; - ParentTM = parenttm; - CurTime = time; - - XDim = resolution + 1; - YDim = resolution + 1; - ZDim = resolution + 1; - - // assert that none of the dimensions - // were too big. (if this happened, VoxelData is going - // to be a *HUMONGOUS* amount of memory...) - assert(XDim < 256); - assert(YDim < 256); - assert(ZDim < 256); - - // Allocate visibility flags array - VisData = new uint8[XDim * YDim * ZDim]; - if (VisData == NULL) { - throw ErrorClass("out of memory!"); - } - - memset(VisData,0,XDim*YDim*ZDim); - - /* - ** compute the two corners of the bounding box of - ** these meshes. Note that these coordinates are - ** be specified in the space defined by ParentTM. - */ - Point3 min; - Point3 max; - compute_dimensions(meshlist,ParentTM,CurTime,&min,&max); - - - /* - ** The voxelizer uses three values: offset, size, - ** and scale: - ** - ** offset - the position of the "most negative" corner - ** size - dimensions of the box - ** scale - scale factor to apply to vertices after they've - ** been translated by -offset - ** - */ - Size = max - min; - Offset = min; - Scale.x = Resolution / Size.x; - Scale.y = Resolution / Size.y; - Scale.z = Resolution / Size.z; - - - /* - ** Dimensions of a single voxel block - */ - BlockXDim = Size.x / Resolution; - BlockYDim = Size.y / Resolution; - BlockZDim = Size.z / Resolution; - - - /* - ** Voxelize the meshes! - */ - Quantize_Meshes - ( - meshlist, - meter - ); - -} - - -/************************************************************************ -* VoxelClass Destructor -* -* De-Allocates memory used by the voxel object -* -* INPUTS: -* none -* -* OUTPUS: -* none -* -************************************************************************/ -VoxelClass::~VoxelClass() -{ - if (VisData != NULL) delete[] VisData; -} - - -/************************************************************************ -* VoxelClass::Quantize_Meshes -* -* Generataes voxel data from the list of meshes passed in. -* -* INPUTS: -* meshlist - list of meshes to "voxelize" -* meter - progress meter object -* -* OUTPUS: -* none -* -************************************************************************/ -void VoxelClass::Quantize_Meshes -( - INodeListClass & meshlist, - Progress_Meter_Class & meter -) -{ - /* - ** Progress meter updating - */ - meter.Finish_In_Steps(2); - Progress_Meter_Class slabmeter(meter,meter.Increment); - slabmeter.Finish_In_Steps(ZDim); - - /* - ** Generate the Voxel Layer for each slice of the model - */ - float min_z = Offset.z; - float max_z = Offset.z + Size.z; - float sliceh = Size.z / (float)ZDim; - - for (int slicecount = 0; slicecount < ZDim; slicecount++ ) - { - float slicez = min_z + (max_z - min_z) * ((float)slicecount/(float)(ZDim-1)); - - VoxelLayerClass * vlayer = new VoxelLayerClass - ( - meshlist, - CurTime, - ParentTM, - Offset, - Scale, - slicez, - sliceh, - XDim, - YDim - ); - - Set_Layer(*vlayer,slicecount); - - slabmeter.Add_Increment(); - if (slabmeter.Cancelled()) throw ErrorClass("Export Cancelled"); - - delete vlayer; - } - - meter.Add_Increment(); - - // 3D visibility calculations - Progress_Meter_Class vismeter(meter,meter.Increment); - Compute_Visiblity(vismeter); - - meter.Add_Increment(); - - // Compute the voxel bounding box - Compute_Bounding_Box(Size,Offset); -} - -/************************************************************************ -* VoxelClass::Set_Layer -* -* Sets a layer of the Voxel data according to contents of the passed -* bitmap. -* -* INPUTS: -* bitmap - bitmap to use as the source data -* z - z co-ordinate of the layer to set -* -* OUTPUS: -* none -* -************************************************************************/ -void VoxelClass::Set_Layer -( - VoxelLayerClass & vlayer, - uint32 z -) -{ - // bitmap must have same x&y dimensions as the voxel space - if (vlayer.Get_Width() != (unsigned)XDim) return; - if (vlayer.Get_Height() != (unsigned)YDim) return; - - - // Copy the solid voxels into our voxel cube - for (unsigned j=0; j= 0; x--) { - if (raw_read_vis(x,y,z) == VIS_SOLID) break; - raw_set_vis(x,y,z,VIS_VISIBLE); - } - } - - // Tunneling in the Y direction - for (x = 0; x < (int)XDim; x++) { - - for (y = 0; y < (int)YDim; y++) { - if (raw_read_vis(x,y,z) == VIS_SOLID) break; - raw_set_vis(x,y,z,VIS_VISIBLE); - } - - for (y = (int)YDim-1; y >= 0; y--) { - if (raw_read_vis(x,y,z) == VIS_SOLID) break; - raw_set_vis(x,y,z,VIS_VISIBLE); - } - } - - meter.Add_Increment(); - if (meter.Cancelled()) throw ErrorClass("Export Cancelled"); - } // done with the X-Y layers - - - ///////////////////////////////////////////////////////////// - // Now I'm going to tunnel up and down through the object. - // To do this, I will loop across the width of the object - // (the X direction) and at each step tunnel through the - // Y-Z plane from all points along the top and bottom. - ///////////////////////////////////////////////////////////// - for (x = 0; x < (int)XDim; x++) { - - // Tunneling in the Z direction - for (y = 0; y < (int)YDim; y++) { - - for (z = 0; z < (int)ZDim; z++) { - if (raw_read_vis(x,y,z) == VIS_SOLID) break; - raw_set_vis(x,y,z,VIS_VISIBLE); - } - - for (z = (int)ZDim-1; z >= 0; z--) { - if (raw_read_vis(x,y,z) == VIS_SOLID) break; - raw_set_vis(x,y,z,VIS_VISIBLE); - } - } - - meter.Add_Increment(); - if (meter.Cancelled()) throw ErrorClass("Export Cancelled"); - } // done with the X-Z layers - - - /////////////////////////////////////////////////////////// - // Now, we search for all of the VIS_UNKNOWN voxels and - // set them to VIS_SOLID and we are done voxelizing - /////////////////////////////////////////////////////////// - for (z = 0; z < (int)ZDim; z++) { - for (y = 0; y < (int)YDim; y++) { - for (x = 0; x < (int)XDim; x++) { - - int vis = raw_read_vis(x,y,z); - if (vis == VIS_UNKNOWN) { - raw_set_vis(x,y,z,VIS_SOLID); - } - - } - } - meter.Add_Increment(); - if (meter.Cancelled()) throw ErrorClass("Export Cancelled"); - } -} - - -/************************************************************************ -* VoxelClass::raw_read_vis -* -* safe read of the visiblity data at i,j,k -* -* INPUTS: -* i,j,k - integer indices of the visiblity data to read -* -* OUTPUS: -* none -* -************************************************************************/ -uint8 VoxelClass::raw_read_vis -( - int i, - int j, - int k -) -{ - if (i<0) return 0; - if (j<0) return 0; - if (k<0) return 0; - if (i>=(int)XDim) return 0; - if (j>=(int)YDim) return 0; - if (k>=(int)ZDim) return 0; - - return VisData[i + j*XDim + k*XDim*YDim]; -} - -/************************************************************************ -* VoxelClass::raw_set_vis -* -* safe set of the visibility data at i,j,k -* -* INPUTS: -* i,j,k - integer indices of the visibility data to set -* val - value to set. -* -* OUTPUS: -* none -* -************************************************************************/ -void VoxelClass::raw_set_vis( - int i, - int j, - int k, - uint8 val -) -{ - if (i<0) return; - if (j<0) return; - if (k<0) return; - if (i>=(int)XDim) return; - if (j>=(int)YDim) return; - if (k>=(int)ZDim) return; - - VisData[i + j*XDim + k*XDim*YDim] = val; - return; -} - - -void compute_dimensions -( - INodeListClass & meshlist, - const Matrix3 & parenttm, - TimeValue curtime, - Point3 * set_min, - Point3 * set_max -) -{ - // Find the minimum and maximum extents in the X, Y, and Z directions. - // Also find the total surface area. - Point3 min; - Point3 max; - float surface_area = 0.0; - - BOOL first = TRUE; - - for ( unsigned i = 0; i < meshlist.Num_Nodes() ; ++ i ) - { - - // Get the relavent data from the INode - INode * n = meshlist[i]; - Object * obj = n->EvalWorldState(curtime).obj; - TriObject * tri = (TriObject *)obj->ConvertToType(curtime, triObjectClassID); - Mesh * mesh = &(tri->mesh); - Matrix3 tm = n->GetObjTMAfterWSM(curtime); - - - // Compute a matrix which takes vertices of this mesh into the - // specified parent space. - Matrix3 delta = tm * Inverse(parenttm); - - unsigned verts = mesh->getNumVerts(); - unsigned faces = mesh->getNumFaces(); - - for ( unsigned vert_index = 0; vert_index < verts; ++ vert_index ) - { - Point3 p = delta * mesh->verts [vert_index]; - - if ( first ) - { - first = FALSE; - min = max = p; - } - else - { - if ( p.x < min.x ) min.x = p.x; - if ( p.y < min.y ) min.y = p.y; - if ( p.z < min.z ) min.z = p.z; - - if ( p.x > max.x ) max.x = p.x; - if ( p.y > max.y ) max.y = p.y; - if ( p.z > max.z ) max.z = p.z; - } - } - - for ( unsigned face_index = 0; face_index < faces; ++ face_index ) - { - Face face = mesh->faces [ face_index ]; - - Point3 a = mesh->verts [ face.v[0] ]; - Point3 b = mesh->verts [ face.v[1] ]; - Point3 c = mesh->verts [ face.v[2] ]; - - double area = 0.5 * Length ( CrossProd ( b - a, c - a ) ); - - surface_area += (float) area; - } - } - - // In the odd case that there are no vertices.... - if ( first ) - { - min = max = Point3 (0,0,0); - } - - *set_min = min; - *set_max = max; -} - -uint8 VoxelClass::Is_Solid(int i,int j,int k) -{ - return (raw_read_vis(i,j,k) == VIS_SOLID); -} - -void VoxelClass::Compute_Physical_Properties(double Volume[1],double CM[3],double I[9]) -{ - int i,j,k; - - // volume of a single voxel block: - double bvol = BlockXDim * BlockYDim * BlockZDim; - - // volume of object - double volume = 0.0; - Point3 cm(0.0,0.0,0.0); - int numblocks = 0; - - //////////////////////////////////////////////////////////////////////// - // compute the volume and the center of mass - //////////////////////////////////////////////////////////////////////// - for (k=0; k < ZDim; k++) { - for (j=0; j < YDim; j++) { - for (i=0; i < XDim; i++) { - if (Is_Solid(i,j,k)) { - - // Add this block's volume to the total - volume += bvol; - - // Add this block's position to the CM computation - cm += Voxel_Position(i,j,k); - numblocks++; - } - } - } - } - - cm.x = cm.x / (double)numblocks; - cm.y = cm.y / (double)numblocks; - cm.z = cm.z / (double)numblocks; - - CM[0] = cm.x; - CM[1] = cm.y; - CM[2] = cm.z; - - Volume[0] = volume; - - //////////////////////////////////////////////////////////////////////// - // compute the inertia tensor assuming constant density and factoring - // density out: - // - // - // ( ( ( 2 2 - // | | | y + z -(xy) -(xz) - // | | | - // | | | 2 2 - // I= den*| | | -(xy) x + z -(yz) dx dy dz - // | | | - // | | | 2 2 - // | | | -(xz) -(yz) x + y - // ) ) ) - // - //////////////////////////////////////////////////////////////////////// - - for (i=0; i < 9; i++) { - I[i] = 0.0; - } - - for (k=0; k < ZDim; k++) { - for (j=0; j < YDim; j++) { - for (i=0; i < XDim; i++) { - if (Is_Solid(i,j,k)) { - - // position of block, relative to the CM - Point3 pos = Voxel_Position(i,j,k) - cm; - - // moments of inertia - double y2z2 = pos.y * pos.y + pos.z * pos.z; - double x2z2 = pos.x * pos.x + pos.z * pos.z; - double x2y2 = pos.x * pos.x + pos.y * pos.y; - - // products of inertia - double xy = pos.x * pos.y; - double xz = pos.x * pos.z; - double yz = pos.y * pos.z; - - // add to the running total! - I[0] += y2z2 * bvol; - I[1] += -xy * bvol; - I[2] += -xz * bvol; - - I[3] += -xy * bvol; - I[4] += x2z2 * bvol; - I[5] += -yz * bvol; - - I[6] += -xz * bvol; - I[7] += -yz * bvol; - I[8] += x2y2 * bvol; - } - } - } - } -} - -Point3 VoxelClass::Voxel_Position(int i,int j,int k) -{ - // returns the coordinates of the center of block(i,j,k) - return Point3( - Offset.x + i * BlockXDim + BlockXDim / 2.0, - Offset.y + j * BlockYDim + BlockYDim / 2.0, - Offset.z + k * BlockZDim + BlockZDim / 2.0 - ); -} \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/vxl.h b/Generals/Code/Tools/WW3D/max2w3d/vxl.h deleted file mode 100644 index 9cbc32e27e6..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/vxl.h +++ /dev/null @@ -1,144 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/vxl.h 4 10/28/97 6:08p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/vxl.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/26/97 1:35p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef VXL_H -#define VXL_H - -#ifndef ALWAYS_H -#include "always.h" -#endif - -#include - -#ifndef NODELIST_H -#include "nodelist.h" -#endif - -#ifndef VXLLAYER_H -#include "vxllayer.h" -#endif - -#ifndef PROGRESS_H -#include "PROGRESS.H" -#endif - - -/* - This class is used to compute approximate physical properties of a polygon - mesh or meshes. Some of these properties are listed below: - - - Moment of Inertia Tensor (with density factored out) - - Center of Mass - - Volume - - It is a cannibalized version of the code from the voxel plugin. -*/ - -class VoxelClass -{ -public: - - VoxelClass( - INodeListClass & meshlist, - int resolution, - Matrix3 parenttm, - TimeValue time, - Progress_Meter_Class & meter - ); - - ~VoxelClass(void); - - int Get_Width() { return XDim; } - int Get_Height() { return YDim; } - int Num_Layers() { return ZDim; } - uint8 Is_Solid(int i,int j,int k); - - void Compute_Physical_Properties(double Volume[1],double CM[3],double I[9]); - -private: - - int XDim; - int YDim; - int ZDim; - - double BlockXDim; - double BlockYDim; - double BlockZDim; - - unsigned char * VisData; - - float Resolution; // resolution of the voxel grid - TimeValue CurTime; - Point3 Offset; - Point3 Size; - Point3 Scale; // three scale values to fit the meshes into the desired grid - - Point3 BoxCorner[8]; // World-Space corners of the bounding box of the voxel space - Matrix3 ParentTM; // coordinate system of the parent of this object. - - void raw_set_vis(int i,int j,int k,uint8 val); - uint8 raw_read_vis(int i,int j,int k); - - int voxel_touches_space(int i,int j,int k); - void purge_interior(void); - - void Quantize_Meshes - ( - INodeListClass & meshlist, - Progress_Meter_Class & meter - ); - - // set one layer of the voxel object - void Set_Layer - ( - VoxelLayerClass & layer, - uint32 z - ); - - // compute the bounding box - void Compute_Bounding_Box(Point3 size,Point3 offset); - - // 3D visibility - void Compute_Visiblity(Progress_Meter_Class & meter); - - // returns the position of the center of voxel(i,j,k) - Point3 Voxel_Position(int i,int j,int k); -}; - - -#endif /*VXL_H*/ \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/vxldbg.cpp b/Generals/Code/Tools/WW3D/max2w3d/vxldbg.cpp deleted file mode 100644 index 3928b7e1393..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/vxldbg.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/vxldbg.cpp 3 10/28/97 6:08p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Engine * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/vxldbg.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/14/97 3:07p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "vxldbg.h" -#include "resource.h" -#include "dllmain.h" - -/* -** Static functions -*/ -static BOOL CALLBACK _dialog_proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam); - -static PaletteClass _VoxelPalette; - -VoxelDebugWindowClass::VoxelDebugWindowClass(VoxelClass * vxl) : - CurLayer(0), - Bitmap(NULL), - Voxel(vxl), - WindowHWND(0), - ViewportHWND(0), - LayerSpin(NULL) -{ - _VoxelPalette[0] = RGBClass(0,0,0); - _VoxelPalette[1] = RGBClass(128,255,128); -} - -VoxelDebugWindowClass::~VoxelDebugWindowClass(void) -{ - ReleaseISpinner(LayerSpin); -} - -void VoxelDebugWindowClass::Display_Window(void) -{ - DialogBoxParam - ( - AppInstance, - MAKEINTRESOURCE (IDD_VOXEL_DEBUG_DIALOG), - NULL, - (DLGPROC) _dialog_proc, - (LPARAM) this - ); -} - - -bool VoxelDebugWindowClass::Dialog_Proc -( - HWND hWnd, - UINT message, - WPARAM wParam, - LPARAM -) -{ - RECT crect; - - switch (message ) { - - /******************************************************************* - * WM_INITDIALOG - * - * Initialize all of the custom controls for the dialog box - * - *******************************************************************/ - case WM_INITDIALOG: - - // keep a handle to the window - WindowHWND = hWnd; - - // keep a handle to the control that I'm using for the voxel viewport. - ViewportHWND = GetDlgItem(WindowHWND,IDC_VOXEL_VIEWPORT); - - // create a DIB that will be drawn on top of the VOXEL_VIEWPORT control. - GetClientRect(ViewportHWND,&crect); - Bitmap = new SimpleDIBClass(ViewportHWND,Voxel->Get_Width(),Voxel->Get_Height(),_VoxelPalette); - - // initialize the layer spinner - LayerSpin = SetupIntSpinner - ( - hWnd, - IDC_LAYER_SPIN, - IDC_LAYER_EDIT, - 0, - Voxel->Num_Layers(), - 0 - ); - - update_display(); - - SetCursor(LoadCursor (NULL, IDC_ARROW)); - - return 1; - - - /******************************************************************* - * WM_COMMAND - * - * - *******************************************************************/ - case WM_COMMAND: - - switch (LOWORD(wParam)) - { - case IDOK: - - // done! - SetCursor(LoadCursor (NULL, IDC_WAIT)); - EndDialog(hWnd, 1); - break; - } - return 1; - - /******************************************************************* - * CC_SPINNER_CHANGE - * - * Max custom spinner controls - * - *******************************************************************/ - case CC_SPINNER_CHANGE: - - switch (LOWORD(wParam) ) - { - case IDC_LAYER_SPIN: - - CurLayer = LayerSpin->GetIVal(); - update_display(); - break; - } - - - /******************************************************************* - * WM_PAINT - * - * - *******************************************************************/ - case WM_PAINT: - - update_display(); - - GetClientRect(ViewportHWND,&crect); - ValidateRect(ViewportHWND,&crect); - - break; - - } - return 0; -} - - -void VoxelDebugWindowClass::update_display(void) -{ - int i,j; - - /* - ** Bail out if everything isn't right - */ - if ((Bitmap == NULL) || (Voxel == NULL)) { - return; - } - - /* - ** Update the contents of the DIB based on - ** the contents of the current voxel layer. - */ - - Bitmap->Clear(0); - - for (j=0; j < Voxel->Get_Height(); j++) { - for (i=0; i < Voxel->Get_Width(); i++) { - if (Voxel->Is_Solid(i,j,CurLayer)) { - Bitmap->Set_Pixel(i,j,1); - } - } - } - - /* - ** Blit the DIB onto the dialog box. - */ - HDC hdcwindow = GetDC(ViewportHWND); - HDC hdcdib = CreateCompatibleDC(hdcwindow); - HBITMAP holdbitmap = (HBITMAP)SelectObject(hdcdib, Bitmap->Get_Handle()); - RECT crect; - - GetClientRect(ViewportHWND,&crect); - int cx = (crect.right - crect.left) / 2; - int cy = (crect.bottom - crect.top) / 2; - int x0 = 0; //cx - Bitmap->Get_Width(); - int y0 = 0; //cy - Bitmap->Get_Height(); - int x1 = 2 * Bitmap->Get_Width(); //cx + Bitmap->Get_Width(); - int y1 = 2 * Bitmap->Get_Height(); //cy + Bitmap->Get_Height(); - -// BitBlt(hdcwindow,0,0,Bitmap->Get_Width(),Bitmap->Get_Height(),hdcdib,0,0,SRCCOPY); - StretchBlt( hdcwindow, x0, y0, x1, y1, - hdcdib, 0, 0, Bitmap->Get_Width(), Bitmap->Get_Height(), SRCCOPY); - - SelectObject(hdcdib, holdbitmap); - - ReleaseDC(WindowHWND, hdcwindow); - DeleteDC(hdcdib); -} - - -BOOL CALLBACK _dialog_proc -( - HWND hWnd, - UINT message, - WPARAM wParam, - LPARAM lParam -) -{ - static VoxelDebugWindowClass * window = NULL; - - if (message == WM_INITDIALOG) { - window = (VoxelDebugWindowClass *) lParam; - } - - if (window) { - return window->Dialog_Proc(hWnd, message, wParam, lParam); - } else { - return FALSE; - } -} - diff --git a/Generals/Code/Tools/WW3D/max2w3d/vxldbg.h b/Generals/Code/Tools/WW3D/max2w3d/vxldbg.h deleted file mode 100644 index 5bafca4276f..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/vxldbg.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/vxldbg.h 3 10/28/97 6:08p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Engine * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/vxldbg.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/14/97 3:07p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef VXLDBG_H -#define VXLDBG_H - -#ifndef ALWAYS_H -#include "always.h" -#endif - -#include - -#ifndef SIMPDIB_H -#include "simpdib.h" -#endif - -#ifndef VXL_H -#include "vxl.h" -#endif - - -class VoxelDebugWindowClass -{ -public: - - VoxelDebugWindowClass(VoxelClass * vxl); - ~VoxelDebugWindowClass(void); - - void Display_Window(void); - bool Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM); - -private: - - int CurLayer; - - SimpleDIBClass * Bitmap; - VoxelClass * Voxel; - HWND WindowHWND; - HWND ViewportHWND; - ISpinnerControl * LayerSpin; - - void update_display(void); -}; - - - -#endif diff --git a/Generals/Code/Tools/WW3D/max2w3d/vxllayer.cpp b/Generals/Code/Tools/WW3D/max2w3d/vxllayer.cpp deleted file mode 100644 index 4a6052ea712..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/vxllayer.cpp +++ /dev/null @@ -1,783 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/vxllayer.cpp 4 10/28/97 6:08p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G * - * * - * File Name : VXLLAYER.CPP * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 06/10/97 * - * * - * Last Update : June 10, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * VoxelLayerClass::VoxelLayerClass -- Constructor for VoxelLayerClass * - * VoxelLayerClass::Intersect_Triangle -- Intersect a triangle with the slab * - * VoxelLayerClass::Draw_Line -- Draw a line of voxels into the slab * - * VoxelLayerClass::Scan_Triangle -- Clip and scan-convert a triangle into the slab * - * clip_tri_to_slab -- Clips a triangle against a voxel slab * - * clip_poly -- clip a polygon against a single 3D plane * - * output -- Emit a vertex into a polygons vertex list * - * inside -- Test whether a point is in the front half-space of a plane * - * intersect -- compute intersection between a line and a plane * - * clear_scan_table -- clears the static scanline table * - * fixup_scan_table -- ensure all spans are left->right in order * - * scan_edge -- Scan convert an edge * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "vxllayer.h" -#include "plane.h" - - -/*************************************************************************************** -** local types -***************************************************************************************/ -struct vertexstruct -{ - Point3 Pos; - Point3 Bary; -}; - -struct scanstruct -{ - vertexstruct P[2]; -}; - - -/*************************************************************************************** -** static data -***************************************************************************************/ -static scanstruct _scantab[256]; - -const int LEFT = 0; -const int RIGHT = 1; -const float EMPTY_SPAN = -10000.0f; - - - -/*************************************************************************************** -** local functions -***************************************************************************************/ -static void clip_tri_to_slab( - Point3 p0, - Point3 p1, - Point3 p2, - float z0, - float z1, - vertexstruct * outverts, - int * setnum); - -static void clip_poly( - vertexstruct * inverts, - int innum, - vertexstruct * outverts, - int * outnum, - const PlaneClass & clipplane); - -static void output( - const vertexstruct & outvert, - vertexstruct * poly, - int * numverts); - -static int inside( - const vertexstruct & p, - const PlaneClass & plane); - -static vertexstruct intersect( - const vertexstruct & p0, - const vertexstruct & p1, - const PlaneClass & plane); - -static void clear_scan_table(void); - -static void fixup_scan_table( - int y0, - int y1); - -static void scan_edge( - const vertexstruct & p0, - const vertexstruct & p1); - - - - - - - -/*********************************************************************************************** - * VoxelLayerClass::VoxelLayerClass -- Constructor for VoxelLayerClass * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/10/1997 GH : Created. * - *=============================================================================================*/ -VoxelLayerClass::VoxelLayerClass -( - INodeListClass & object_list, - TimeValue time, - Matrix3 parenttm, - Point3 offset, - Point3 scale, - float slicez, - float sliceh, - int bmwidth, - int bmheight -) -{ - unsigned i; - - SliceZ = slicez; - SliceH = sliceh; - SliceZ0 = slicez - sliceh / 2; - SliceZ1 = slicez + sliceh / 2; - - bitmap_width = bmwidth; - bitmap_height = bmheight; - - // Initialize everything with zero - memset ( &(Solid[0][0]), 0, sizeof(Solid)); - - // Go through the list of objects and intersect them with the plane. - for ( i = 0; i < object_list.Num_Nodes(); i++ ) - { - // Get relavent data from MAX - INode * inode = object_list[i]; - Object * obj = inode->EvalWorldState(time).obj; - TriObject * tri = (TriObject *)obj->ConvertToType(time, triObjectClassID); - Mesh * mesh = &(tri->mesh); - Matrix3 objtm = inode->GetObjectTM(time); - - // Compute a delta matrix which puts vertices into the parent space - Matrix3 delta = objtm * Inverse(parenttm); - - // Loop through each face, intersecting it with the slice. - unsigned faces = mesh->getNumFaces(); - for ( unsigned face_index = 0; face_index < faces; ++ face_index ) - { - Face & face = mesh->faces [ face_index ]; - - // transform the vertices into the parent space - Point3 a = mesh->verts [ face.v[0] ] * delta; - Point3 b = mesh->verts [ face.v[1] ] * delta; - Point3 c = mesh->verts [ face.v[2] ] * delta; - - // shift the vertices to the origin - a.x -= offset.x; - a.y -= offset.y; - b.x -= offset.x; - b.y -= offset.y; - c.x -= offset.x; - c.y -= offset.y; - - // scale the vertices into the voxel grid - a.x *= scale.x; - a.y *= scale.y; - b.x *= scale.x; - b.y *= scale.y; - c.x *= scale.x; - c.y *= scale.y; - -// Intersect_Triangle ( a, b, c, SliceZ ); - Scan_Triangle( a, b, c ); - } - } -} - - - -/*********************************************************************************************** - * VoxelLayerClass::Intersect_Triangle -- Intersect a triangle with the slab * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/10/1997 GH : Created. * - *=============================================================================================*/ -void VoxelLayerClass::Intersect_Triangle -( - Point3 a, - Point3 b, - Point3 c, - float z -) -{ - double start_x, start_y, end_x, end_y; - - // If the triangle is wholly above or below the intersection plane, - // it does not intersect with the plane. - if ( a.z < z && b.z < z && c.z < z ) - return; - - if ( a.z > z && b.z > z && c.z > z ) - return; - - // Find the upward intersection moving counterclockwise. This will be - // the start of the edge. - if ( a.z < z && b.z >= z ) - { - start_x = a.x + (b.x - a.x) * (z - a.z) / (b.z - a.z); - start_y = a.y + (b.y - a.y) * (z - a.z) / (b.z - a.z); - } - else if ( b.z < z && c.z >= z ) - { - start_x = b.x + (c.x - b.x) * (z - b.z) / (c.z - b.z); - start_y = b.y + (c.y - b.y) * (z - b.z) / (c.z - b.z); - } - else if ( c.z < z && a.z >= z ) - { - start_x = c.x + (a.x - c.x) * (z - c.z) / (a.z - c.z); - start_y = c.y + (a.y - c.y) * (z - c.z) / (a.z - c.z); - } - else - { - return; - } - - // Find the downward intersection moving counterclockwise. This is the end - // of the edge. - if ( a.z >= z && b.z < z ) - { - end_x = a.x + (b.x - a.x) * (z - a.z) / (b.z - a.z); - end_y = a.y + (b.y - a.y) * (z - a.z) / (b.z - a.z); - } - else if ( b.z >= z && c.z < z ) - { - end_x = b.x + (c.x - b.x) * (z - b.z) / (c.z - b.z); - end_y = b.y + (c.y - b.y) * (z - b.z) / (c.z - b.z); - } - else if ( c.z >= z && a.z < z ) - { - end_x = c.x + (a.x - c.x) * (z - c.z) / (a.z - c.z); - end_y = c.y + (a.y - c.y) * (z - c.z) / (a.z - c.z); - } - else - { - return; - } - - // Draw the edge into the bitmap. - Draw_Line(start_x, start_y, end_x, end_y); -} - - -/*********************************************************************************************** - * VoxelLayerClass::Draw_Line -- Draw a line of voxels into the slab * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/10/1997 GH : Created. * - *=============================================================================================*/ -void VoxelLayerClass::Draw_Line -( - double x0, - double y0, - double x1, - double y1 -) -{ - // Fill in the squares containing the line's endpoints. - Add_Solid((int)x0, (int)y0); - Add_Solid((int)x1, (int)y1); - - // Fill in the squares between the endpoints. - double delta_x = fabs (x1 - x0); - double delta_y = fabs (y1 - y0); - - if ( delta_x > delta_y ) - { - // This is an X-major line. - if ( x0 > x1 ) - { - double temp = x0; - x0 = x1; - x1 = temp; - - temp = y0; - y0 = y1; - y1 = temp; - } - - double step_y = (y1 - y0) / delta_x; - - double y = y0 + step_y * (floor (x0 + 1) - x0); - - for ( int x = (int) x0; x < (int) x1; ++ x ) - { - if ( (int) y >= 0 && (int) y < bitmap_height ) - { - Add_Solid(x, (int)y); - Add_Solid(x + 1, (int)y); - } - - y += step_y; - } - } - else - { - // This is a Y-major line. - if ( y0 > y1 ) - { - double temp = x0; - x0 = x1; - x1 = temp; - - temp = y0; - y0 = y1; - y1 = temp; - } - - double step_x = (x1 - x0) / delta_y; - - double x = x0 + step_x * (floor (y0 + 1) - y0); - - for ( int y = (int) y0; y < (int) y1; ++ y ) - { - if ( (int) x >= 0 && (int) x < 256 ) - { - Add_Solid((int)x, y); - Add_Solid((int)x, y+1); - } - } - } -} - - - -/*********************************************************************************************** - * VoxelLayerClass::Scan_Triangle -- Clip and scan-convert a triangle into the slab * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/10/1997 GH : Created. * - *=============================================================================================*/ -void VoxelLayerClass::Scan_Triangle -( - Point3 p0, - Point3 p1, - Point3 p2 -) -{ - int i; - - // check if the entire triangle is above or below the slab: - if (p0.z < SliceZ0 && p1.z < SliceZ0 && p2.z < SliceZ1) return; - if (p0.z > SliceZ1 && p1.z > SliceZ1 && p2.z > SliceZ1) return; - - // clip the triangle to the slab - vertexstruct polyvert[8]; - int numverts; - - clip_tri_to_slab(p0,p1,p2,SliceZ0,SliceZ1,polyvert,&numverts); - if (numverts == 0) return; - - // clear the scanline table, get y-extents of polygon - clear_scan_table(); - - float miny = polyvert[0].Pos.y; - float maxy = polyvert[0].Pos.y; - - for (i=1; i maxy) maxy = polyvert[i].Pos.y; - } - - // scanconvert the triangle - int start = numverts - 1; - for (i=0; i= 0.0f) { - return 1; - } else { - return 0; - } -} - - -/*********************************************************************************************** - * intersect -- compute intersection between a line and a plane * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/10/1997 GH : Created. * - *=============================================================================================*/ -static vertexstruct intersect -( - const vertexstruct & p0, - const vertexstruct & p1, - const PlaneClass & plane -) -{ - float t; - - Point3 delta = p1.Pos - p0.Pos; - - float num = -( plane.N[0] * p0.Pos.x + - plane.N[1] * p0.Pos.y + - plane.N[2] * p0.Pos.z + plane.D ); - - float den = plane.N[0] * delta.x + - plane.N[1] * delta.y + - plane.N[2] * delta.z; - - if (den != 0.0f) { - t = num / den; - } else { - t = 0.0f; - } - - vertexstruct i; - i.Pos = (1.0f - t) * p0.Pos + t*p1.Pos; - i.Bary = (1.0f - t) * p0.Bary + t*p1.Bary; - return i; -} - - -/*********************************************************************************************** - * clear_scan_table -- clears the static scanline table * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/10/1997 GH : Created. * - *=============================================================================================*/ -static void clear_scan_table(void) -{ - memset(_scantab,0,sizeof(_scantab)); - for (int i=0; i<256; i++) { - _scantab[i].P[0].Pos.x = EMPTY_SPAN; - _scantab[i].P[1].Pos.x = EMPTY_SPAN; - } -} - -/*********************************************************************************************** - * fixup_scan_table -- ensure all spans are left->right in order * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/10/1997 GH : Created. * - *=============================================================================================*/ -static void fixup_scan_table(int y0,int y1) -{ - int i; - assert(y1 >= y0); - - // Ensure the left -> right convention is followed. - for (i=y0; i<=y1; i++) { - if (_scantab[i].P[LEFT].Pos.x > _scantab[i].P[RIGHT].Pos.x) { - vertexstruct tmp = _scantab[i].P[LEFT]; - _scantab[i].P[LEFT] = _scantab[i].P[RIGHT]; - _scantab[i].P[RIGHT] = tmp; - } - } - - // Ensure that we leave no gaps. - for (i=y0; i _scantab[i].P[RIGHT].Pos.x) { - - _scantab[i+1].P[LEFT].Pos.x = _scantab[i].P[RIGHT].Pos.x; - - } - } -} - - -/*********************************************************************************************** - * scan_edge -- Scan convert an edge * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/10/1997 GH : Created. * - *=============================================================================================*/ -static void scan_edge -( - const vertexstruct & p0, - const vertexstruct & p1 -) -{ - // is this a perfectly horizontal edge: - if (floor(p0.Pos.y) == floor(p1.Pos.y)) { - - int si = (int)floor(p0.Pos.y); - const vertexstruct *left, *right; - - if (p0.Pos.x < p1.Pos.x) { - left = &p0; - right = &p1; - } else { - left = &p1; - right = &p0; - } - - // does this scanline already have a span in it? - if (_scantab[si].P[0].Pos.x != EMPTY_SPAN) { - - // yes, expand this scanline's span to include this span - if (left->Pos.x < _scantab[si].P[LEFT].Pos.x) { - _scantab[si].P[LEFT] = *left; - } - - if (right->Pos.x > _scantab[si].P[RIGHT].Pos.x) { - _scantab[si].P[RIGHT] = *right; - } - - } else { - - // no, set this scanline with the span for this edge - _scantab[si].P[LEFT] = *left; - _scantab[si].P[RIGHT] = *right; - - } - return; - } - - // is this a left or right edge: - int side; - const vertexstruct *top, *bot; - - if (p0.Pos.y < p1.Pos.y) { - side = RIGHT; - top = &p0; - bot = &p1; - } else { - side = LEFT; - top = &p1; - bot = &p0; - } - - // scan the edge into _scantab - for (double y = floor(top->Pos.y); y <= floor(bot->Pos.y); y += 1.0f) { - - // parametric position on the scanline: - double t = (y - floor(top->Pos.y)) / (floor(bot->Pos.y) - floor(top->Pos.y)); - - // position: - _scantab[(int)y].P[side].Pos = (1.0f - (float)t)*top->Pos + (float)t*bot->Pos; - - // barycentric coords: - _scantab[(int)y].P[side].Bary = (1.0f - (float)t)*top->Bary + (float)t*bot->Bary; - } -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/vxllayer.h b/Generals/Code/Tools/WW3D/max2w3d/vxllayer.h deleted file mode 100644 index a824bb092cd..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/vxllayer.h +++ /dev/null @@ -1,149 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/vxllayer.h 3 10/28/97 6:08p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/vxllayer.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/26/97 1:35p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef VXLLAYER_H -#define VXLLAYER_H - -#include - - -#ifndef BITTYPE_H -#include "BITTYPE.H" -#endif - -#ifndef NODELIST_H -#include "nodelist.h" -#endif - -const sint8 VOXEL_VISIBLE = 0; // voxels that are "outside" the object -const sint8 VOXEL_SOLID = 1; // voxels that are part of the object -const sint8 VOXEL_UNKNOWN = -1; // either inside or outside, don't know yet -const int max_bitmap_width = 256; -const int max_bitmap_height = 256; - - -class VoxelLayerClass -{ -public: - - VoxelLayerClass(); - - VoxelLayerClass - ( - INodeListClass & objectlist, - TimeValue time, - Matrix3 parenttm, - Point3 offset, - Point3 scale, - float slicez, - float sliceh, - int bmwidth, - int bmheight - ); - - ~VoxelLayerClass() {}; - - BOOL Is_Visible( int x, int y ) - { - if (x < 0 || x >= bitmap_width || y < 0 || y >= bitmap_height) { - return TRUE; - } - - if (Solid[x][y] == 0) { - return TRUE; - } else { - return FALSE; - } - } - - BOOL Is_Solid( int x, int y ) - { - if (x < 0 || x >= bitmap_width || y < 0 || y >= bitmap_height) { - return FALSE; - } - - if (Solid[x][y] == VOXEL_SOLID) { - return TRUE; - } else { - return FALSE; - } - } - - unsigned int Get_Width(void) { return bitmap_width; } - unsigned int Get_Height(void) { return bitmap_height; } - -protected: - - void Set_Visible ( int x, int y ) - { - if (x >= 0 && x < bitmap_width && y >= 0 && y < bitmap_height && Solid[x][y] != VOXEL_SOLID ) - { - Solid[x][y] = VOXEL_VISIBLE; - } - } - - void Add_Solid(int x,int y) - { - // check if the point is outside the bitmap: - if (x >= 0 && x < bitmap_width && y >= 0 && y < bitmap_height) { - Solid[x][y] = VOXEL_SOLID; - } - } - - // draw a line of voxels into the bitmap - void Draw_Line(double x0,double y0,double x1,double y1); - - // draw the intersection between the triangle and the voxel plane - void Intersect_Triangle(Point3 a,Point3 b,Point3 c,float z); - - // scan convert the polygon fragment in this voxel slab - void Scan_Triangle(Point3 a,Point3 b,Point3 c); - - sint8 Solid[max_bitmap_width][max_bitmap_height]; - - float SliceZ; - float SliceH; - float SliceZ0; - float SliceZ1; - - int bitmap_width; - int bitmap_height; -}; - - -#endif /*VXLLAYER_H*/ diff --git a/Generals/Code/Tools/WW3D/max2w3d/w3d_file.h b/Generals/Code/Tools/WW3D/max2w3d/w3d_file.h deleted file mode 100644 index f6612b1bf3c..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/w3d_file.h +++ /dev/null @@ -1,2081 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /VSS_Sync/ww3d2/w3d_file.h 16 8/29/01 9:49p Vss_sync $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Library * - * * - * $Archive:: /VSS_Sync/ww3d2/w3d_file.h $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 8/29/01 7:29p $* - * * - * $Revision:: 16 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef W3D_FILE_H -#define W3D_FILE_H - -#include "always.h" -#include "BITTYPE.H" -#include "iostruct.h" -#include - -/******************************************************************************** - -NAMING CONVENTIONS: - - Typical render object name is 15 characters + NULL - Meshes have 31 + NULL character name formed from the concatenation of the "container" - model name and the mesh's name: "ContainerName.MeshName" - Animations have 31 + NULL character names formed from the concatenation of the Hierarchy tree - name with the animation name: "AnimationName.HierarchyName" - Textures have unlimited name length. - Typically you can determine which 'W3D' file a render object came from by looking - at its name. If the name contains a '.' then the filename is the string before - the '.' and if not, then the render object name is the name of the file. - -VERSION NUMBERS: - - Each Major chunk type will contain a "header" as its first - sub-chunk. The first member of this header will be a Version - number formatted so that its major revision number is the - high two bytes and its minor revision number is the lower two - bytes. - -Version 1.0: - - MESHES - contained the following chunks: - W3D_CHUNK_MESH_HEADER, // header for a mesh - W3D_CHUNK_VERTICES, // array of vertices - W3D_CHUNK_VERTEX_NORMALS, // array of normals - W3D_CHUNK_SURRENDER_NORMALS, // array of surrender normals (one per vertex as req. by surrender) - W3D_CHUNK_TEXCOORDS, // array of texture coordinates - W3D_CHUNK_MATERIALS, // array of materials - W3D_CHUNK_TRIANGLES, // array of triangles - W3D_CHUNK_SURRENDER_TRIANGLES,// array of surrender format tris - W3D_CHUNK_MESH_USER_TEXT, // Name of owning hierarchy, text from the MAX comment field - - HIERARCHY TREES - contained the following chunks: - W3D_CHUNK_HIERARCHY_HEADER, - W3D_CHUNK_PIVOTS, - W3D_CHUNK_PIVOT_FIXUPS, - - HIERARCHY ANIMATIONS - contained the following chunks: - W3D_CHUNK_ANIMATION_HEADER, - W3D_CHUNK_ANIMATION_CHANNEL, - - MESH CONNECTIONS - (blueprint for a hierarchical model) contained these chunks: - - -Version 2.0: - - MESHES: - - - Mesh header now contains the hierarchy model name. The mesh name will be built - as . instead of the old convention: . - - - The material chunk is replaced with a new material structure which contains - some information for animating materials. - - - Vertex Influences link vertices of a mesh to bones in a hierarchy, this is - the information needed for skinning. - - - Damage chunks added. A damage chunk contains a new set of materials, a set - of vertex offsets, and a set of vertex colors. - - Added the following chunks: - - W3D_CHUNK_VERTEX_COLORS, - W3D_CHUNK_VERTEX_INFLUENCES, - W3D_CHUNK_DAMAGE, - W3D_CHUNK_DAMAGE_HEADER, - W3D_CHUNK_DAMAGE_MATERIALS, - W3D_CHUNK_DAMAGE_VERTICES, - W3D_CHUNK_DAMAGE_COLORS, - W3D_CHUNK_MATERIALS2, - - MESH CONNECTIONS: Hierarchy models can now contain skins and collision meshes - in addition to the normal meshes. - - W3D_CHUNK_COLLISION_CONNECTION, // collision meshes connected to the hierarchy - W3D_CHUNK_SKIN_CONNECTION, // skins connected to the hierarchy - W3D_CHUNK_CONNECTION_AUX_DATA // extension of the connection header - - -Dec 12, 1997 - - Changed MESH_CONNECTIONS chunks into HMODEL chunks because the name - mesh connections was becoming more and more inappropriate... This was only - a data structure naming change so no-one other than the coders are affected - - Added W3D_CHUNK_LODMODEL. An LOD Model contains a set of names for - render objects, each with a specified distance range. - - -Feb 6, 1998 - - Added W3D_CHUNK_SECTMESH and its sub-chunks. This will be the file - format for the terrain geometry exported from POV's Atlas tool. - -March 29, 1998 : Version 3.0 - - - New material chunk which supports the new features of the 3D engine - - Modified HTrees to always have a root transform to remove all of the - special case -1 bone indexes. - - Added new mesh types, A mesh can now be categorized as: normal, - aligned, skin, collision, or shadow. - -June 22, 1998 - - Removed the "SECTMESH" chunks which were never implemented or used. - - Adding a new type of object: The 'Tilemap'. This simple-sounding object - is a binary partition tree of tiles where tiles are rectangular regions of - space. In each leaf to the tree, a mesh is referenced. The tile map is - made of several chunks: - - - W3D_CHUNK_TILEMAP - - W3D_CHUNK_TILEMAP_HEADER - - W3D_CHUNK_TILES - - W3D_CHUNK_MESH - - W3D_CHUNK_MESH - ... - - - W3D_CHUNK_PARTITION_TREE - - W3D_CHUNK_PARTITION_TREE_HEADER - - W3D_CHUNK_PARTITION_TREE_NODES - - - W3D_CHUNK_TILE_INSTANCES - - W3D_CHUNK_TILE_INSTANCE - -October 19, 1998 - - Created the w3d_obsolete.h header file and moved everything that I could into - it. This header was getting so messy that even I couldn't understand it so - hopefully this helps a little... - - Updating the mesh format as part of the conversion to Surrender1.40. Some - of the new features in this mesh format are: - - per pass, per stage U-V coordinate arrays - - per pass vertex diffuse color arrays - - per pass vertex specular color arrays - - per pass vertex pre-calced diffuse illumination arrays - - In addition, the way you describe the materials for a mesh has *completely* - changed. The new system separates the concepts of VertexMaterial, Texture - and Shader. A VertexMaterial defines the parameters which control the - gradient calculations for vertices. Textures you know about. Shaders - define how the gradients (diffuse and specular) are combined with the texture - and the frame buffer. In addition, a mesh can have several passes; each - pass having VertexMaterials, Textures and Shaders - - new chunk to describe a shader, contains a W3dShaderStruct - - new chunk to describe a vertex material, contains a W3dVertexMaterialStruct - - textures use the old 'Map3' chunk still - - new chunk to describe a "pass" for the mesh - - new chunk to tie up all of these vertex materials, shaders, and textures - - new chunks for specifying per-poly, per-pass arrays of texture, shader, and - vertex material indices. - - The culling system changed a bit requiring some re-working of the "Tilemap" - so I have removed the tilemap chunks. At this point in time, all of the AABTree - building is being done at run-time. Once we get the editor a little farther - along, we'll define some new chunks for this stuff. - - At this point in time, meshes look like the following. I've placed an asterisk - next to the new chunk types. - - W3D_CHUNK_MESH - W3D_CHUNK_MESH_HEADER3 - W3D_CHUNK_MESH_USER_TEXT - W3D_CHUNK_VERTICES - W3D_CHUNK_VERTEX_NORMALS - W3D_CHUNK_VERTEX_INFLUENCES - W3D_CHUNK_TRIANGLES -* W3D_CHUNK_VERTEX_SHADE_INDICES - -* W3D_CHUNK_MATERIAL_INFO // how many passes, vertex mtls, shaders, and textures... -* W3D_CHUNK_SHADERS // array of W3dShaderStruct's -* W3D_CHUNK_VERTEX_MATERIALS -* W3D_CHUNK_VERTEX_MATERIAL -* W3D_CHUNK_VERTEX_MATERIAL_NAME -* W3D_CHUNK_VERTEX_MATERIAL_INFO - ... - -* W3D_CHUNK_TEXTURES -* W3D_CHUNK_TEXTURE -* W3D_CHUNK_TEXTURE_NAME -* W3D_CHUNK_TEXTURE_INFO - ... - -* W3D_CHUNK_MATERIAL_PASS -* W3D_CHUNK_VERTEX_MATERIAL_IDS -* W3D_CHUNK_SHADER_IDS - -* W3D_CHUNK_DCG -* W3D_CHUNK_DIG -* W3D_CHUNK_SCG - -* W3D_CHUNK_TEXTURE_STAGE -* W3D_CHUNK_TEXTURE_IDS -* W3D_CHUNK_STAGE_TEXCOORDS - - - Added a Collection chunk type. When we export a bunch of independent meshes - (turning off the hierarchy and animation options) this chunk will be added - on to the end of the file. It lists by name each render object that was - defined in the file. Presumably the run-time asset manager will be able - to give you a "collection" render object which will be named the same as - the w3d file that it came from and will contain the name or an actual instance - of each of the meshes. This is a feature that was added for the Commando - level editor. - - Added the W3D_CHUNK_POINTS chunk. This is used to implement "snap points" - for the level editor. It is just an array of points that were found in - the max scene (helper object->point). We make these points co-incide in - the level editor to snap objects together. This chunk can occur inside a - mesh, hmodel, or collection chunk. When it does, the points should simply - be associated with the model being defined. - -August 5, 1999 - - Adding Null Object exporting - -March 28, 2000 - - Adding Merge objects to collections. We already have "Proxy" objects which ask - the level editor to instatiate an object at a given transform. Now we will - have "Merge" objects which mean a copy of the named model should be merged in - with this model. This is used in the case of building interiors. We can create - a building interior and lightmap it as a separate collection, then "merge" it - with the level collection (multiple times even) and the tool will pre-transform - the meshes and add them to the collection. - -March 31, 2000 - - Changed W3D_CHUNK_MERGE_NODE to W3D_CHUNK_TRANSFORM_NODE. Same data - slightly - different application. Now the information will indicate how a w3d asset with the - same name as that in the node should pre-transform itself relative to the object - that contains the transform node. - -April 07, 2000 - - Added W3D_CHUNK_LIGHTSCAPE, W3D_CHUNK_LIGHTSCAPE_LIGHT and W3D_CHUNK_LIGHT_TRANSFORM. - These chunks form part of the output of new Westwood light file type (.wlt). - -July 10, 2000 - - Added W3D_CHUNK_VERTEX_MAPPER_ARGS1 and renamed W3D_CHUNK_VERTEX_MAPPER_ARGS to - W3D_CHUNK_VERTEX_MAPPER_ARGS0. These are the mapper args for the first and second - texture stages. The choice of mapper for the second stage has been added to the - 'Attributes' field in W3dVertexMaterialStruct. - -August 5, 2000 - - Added W3D_CHUNK_LIGHT_GLARE and its sub-chunks. Light glares are going to - be a new 'geometry type' which simply define points where light glare effects - should be placed. The application will supply a callback to the WW3D code - which indicates the visibilty of any light glares in the view frustum. - -June 5, 2001 - - (gth) Adding line rendering options to particle systems today. This involves a - new line-properties chunk and a RenderMode variable added to the InfoV2 struct. - -********************************************************************************/ - - -#define W3D_MAKE_VERSION(major,minor) (((major) << 16) | (minor)) -#define W3D_GET_MAJOR_VERSION(ver) ((ver)>>16) -#define W3D_GET_MINOR_VERSION(ver) ((ver) & 0xFFFF) - -#define W3D_NAME_LEN 16 - - - -/******************************************************************************** - - CHUNK TYPES FOR ALL 3D DATA - - All 3d data is stored in chunks similar to an IFF file. Each - chunk will be headed by an ID and size field. - - All structures defined in this header file are prefixed with - W3d to prevent naming conflicts with in-game structures which - may be slightly different than the on-disk structures. - - Oct 19,1998: Moved obsolete chunk id's to w3d_obsolete.h, added many - new chunk types. - -********************************************************************************/ - -enum { - - W3D_CHUNK_MESH =0x00000000, // Mesh definition - W3D_CHUNK_VERTICES =0x00000002, // array of vertices (array of W3dVectorStruct's) - W3D_CHUNK_VERTEX_NORMALS =0x00000003, // array of normals (array of W3dVectorStruct's) - W3D_CHUNK_MESH_USER_TEXT =0x0000000C, // Text from the MAX comment field (Null terminated string) - W3D_CHUNK_VERTEX_INFLUENCES =0x0000000E, // Mesh Deformation vertex connections (array of W3dVertInfStruct's) - W3D_CHUNK_MESH_HEADER3 =0x0000001F, // mesh header contains general info about the mesh. (W3dMeshHeader3Struct) - W3D_CHUNK_TRIANGLES =0x00000020, // New improved triangles chunk (array of W3dTriangleStruct's) - W3D_CHUNK_VERTEX_SHADE_INDICES =0x00000022, // shade indexes for each vertex (array of uint32's) - - W3D_CHUNK_PRELIT_UNLIT =0x00000023, // optional unlit material chunk wrapper - W3D_CHUNK_PRELIT_VERTEX =0x00000024, // optional vertex-lit material chunk wrapper - W3D_CHUNK_PRELIT_LIGHTMAP_MULTI_PASS =0x00000025, // optional lightmapped multi-pass material chunk wrapper - W3D_CHUNK_PRELIT_LIGHTMAP_MULTI_TEXTURE =0x00000026, // optional lightmapped multi-texture material chunk wrapper - - W3D_CHUNK_MATERIAL_INFO =0x00000028, // materials information, pass count, etc (contains W3dMaterialInfoStruct) - - W3D_CHUNK_SHADERS =0x00000029, // shaders (array of W3dShaderStruct's) - - W3D_CHUNK_VERTEX_MATERIALS =0x0000002A, // wraps the vertex materials - W3D_CHUNK_VERTEX_MATERIAL =0x0000002B, - W3D_CHUNK_VERTEX_MATERIAL_NAME =0x0000002C, // vertex material name (NULL-terminated string) - W3D_CHUNK_VERTEX_MATERIAL_INFO =0x0000002D, // W3dVertexMaterialStruct - W3D_CHUNK_VERTEX_MAPPER_ARGS0 =0x0000002E, // Null-terminated string - W3D_CHUNK_VERTEX_MAPPER_ARGS1 =0x0000002F, // Null-terminated string - - W3D_CHUNK_TEXTURES =0x00000030, // wraps all of the texture info - W3D_CHUNK_TEXTURE =0x00000031, // wraps a texture definition - W3D_CHUNK_TEXTURE_NAME =0x00000032, // texture filename (NULL-terminated string) - W3D_CHUNK_TEXTURE_INFO =0x00000033, // optional W3dTextureInfoStruct - - W3D_CHUNK_MATERIAL_PASS =0x00000038, // wraps the information for a single material pass - W3D_CHUNK_VERTEX_MATERIAL_IDS =0x00000039, // single or per-vertex array of uint32 vertex material indices (check chunk size) - W3D_CHUNK_SHADER_IDS =0x0000003A, // single or per-tri array of uint32 shader indices (check chunk size) - W3D_CHUNK_DCG =0x0000003B, // per-vertex diffuse color values (array of W3dRGBAStruct's) - W3D_CHUNK_DIG =0x0000003C, // per-vertex diffuse illumination values (array of W3dRGBStruct's) - W3D_CHUNK_SCG =0x0000003E, // per-vertex specular color values (array of W3dRGBStruct's) - - W3D_CHUNK_TEXTURE_STAGE =0x00000048, // wrapper around a texture stage. - W3D_CHUNK_TEXTURE_IDS =0x00000049, // single or per-tri array of uint32 texture indices (check chunk size) - W3D_CHUNK_STAGE_TEXCOORDS =0x0000004A, // per-vertex texture coordinates (array of W3dTexCoordStruct's) - W3D_CHUNK_PER_FACE_TEXCOORD_IDS =0x0000004B, // indices to W3D_CHUNK_STAGE_TEXCOORDS, (array of Vector3i) - - - W3D_CHUNK_DEFORM =0x00000058, // mesh deform or 'damage' information. - W3D_CHUNK_DEFORM_SET =0x00000059, // set of deform information - W3D_CHUNK_DEFORM_KEYFRAME =0x0000005A, // a keyframe of deform information in the set - W3D_CHUNK_DEFORM_DATA =0x0000005B, // deform information about a single vertex - - W3D_CHUNK_PS2_SHADERS =0x00000080, // Shader info specific to the Playstation 2. - - W3D_CHUNK_AABTREE =0x00000090, // Axis-Aligned Box Tree for hierarchical polygon culling - W3D_CHUNK_AABTREE_HEADER, // catalog of the contents of the AABTree - W3D_CHUNK_AABTREE_POLYINDICES, // array of uint32 polygon indices with count=mesh.PolyCount - W3D_CHUNK_AABTREE_NODES, // array of W3dMeshAABTreeNode's with count=aabheader.NodeCount - - W3D_CHUNK_HIERARCHY =0x00000100, // hierarchy tree definition - W3D_CHUNK_HIERARCHY_HEADER, - W3D_CHUNK_PIVOTS, - W3D_CHUNK_PIVOT_FIXUPS, // only needed by the exporter... - - W3D_CHUNK_ANIMATION =0x00000200, // hierarchy animation data - W3D_CHUNK_ANIMATION_HEADER, - W3D_CHUNK_ANIMATION_CHANNEL, // channel of vectors - W3D_CHUNK_BIT_CHANNEL, // channel of boolean values (e.g. visibility) - - W3D_CHUNK_COMPRESSED_ANIMATION =0x00000280, // compressed hierarchy animation data - W3D_CHUNK_COMPRESSED_ANIMATION_HEADER, // describes playback rate, number of frames, and type of compression - W3D_CHUNK_COMPRESSED_ANIMATION_CHANNEL, // compressed channel, format dependent on type of compression - W3D_CHUNK_COMPRESSED_BIT_CHANNEL, // compressed bit stream channel, format dependent on type of compression - - W3D_CHUNK_MORPH_ANIMATION =0x000002C0, // hierarchy morphing animation data (morphs between poses, for facial animation) - W3D_CHUNK_MORPHANIM_HEADER, // W3dMorphAnimHeaderStruct describes playback rate, number of frames, and type of compression - W3D_CHUNK_MORPHANIM_CHANNEL, // wrapper for a channel - W3D_CHUNK_MORPHANIM_POSENAME, // name of the other anim which contains the poses for this morph channel - W3D_CHUNK_MORPHANIM_KEYDATA, // morph key data for this channel - W3D_CHUNK_MORPHANIM_PIVOTCHANNELDATA, // uin32 per pivot in the htree, indicating which channel controls the pivot - - W3D_CHUNK_HMODEL =0x00000300, // blueprint for a hierarchy model - W3D_CHUNK_HMODEL_HEADER, // Header for the hierarchy model - W3D_CHUNK_NODE, // render objects connected to the hierarchy - W3D_CHUNK_COLLISION_NODE, // collision meshes connected to the hierarchy - W3D_CHUNK_SKIN_NODE, // skins connected to the hierarchy - OBSOLETE_W3D_CHUNK_HMODEL_AUX_DATA, // extension of the hierarchy model header - OBSOLETE_W3D_CHUNK_SHADOW_NODE, // shadow object connected to the hierarchy - - W3D_CHUNK_LODMODEL =0x00000400, // blueprint for an LOD model. This is simply a - W3D_CHUNK_LODMODEL_HEADER, // collection of 'n' render objects, ordered in terms - W3D_CHUNK_LOD, // of their expected rendering costs. (highest is first) - - W3D_CHUNK_COLLECTION =0x00000420, // collection of render object names - W3D_CHUNK_COLLECTION_HEADER, // general info regarding the collection - W3D_CHUNK_COLLECTION_OBJ_NAME, // contains a string which is the name of a render object - W3D_CHUNK_PLACEHOLDER, // contains information about a 'dummy' object that will be instanced later - W3D_CHUNK_TRANSFORM_NODE, // contains the filename of another w3d file that should be transformed by this node - - W3D_CHUNK_POINTS =0x00000440, // array of W3dVectorStruct's. May appear in meshes, hmodels, lodmodels, or collections. - - W3D_CHUNK_LIGHT =0x00000460, // description of a light - W3D_CHUNK_LIGHT_INFO, // generic light parameters - W3D_CHUNK_SPOT_LIGHT_INFO, // extra spot light parameters - W3D_CHUNK_NEAR_ATTENUATION, // optional near attenuation parameters - W3D_CHUNK_FAR_ATTENUATION, // optional far attenuation parameters - - W3D_CHUNK_EMITTER =0x00000500, // description of a particle emitter - W3D_CHUNK_EMITTER_HEADER, // general information such as name and version - W3D_CHUNK_EMITTER_USER_DATA, // user-defined data that specific loaders can switch on - W3D_CHUNK_EMITTER_INFO, // generic particle emitter definition - W3D_CHUNK_EMITTER_INFOV2, // generic particle emitter definition (version 2.0) - W3D_CHUNK_EMITTER_PROPS, // Key-frameable properties - OBSOLETE_W3D_CHUNK_EMITTER_COLOR_KEYFRAME, // structure defining a single color keyframe - OBSOLETE_W3D_CHUNK_EMITTER_OPACITY_KEYFRAME, // structure defining a single opacity keyframe - OBSOLETE_W3D_CHUNK_EMITTER_SIZE_KEYFRAME, // structure defining a single size keyframe - W3D_CHUNK_EMITTER_LINE_PROPERTIES, // line properties, used by line rendering mode - W3D_CHUNK_EMITTER_ROTATION_KEYFRAMES, // rotation keys for the particles - W3D_CHUNK_EMITTER_FRAME_KEYFRAMES, // frame keys (u-v based frame animation) - - W3D_CHUNK_AGGREGATE =0x00000600, // description of an aggregate object - W3D_CHUNK_AGGREGATE_HEADER, // general information such as name and version - W3D_CHUNK_AGGREGATE_INFO, // references to 'contained' models - W3D_CHUNK_TEXTURE_REPLACER_INFO, // information about which meshes need textures replaced - W3D_CHUNK_AGGREGATE_CLASS_INFO, // information about the original class that created this aggregate - - W3D_CHUNK_HLOD =0x00000700, // description of an HLod object (see HLodClass) - W3D_CHUNK_HLOD_HEADER, // general information such as name and version - W3D_CHUNK_HLOD_LOD_ARRAY, // wrapper around the array of objects for each level of detail - W3D_CHUNK_HLOD_SUB_OBJECT_ARRAY_HEADER, // info on the objects in this level of detail array - W3D_CHUNK_HLOD_SUB_OBJECT, // an object in this level of detail array - W3D_CHUNK_HLOD_AGGREGATE_ARRAY, // array of aggregates, contains W3D_CHUNK_SUB_OBJECT_ARRAY_HEADER and W3D_CHUNK_SUB_OBJECT_ARRAY - W3D_CHUNK_HLOD_PROXY_ARRAY, // array of proxies, used for application-defined purposes, provides a name and a bone. - - W3D_CHUNK_BOX =0x00000740, // defines an collision box render object (W3dBoxStruct) - W3D_CHUNK_SPHERE, - W3D_CHUNK_RING, - - W3D_CHUNK_NULL_OBJECT =0x00000750, // defines a NULL object (W3dNullObjectStruct) - - W3D_CHUNK_LIGHTSCAPE =0x00000800, // wrapper for lights created with Lightscape. - W3D_CHUNK_LIGHTSCAPE_LIGHT, // definition of a light created with Lightscape. - W3D_CHUNK_LIGHT_TRANSFORM, // position and orientation (defined as right-handed 4x3 matrix transform W3dLightTransformStruct). - - W3D_CHUNK_DAZZLE =0x00000900, // wrapper for a glare object. Creates halos and flare lines seen around a bright light source - W3D_CHUNK_DAZZLE_NAME, // null-terminated string, name of the dazzle (typical w3d object naming: "container.object") - W3D_CHUNK_DAZZLE_TYPENAME, // null-terminated string, type of dazzle (from dazzle.ini) - - W3D_CHUNK_SOUNDROBJ =0x00000A00, // description of a sound render object - W3D_CHUNK_SOUNDROBJ_HEADER, // general information such as name and version - W3D_CHUNK_SOUNDROBJ_DEFINITION, // chunk containing the definition of the sound that is to play - -}; - - - -struct W3dChunkHeader -{ - uint32 ChunkType; // Type of chunk (see above enumeration) - uint32 ChunkSize; // Size of the chunk, (not including the chunk header) -}; - - - -///////////////////////////////////////////////////////////////////////////////////////////// -// vector -///////////////////////////////////////////////////////////////////////////////////////////// -typedef IOVector3Struct W3dVectorStruct; - -///////////////////////////////////////////////////////////////////////////////////////////// -// quaternion -///////////////////////////////////////////////////////////////////////////////////////////// -typedef IOQuaternionStruct W3dQuaternionStruct; - -///////////////////////////////////////////////////////////////////////////////////////////// -// texture coordinate -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dTexCoordStruct -{ - bool operator == (W3dTexCoordStruct t) - { - return ((U == t.U) && (V == t.V)); - } - - float32 U; // U,V coordinates - float32 V; -}; - -///////////////////////////////////////////////////////////////////////////////////////////// -// rgb color, one byte per channel, padded to an even 4 bytes -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dRGBStruct -{ - W3dRGBStruct () {} - W3dRGBStruct (uint8 r, uint8 g, uint8 b) - { - R = r; - G = g; - B = b; - } - - void Set (uint8 r, uint8 g, uint8 b) - { - R = r; - G = g; - B = b; - } - - void Set (float r, float g, float b) - { - R = (unsigned char) MIN ((float) UCHAR_MAX, MAX (0.0f, r) * ((float) (UCHAR_MAX + 1))); - G = (unsigned char) MIN ((float) UCHAR_MAX, MAX (0.0f, g) * ((float) (UCHAR_MAX + 1))); - B = (unsigned char) MIN ((float) UCHAR_MAX, MAX (0.0f, b) * ((float) (UCHAR_MAX + 1))); - } - - bool operator == (W3dRGBStruct c) - { - return ((R == c.R) && (G == c.G) && (B == c.B)); - } - - bool operator != (W3dRGBStruct c) - { - return (!(*this == c)); - } - - W3dRGBStruct operator += (W3dRGBStruct c) - { - R = MIN (((unsigned) R) + ((unsigned) c.R), (unsigned) UCHAR_MAX); - G = MIN (((unsigned) G) + ((unsigned) c.G), (unsigned) UCHAR_MAX); - B = MIN (((unsigned) B) + ((unsigned) c.B), (unsigned) UCHAR_MAX); - return (*this); - } - - W3dRGBStruct operator *= (W3dRGBStruct c) - { - R = (((unsigned) R) * ((unsigned) c.R)) / ((unsigned) UCHAR_MAX); - G = (((unsigned) G) * ((unsigned) c.G)) / ((unsigned) UCHAR_MAX); - B = (((unsigned) B) * ((unsigned) c.B)) / ((unsigned) UCHAR_MAX); - return (*this); - } - - unsigned Get_Color() - { - return (R<<24)|(G<<16)|(B<<8); - } - - uint8 R; - uint8 G; - uint8 B; - uint8 pad; -}; - -struct W3dRGBAStruct -{ - uint8 R; - uint8 G; - uint8 B; - uint8 A; -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// -// MATERIALS -// -// Surrender 1.40 significantly changed the way that materials are described. To -// accomodate this, the w3d file format has changed since there are new features and -// optimizations that we want to take advangage of. -// -// The VertexMaterial defines parameters which control the calculation of the primary -// and secondary gradients. The shader defines how those gradients are combined with -// the texel and the frame buffer contents. -// -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dMaterialInfoStruct -{ - uint32 PassCount; // how many material passes this render object uses - uint32 VertexMaterialCount; // how many vertex materials are used - uint32 ShaderCount; // how many shaders are used - uint32 TextureCount; // how many textures are used -}; - - -#define W3DVERTMAT_USE_DEPTH_CUE 0x00000001 -#define W3DVERTMAT_ARGB_EMISSIVE_ONLY 0x00000002 -#define W3DVERTMAT_COPY_SPECULAR_TO_DIFFUSE 0x00000004 -#define W3DVERTMAT_DEPTH_CUE_TO_ALPHA 0x00000008 - -#define W3DVERTMAT_STAGE0_MAPPING_MASK 0x00FF0000 -#define W3DVERTMAT_STAGE0_MAPPING_UV 0x00000000 -#define W3DVERTMAT_STAGE0_MAPPING_ENVIRONMENT 0x00010000 -#define W3DVERTMAT_STAGE0_MAPPING_CHEAP_ENVIRONMENT 0x00020000 -#define W3DVERTMAT_STAGE0_MAPPING_SCREEN 0x00030000 -#define W3DVERTMAT_STAGE0_MAPPING_LINEAR_OFFSET 0x00040000 -#define W3DVERTMAT_STAGE0_MAPPING_SILHOUETTE 0x00050000 -#define W3DVERTMAT_STAGE0_MAPPING_SCALE 0x00060000 -#define W3DVERTMAT_STAGE0_MAPPING_GRID 0x00070000 -#define W3DVERTMAT_STAGE0_MAPPING_ROTATE 0x00080000 -#define W3DVERTMAT_STAGE0_MAPPING_SINE_LINEAR_OFFSET 0x00090000 -#define W3DVERTMAT_STAGE0_MAPPING_STEP_LINEAR_OFFSET 0x000A0000 -#define W3DVERTMAT_STAGE0_MAPPING_ZIGZAG_LINEAR_OFFSET 0x000B0000 -#define W3DVERTMAT_STAGE0_MAPPING_WS_CLASSIC_ENV 0x000C0000 -#define W3DVERTMAT_STAGE0_MAPPING_WS_ENVIRONMENT 0x000D0000 -#define W3DVERTMAT_STAGE0_MAPPING_GRID_CLASSIC_ENV 0x000E0000 -#define W3DVERTMAT_STAGE0_MAPPING_GRID_ENVIRONMENT 0x000F0000 -#define W3DVERTMAT_STAGE0_MAPPING_RANDOM 0x00100000 -#define W3DVERTMAT_STAGE0_MAPPING_EDGE 0x00110000 -#define W3DVERTMAT_STAGE0_MAPPING_BUMPENV 0x00120000 - -#define W3DVERTMAT_STAGE1_MAPPING_MASK 0x0000FF00 -#define W3DVERTMAT_STAGE1_MAPPING_UV 0x00000000 -#define W3DVERTMAT_STAGE1_MAPPING_ENVIRONMENT 0x00000100 -#define W3DVERTMAT_STAGE1_MAPPING_CHEAP_ENVIRONMENT 0x00000200 -#define W3DVERTMAT_STAGE1_MAPPING_SCREEN 0x00000300 -#define W3DVERTMAT_STAGE1_MAPPING_LINEAR_OFFSET 0x00000400 -#define W3DVERTMAT_STAGE1_MAPPING_SILHOUETTE 0x00000500 -#define W3DVERTMAT_STAGE1_MAPPING_SCALE 0x00000600 -#define W3DVERTMAT_STAGE1_MAPPING_GRID 0x00000700 -#define W3DVERTMAT_STAGE1_MAPPING_ROTATE 0x00000800 -#define W3DVERTMAT_STAGE1_MAPPING_SINE_LINEAR_OFFSET 0x00000900 -#define W3DVERTMAT_STAGE1_MAPPING_STEP_LINEAR_OFFSET 0x00000A00 -#define W3DVERTMAT_STAGE1_MAPPING_ZIGZAG_LINEAR_OFFSET 0x00000B00 -#define W3DVERTMAT_STAGE1_MAPPING_WS_CLASSIC_ENV 0x00000C00 -#define W3DVERTMAT_STAGE1_MAPPING_WS_ENVIRONMENT 0x00000D00 -#define W3DVERTMAT_STAGE1_MAPPING_GRID_CLASSIC_ENV 0x00000E00 -#define W3DVERTMAT_STAGE1_MAPPING_GRID_ENVIRONMENT 0x00000F00 -#define W3DVERTMAT_STAGE1_MAPPING_RANDOM 0x00001000 -#define W3DVERTMAT_STAGE1_MAPPING_EDGE 0x00001100 -#define W3DVERTMAT_STAGE1_MAPPING_BUMPENV 0x00001200 - -#define W3DVERTMAT_PSX_MASK 0xFF000000 -#define W3DVERTMAT_PSX_TRANS_MASK 0x07000000 -#define W3DVERTMAT_PSX_TRANS_NONE 0x00000000 -#define W3DVERTMAT_PSX_TRANS_100 0x01000000 -#define W3DVERTMAT_PSX_TRANS_50 0x02000000 -#define W3DVERTMAT_PSX_TRANS_25 0x03000000 -#define W3DVERTMAT_PSX_TRANS_MINUS_100 0x04000000 -#define W3DVERTMAT_PSX_NO_RT_LIGHTING 0x08000000 - -struct W3dVertexMaterialStruct -{ - W3dVertexMaterialStruct(void) {} - - bool operator == (W3dVertexMaterialStruct vm) - { - return ( Attributes == vm.Attributes - && Ambient == vm.Ambient - && Diffuse == vm.Diffuse - && Specular == vm.Specular - && Emissive == vm.Emissive - && Shininess == vm.Shininess - && Opacity == vm.Opacity - && Translucency == vm.Translucency); - } - - bool operator != (W3dVertexMaterialStruct vm) - { - return (!(*this == vm)); - } - - uint32 Attributes; // bitfield for the flags defined above - W3dRGBStruct Ambient; - W3dRGBStruct Diffuse; - W3dRGBStruct Specular; - W3dRGBStruct Emissive; - float32 Shininess; // how tight the specular highlight will be, 1 - 1000 (default = 1) - float32 Opacity; // how opaque the material is, 0.0 = invisible, 1.0 = fully opaque (default = 1) - float32 Translucency; // how much light passes through the material. (default = 0) -}; - -inline void W3d_Vertex_Material_Reset(W3dVertexMaterialStruct * vmat) -{ - vmat->Attributes = 0; - vmat->Ambient.R = vmat->Ambient.G = vmat->Ambient.B = 255; - vmat->Diffuse.R = vmat->Diffuse.G = vmat->Diffuse.B = 255; - vmat->Specular.R = vmat->Specular.G = vmat->Specular.B = 0; - vmat->Emissive.R = vmat->Emissive.G = vmat->Emissive.B = 0; - vmat->Shininess = 1.0f; - vmat->Opacity = 1.0f; - vmat->Translucency = 0.0f; -} - - -// W3dShaderStruct bits. These control every setting in the shader. Use the helper functions -// to set them and test them more easily. -enum -{ - W3DSHADER_DEPTHCOMPARE_PASS_NEVER = 0, // pass never (i.e. always fail depth comparison test) - W3DSHADER_DEPTHCOMPARE_PASS_LESS, // pass if incoming less than stored - W3DSHADER_DEPTHCOMPARE_PASS_EQUAL, // pass if incoming equal to stored - W3DSHADER_DEPTHCOMPARE_PASS_LEQUAL, // pass if incoming less than or equal to stored (default) - W3DSHADER_DEPTHCOMPARE_PASS_GREATER, // pass if incoming greater than stored - W3DSHADER_DEPTHCOMPARE_PASS_NOTEQUAL, // pass if incoming not equal to stored - W3DSHADER_DEPTHCOMPARE_PASS_GEQUAL, // pass if incoming greater than or equal to stored - W3DSHADER_DEPTHCOMPARE_PASS_ALWAYS, // pass always - W3DSHADER_DEPTHCOMPARE_PASS_MAX, // end of enumeration - - W3DSHADER_DEPTHMASK_WRITE_DISABLE = 0, // disable depth buffer writes - W3DSHADER_DEPTHMASK_WRITE_ENABLE, // enable depth buffer writes (default) - W3DSHADER_DEPTHMASK_WRITE_MAX, // end of enumeration - - W3DSHADER_ALPHATEST_DISABLE = 0, // disable alpha testing (default) - W3DSHADER_ALPHATEST_ENABLE, // enable alpha testing - W3DSHADER_ALPHATEST_MAX, // end of enumeration - - W3DSHADER_DESTBLENDFUNC_ZERO = 0, // destination pixel doesn't affect blending (default) - W3DSHADER_DESTBLENDFUNC_ONE, // destination pixel added unmodified - W3DSHADER_DESTBLENDFUNC_SRC_COLOR, // destination pixel multiplied by fragment RGB components - W3DSHADER_DESTBLENDFUNC_ONE_MINUS_SRC_COLOR, // destination pixel multiplied by one minus (i.e. inverse) fragment RGB components - W3DSHADER_DESTBLENDFUNC_SRC_ALPHA, // destination pixel multiplied by fragment alpha component - W3DSHADER_DESTBLENDFUNC_ONE_MINUS_SRC_ALPHA, // destination pixel multiplied by fragment inverse alpha - W3DSHADER_DESTBLENDFUNC_SRC_COLOR_PREFOG, // destination pixel multiplied by fragment RGB components prior to fogging - W3DSHADER_DESTBLENDFUNC_MAX, // end of enumeration - - W3DSHADER_PRIGRADIENT_DISABLE = 0, // disable primary gradient (same as OpenGL 'decal' texture blend) - W3DSHADER_PRIGRADIENT_MODULATE, // modulate fragment ARGB by gradient ARGB (default) - W3DSHADER_PRIGRADIENT_ADD, // add gradient RGB to fragment RGB, copy gradient A to fragment A - W3DSHADER_PRIGRADIENT_BUMPENVMAP, // environment-mapped bump mapping - W3DSHADER_PRIGRADIENT_MAX, // end of enumeration - - W3DSHADER_SECGRADIENT_DISABLE = 0, // don't draw secondary gradient (default) - W3DSHADER_SECGRADIENT_ENABLE, // add secondary gradient RGB to fragment RGB - W3DSHADER_SECGRADIENT_MAX, // end of enumeration - - W3DSHADER_SRCBLENDFUNC_ZERO = 0, // fragment not added to color buffer - W3DSHADER_SRCBLENDFUNC_ONE, // fragment added unmodified to color buffer (default) - W3DSHADER_SRCBLENDFUNC_SRC_ALPHA, // fragment RGB components multiplied by fragment A - W3DSHADER_SRCBLENDFUNC_ONE_MINUS_SRC_ALPHA, // fragment RGB components multiplied by fragment inverse (one minus) A - W3DSHADER_SRCBLENDFUNC_MAX, // end of enumeration - - W3DSHADER_TEXTURING_DISABLE = 0, // no texturing (treat fragment initial color as 1,1,1,1) (default) - W3DSHADER_TEXTURING_ENABLE, // enable texturing - W3DSHADER_TEXTURING_MAX, // end of enumeration - - W3DSHADER_DETAILCOLORFUNC_DISABLE = 0, // local (default) - W3DSHADER_DETAILCOLORFUNC_DETAIL, // other - W3DSHADER_DETAILCOLORFUNC_SCALE, // local * other - W3DSHADER_DETAILCOLORFUNC_INVSCALE, // ~(~local * ~other) = local + (1-local)*other - W3DSHADER_DETAILCOLORFUNC_ADD, // local + other - W3DSHADER_DETAILCOLORFUNC_SUB, // local - other - W3DSHADER_DETAILCOLORFUNC_SUBR, // other - local - W3DSHADER_DETAILCOLORFUNC_BLEND, // (localAlpha)*local + (~localAlpha)*other - W3DSHADER_DETAILCOLORFUNC_DETAILBLEND, // (otherAlpha)*local + (~otherAlpha)*other - W3DSHADER_DETAILCOLORFUNC_MAX, // end of enumeration - - W3DSHADER_DETAILALPHAFUNC_DISABLE = 0, // local (default) - W3DSHADER_DETAILALPHAFUNC_DETAIL, // other - W3DSHADER_DETAILALPHAFUNC_SCALE, // local * other - W3DSHADER_DETAILALPHAFUNC_INVSCALE, // ~(~local * ~other) = local + (1-local)*other - W3DSHADER_DETAILALPHAFUNC_MAX, // end of enumeration - - W3DSHADER_DEPTHCOMPARE_DEFAULT = W3DSHADER_DEPTHCOMPARE_PASS_LEQUAL, - W3DSHADER_DEPTHMASK_DEFAULT = W3DSHADER_DEPTHMASK_WRITE_ENABLE, - W3DSHADER_ALPHATEST_DEFAULT = W3DSHADER_ALPHATEST_DISABLE, - W3DSHADER_DESTBLENDFUNC_DEFAULT = W3DSHADER_DESTBLENDFUNC_ZERO, - W3DSHADER_PRIGRADIENT_DEFAULT = W3DSHADER_PRIGRADIENT_MODULATE, - W3DSHADER_SECGRADIENT_DEFAULT = W3DSHADER_SECGRADIENT_DISABLE, - W3DSHADER_SRCBLENDFUNC_DEFAULT = W3DSHADER_SRCBLENDFUNC_ONE, - W3DSHADER_TEXTURING_DEFAULT = W3DSHADER_TEXTURING_DISABLE, - W3DSHADER_DETAILCOLORFUNC_DEFAULT = W3DSHADER_DETAILCOLORFUNC_DISABLE, - W3DSHADER_DETAILALPHAFUNC_DEFAULT = W3DSHADER_DETAILALPHAFUNC_DISABLE, -}; - -enum PS2_SHADER_SETTINGS { - PSS_SRC = 0, - PSS_DEST, - PSS_ZERO, - - PSS_SRC_ALPHA = 0, - PSS_DEST_ALPHA, - PSS_ONE, - - // From combo box. To match the PC default gradient. - PSS_PRIGRADIENT_DECAL = 0, - PSS_PRIGRADIENT_MODULATE, - PSS_PRIGRADIENT_HIGHLIGHT, - PSS_PRIGRADIENT_HIGHLIGHT2, - - // Actual PS2 numbers. - PSS_PS2_PRIGRADIENT_MODULATE = 0, - PSS_PS2_PRIGRADIENT_DECAL, - PSS_PS2_PRIGRADIENT_HIGHLIGHT, - PSS_PS2_PRIGRADIENT_HIGHLIGHT2, - - - PSS_DEPTHCOMPARE_PASS_NEVER = 0, - PSS_DEPTHCOMPARE_PASS_LESS, - PSS_DEPTHCOMPARE_PASS_ALWAYS, - PSS_DEPTHCOMPARE_PASS_LEQUAL, -}; - -struct W3dShaderStruct -{ - W3dShaderStruct(void) {} - uint8 DepthCompare; - uint8 DepthMask; - uint8 ColorMask; // now obsolete and ignored - uint8 DestBlend; - uint8 FogFunc; // now obsolete and ignored - uint8 PriGradient; - uint8 SecGradient; - uint8 SrcBlend; - uint8 Texturing; - uint8 DetailColorFunc; - uint8 DetailAlphaFunc; - uint8 ShaderPreset; // now obsolete and ignored - uint8 AlphaTest; - uint8 PostDetailColorFunc; - uint8 PostDetailAlphaFunc; - uint8 pad[1]; -}; - -struct W3dPS2ShaderStruct -{ - uint8 DepthCompare; - uint8 DepthMask; - uint8 PriGradient; - uint8 Texturing; - uint8 AlphaTest; - uint8 AParam; - uint8 BParam; - uint8 CParam; - uint8 DParam; - uint8 pad[3]; -}; - -inline void W3d_Shader_Reset(W3dShaderStruct * s) { - s->DepthCompare = W3DSHADER_DEPTHCOMPARE_PASS_LEQUAL; - s->DepthMask = W3DSHADER_DEPTHMASK_WRITE_ENABLE; - s->ColorMask = 0; // obsolete - s->DestBlend = W3DSHADER_DESTBLENDFUNC_ZERO; - s->FogFunc = 0; // obsolete - s->PriGradient = W3DSHADER_PRIGRADIENT_MODULATE; - s->SecGradient = W3DSHADER_SECGRADIENT_DISABLE; - s->SrcBlend = W3DSHADER_SRCBLENDFUNC_ONE; - s->Texturing = W3DSHADER_TEXTURING_DISABLE; - s->DetailColorFunc = W3DSHADER_DETAILCOLORFUNC_DISABLE; - s->DetailAlphaFunc = W3DSHADER_DETAILALPHAFUNC_DISABLE; - s->ShaderPreset = 0; // obsolete - s->AlphaTest = W3DSHADER_ALPHATEST_DISABLE; - s->PostDetailColorFunc = W3DSHADER_DETAILCOLORFUNC_DISABLE; - s->PostDetailAlphaFunc = W3DSHADER_DETAILALPHAFUNC_DISABLE; - s->pad[0] = 0; - } - -inline void W3d_Shader_Set_Depth_Compare(W3dShaderStruct * s,int val) { s->DepthCompare = val; } -inline void W3d_Shader_Set_Depth_Mask(W3dShaderStruct * s,int val) { s->DepthMask = val; } -inline void W3d_Shader_Set_Dest_Blend_Func(W3dShaderStruct * s,int val) { s->DestBlend = val; } -inline void W3d_Shader_Set_Pri_Gradient(W3dShaderStruct * s,int val) { s->PriGradient = val; } -inline void W3d_Shader_Set_Sec_Gradient(W3dShaderStruct * s,int val) { s->SecGradient = val; } -inline void W3d_Shader_Set_Src_Blend_Func(W3dShaderStruct * s,int val) { s->SrcBlend = val; } -inline void W3d_Shader_Set_Texturing(W3dShaderStruct * s,int val) { s->Texturing = val; } -inline void W3d_Shader_Set_Detail_Color_Func(W3dShaderStruct * s,int val) { s->DetailColorFunc = val; } -inline void W3d_Shader_Set_Detail_Alpha_Func(W3dShaderStruct * s,int val) { s->DetailAlphaFunc = val; } -inline void W3d_Shader_Set_Alpha_Test(W3dShaderStruct * s,int val) { s->AlphaTest = val; } -inline void W3d_Shader_Set_Post_Detail_Color_Func(W3dShaderStruct * s,int val) { s->PostDetailColorFunc = val; } -inline void W3d_Shader_Set_Post_Detail_Alpha_Func(W3dShaderStruct * s,int val) { s->PostDetailAlphaFunc = val; } - -// These functions use the existing W3dShaderStruct unused members to store PS2 specific parameters. -// At mesh save time, if a PS2 material was used, a separate PS2 material chunk is saved out. -// If W3dShaderStruct is changed this should still work because it is only used for the PS2 stuff. -inline void W3d_Shader_Set_PS2_Param_A(W3dShaderStruct *s, int val) {s->ColorMask = val;} -inline void W3d_Shader_Set_PS2_Param_B(W3dShaderStruct *s, int val) {s->FogFunc = val;} -inline void W3d_Shader_Set_PS2_Param_C(W3dShaderStruct *s, int val) {s->ShaderPreset = val;} -inline void W3d_Shader_Set_PS2_Param_D(W3dShaderStruct *s, int val) {s->pad[0] = val;} - -inline int W3d_Shader_Get_PS2_Param_A(const W3dShaderStruct *s) {return (s->ColorMask);} -inline int W3d_Shader_Get_PS2_Param_B(const W3dShaderStruct *s) {return (s->FogFunc);} -inline int W3d_Shader_Get_PS2_Param_C(const W3dShaderStruct *s) {return (s->ShaderPreset);} -inline int W3d_Shader_Get_PS2_Param_D(const W3dShaderStruct *s) {return (s->pad[0]);} - -inline int W3d_Shader_Get_PS2_Param_A(const W3dPS2ShaderStruct *s) {return (s->AParam);} -inline int W3d_Shader_Get_PS2_Param_B(const W3dPS2ShaderStruct *s) {return (s->BParam);} -inline int W3d_Shader_Get_PS2_Param_C(const W3dPS2ShaderStruct *s) {return (s->CParam);} -inline int W3d_Shader_Get_PS2_Param_D(const W3dPS2ShaderStruct *s) {return (s->DParam);} - -inline int W3d_Shader_Get_Depth_Compare(const W3dPS2ShaderStruct * s) { return s->DepthCompare; } -inline int W3d_Shader_Get_Depth_Mask(const W3dPS2ShaderStruct * s) { return s->DepthMask; } -inline int W3d_Shader_Get_Pri_Gradient(const W3dPS2ShaderStruct * s) { return s->PriGradient; } -inline int W3d_Shader_Get_Texturing(const W3dPS2ShaderStruct * s) { return s->Texturing; } -inline int W3d_Shader_Get_Alpha_Test(const W3dPS2ShaderStruct * s) { return s->AlphaTest; } - - -inline int W3d_Shader_Get_Depth_Compare(const W3dShaderStruct * s) { return s->DepthCompare; } -inline int W3d_Shader_Get_Depth_Mask(const W3dShaderStruct * s) { return s->DepthMask; } -inline int W3d_Shader_Get_Dest_Blend_Func(const W3dShaderStruct * s) { return s->DestBlend; } -inline int W3d_Shader_Get_Pri_Gradient(const W3dShaderStruct * s) { return s->PriGradient; } -inline int W3d_Shader_Get_Sec_Gradient(const W3dShaderStruct * s) { return s->SecGradient; } -inline int W3d_Shader_Get_Src_Blend_Func(const W3dShaderStruct * s) { return s->SrcBlend; } -inline int W3d_Shader_Get_Texturing(const W3dShaderStruct * s) { return s->Texturing; } -inline int W3d_Shader_Get_Detail_Color_Func(const W3dShaderStruct * s) { return s->DetailColorFunc; } -inline int W3d_Shader_Get_Detail_Alpha_Func(const W3dShaderStruct * s) { return s->DetailAlphaFunc; } -inline int W3d_Shader_Get_Alpha_Test(const W3dShaderStruct * s) { return s->AlphaTest; } -inline int W3d_Shader_Get_Post_Detail_Color_Func(const W3dShaderStruct * s) { return s->PostDetailColorFunc; } -inline int W3d_Shader_Get_Post_Detail_Alpha_Func(const W3dShaderStruct * s) { return s->PostDetailAlphaFunc; } - - - -///////////////////////////////////////////////////////////////////////////////////////////// -// Texture Animation parameters -// May occur inside a texture chunk if its needed -///////////////////////////////////////////////////////////////////////////////////////////// -#define W3DTEXTURE_PUBLISH 0x0001 // this texture should be "published" (indirected so its changeable in code) -#define W3DTEXTURE_RESIZE_OBSOLETE 0x0002 // this texture should be resizeable (OBSOLETE!!!) -#define W3DTEXTURE_NO_LOD 0x0004 // this texture should not have any LOD (mipmapping or resizing) -#define W3DTEXTURE_CLAMP_U 0x0008 // this texture should be clamped on U -#define W3DTEXTURE_CLAMP_V 0x0010 // this texture should be clamped on V -#define W3DTEXTURE_ALPHA_BITMAP 0x0020 // this texture's alpha channel should be collapsed to one bit - -// Specify desired no. of mip-levels to be generated. -#define W3DTEXTURE_MIP_LEVELS_MASK 0x00c0 -#define W3DTEXTURE_MIP_LEVELS_ALL 0x0000 // generate all mip-levels -#define W3DTEXTURE_MIP_LEVELS_2 0x0040 // generate up to 2 mip-levels (NOTE: use W3DTEXTURE_NO_LOD to generate just 1 mip-level) -#define W3DTEXTURE_MIP_LEVELS_3 0x0080 // generate up to 3 mip-levels -#define W3DTEXTURE_MIP_LEVELS_4 0x00c0 // generate up to 4 mip-levels - -// Hints to describe the intended use of the various passes / stages -// This will go into the high byte of Attributes. -#define W3DTEXTURE_HINT_SHIFT 8 // number of bits to shift up -#define W3DTEXTURE_HINT_MASK 0x0000ff00 // mask for shifted hint value - -#define W3DTEXTURE_HINT_BASE 0x0000 // base texture -#define W3DTEXTURE_HINT_EMISSIVE 0x0100 // emissive map -#define W3DTEXTURE_HINT_ENVIRONMENT 0x0200 // environment/reflection map -#define W3DTEXTURE_HINT_SHINY_MASK 0x0300 // shinyness mask map - -#define W3DTEXTURE_TYPE_MASK 0x1000 -#define W3DTEXTURE_TYPE_COLORMAP 0x0000 // Color map. -#define W3DTEXTURE_TYPE_BUMPMAP 0x1000 // Grayscale heightmap (to be converted to bumpmap). - -// Animation types -#define W3DTEXTURE_ANIM_LOOP 0x0000 -#define W3DTEXTURE_ANIM_PINGPONG 0x0001 -#define W3DTEXTURE_ANIM_ONCE 0x0002 -#define W3DTEXTURE_ANIM_MANUAL 0x0003 - -struct W3dTextureInfoStruct -{ - W3dTextureInfoStruct(void) {} - uint16 Attributes; // flags for this texture - uint16 AnimType; // animation logic - uint32 FrameCount; // Number of frames (1 if not animated) - float32 FrameRate; // Frame rate, frames per second in floating point -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// -// A triangle, occurs inside the W3D_CHUNK_TRIANGLES chunk -// This was introduced with version 3.0 of the file format -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dTriStruct -{ - uint32 Vindex[3]; // vertex,vnormal,texcoord,color indices - uint32 Attributes; // attributes bits - W3dVectorStruct Normal; // plane normal - float32 Dist; // plane distance -}; - -///////////////////////////////////////////////////////////////////////////////////////////// -// Flags for the Triangle Attributes member -///////////////////////////////////////////////////////////////////////////////////////////// -typedef enum -{ - SURFACE_TYPE_LIGHT_METAL = 0, - SURFACE_TYPE_HEAVY_METAL, - SURFACE_TYPE_WATER, - SURFACE_TYPE_SAND, - SURFACE_TYPE_DIRT, - SURFACE_TYPE_MUD, - SURFACE_TYPE_GRASS, - SURFACE_TYPE_WOOD, - SURFACE_TYPE_CONCRETE, - SURFACE_TYPE_FLESH, - SURFACE_TYPE_ROCK, - SURFACE_TYPE_SNOW, - SURFACE_TYPE_ICE, - SURFACE_TYPE_DEFAULT, - SURFACE_TYPE_GLASS, - SURFACE_TYPE_CLOTH, - SURFACE_TYPE_TIBERIUM_FIELD, - SURFACE_TYPE_FOLIAGE_PERMEABLE, - SURFACE_TYPE_GLASS_PERMEABLE, - SURFACE_TYPE_ICE_PERMEABLE, - SURFACE_TYPE_CLOTH_PERMEABLE, - SURFACE_TYPE_ELECTRICAL, - SURFACE_TYPE_FLAMMABLE, - SURFACE_TYPE_STEAM, - SURFACE_TYPE_ELECTRICAL_PERMEABLE, - SURFACE_TYPE_FLAMMABLE_PERMEABLE, - SURFACE_TYPE_STEAM_PERMEABLE, - - SURFACE_TYPE_MAX // NOTE: if you add a surface type, add it to the SurfaceEffects.INI file! -} W3D_SURFACE_TYPES; - -const char * const SURFACE_TYPE_STRINGS[SURFACE_TYPE_MAX] = -{ - "Light Metal", - "Heavy Metal", - "Water", - "Sand", - "Dirt", - "Mud", - "Grass", - "Wood", - "Concrete", - "Flesh", - "Rock", - "Snow", - "Ice", - "Default", - "Glass", - "Cloth", - "Tiberium Field", - "Foliage Permeable", - "Glass Permeable", - "Ice Permeable", - "Cloth Permeable", - "Electrical", - "Electrical Permeable", - "Flammable", - "Flammable Permeable", - "Steam", - "Steam Permeable", -}; - -///////////////////////////////////////////////////////////////////////////////////////////// -// Flags for the Mesh Attributes member -///////////////////////////////////////////////////////////////////////////////////////////// -#define W3D_MESH_FLAG_NONE 0x00000000 // plain ole normal mesh -#define W3D_MESH_FLAG_COLLISION_BOX 0x00000001 // (obsolete as of 4.1) mesh is a collision box (should be 8 verts, should be hidden, etc) -#define W3D_MESH_FLAG_SKIN 0x00000002 // (obsolete as of 4.1) skin mesh -#define W3D_MESH_FLAG_SHADOW 0x00000004 // (obsolete as of 4.1) intended to be projected as a shadow -#define W3D_MESH_FLAG_ALIGNED 0x00000008 // (obsolete as of 4.1) always aligns with camera - -#define W3D_MESH_FLAG_COLLISION_TYPE_MASK 0x00000FF0 // mask for the collision type bits -#define W3D_MESH_FLAG_COLLISION_TYPE_SHIFT 4 // shifting to get to the collision type bits -#define W3D_MESH_FLAG_COLLISION_TYPE_PHYSICAL 0x00000010 // physical collisions -#define W3D_MESH_FLAG_COLLISION_TYPE_PROJECTILE 0x00000020 // projectiles (rays) collide with this -#define W3D_MESH_FLAG_COLLISION_TYPE_VIS 0x00000040 // vis rays collide with this mesh -#define W3D_MESH_FLAG_COLLISION_TYPE_CAMERA 0x00000080 // camera rays/boxes collide with this mesh -#define W3D_MESH_FLAG_COLLISION_TYPE_VEHICLE 0x00000100 // vehicles collide with this mesh (and with physical collision meshes) - -#define W3D_MESH_FLAG_HIDDEN 0x00001000 // this mesh is hidden by default -#define W3D_MESH_FLAG_TWO_SIDED 0x00002000 // render both sides of this mesh -#define OBSOLETE_W3D_MESH_FLAG_LIGHTMAPPED 0x00004000 // obsolete lightmapped mesh - // NOTE: retained for backwards compatibility - use W3D_MESH_FLAG_PRELIT_* instead. -#define W3D_MESH_FLAG_CAST_SHADOW 0x00008000 // this mesh casts shadows - -#define W3D_MESH_FLAG_GEOMETRY_TYPE_MASK 0x00FF0000 // (introduced with 4.1) -#define W3D_MESH_FLAG_GEOMETRY_TYPE_NORMAL 0x00000000 // (4.1+) normal mesh geometry -#define W3D_MESH_FLAG_GEOMETRY_TYPE_CAMERA_ALIGNED 0x00010000 // (4.1+) camera aligned mesh -#define W3D_MESH_FLAG_GEOMETRY_TYPE_SKIN 0x00020000 // (4.1+) skin mesh -#define OBSOLETE_W3D_MESH_FLAG_GEOMETRY_TYPE_SHADOW 0x00030000 // (4.1+) shadow mesh OBSOLETE! -#define W3D_MESH_FLAG_GEOMETRY_TYPE_AABOX 0x00040000 // (4.1+) aabox OBSOLETE! -#define W3D_MESH_FLAG_GEOMETRY_TYPE_OBBOX 0x00050000 // (4.1+) obbox OBSOLETE! -#define W3D_MESH_FLAG_GEOMETRY_TYPE_CAMERA_ORIENTED 0x00060000 // (4.1+) camera oriented mesh (points _towards_ camera) - -#define W3D_MESH_FLAG_PRELIT_MASK 0x0F000000 // (4.2+) -#define W3D_MESH_FLAG_PRELIT_UNLIT 0x01000000 // mesh contains an unlit material chunk wrapper -#define W3D_MESH_FLAG_PRELIT_VERTEX 0x02000000 // mesh contains a precalculated vertex-lit material chunk wrapper -#define W3D_MESH_FLAG_PRELIT_LIGHTMAP_MULTI_PASS 0x04000000 // mesh contains a precalculated multi-pass lightmapped material chunk wrapper -#define W3D_MESH_FLAG_PRELIT_LIGHTMAP_MULTI_TEXTURE 0x08000000 // mesh contains a precalculated multi-texture lightmapped material chunk wrapper - -#define W3D_MESH_FLAG_SHATTERABLE 0x10000000 // this mesh is shatterable. -#define W3D_MESH_FLAG_NPATCHABLE 0x20000000 // it is ok to NPatch this mesh - -/******************************************************************************** - - Meshes - - Version 3 Mesh Header, trimmed out some of the junk that was in the - previous versions. - -********************************************************************************/ - -#define W3D_CURRENT_MESH_VERSION W3D_MAKE_VERSION(4,2) - -#define W3D_VERTEX_CHANNEL_LOCATION 0x00000001 // object-space location of the vertex -#define W3D_VERTEX_CHANNEL_NORMAL 0x00000002 // object-space normal for the vertex -#define W3D_VERTEX_CHANNEL_TEXCOORD 0x00000004 // texture coordinate -#define W3D_VERTEX_CHANNEL_COLOR 0x00000008 // vertex color -#define W3D_VERTEX_CHANNEL_BONEID 0x00000010 // per-vertex bone id for skins - -#define W3D_FACE_CHANNEL_FACE 0x00000001 // basic face info, W3dTriStruct... - -// boundary values for W3dMeshHeaderStruct::SortLevel -#define SORT_LEVEL_NONE 0 -#define MAX_SORT_LEVEL 32 -#define SORT_LEVEL_BIN1 10 -#define SORT_LEVEL_BIN2 15 -#define SORT_LEVEL_BIN3 20 - -struct W3dMeshHeader3Struct -{ - uint32 Version; - uint32 Attributes; - - char MeshName[W3D_NAME_LEN]; - char ContainerName[W3D_NAME_LEN]; - - // - // Counts, these can be regarded as an inventory of what is to come in the file. - // - uint32 NumTris; // number of triangles - uint32 NumVertices; // number of unique vertices - uint32 NumMaterials; // number of unique materials - uint32 NumDamageStages; // number of damage offset chunks - sint32 SortLevel; // static sorting level of this mesh - uint32 PrelitVersion; // mesh generated by this version of Lightmap Tool - uint32 FutureCounts[1]; // future counts - - uint32 VertexChannels; // bits for presence of types of per-vertex info - uint32 FaceChannels; // bits for presence of types of per-face info - - // - // Bounding volumes - // - W3dVectorStruct Min; // Min corner of the bounding box - W3dVectorStruct Max; // Max corner of the bounding box - W3dVectorStruct SphCenter; // Center of bounding sphere - float32 SphRadius; // Bounding sphere radius - -}; - -// -// Vertex Influences. For "skins" each vertex can be associated with a -// different bone. -// -struct W3dVertInfStruct -{ - uint16 BoneIdx; - uint8 Pad[6]; -}; - -// -// Deform information. Each mesh can have sets of keyframes of -// deform info associated with it. -// -struct W3dMeshDeform -{ - uint32 SetCount; - uint32 AlphaPasses; - uint32 reserved[3]; -}; - -// -// Deform set information. Each set is made up of a series -// of keyframes. -// -struct W3dDeformSetInfo -{ - uint32 KeyframeCount; - uint32 flags; - uint32 reserved[1]; -}; - -#define W3D_DEFORM_SET_MANUAL_DEFORM 0x00000001 // set is isn't applied during sphere or point tests. - -// -// Deform keyframe information. Each keyframe is made up of -// a set of per-vert deform data. -// -struct W3dDeformKeyframeInfo -{ - float32 DeformPercent; - uint32 DataCount; - uint32 reserved[2]; -}; - -// -// Deform data. Contains deform information about a vertex -// in the mesh. -// -struct W3dDeformData -{ - uint32 VertexIndex; - W3dVectorStruct Position; - W3dRGBAStruct Color; - uint32 reserved[2]; -}; - -// -// AABTree header. Each mesh can have an associated Axis-Aligned-Bounding-Box tree -// which is used for collision detection and certain rendering algorithms (like -// texture projection. -// -struct W3dMeshAABTreeHeader -{ - uint32 NodeCount; - uint32 PolyCount; - uint32 Padding[6]; -}; - -// -// AABTree Node. This is a node in the AABTree. -// If the MSB of FrontOrPoly0 is 1, then the node is a leaf and contains Poly0 and PolyCount -// else, the node is not a leaf and contains indices to its front and back children. This matches -// the format used by AABTreeClass in WW3D. -// -struct W3dMeshAABTreeNode -{ - W3dVectorStruct Min; // min corner of the box - W3dVectorStruct Max; // max corner of the box - uint32 FrontOrPoly0; // index of the front child or poly0 (if MSB is set, then leaf and poly0 is valid) - uint32 BackOrPolyCount; // index of the back child or polycount -}; - - -/******************************************************************************** - - WHT ( Westwood Hierarchy Tree ) - - A hierarchy tree defines a set of coordinate systems which are connected - hierarchically. The header defines the name, number of pivots, etc. - The pivots chunk will contain a W3dPivotStructs for each node in the - tree. - - The W3dPivotFixupStruct contains a transform for each MAX coordinate - system and our version of that same coordinate system (bone). It is - needed when the user exports the base pose using "Translation Only". - These are the matrices which go from the MAX rotated coordinate systems - to a system which is unrotated in the base pose. These transformations - are needed when exporting a hierarchy animation with the given hierarchy - tree file. - - Another explanation of these kludgy "fixup" matrices: - - What are the "fixup" matrices? These are the transforms which - were applied to the base pose when the user wanted to force the - base pose to use only matrices with certain properties. For - example, if we wanted the base pose to use translations only, - the fixup transform for each node is a transform which when - multiplied by the real node's world transform, yeilds a pure - translation matrix. Fixup matrices are used in the mesh - exporter since all vertices must be transformed by their inverses - in order to make things work. They also show up in the animation - exporter because they are needed to make the animation work with - the new base pose. - -********************************************************************************/ - -#define W3D_CURRENT_HTREE_VERSION W3D_MAKE_VERSION(4,1) - -struct W3dHierarchyStruct -{ - uint32 Version; - char Name[W3D_NAME_LEN]; // Name of the hierarchy - uint32 NumPivots; - W3dVectorStruct Center; -}; - -struct W3dPivotStruct -{ - char Name[W3D_NAME_LEN]; // Name of the node (UR_ARM, LR_LEG, TORSO, etc) - uint32 ParentIdx; // 0xffffffff = root pivot; no parent - W3dVectorStruct Translation; // translation to pivot point - W3dVectorStruct EulerAngles; // orientation of the pivot point - W3dQuaternionStruct Rotation; // orientation of the pivot point -}; - -struct W3dPivotFixupStruct -{ - float32 TM[4][3]; // this is a direct dump of a MAX 3x4 matrix -}; - - -/******************************************************************************** - - WHA (Westwood Hierarchy Animation) - - A Hierarchy Animation is a set of data defining deltas from the base - position of a hierarchy tree. Translation and Rotation channels can be - attached to any node of the hierarchy tree which the animation is - associated with. - -********************************************************************************/ - -#define W3D_CURRENT_HANIM_VERSION W3D_MAKE_VERSION(4,1) -#define W3D_CURRENT_COMPRESSED_HANIM_VERSION W3D_MAKE_VERSION(0,1) -#define W3D_CURRENT_MORPH_HANIM_VERSION W3D_MAKE_VERSION(0,1) - -struct W3dAnimHeaderStruct -{ - uint32 Version; - char Name[W3D_NAME_LEN]; - char HierarchyName[W3D_NAME_LEN]; - uint32 NumFrames; - uint32 FrameRate; - -}; - -struct W3dCompressedAnimHeaderStruct -{ - uint32 Version; - char Name[W3D_NAME_LEN]; - char HierarchyName[W3D_NAME_LEN]; - uint32 NumFrames; - uint16 FrameRate; - uint16 Flavor; -}; - - -enum -{ - ANIM_CHANNEL_X = 0, - ANIM_CHANNEL_Y, - ANIM_CHANNEL_Z, - ANIM_CHANNEL_XR, - ANIM_CHANNEL_YR, - ANIM_CHANNEL_ZR, - ANIM_CHANNEL_Q, - - ANIM_CHANNEL_TIMECODED_X, - ANIM_CHANNEL_TIMECODED_Y, - ANIM_CHANNEL_TIMECODED_Z, - ANIM_CHANNEL_TIMECODED_Q, - - ANIM_CHANNEL_ADAPTIVEDELTA_X, - ANIM_CHANNEL_ADAPTIVEDELTA_Y, - ANIM_CHANNEL_ADAPTIVEDELTA_Z, - ANIM_CHANNEL_ADAPTIVEDELTA_Q, -}; - -// -// Flavor Enumerations -// -enum -{ - ANIM_FLAVOR_TIMECODED = 0, - ANIM_FLAVOR_ADAPTIVE_DELTA, - - ANIM_FLAVOR_VALID -}; - -// Begin Classic Structures - -struct W3dAnimChannelStruct -{ - uint16 FirstFrame; - uint16 LastFrame; - uint16 VectorLen; // length of each vector in this channel - uint16 Flags; // channel type. - uint16 Pivot; // pivot affected by this channel - uint16 pad; - float32 Data[1]; // will be (LastFrame - FirstFrame + 1) * VectorLen long -}; - -enum -{ - BIT_CHANNEL_VIS = 0, // turn meshes on and off depending on anim frame. - BIT_CHANNEL_TIMECODED_VIS, -}; - -struct W3dBitChannelStruct -{ - uint16 FirstFrame; // all frames outside "First" and "Last" are assumed = DefaultVal - uint16 LastFrame; - uint16 Flags; // channel type. - uint16 Pivot; // pivot affected by this channel - uint8 DefaultVal; // default state when outside valid range. - uint8 Data[1]; // will be (LastFrame - FirstFrame + 1) / 8 long -}; - -// End Classic Structures -// Begin Time Coded Structures - -// A time code is a uint32 that prefixes each vector -// the MSB is used to indicate a binary (non interpolated) movement - -#define W3D_TIMECODED_BINARY_MOVEMENT_FLAG 0x80000000 - -struct W3dTimeCodedAnimChannelStruct -{ - uint32 NumTimeCodes; // number of time coded entries - uint16 Pivot; // pivot affected by this channel - uint8 VectorLen; // length of each vector in this channel - uint8 Flags; // channel type. - uint32 Data[1]; // will be (NumTimeCodes * ((VectorLen * sizeof(uint32)) + sizeof(uint32))) -}; - -// The bit channel is encoded right into the MSB of each time code -#define W3D_TIMECODED_BIT_MASK 0x80000000 - -struct W3dTimeCodedBitChannelStruct -{ - uint32 NumTimeCodes; // number of time coded entries - uint16 Pivot; // pivot affected by this channel - uint8 Flags; // channel type. - uint8 DefaultVal; // default state when outside valid range. - uint32 Data[1]; // will be (NumTimeCodes * sizeof(uint32)) -}; - -// End Time Coded Structures -// Begin AdaptiveDelta Structures -struct W3dAdaptiveDeltaAnimChannelStruct -{ - uint32 NumFrames; // number of frames of animation - uint16 Pivot; // pivot effected by this channel - uint8 VectorLen; // num Channels - uint8 Flags; // channel type - float Scale; // Filter Table Scale - - uint32 Data[1]; // OpCode Data Stream - -}; -// End AdaptiveDelta Structures - -/******************************************************************************** - - HMorphAnimClass - - This is an animation format which describes morphs between poses in another - animation. It is used for Renegade's facial animation system. There is - a normal anim which defines the pose for each phoneme and then a "Morph Anim" - which defines the transitions between phonemes over time. In addition there - is the concept of multiple morph channels in a morph anim. Each "channel" - controls a set of pivots in the skeleton and has its own set of morph keys - and poses. This lets us have one set of poses for expressions and another - for phonemes (a bone is only moved in one or the other anims though) - - The chunks used to describe a "morph" anim are as follows: - - W3D_CHUNK_MORPH_ANIMATION =0x000002C0, // wrapper for the entire anim - W3D_CHUNK_MORPHANIM_HEADER, // W3dMorphAnimHeaderStruct describes playback rate, number of frames, and type of compression - W3D_CHUNK_MORPHANIM_CHANNEL, // wrapper for a channel - W3D_CHUNK_MORPHANIM_POSENAME, // name of the other anim which contains the poses for this morph channel - W3D_CHUNK_MORPHANIM_KEYDATA, // array of W3dMorphAnimKeyStruct's (use chunk length to determine how many) - W3D_CHUNK_MORPHANIM_PIVOTCHANNELDATA, // uin32 per pivot in the htree, indicating which channel controls the pivot - - -********************************************************************************/ -struct W3dMorphAnimHeaderStruct -{ - uint32 Version; - char Name[W3D_NAME_LEN]; - char HierarchyName[W3D_NAME_LEN]; - uint32 FrameCount; - float32 FrameRate; - uint32 ChannelCount; -}; - -struct W3dMorphAnimKeyStruct -{ - uint32 MorphFrame; - uint32 PoseFrame; -}; - - - -/******************************************************************************** - - HModel - Hiearchical Model - - A Hierarchy Model is a set of render objects which should be attached to - bones in a hierarchy tree. There can be multiple objects per node - in the tree. Or there may be no objects attached to a particular bone. - - (gth) 09/22/2000 - Simplified the HModel file format. The W3DHModelAuxDataStruct - was un-needed and moved to w3d_obsolete.h. The safe way to parse previous - and current HModel formats is this: - - Read in the header from W3D_CHUNK_HMODEL_HEADER - - Allocate space for 'NumConnections' nodes that will follow - - Read in the rest of the chunks - - Create a sub-object for W3D_CHUNK_NODE, W3D_CHUNK_COLLISION_NODE, or - W3D_CHUNK_SKIN_NODE. - - Skip the OBSOLETE_W3D_CHUNK_HMODEL_AUX_DATA and OBSOLETE_W3D_CHUNK_SHADOW_NODE - -********************************************************************************/ - -#define W3D_CURRENT_HMODEL_VERSION W3D_MAKE_VERSION(4,2) - -struct W3dHModelHeaderStruct -{ - uint32 Version; - char Name[W3D_NAME_LEN]; // Name of this model - char HierarchyName[W3D_NAME_LEN]; // Name of the hierarchy tree this model uses - uint16 NumConnections; -}; - - -struct W3dHModelNodeStruct -{ - // Note: the full name of the Render object is expected to be: . - char RenderObjName[W3D_NAME_LEN]; - uint16 PivotIdx; -}; - - -/******************************************************************************** - - (LODModel - Level-Of-Detail Model) - - An LOD Model is a set of render objects which are interchangeable and - designed to be different resolution versions of the same object. - -********************************************************************************/ - -struct W3dLODModelHeaderStruct -{ - uint32 Version; - char Name[W3D_NAME_LEN]; // Name of this LOD Model - uint16 NumLODs; -}; - -struct W3dLODStruct -{ - char RenderObjName[2*W3D_NAME_LEN]; - float32 LODMin; // "artist" inspired switching distances - float32 LODMax; -}; - - -/******************************************************************************** - - Collection - - A collection chunk is generated when the user exports a bunch of meshes. - The collection will be named with the root name of the w3d file and will - contain a string chunk for the name of each render object in the collection. - A collection may also contain a "Snap Points" chunk. - - W3D_CHUNK_COLLECTION - W3D_CHUNK_COLLECTION_HEADER - W3D_CHUNK_SNAP_POINTS - W3D_CHUNK_COLLECTION_OBJ_NAME - W3D_CHUNK_COLLECTION_OBJ_NAME - W3D_CHUNK_COLLECTION_OBJ_NAME - ... - -********************************************************************************/ - -#define W3D_CURRENT_COLLECTION_VERSION W3D_MAKE_VERSION(4,2) - -struct W3dCollectionHeaderStruct -{ - uint32 Version; - char Name[W3D_NAME_LEN]; - uint32 RenderObjectCount; - uint32 pad[2]; -}; - - -/* -** Placeholder chunks. Also known as "PROXIES". These are used by the Renegade -** level editor to instruct the editor to instance a particular named object -*/ -#define W3D_CURRENT_PLACEHOLDER_VERSION W3D_MAKE_VERSION(1,0) - -// -// Note: This structure is follwed directly by an array of char's 'name_len' in length -// which specify the name of the placeholder object in our Commando-level editor. -// -struct W3dPlaceholderStruct -{ - uint32 version; - float32 transform[4][3]; // this is a direct dump of a MAX 3x4 matrix - uint32 name_len; -}; - - -/* -** Transform chunks. These chunks refer to other W3D files which should be transformed by -** this file. This feature is used to allow user to (for example) lightmap the interior -** of a building once and then just transform that into all of our levels that use it. -*/ -#define W3D_CURRENT_TRANSFORM_VERSION W3D_MAKE_VERSION(1,0) - -// -// Note: This structure is followed directly by an array of char's 'name_len' in length -// which specifies the name of the file to apply the transform to. -// -struct W3dTransformNodeStruct -{ - uint32 version; - float32 transform[4][3]; // this is a direct dump of a MAX 3x4 matrix - uint32 name_len; -}; - - - -/******************************************************************************** - - Lights - - The following structs are used to define lights in the w3d file. Currently - we have point lights, directional lights, and spot lights. - -********************************************************************************/ - -#define W3D_CURRENT_LIGHT_VERSION W3D_MAKE_VERSION(1,0) - -#define W3D_LIGHT_ATTRIBUTE_TYPE_MASK 0x000000FF -#define W3D_LIGHT_ATTRIBUTE_POINT 0x00000001 -#define W3D_LIGHT_ATTRIBUTE_DIRECTIONAL 0x00000002 -#define W3D_LIGHT_ATTRIBUTE_SPOT 0x00000003 -#define W3D_LIGHT_ATTRIBUTE_CAST_SHADOWS 0x00000100 - -struct W3dLightStruct -{ - uint32 Attributes; - uint32 Unused; // Old exclusion bit deprecated - W3dRGBStruct Ambient; - W3dRGBStruct Diffuse; - W3dRGBStruct Specular; - float32 Intensity; -}; - -struct W3dSpotLightStruct -{ - W3dVectorStruct SpotDirection; - float32 SpotAngle; - float32 SpotExponent; -}; - -struct W3dLightAttenuationStruct -{ - float32 Start; - float32 End; -}; - -struct W3dLightTransformStruct -{ - float32 Transform [3][4]; -}; - - -/******************************************************************************** - - Particle emitters - - The following structs are used to define emitters in the w3d file. - -********************************************************************************/ - -#define W3D_CURRENT_EMITTER_VERSION 0x00020000 - -// -// This enum contains valid defines for the Type field -// of the W3dEmitterUserInfoStruct. The programmer -// can add entries here that their specific loader -// can switch on to determine what type the emitter is. -// -// NOTE: Please add a string the the EMITTER_TYPE_NAMES -// array when you add an entry to the enum. -// -enum -{ - EMITTER_TYPEID_DEFAULT = 0, - EMITTER_TYPEID_COUNT -}; - -// -// The definition of this string array can be found in -// Part_Ldr.cpp. Please update this array accordingly. -// -extern const char *EMITTER_TYPE_NAMES[EMITTER_TYPEID_COUNT]; - -struct W3dEmitterHeaderStruct -{ - uint32 Version; - char Name[W3D_NAME_LEN]; -}; - -struct W3dEmitterUserInfoStruct -{ - uint32 Type; // One of the EMITTER_TYPEID_ enum's defined above - uint32 SizeofStringParam; // Size (in bytes) of the following string data - char StringParam[1]; // Array of bytes. Where "count = SizeofStringParam" -}; - -struct W3dEmitterInfoStruct -{ - char TextureFilename[260]; - float32 StartSize; - float32 EndSize; - float32 Lifetime; - float32 EmissionRate; - float32 MaxEmissions; - float32 VelocityRandom; - float32 PositionRandom; - float32 FadeTime; - float32 Gravity; - float32 Elasticity; - W3dVectorStruct Velocity; - W3dVectorStruct Acceleration; - W3dRGBAStruct StartColor; - W3dRGBAStruct EndColor; -}; - -struct W3dVolumeRandomizerStruct -{ - uint32 ClassID; - float32 Value1; - float32 Value2; - float32 Value3; - uint32 reserved[4]; -}; - -#define W3D_EMITTER_RENDER_MODE_TRI_PARTICLES 0 -#define W3D_EMITTER_RENDER_MODE_QUAD_PARTICLES 1 -#define W3D_EMITTER_RENDER_MODE_LINE 2 - -#define W3D_EMITTER_FRAME_MODE_1x1 0 -#define W3D_EMITTER_FRAME_MODE_2x2 1 -#define W3D_EMITTER_FRAME_MODE_4x4 2 -#define W3D_EMITTER_FRAME_MODE_8x8 3 -#define W3D_EMITTER_FRAME_MODE_16x16 4 - -struct W3dEmitterInfoStructV2 -{ - uint32 BurstSize; - W3dVolumeRandomizerStruct CreationVolume; - W3dVolumeRandomizerStruct VelRandom; - float32 OutwardVel; - float32 VelInherit; - W3dShaderStruct Shader; - uint32 RenderMode; // render as particles or lines? - uint32 FrameMode; // chop the texture into a grid of smaller squares? - uint32 reserved[6]; -}; - -// W3D_CHUNK_EMITTER_PROPS -// Contains a W3dEmitterPropertyStruct followed by a number of color keyframes, -// opacity keyframes, and size keyframes - -struct W3dEmitterPropertyStruct -{ - uint32 ColorKeyframes; - uint32 OpacityKeyframes; - uint32 SizeKeyframes; - W3dRGBAStruct ColorRandom; - float32 OpacityRandom; - float32 SizeRandom; - uint32 reserved[4]; -}; - - -struct W3dEmitterColorKeyframeStruct -{ - float32 Time; - W3dRGBAStruct Color; -}; - -struct W3dEmitterOpacityKeyframeStruct -{ - float32 Time; - float32 Opacity; -}; - -struct W3dEmitterSizeKeyframeStruct -{ - float32 Time; - float32 Size; -}; - -// W3D_CHUNK_EMITTER_ROTATION_KEYFRAMES -// Contains a W3dEmitterRotationHeaderStruct followed by a number of -// rotational velocity keyframes. -struct W3dEmitterRotationHeaderStruct -{ - uint32 KeyframeCount; - float32 Random; // random initial rotational velocity (rotations/sec) - float32 OrientationRandom; // random initial orientation (rotations, 1.0=360deg) - uint32 Reserved[1]; -}; - -struct W3dEmitterRotationKeyframeStruct -{ - float32 Time; - float32 Rotation; // rotational velocity in rotations/sec -}; - -// W3D_CHUNK_EMITTER_FRAME_KEYFRAMES -// Contains a W3dEmitterFrameHeaderStruct followed by a number of -// frame keyframes (sub-texture indexing) -struct W3dEmitterFrameHeaderStruct -{ - uint32 KeyframeCount; - float32 Random; - uint32 Reserved[2]; -}; - -struct W3dEmitterFrameKeyframeStruct -{ - float32 Time; - float32 Frame; -}; - - -// W3D_CHUNK_EMITTER_LINE_PROPERTIES -// Contains a W3dEmitterLinePropertiesStruct. -// Emiter Line Flags (used in the Flags field of W3dEmitterLinePropertiesStruct): -#define W3D_ELINE_MERGE_INTERSECTIONS 0x00000001 // Merge intersections -#define W3D_ELINE_FREEZE_RANDOM 0x00000002 // Freeze random (note: offsets are in camera space) -#define W3D_ELINE_DISABLE_SORTING 0x00000004 // Disable sorting (even if shader has alpha-blending) -#define W3D_ELINE_END_CAPS 0x00000008 // Draw end caps on the line -#define W3D_ELINE_TEXTURE_MAP_MODE_MASK 0xFF000000 // Must cover all possible TextureMapMode values - -#define W3D_ELINE_TEXTURE_MAP_MODE_OFFSET 24 // By how many bits do I need to shift the texture mapping mode? -#define W3D_ELINE_UNIFORM_WIDTH_TEXTURE_MAP 0x00000000 // Entire line uses one row of texture (constant V) -#define W3D_ELINE_UNIFORM_LENGTH_TEXTURE_MAP 0x00000001 // Entire line uses one row of texture stretched length-wise -#define W3D_ELINE_TILED_TEXTURE_MAP 0x00000002 // Tiled continuously over line - -#define W3D_ELINE_DEFAULT_BITS (W3D_ELINE_MERGE_INTERSECTIONS | (W3D_ELINE_UNIFORM_WIDTH_TEXTURE_MAP << W3D_ELINE_TEXTURE_MAP_MODE_OFFSET)) - - -struct W3dEmitterLinePropertiesStruct -{ - uint32 Flags; - uint32 SubdivisionLevel; - float32 NoiseAmplitude; - float32 MergeAbortFactor; - float32 TextureTileFactor; - float32 UPerSec; - float32 VPerSec; - uint32 Reserved[9]; -}; - - -/******************************************************************************** - - Aggregate objects - - The following structs are used to define aggregates in the w3d file. An - 'aggregate' is simply a 'shell' that contains references to a hierarchy - model and subobjects to attach to its bones. - -********************************************************************************/ - -#define W3D_CURRENT_AGGREGATE_VERSION 0x00010003 -const int MESH_PATH_ENTRIES = 15; -const int MESH_PATH_ENTRY_LEN = (W3D_NAME_LEN * 2); - -struct W3dAggregateHeaderStruct -{ - uint32 Version; - char Name[W3D_NAME_LEN]; -}; - -struct W3dAggregateInfoStruct -{ - char BaseModelName[W3D_NAME_LEN*2]; - uint32 SubobjectCount; -}; - -struct W3dAggregateSubobjectStruct -{ - char SubobjectName[W3D_NAME_LEN*2]; - char BoneName[W3D_NAME_LEN*2]; -}; - -// -// Structures for version 1.1 and newer -// -struct W3dTextureReplacerHeaderStruct -{ - uint32 ReplacedTexturesCount; -}; - -struct W3dTextureReplacerStruct -{ - char MeshPath[MESH_PATH_ENTRIES][MESH_PATH_ENTRY_LEN]; - char BonePath[MESH_PATH_ENTRIES][MESH_PATH_ENTRY_LEN]; - char OldTextureName[260]; - char NewTextureName[260]; - W3dTextureInfoStruct TextureParams; -}; - -// -// Flags used in the W3dAggregateMiscInfo structure -// -const int W3D_AGGREGATE_FORCE_SUB_OBJ_LOD = 0x00000001; - -// -// Structures for version 1.2 and newer -// -struct W3dAggregateMiscInfo -{ - uint32 OriginalClassID; - uint32 Flags; - uint32 reserved[3]; -}; - - -/******************************************************************************** - - HLod (Hierarchical LOD Model) - - This is a hierarchical model which has multiple arrays of models which can - be switched for LOD purposes. - - Relevant Chunks: - ---------------- - W3D_CHUNK_HLOD =0x00000700, // description of an HLod object (see HLodClass) - W3D_CHUNK_HLOD_HEADER, // general information such as name and version - W3D_CHUNK_HLOD_LOD_ARRAY, // wrapper around the array of objects for each level of detail - W3D_CHUNK_HLOD_SUB_OBJECT_ARRAY_HEADER, // info on the objects in this level of detail array - W3D_CHUNK_HLOD_SUB_OBJECT, // an object in this level of detail array - W3D_CHUNK_HLOD_AGGREGATE_ARRAY, // array of aggregates, contains W3D_CHUNK_SUB_OBJECT_ARRAY_HEADER and W3D_CHUNK_SUB_OBJECT_ARRAY - W3D_CHUNK_HLOD_PROXY_ARRAY, // array of proxies, used for application-defined purposes - - An HLOD is the basic hierarchical model format used by W3D. It references - an HTree for its hierarchical structure and animation data and several arrays - of sub-objects; one for each LOD in the model. In addition, it can contain - an array of "aggregates" which are references to external W3D objects to - be automatically attached into it. And it can have a list of "proxy" objects - which can be used for application purposes such as instantiating game objects - at the specified transform. - -********************************************************************************/ - -#define W3D_CURRENT_HLOD_VERSION W3D_MAKE_VERSION(1,0) -#define NO_MAX_SCREEN_SIZE WWMATH_FLOAT_MAX - -struct W3dHLodHeaderStruct -{ - uint32 Version; - uint32 LodCount; - char Name[W3D_NAME_LEN]; - char HierarchyName[W3D_NAME_LEN]; // name of the hierarchy tree to use (\0 if none) -}; - -struct W3dHLodArrayHeaderStruct -{ - uint32 ModelCount; - float32 MaxScreenSize; // if model is bigger than this, switch to higher lod. -}; - -struct W3dHLodSubObjectStruct -{ - uint32 BoneIndex; - char Name[W3D_NAME_LEN*2]; -}; - - -/******************************************************************************** - - Collision Boxes - - Collision boxes are meant to be used for, you guessed it, collision detection. - For this reason, they only contain a minimal amount of rendering information - (a color). - - Axis Aligned - This is a bounding box which is *always* aligned with the world - coordinate system. So, the center point is to be transformed by whatever - transformation matrix is being used but the extents always point down the - world space x,y, and z axes. (in effect, you are translating the center). - - Oriented - This is an oriented 3D box. It is aligned with the coordinate system - it is in. So its extents always point along the local coordinate system axes. - -********************************************************************************/ -#define W3D_BOX_CURRENT_VERSION W3D_MAKE_VERSION(1,0) - -#define W3D_BOX_ATTRIBUTE_ORIENTED 0x00000001 -#define W3D_BOX_ATTRIBUTE_ALIGNED 0x00000002 -#define W3D_BOX_ATTRIBUTE_COLLISION_TYPE_MASK 0x00000FF0 // mask for the collision type bits -#define W3D_BOX_ATTRIBUTE_COLLISION_TYPE_SHIFT 4 // shifting to get to the collision type bits -#define W3D_BOX_ATTRIBTUE_COLLISION_TYPE_PHYSICAL 0x00000010 // physical collisions -#define W3D_BOX_ATTRIBTUE_COLLISION_TYPE_PROJECTILE 0x00000020 // projectiles (rays) collide with this -#define W3D_BOX_ATTRIBTUE_COLLISION_TYPE_VIS 0x00000040 // vis rays collide with this mesh -#define W3D_BOX_ATTRIBTUE_COLLISION_TYPE_CAMERA 0x00000080 // cameras collide with this mesh -#define W3D_BOX_ATTRIBTUE_COLLISION_TYPE_VEHICLE 0x00000100 // vehicles collide with this mesh - -struct W3dBoxStruct -{ - uint32 Version; // file format version - uint32 Attributes; // box attributes (above #define's) - char Name[2*W3D_NAME_LEN]; // name is in the form . - W3dRGBStruct Color; // color to use when drawing the box - W3dVectorStruct Center; // center of the box - W3dVectorStruct Extent; // extent of the box -}; - - - - -/******************************************************************************** - - NULL Objects - - Null objects are used by the LOD system to make meshes dissappear at lower - levels of detail. - -********************************************************************************/ -#define W3D_NULL_OBJECT_CURRENT_VERSION W3D_MAKE_VERSION(1,0) - -struct W3dNullObjectStruct -{ - uint32 Version; // file format version - uint32 Attributes; // object attributes (currently un-used) - uint32 pad[2]; // pad space - char Name[2*W3D_NAME_LEN]; // name is in the form . -}; - - -/******************************************************************************** - - Dazzle Objects - - The only data needed to instantiate a dazzle object is the type-name of - the dazzle to use. The dazzle is always assumed to be at the pivot point - of the bone it is attached to (you should enable Export_Transform) for - dazzles. If the dazzle-type (from dazzle.ini) is directional, then the - coordinate-system of the bone will define the direction. - -********************************************************************************/ - - - -/******************************************************************************** - - Sound render objects - - The following structs are used to define sound render object in the w3d file. - - These objects are used to trigger a sound effect in the world. When the object - is shown, its associated sound is added to the world and played, when the object - is hidden, the associated sound is stopped and removed from the world. - - -********************************************************************************/ - -#define W3D_CURRENT_SOUNDROBJ_VERSION 0x00010000 - -// -// Note: This structure is follwed directly by a chunk (W3D_CHUNK_SOUNDROBJ_DEFINITION) -// that contains an embedded AudibleSoundDefinitionClass's storage. See audibledound.h -// for details. -// -struct W3dSoundRObjHeaderStruct -{ - uint32 Version; - char Name[W3D_NAME_LEN]; - uint32 Flags; - uint32 Padding[8]; -}; - - -/* -** Include the obsolete structures and chunk ID's -*/ -#include "w3d_obsolete.h" - - -#endif // W3D_FILE_H diff --git a/Generals/Code/Tools/WW3D/max2w3d/w3d_obsolete.h b/Generals/Code/Tools/WW3D/max2w3d/w3d_obsolete.h deleted file mode 100644 index d420ec2979a..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/w3d_obsolete.h +++ /dev/null @@ -1,333 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/w3d_obsolete.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 9/22/00 10:40a $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef W3D_OBSOLETE_H -#define W3D_OBSOLETE_H - - -///////////////////////////////////////////////////////////////////////////////////////////// -// Obsolete chunk id's -// At one point in time I was using the 'O' prefix to mean obsolete. Now we just move stuff -// into this file... -///////////////////////////////////////////////////////////////////////////////////////////// -enum -{ - W3D_CHUNK_MESH_HEADER =0x00000001, // header for a mesh - W3D_CHUNK_SURRENDER_NORMALS =0x00000004, // array of surrender normals (one per vertex as req. by surrender) - W3D_CHUNK_TEXCOORDS =0x00000005, // array of texture coordinates - O_W3D_CHUNK_MATERIALS =0x00000006, // array of materials - O_W3D_CHUNK_TRIANGLES =0x00000007, // array of triangles - O_W3D_CHUNK_QUADRANGLES =0x00000008, // array of quads - O_W3D_CHUNK_SURRENDER_TRIANGLES =0x00000009, // array of surrender format tris - O_W3D_CHUNK_POV_TRIANGLES =0x0000000A, // POV format triangles - O_W3D_CHUNK_POV_QUADRANGLES =0x0000000B, // POV format quads - W3D_CHUNK_VERTEX_COLORS =0x0000000D, // Pre-set vertex coloring - W3D_CHUNK_DAMAGE =0x0000000F, // Mesh damage, new set of materials, vertex positions, vertex colors - W3D_CHUNK_DAMAGE_HEADER =0x00000010, // Header for the damage data, tells what is coming - W3D_CHUNK_DAMAGE_VERTICES =0x00000011, // Array of modified vertices (W3dMeshDamageVertexStruct's) - W3D_CHUNK_DAMAGE_COLORS =0x00000012, // Array of modified vert colors (W3dMeshDamageColorStruct's) - W3D_CHUNK_DAMAGE_MATERIALS =0x00000013, - - O_W3D_CHUNK_MATERIALS2 =0x00000014, // array of version 2 materials (with animation frame counts) - - W3D_CHUNK_MATERIALS3 =0x00000015, // array of version 3 materials (all new surrender features supported) - W3D_CHUNK_MATERIAL3 =0x00000016, // Each version 3 material wrapped with this chunk ID - W3D_CHUNK_MATERIAL3_NAME =0x00000017, // Name of the material (array of chars, null terminated) - W3D_CHUNK_MATERIAL3_INFO =0x00000018, // contains a W3dMaterial3Struct, general material info - W3D_CHUNK_MATERIAL3_DC_MAP =0x00000019, // wraps the following two chunks, diffuse color texture - W3D_CHUNK_MAP3_FILENAME =0x0000001A, // filename of the texture - W3D_CHUNK_MAP3_INFO =0x0000001B, // a W3dMap3Struct - W3D_CHUNK_MATERIAL3_DI_MAP =0x0000001C, // diffuse illimination map, same format as other maps - W3D_CHUNK_MATERIAL3_SC_MAP =0x0000001D, // specular color map, same format as other maps - W3D_CHUNK_MATERIAL3_SI_MAP =0x0000001E, // specular illumination map, same format as other maps - W3D_CHUNK_PER_TRI_MATERIALS =0x00000021, // Multi-Mtl meshes - An array of uint16 material id's -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// -// Version 1.0 Material, array of these are found inside the W3D_CHUNK_MATERIALS chunk. -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dMaterialStruct -{ - char MaterialName[W3D_NAME_LEN]; // name of the material (NULL terminated) - char PrimaryName[W3D_NAME_LEN]; // primary texture name (NULL terminated) - char SecondaryName[W3D_NAME_LEN]; // secondary texture name (NULL terminated) - uint32 RenderFlags; // Rendering flags - uint8 Red; // Rgb colors - uint8 Green; - uint8 Blue; -}; - -///////////////////////////////////////////////////////////////////////////////////////////// -// Version 2.0 Material, array of these are found inside the W3D_CHUNK_MATERIALS2 chunk. -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dMaterial2Struct -{ - char MaterialName[W3D_NAME_LEN]; // name of the material (NULL terminated) - char PrimaryName[W3D_NAME_LEN]; // primary texture name (NULL terminated) - char SecondaryName[W3D_NAME_LEN]; // secondary texture name (NULL terminated) - uint32 RenderFlags; // Rendering flags - uint8 Red; // Rgb colors - uint8 Green; - uint8 Blue; - uint8 Alpha; - - uint16 PrimaryNumFrames; // number of animated frames (if 1, not animated) - uint16 SecondaryNumFrames; // number of animated frames (if 1, not animated) - - char Pad[12]; // expansion room -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// -// MATERIAL ATTRIBUTES (version 3.0 onward) -///////////////////////////////////////////////////////////////////////////////////////////// -// Use alpha enables alpha channels, etc, Use sorting causes display lists using -// this material to be sorted (even with z-buf, translucent materials need to be sorted) -#define W3DMATERIAL_USE_ALPHA 0x00000001 -#define W3DMATERIAL_USE_SORTING 0x00000002 - -// Hints for render devices that cannot support all features -#define W3DMATERIAL_HINT_DIT_OVER_DCT 0x00000010 -#define W3DMATERIAL_HINT_SIT_OVER_SCT 0x00000020 -#define W3DMATERIAL_HINT_DIT_OVER_DIG 0x00000040 -#define W3DMATERIAL_HINT_SIT_OVER_SIG 0x00000080 -#define W3DMATERIAL_HINT_FAST_SPECULAR_AFTER_ALPHA 0x00000100 - -// Last byte is for PSX: Translucency type and a lighting disable flag. -#define W3DMATERIAL_PSX_MASK 0xFF000000 -#define W3DMATERIAL_PSX_TRANS_MASK 0x07000000 -#define W3DMATERIAL_PSX_TRANS_NONE 0x00000000 -#define W3DMATERIAL_PSX_TRANS_100 0x01000000 -#define W3DMATERIAL_PSX_TRANS_50 0x02000000 -#define W3DMATERIAL_PSX_TRANS_25 0x03000000 -#define W3DMATERIAL_PSX_TRANS_MINUS_100 0x04000000 -#define W3DMATERIAL_PSX_NO_RT_LIGHTING 0x08000000 - -///////////////////////////////////////////////////////////////////////////////////////////// -// MAPPING TYPES (version 3.0 onward) -///////////////////////////////////////////////////////////////////////////////////////////// -#define W3DMAPPING_UV 0 -#define W3DMAPPING_ENVIRONMENT 1 - -///////////////////////////////////////////////////////////////////////////////////////////// -// Version 3.0 Material, A W3D_CHUNK_MATERIALS3 chunk will wrap a bunch of -// W3D_CHUNK_MATERIAL3 chunks. Inside each chunk will be a name chunk, an 'info' chunk which -// contains the following struct, and one or more map chunks. a mesh with 2 materials might -// look like: -// -// W3D_CHUNK_MATERIALS3 <-- simply a wrapper around the array of mtls -// W3D_CHUNK_MATERIAL3 <-- a wrapper around each material -// W3D_CHUNK_STRING <-- name of the material -// W3D_CHUNK_MATERIAL3_INFO <-- standard material properties, a W3dMaterial3Struct -// W3D_CHUNK_MATERIAL3_DC_MAP <-- a map, W3dMap3Struct -// W3D_CHUNK_STRING <-- filename of the map -// W3D_CHUNK_MAP_INFO <-- map parameters -// W3D_CHUNK_MATERIAL3_SC_MAP -// W3D_CHUNK_STRING <-- filename of the map -// W3D_CHUNK_MAP_INFO -// W3D_CHUNK_MATERIAL3 -// W3D_CHUNK_MATERIAL3_NAME -// W3D_CHUNK_MATERIAL3_INFO -// W3D_CHUNK_MATERIAL3_SI_MAP -// -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dMaterial3Struct -{ - uint32 Attributes; // flags,hints,etc. - - W3dRGBStruct DiffuseColor; // diffuse color - W3dRGBStruct SpecularColor; // specular color - - W3dRGBStruct EmissiveCoefficients; // emmissive coefficients, default to 0,0,0 - W3dRGBStruct AmbientCoefficients; // ambient coefficients, default to 1,1,1 - W3dRGBStruct DiffuseCoefficients; // diffuse coeficients, default to 1,1,1 - W3dRGBStruct SpecularCoefficients; // specular coefficients, default to 0,0,0 - - float32 Shininess; // how tight the specular highlight will be, 1 - 1000 (default = 1) - float32 Opacity; // how opaque the material is, 0.0 = invisible, 1.0 = fully opaque (default = 1) - float32 Translucency; // how much light passes through the material. (default = 0) - float32 FogCoeff; // effect of fog (0.0=not fogged, 1.0=fogged) (default = 1) -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// -// A map, only occurs as part of a material, will be preceeded by its name. -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dMap3Struct -{ - uint16 MappingType; // Mapping type, will be one of the above #defines (e.g. W3DMAPPING_UV) - uint16 FrameCount; // Number of frames (1 if not animated) - float32 FrameRate; // Frame rate, frames per second in floating point -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// -// A triangle, occurs inside the W3D_CHUNK_SURRENDER_TRIANGLES chunk -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dSurrenderTriStruct -{ - uint32 Vindex[3]; // vertex, vert normal, and texture coord indexes (all use same index) - W3dTexCoordStruct TexCoord[3]; // texture coordinates (OBSOLETE!!!) - uint32 MaterialIdx; // material index - W3dVectorStruct Normal; // Face normal - uint32 Attributes; // collision flags, sort method, etc - W3dRGBStruct Gouraud[3]; // Pre-set shading values (OBSOLETE!!!) -}; - -///////////////////////////////////////////////////////////////////////////////////////////// -// Original (Obsolete) Mesh Header -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dMeshHeaderStruct -{ - uint32 Version; // Currently version 0x100 - char MeshName[W3D_NAME_LEN]; // name of the mesh (Null terminated) - uint32 Attributes; - - // - // Counts, these can be regarded as an inventory of what is to come in the file. - // - uint32 NumTris; // number of triangles (OBSOLETE!) - uint32 NumQuads; // number of quads; (OBSOLETE!) - uint32 NumSrTris; // number of triangles - - uint32 NumPovTris; // (NOT USED) - uint32 NumPovQuads; // (NOT USED) - - uint32 NumVertices; // number of unique vertices - uint32 NumNormals; // number of unique normals (OBSOLETE!) - uint32 NumSrNormals; // number of surrender normals (MUST EQUAL NumVertices or 0) - - uint32 NumTexCoords; // number of unique texture coords (MUST EQUAL NumVertices or 0) - uint32 NumMaterials; // number of unique materials needed - - uint32 NumVertColors; // number of vertex colors (MUST EQUAL NumVertices or 0) - uint32 NumVertInfluences;// vertex influences(MUST EQUAL NumVertices or 0) - uint32 NumDamageStages; // number of damage offset chunks - uint32 FutureCounts[5]; // reserve space for future counts (set to zero). - - // - // LOD controls - // - float32 LODMin; // min LOD distance - float32 LODMax; // max LOD distance - - // - // Collision / rendering quick-rejection - // - W3dVectorStruct Min; // Min corner of the bounding box - W3dVectorStruct Max; // Max corner of the bounding box - W3dVectorStruct SphCenter; // Center of bounding sphere - float32 SphRadius; // Bounding sphere radius - - // - // Default transformation - // - W3dVectorStruct Translation; - float32 Rotation[9]; - - // - // Physics Properties - // - W3dVectorStruct MassCenter; // Center of mass in object space - float32 Inertia[9]; // Inertia tensor (relative to MassCenter) - float32 Volume; // volume of the object - - // - // Name of possible hierarchy this mesh should be attached to - // - char HierarchyTreeName[W3D_NAME_LEN]; - char HierarchyModelName[W3D_NAME_LEN]; - uint32 FutureUse[24]; // Reserved for future use -}; - - -// -// Mesh Damage. This can include a new set of materials for the mesh, -// new positions for certain vertices in the mesh, and new vertex -// colors for certain vertices. -// -struct W3dMeshDamageStruct -{ - uint32 NumDamageMaterials; // number of materials to replace - uint32 NumDamageVerts; // number of vertices to replace - uint32 NumDamageColors; // number of vertex colors to replace - uint32 DamageIndex; // what index is this damage chunk assigned to - uint32 FutureUse[4]; -}; - -struct W3dMeshDamageVertexStruct -{ - uint32 VertexIndex; - W3dVectorStruct NewVertex; -}; - -struct W3dMeshDamageColorStruct -{ - uint32 VertexIndex; - W3dRGBStruct NewColor; -}; - - - -// -// W3dHModelAuxDataStruct. HModels had this extra chunk defining the counts of individual -// types of objects to be found in the model and some obsolete distance-based LOD settings. -// As changes were made to the ww3d library, all of this became useles so the chunk was -// "retired". -// -struct W3dHModelAuxDataStruct -{ - uint32 Attributes; - uint32 MeshCount; - uint32 CollisionCount; - uint32 SkinCount; - uint32 ShadowCount; - uint32 NullCount; - uint32 FutureCounts[6]; - - float32 LODMin; - float32 LODMax; - uint32 FutureUse[32]; -}; - - -#endif // W3D_OBSOLETE_H diff --git a/Generals/Code/Tools/WW3D/max2w3d/w3dappdata.cpp b/Generals/Code/Tools/WW3D/max2w3d/w3dappdata.cpp deleted file mode 100644 index e590ea8b74d..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/w3dappdata.cpp +++ /dev/null @@ -1,756 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/w3dappdata.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 8/21/01 9:45a $* - * * - * $Revision:: 9 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Is_Bone -- check if a node is a "bone" * - * Is_Geometry -- Check if an INode is marked for "geometry" export * - * Is_Normal_Mesh -- check if a node is a mesh * - * Is_Camera_Aligned_Mesh -- check if a node is to be a camera aligned mesh * - * Is_Camera_Oriented_Mesh -- check if a node is to be a camera oriented mesh * - * Is_Collision_AABox -- check if a node is a collision box mesh * - * Is_Collision_OBBox -- check if a node is a collision box mesh * - * Is_Skin -- check if a node is a skin * - * Is_Shadow -- check if a node marked to cast shadows * - * Is_Damage -- check if a node is a damage version of a mesh * - * Is_Damage_For_Mesh -- check if a node is a damage version of a particular mesh * - * Is_Physical_Collision -- Is node categorized as "physical collision geometry" * - * Is_Projectile_Collision -- Is node categorized as "projectile collision geometry"? * - * Is_Vis_Collision -- Is node categorized as "vis collision geometry"? * - * Is_Camera_Collision -- Is node categorized as "camera collision geometry"? * - * Is_Hidden -- checks whether the node should be hidden * - * Is_Two_Sided -- Checks whether the node should be two sided * - * Is_ZNormals -- checks if the node should be exported with 0,0,1 vert normals * - * Is_Dazzle -- check if a node is a dazzle object * - * Is_Aggregate -- check if a node is an aggregate object * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "w3dappdata.h" -#include "w3dutil.h" -#include "util.h" -#include "modstack.h" - - -/*********************************************************************************************** -** -** W3DAppData2Struct Implementation -** -***********************************************************************************************/ - -/* -** Current version of the W3dAppData2 structure -** History: -** version 0 - initial implementation. -** version 1 - added camera collision option, initialize to match physical collision settting -** when converting from version 0. -*/ -const int W3DAPPDATA2_CURRENT_VERSION = 1; - - - -W3DAppData2Struct::W3DAppData2Struct(void) : - ExportFlags(0), - GeometryType(0), - GeometryFlags(0), - CollisionFlags(0) -{ - memset(UnUsed,0,sizeof(UnUsed)); - Init_With_Other_Defaults(); -} - -W3DAppData2Struct::W3DAppData2Struct(W3DAppData0Struct & olddata) : - ExportFlags(0), - GeometryType(0), - GeometryFlags(0), - CollisionFlags(0) -{ - memset(UnUsed,0,sizeof(UnUsed)); - Init_From_AppData0(olddata); -} - -void W3DAppData2Struct::Init_With_Mesh_Defaults(void) -{ - ExportFlags = (EXPORT_TRANSFORM|EXPORT_GEOMETRY); - GeometryType = GEO_TYPE_NORMAL_MESH; - GeometryFlags = 0; - CollisionFlags = 0; - memset(UnUsed,0,sizeof(UnUsed)); - - Set_Version(W3DAPPDATA2_CURRENT_VERSION); -} - -void W3DAppData2Struct::Init_With_Other_Defaults(void) -{ - ExportFlags = 0; - GeometryType = 0; - GeometryFlags = 0; - CollisionFlags = 0; - memset(UnUsed,0,sizeof(UnUsed)); - - Set_Version(W3DAPPDATA2_CURRENT_VERSION); -} - -void W3DAppData2Struct::Init_From_AppData0(W3DAppData0Struct & olddata) -{ - Init_With_Other_Defaults(); - - Enable_Export_Transform(olddata.Is_Bone()); - Enable_Export_Geometry(olddata.Is_Geometry()); - - if (olddata.Is_Camera_Aligned_Mesh()) { - Set_Geometry_Type(GEO_TYPE_CAMERA_ALIGNED); - } - if (olddata.Is_Camera_Oriented_Mesh()) { - Set_Geometry_Type(GEO_TYPE_CAMERA_ORIENTED); - } - if (olddata.Is_Collision_AABox()) { - Set_Geometry_Type(GEO_TYPE_AABOX); - } - if (olddata.Is_Collision_OBBox()) { - Set_Geometry_Type(GEO_TYPE_OBBOX); - } - if (olddata.Is_Normal_Mesh()) { - Set_Geometry_Type(GEO_TYPE_NORMAL_MESH); - } - if (olddata.Is_Null()) { - Set_Geometry_Type(GEO_TYPE_NULL); - } - - Enable_Hidden(olddata.Is_Hidden()); - Enable_Two_Sided(olddata.Is_Two_Sided()); - Enable_Shadow(olddata.Is_Shadow()); - Enable_Vertex_Alpha(olddata.Is_Vertex_Alpha()); - Enable_ZNormals(olddata.Is_ZNormals()); - Enable_Physical_Collision(olddata.Is_Physical_Collision()); - Enable_Projectile_Collision(olddata.Is_Projectile_Collision()); - Enable_Vis_Collision(olddata.Is_Vis_Collision()); - Enable_Camera_Collision(olddata.Is_Physical_Collision()); // make camera setting match physical - - Set_Version(W3DAPPDATA2_CURRENT_VERSION); -} - -void W3DAppData2Struct::Update_Version(void) -{ - /* - ** If this is a version 0 struct, We need to initialize the camera collision - ** setting to be equal to the physical collision setting and convert to version 1 - */ - if (Get_Version() == 0) { - Enable_Camera_Collision(Is_Physical_Collision_Enabled()); - Set_Version(1); - } - - /* - ** Add future version conversion code here! - */ -} - -bool W3DAppData2Struct::operator == (const W3DAppData2Struct & that) -{ - /* - ** Export flags have to match - */ - if (ExportFlags != that.ExportFlags) return false; - - /* - ** If geometry is enabled, verify the geometry type and options - */ - if (Is_Geometry()) { - if (Get_Geometry_Type() != that.Get_Geometry_Type()) return false; - if (GeometryFlags != that.GeometryFlags) return false; - if (CollisionFlags != that.CollisionFlags) return false; - } - - return true; -} - -bool W3DAppData2Struct::Geometry_Options_Match(const W3DAppData2Struct & that) -{ - if (Get_Geometry_Type() != that.Get_Geometry_Type()) return false; - if (GeometryFlags != that.GeometryFlags) return false; - if (CollisionFlags != that.CollisionFlags) return false; - return true; -} - - -W3DAppData2Struct * W3DAppData2Struct::Get_App_Data -( - INode * node, - bool create_if_missing -) -{ - /* - ** Try to get our AppData which has the export flags - */ - W3DAppData2Struct * wdata = NULL; - AppDataChunk * appdata = node->GetAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,W3D_APPDATA_2); - - /* - ** If there wasn't one, look for an AppData0 chunk and convert that. - ** If there was one, get the data from it - */ - if (appdata) { - - wdata = (W3DAppData2Struct *)(appdata->data); - wdata->Update_Version(); - - } else { - - /* - ** Create a new W3DAppData2Struct for this node - */ - wdata = (W3DAppData2Struct *)malloc(sizeof(W3DAppData2Struct)); - - /* - ** If we have the old AppData0 then initialize from it otherwise - ** just initialize to the defaults - */ - AppDataChunk * oldappdata = node->GetAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,W3D_APPDATA_0); - if (oldappdata) { - - /* - ** initializing from the old app data 0 chunk; - */ - wdata->Init_From_AppData0(*(W3DAppData0Struct*)(oldappdata->data)); - - /* - ** Destroy the old obsolete App Data 0 chunk - */ - node->RemoveAppDataChunk(W3DUtilityClassID, UTILITY_CLASS_ID, W3D_APPDATA_0); - - } else { - - /* - ** If this object looks like it is going to be a mesh, then default - ** it to have the mesh export flags (export its transform and the - ** triangle mesh). Otherwise use the default of completely ignoring it! - */ - if (Is_Max_Tri_Mesh(node)) { - wdata->Init_With_Mesh_Defaults(); - } else { - wdata->Init_With_Other_Defaults(); - } - - } - node->AddAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,2,sizeof(W3DAppData2Struct),wdata); - appdata = node->GetAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,2); - assert(appdata); - - } - - return wdata; -} - - -/*********************************************************************************************** -** -** W3DDazzleAppDataStruct Implementation -** -***********************************************************************************************/ -W3DDazzleAppDataStruct::W3DDazzleAppDataStruct(void) -{ - UnUsed[0] = 0; - UnUsed[1] = 0; - UnUsed[2] = 0; - UnUsed[3] = 0; - memset(DazzleType,0,sizeof(DazzleType)); - strcpy(DazzleType,"DEFAULT"); -} - - -W3DDazzleAppDataStruct * W3DDazzleAppDataStruct::Get_App_Data(INode * node,bool create_if_missing) -{ - /* - ** Try to get the existing AppData chunk - */ - W3DDazzleAppDataStruct * dazzledata = NULL; - AppDataChunk * appdata = node->GetAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,W3D_DAZZLE_APPDATA); - - if (appdata) { - - /* - ** Found it, get the pointer to the dazzle data - */ - dazzledata = (W3DDazzleAppDataStruct *)(appdata->data); - - } else if (create_if_missing) { - - /* - ** Create a new W3DDazzleAppDataStruct for this node - */ - dazzledata = new W3DDazzleAppDataStruct; - node->AddAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,W3D_DAZZLE_APPDATA,sizeof(W3DDazzleAppDataStruct),dazzledata); - - appdata = node->GetAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,W3D_DAZZLE_APPDATA); - assert(appdata); - } - return dazzledata; -} - - - - - -/*********************************************************************************************** -** -** Utility functions for reading the W3D options that are set for a given INode -** -***********************************************************************************************/ - -static int get_geometry_type(INode * node) -{ - assert(node != NULL); - return W3DAppData2Struct::Get_App_Data(node)->Get_Geometry_Type(); -} - -/*********************************************************************************************** - * Is_Bone -- check if a node is a "bone" * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -bool Is_Bone(INode * node) -{ - /* - ** regardless of the bits, skins should not have their transform exported. - */ - if (Is_Skin(node)) return false; - if (Is_Origin(node)) return false; - //if (Is_Proxy(*node)) return false; - else return (W3DAppData2Struct::Get_App_Data(node)->Is_Bone()); -} - -/*********************************************************************************************** - * Is_Geometry -- Check if an INode is marked for "geometry" export * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/13/98 GTH : Created. * - *=============================================================================================*/ -bool Is_Geometry(INode * node) -{ - return (W3DAppData2Struct::Get_App_Data(node)->Is_Geometry()); -} - -/*********************************************************************************************** - * Is_Mesh -- check if a node is a mesh * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -bool Is_Normal_Mesh(INode * node) -{ - if (!Is_Geometry(node)) return false; - if (Is_Skin(node)) return false; - if (Is_Proxy(*node)) return false; - return (get_geometry_type(node) == W3DAppData2Struct::GEO_TYPE_NORMAL_MESH); -} - - -/*********************************************************************************************** - * Is_Camera_Aligned_Mesh -- check if a node is to be a camera aligned mesh * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/5/98 GTH : Created. * - *=============================================================================================*/ -bool Is_Camera_Aligned_Mesh(INode * node) -{ - if (!Is_Geometry(node)) return false; - return (get_geometry_type(node) == W3DAppData2Struct::GEO_TYPE_CAMERA_ALIGNED); -} - -/*********************************************************************************************** - * Is_Camera_Oriented_Mesh -- check if a node is to be a camera oriented mesh * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/2/99 NH : Created. * - *=============================================================================================*/ -bool Is_Camera_Oriented_Mesh(INode * node) -{ - if (!Is_Geometry(node)) return false; - return (get_geometry_type(node) == W3DAppData2Struct::GEO_TYPE_CAMERA_ORIENTED); -} - -/*********************************************************************************************** - * Is_Collision_AABox -- check if a node is a collision box * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -bool Is_Collision_AABox(INode * node) -{ - if (!Is_Geometry(node)) return false; - return (get_geometry_type(node) == W3DAppData2Struct::GEO_TYPE_AABOX); -} - - -/*********************************************************************************************** - * Is_Collision_OBBox -- check if a node is a collision box * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/17/1998 GH : Created. * - *=============================================================================================*/ -bool Is_Collision_OBBox(INode * node) -{ - if (!Is_Geometry(node)) return false; - return (get_geometry_type(node) == W3DAppData2Struct::GEO_TYPE_OBBOX); -} - -/*********************************************************************************************** - * Is_Skin -- check if a node is a skin * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -bool Is_Skin(INode * node) -{ - if (!Is_Geometry(node)) return false; - if (get_geometry_type(node) != W3DAppData2Struct::GEO_TYPE_NORMAL_MESH) return false; - - for (int i = 0; i < node->NumRefs(); i++) { - - ReferenceTarget *refTarg = node->GetReference(i); - - if (refTarg != NULL && refTarg->ClassID() == Class_ID(WSM_DERIVOB_CLASS_ID,0)) { - - IDerivedObject * wsm_der_obj = (IDerivedObject *)refTarg; - //MessageBox(NULL, "WSM found", _T("WSM"), MB_OK); - - for (int j = 0; j < wsm_der_obj->NumModifiers(); j++) { - Modifier * mod = wsm_der_obj->GetModifier(j); - if (mod->ClassID() == SKIN_MOD_CLASS_ID) { - return true; - } - } - } - } - - return false; -} - -/*********************************************************************************************** - * Is_Shadow -- check if a node marked to cast shadows * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -bool Is_Shadow(INode * node) -{ - if (!Is_Geometry(node)) return false; - W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(node); - return (wdata->Is_Shadow_Enabled()); -} - -/*********************************************************************************************** - * Is_Null_Object -- check if a node is a null object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/26/1997 GH : Created. * - *=============================================================================================*/ -bool Is_Null_Object(INode * node) -{ - if (!Is_Geometry(node)) return false; - return (get_geometry_type(node) == W3DAppData2Struct::GEO_TYPE_NULL); -} - - -/*********************************************************************************************** - * Is_Dazzle -- check if a node is a dazzle object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 8/5/2000 gth : Created. * - *=============================================================================================*/ -bool Is_Dazzle(INode * node) -{ - if (!Is_Geometry(node)) return false; - return (get_geometry_type(node) == W3DAppData2Struct::GEO_TYPE_DAZZLE); -} - - -/*********************************************************************************************** - * Is_Aggregate -- check if a node is an aggregate object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/24/2000 gth : Created. * - *=============================================================================================*/ -bool Is_Aggregate(INode * node) -{ - if (!Is_Geometry(node)) return false; - return (get_geometry_type(node) == W3DAppData2Struct::GEO_TYPE_AGGREGATE); -} - -/*********************************************************************************************** - * Is_Physical_Collision -- Is node categorized as "physical collision geometry" * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/23/98 GTH : Created. * - *=============================================================================================*/ -bool Is_Physical_Collision(INode * node) -{ - W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(node); - return (wdata->Is_Physical_Collision_Enabled()); -} - - -/*********************************************************************************************** - * Is_Projectile_Collision -- Is node categorized as "projectile collision geometry"? * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/23/98 GTH : Created. * - *=============================================================================================*/ -bool Is_Projectile_Collision(INode * node) -{ - W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(node); - return (wdata->Is_Projectile_Collision_Enabled()); -} - - -/*********************************************************************************************** - * Is_Projectile_Collision -- Is node categorized as "vis collision geometry"? * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/23/98 GTH : Created. * - *=============================================================================================*/ -bool Is_Vis_Collision(INode * node) -{ - W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(node); - return (wdata->Is_Vis_Collision_Enabled()); -} - - -/*********************************************************************************************** - * Is_Camera_Collision -- Is node categorized as "camera collision geometry"? * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 8/4/2000 gth : Created. * - *=============================================================================================*/ -bool Is_Camera_Collision(INode * node) -{ - W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(node); - return (wdata->Is_Camera_Collision_Enabled()); -} - -/*********************************************************************************************** - * Is_Vehicle_Collision -- Is node categorized as "Vehicle collision geometry"? * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 8/4/2000 gth : Created. * - *=============================================================================================*/ -bool Is_Vehicle_Collision(INode * node) -{ - W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(node); - return (wdata->Is_Vehicle_Collision_Enabled()); -} - -/*********************************************************************************************** - * Is_Hidden -- checks whether the node should be hidden * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * This has nothing to do with its hidden status inside of max. Things hidden in max are * - * ignored by the exporter. (artist request way back...wierd huh?) * - * * - * HISTORY: * - * 11/18/98 GTH : Created. * - *=============================================================================================*/ -bool Is_Hidden(INode * node) -{ - W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(node); - return (wdata->Is_Hidden_Enabled()); -} - - -/*********************************************************************************************** - * Is_Two_Sided -- Checks whether the node should be two sided * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/18/98 GTH : Created. * - *=============================================================================================*/ -bool Is_Two_Sided(INode * node) -{ - W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(node); - return (wdata->Is_Two_Sided_Enabled()); -} - - -/*********************************************************************************************** - * Is_ZNormals -- checks if the node should be exported with 0,0,1 vert normals * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/9/99 GTH : Created. * - *=============================================================================================*/ -bool Is_ZNormals(INode * node) -{ - W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(node); - return (wdata->Is_ZNormals_Enabled()); -} - - -bool Is_Vertex_Alpha(INode * node) -{ - W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(node); - return (wdata->Is_Vertex_Alpha_Enabled()); -} - -bool Is_Shatterable(INode * node) -{ - W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(node); - return (wdata->Is_Shatterable_Enabled()); -} - -bool Is_NPatchable(INode * node) -{ - W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(node); - return (wdata->Is_NPatchable_Enabled()); -} - - - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/w3dappdata.h b/Generals/Code/Tools/WW3D/max2w3d/w3dappdata.h deleted file mode 100644 index 0fd852893ee..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/w3dappdata.h +++ /dev/null @@ -1,415 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/w3dappdata.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 8/21/01 9:44a $* - * * - * $Revision:: 8 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef W3DAPPDATA_H -#define W3DAPPDATA_H - -#include - -/* -** The W3DUtilityClass uses several app-data chunks to store user-options for INodes -** in the MAX scene. Below are the IDs for each app-data chunk type: -*/ - -#define W3D_APPDATA_0 0 -#define W3D_APPDATA_1 1 -#define W3D_APPDATA_2 2 -#define W3D_DAZZLE_APPDATA 3 - - -/* -** Classifying INodes for w3d exporting -** -** NOTE: Use these utility functions rather than going straight to the AppData -** structure! -** -** - There are bits stored in AppData for each node -** - These bits indicate wether something should be exported as hierarchy, -** geometry (and if so, what type of geometry: mesh, collision box, bitmap, etc) -** -** When we say something is "Hierarchy" that means its transform should be put -** into any hierarchy tree or motion being created. In some places I used -** the term "Bone" which means the same thing. -** -** When we say something is "Geometry" that means that the object will become -** some sort of render object (normal mesh, bitmap, collision mesh, etc) -** -*/ - -/* -** Either or both of these will return true for a given INode -*/ -bool Is_Bone(INode * node); -bool Is_Geometry(INode * node); - -/* -** Geometry Type: -** One of the following will return true if the given INode is -** to have its geometry exported -*/ -bool Is_Normal_Mesh(INode * node); -bool Is_Camera_Aligned_Mesh(INode * node); -bool Is_Camera_Oriented_Mesh(INode * node); -bool Is_Collision_AABox(INode * node); -bool Is_Collision_OBBox(INode * node); -bool Is_Skin(INode * node); -bool Is_Shadow(INode * node); -bool Is_Null_Object(INode * node); -bool Is_Dazzle(INode * node); -bool Is_Aggregate(INode * node); - -/* -** Collision Bits, any or all of these may return true for a given INode -*/ -bool Is_Physical_Collision(INode * node); -bool Is_Projectile_Collision(INode * node); -bool Is_Vis_Collision(INode * node); -bool Is_Camera_Collision(INode * node); -bool Is_Vehicle_Collision(INode * node); - -/* -** Miscellaneous settings -*/ -bool Is_Hidden(INode * node); -bool Is_Two_Sided(INode * node); -bool Is_ZNormals(INode * node); -bool Is_Vertex_Alpha(INode * node); -bool Is_Shatterable(INode * node); -bool Is_NPatchable(INode * node); - -/* -** Proxy support. If a node has a name which contains a ~ it is considered a -** proxy for an application defined named object. This overrides all other -** settings (in the future, we shouldn't do things this way!) -*/ -inline bool Is_Proxy(INode &node) -{ - return (::strchr (node.GetName (), '~') != NULL); -} - - - -/* -** AJA 9/24/99 -** NOTE: Whenever you add a new W3DAppDataStruct, you must add an accessor function -** to the bottom of this file. Then the WWScript.dlx project must be modified. That -** project implements an extension to the MAXScript language in the form of a function -** called "wwCopyAppData". The implementation of this wwCopyAppData function must be -** aware of the new W3DAppDataStruct. The modification is pretty straightfoward. -** -** The wwCopyAppData extension was added to MAXScript so that the data we define -** below can be preserve when a model is cloned (copy/instance/reference). What -** happens without using wwCopyAppData is that a new INode is created that contains -** a copy/instance/reference to the original mesh/bone in the source model. When -** this new INode is created, it has no app data. When the app data is examined later -** on, it gets the default values! That means all information concerning Export -** Geometry/Transform, mesh type, and damage region is lost. wwCopyAppData allows -** a script to duplicate a model INCLUDING all W3D app data, so that this information -** is preserved. -*/ - - -/* -** The W3DAppData0Struct contains a bitfield. These #defines are -** used to interpret the bits. -** (gth) NOTE: AppData0 is now OBSOLETE!!! Use W3DAppData2Struct now. -*/ -#define EXPORT_TYPE_MASK 0x000F -#define GEOMETRY_TYPE_MASK 0x01F0 -#define COLLISION_TYPE_MASK 0xF000 - -#define EXPORT_BONE_FLAG 0x0001 // export a bone (transform) for this node -#define EXPORT_GEOMETRY_FLAG 0x0002 // export the geometry for this node -#define EXPORT_HIDDEN_FLAG 0x0004 // mesh should be hidden by default -#define EXPORT_TWO_SIDED_FLAG 0x0008 // mesh should be two sided - -#define GEOMETRY_TYPE_CAMERA_ALIGNED 0x0010 // interpret this geometry as a camera-aligned mesh -#define GEOMETRY_TYPE_NORMAL_MESH 0x0020 // this is a normal mesh -#define GEOMETRY_TYPE_OBBOX 0x0030 // this is an oriented box (should have 8 verts, etc) -#define GEOMETRY_TYPE_AABOX 0x0040 // this is an axis aligned box -#define GEOMETRY_TYPE_CAMERA_ORIENTED 0x0050 // interpret this geometry as a camera-oriented mesh -#define GEOMETRY_TYPE_NULL 0x0100 // this is a null (for LOD) - -#define EXPORT_CAST_SHADOW_FLAG 0x0200 // this mesh casts a shadow -#define EXPORT_VERTEX_ALPHA_FLAG 0x0400 // convert vertex colors to alpha -#define EXPORT_ZNORMALS_FLAG 0x0800 // force vertex normals to point along +z - -#define COLLISION_TYPE_PHYSICAL 0x1000 // runtime engine performs physical collision against this mesh -#define COLLISION_TYPE_PROJECTILE 0x2000 // perform projectile collisions against this mesh -#define COLLISION_TYPE_VIS 0x4000 // perform vis group collisions against this mesh - -#define DEFAULT_MESH_EXPORT_FLAGS (EXPORT_BONE_FLAG | EXPORT_GEOMETRY_FLAG | GEOMETRY_TYPE_NORMAL_MESH) -#define DEFAULT_EXPORT_FLAGS 0 - - -/* -** W3D Utility AppData sub-type 0 (OBSOLETE!) -** ---------------------------------------------------- -** The utility provides a right-click menu which allows -** the user to toggle the export flags. -** (gth) NOTE: AppData0 is now OBSOLETE!!! Use W3DAppData2Struct now. -*/ -struct W3DAppData0Struct -{ - W3DAppData0Struct(void) : ExportFlags(DEFAULT_EXPORT_FLAGS) {} - - bool Is_Bone(void) { return (ExportFlags & EXPORT_BONE_FLAG) == EXPORT_BONE_FLAG; } - bool Is_Geometry(void) { return (ExportFlags & EXPORT_GEOMETRY_FLAG) == EXPORT_GEOMETRY_FLAG; } - - bool Is_Normal_Mesh(void) { return (ExportFlags & GEOMETRY_TYPE_MASK) == GEOMETRY_TYPE_NORMAL_MESH; } - bool Is_Camera_Aligned_Mesh(void) { return (ExportFlags & GEOMETRY_TYPE_MASK) == GEOMETRY_TYPE_CAMERA_ALIGNED; } - bool Is_Camera_Oriented_Mesh(void) { return (ExportFlags & GEOMETRY_TYPE_MASK) == GEOMETRY_TYPE_CAMERA_ORIENTED; } - bool Is_Collision_AABox(void) { return (ExportFlags & GEOMETRY_TYPE_MASK) == GEOMETRY_TYPE_AABOX; } - bool Is_Collision_OBBox(void) { return (ExportFlags & GEOMETRY_TYPE_MASK) == GEOMETRY_TYPE_OBBOX; } - bool Is_Null(void) { return (ExportFlags & GEOMETRY_TYPE_MASK) == GEOMETRY_TYPE_NULL; } - - bool Is_Physical_Collision(void) { return (ExportFlags & COLLISION_TYPE_PHYSICAL) == COLLISION_TYPE_PHYSICAL; } - bool Is_Projectile_Collision(void) { return (ExportFlags & COLLISION_TYPE_PROJECTILE) == COLLISION_TYPE_PROJECTILE; } - bool Is_Vis_Collision(void) { return (ExportFlags & COLLISION_TYPE_VIS) == COLLISION_TYPE_VIS; } - - bool Is_Hidden(void) { return (ExportFlags & EXPORT_HIDDEN_FLAG) == EXPORT_HIDDEN_FLAG; } - bool Is_Two_Sided(void) { return (ExportFlags & EXPORT_TWO_SIDED_FLAG) == EXPORT_TWO_SIDED_FLAG; } - bool Is_Vertex_Alpha(void) { return (ExportFlags & EXPORT_VERTEX_ALPHA_FLAG) == EXPORT_VERTEX_ALPHA_FLAG; } - bool Is_ZNormals(void) { return (ExportFlags & EXPORT_ZNORMALS_FLAG) == EXPORT_ZNORMALS_FLAG; } - bool Is_Shadow(void) { return (ExportFlags & EXPORT_CAST_SHADOW_FLAG) == EXPORT_CAST_SHADOW_FLAG; } - - unsigned short ExportFlags; // what was I thinking??? (gth) -}; - - - -/* -** W3D Utility AppData sub-type 1 -** ---------------------------------------------------- -** This AppData contains the damage region number for -** the current object. -*/ - -// Maximum number of damage regions on a model. -#define MAX_DAMAGE_REGIONS ((char)16) -// Value that represents no damage region. -#define NO_DAMAGE_REGION ((char)-1) - -struct W3DAppData1Struct -{ - W3DAppData1Struct(void) : DamageRegion(NO_DAMAGE_REGION) { } - - /* - ** NO_DAMAGE_REGION means the object isn't part of - ** any damage region, 0 through MAX_DAMAGE_REGIONS-1 - ** are valid damage regions. - */ - char DamageRegion; -}; - - - -/* -** W3D Utility AppData sub-type 2 -** ---------------------------------------------------- -** This is an app-data struct that is meant to contain all -** of the w3d export options for an object in MAX. It -** replaces the old AppData sub-type 0. Call the static -** member functions in the class to get a pointer to -** the AppData2 struct hanging off any INode and automatically -** create one for you if there isn't already one... -*/ - -struct W3DAppData2Struct -{ - W3DAppData2Struct(void); - W3DAppData2Struct(W3DAppData0Struct & olddata); - - void Init_With_Mesh_Defaults(void); - void Init_With_Other_Defaults(void); - void Init_From_AppData0(W3DAppData0Struct & olddata); - void Update_Version(void); - - enum GeometryTypeEnum - { - GEO_TYPE_CAMERA_ALIGNED = 0x00000001, // Geometry types are mutually exclusive - GEO_TYPE_NORMAL_MESH = 0x00000002, - GEO_TYPE_OBBOX = 0x00000003, - GEO_TYPE_AABOX = 0x00000004, - GEO_TYPE_CAMERA_ORIENTED = 0x00000005, - GEO_TYPE_NULL = 0x00000006, - GEO_TYPE_DAZZLE = 0x00000007, - GEO_TYPE_AGGREGATE = 0x00000008, - }; - - /* - ** Read Access - */ - bool Is_Bone(void) const { return (ExportFlags & EXPORT_TRANSFORM) == EXPORT_TRANSFORM; } - bool Is_Geometry(void) const { return (ExportFlags & EXPORT_GEOMETRY) == EXPORT_GEOMETRY; } - - int Get_Geometry_Type(void) const { return GeometryType; } - bool Is_Normal_Mesh(void) const { return GeometryType == GEO_TYPE_NORMAL_MESH; } - bool Is_Camera_Aligned_Mesh(void) const { return GeometryType == GEO_TYPE_CAMERA_ALIGNED; } - bool Is_Camera_Oriented_Mesh(void) const { return GeometryType == GEO_TYPE_CAMERA_ORIENTED; } - bool Is_Collision_AABox(void) const { return GeometryType == GEO_TYPE_AABOX; } - bool Is_Collision_OBBox(void) const { return GeometryType == GEO_TYPE_OBBOX; } - bool Is_Null(void) const { return GeometryType == GEO_TYPE_NULL; } - bool Is_Dazzle(void) const { return GeometryType == GEO_TYPE_DAZZLE; } - - bool Is_Hidden_Enabled(void) const { return (GeometryFlags & GEOMETRY_FLAG_HIDDEN) == GEOMETRY_FLAG_HIDDEN; } - bool Is_Two_Sided_Enabled(void) const { return (GeometryFlags & GEOMETRY_FLAG_TWO_SIDED) == GEOMETRY_FLAG_TWO_SIDED; } - bool Is_Vertex_Alpha_Enabled(void) const { return (GeometryFlags & GEOMETRY_FLAG_VERTEX_ALPHA) == GEOMETRY_FLAG_VERTEX_ALPHA; } - bool Is_ZNormals_Enabled(void) const { return (GeometryFlags & GEOMETRY_FLAG_ZNORMALS) == GEOMETRY_FLAG_ZNORMALS; } - bool Is_Shadow_Enabled(void) const { return (GeometryFlags & GEOMETRY_FLAG_CAST_SHADOW) == GEOMETRY_FLAG_CAST_SHADOW; } - bool Is_Shatterable_Enabled(void) const { return (GeometryFlags & GEOMETRY_FLAG_SHATTERABLE) == GEOMETRY_FLAG_SHATTERABLE; } - bool Is_NPatchable_Enabled(void) const { return (GeometryFlags & GEOMETRY_FLAG_NPATCHABLE) == GEOMETRY_FLAG_NPATCHABLE; } - - bool Is_Physical_Collision_Enabled(void) const { return (CollisionFlags & COLLISION_FLAG_PHYSICAL) == COLLISION_FLAG_PHYSICAL; } - bool Is_Projectile_Collision_Enabled(void) const { return (CollisionFlags & COLLISION_FLAG_PROJECTILE) == COLLISION_FLAG_PROJECTILE; } - bool Is_Vis_Collision_Enabled(void) const { return (CollisionFlags & COLLISION_FLAG_VIS) == COLLISION_FLAG_VIS; } - bool Is_Camera_Collision_Enabled(void) const { return (CollisionFlags & COLLISION_FLAG_CAMERA) == COLLISION_FLAG_CAMERA; } - bool Is_Vehicle_Collision_Enabled(void) const { return (CollisionFlags & COLLISION_FLAG_VEHICLE) == COLLISION_FLAG_VEHICLE; } - - /* - ** Write Access - */ - void Enable_Export_Transform(bool onoff) { if (onoff) { ExportFlags |= EXPORT_TRANSFORM; } else { ExportFlags &= ~EXPORT_TRANSFORM; } } - void Enable_Export_Geometry(bool onoff) { if (onoff) { ExportFlags |= EXPORT_GEOMETRY; } else { ExportFlags &= ~EXPORT_GEOMETRY; } } - - void Set_Geometry_Type(GeometryTypeEnum type) { GeometryType = (unsigned int)type; } - - void Enable_Hidden(bool onoff) { if (onoff) { GeometryFlags |= GEOMETRY_FLAG_HIDDEN; } else { GeometryFlags &= ~GEOMETRY_FLAG_HIDDEN; } } - void Enable_Two_Sided(bool onoff) { if (onoff) { GeometryFlags |= GEOMETRY_FLAG_TWO_SIDED; } else { GeometryFlags &= ~GEOMETRY_FLAG_TWO_SIDED; } } - void Enable_Shadow(bool onoff) { if (onoff) { GeometryFlags |= GEOMETRY_FLAG_CAST_SHADOW; } else { GeometryFlags &= ~GEOMETRY_FLAG_CAST_SHADOW; } } - void Enable_Vertex_Alpha(bool onoff) { if (onoff) { GeometryFlags |= GEOMETRY_FLAG_VERTEX_ALPHA; } else { GeometryFlags &= ~GEOMETRY_FLAG_VERTEX_ALPHA; } } - void Enable_ZNormals(bool onoff) { if (onoff) { GeometryFlags |= GEOMETRY_FLAG_ZNORMALS; } else { GeometryFlags &= ~GEOMETRY_FLAG_ZNORMALS; } } - void Enable_Shatterable(bool onoff) { if (onoff) { GeometryFlags |= GEOMETRY_FLAG_SHATTERABLE; } else { GeometryFlags &= ~GEOMETRY_FLAG_SHATTERABLE; } } - void Enable_NPatchable(bool onoff) { if (onoff) { GeometryFlags |= GEOMETRY_FLAG_NPATCHABLE; } else { GeometryFlags &= ~GEOMETRY_FLAG_NPATCHABLE; } } - - void Enable_Physical_Collision(bool onoff) { if (onoff) { CollisionFlags |= COLLISION_FLAG_PHYSICAL; } else { CollisionFlags &= ~COLLISION_FLAG_PHYSICAL; } } - void Enable_Projectile_Collision(bool onoff) { if (onoff) { CollisionFlags |= COLLISION_FLAG_PROJECTILE; } else { CollisionFlags &= ~COLLISION_FLAG_PROJECTILE; } } - void Enable_Vis_Collision(bool onoff) { if (onoff) { CollisionFlags |= COLLISION_FLAG_VIS; } else { CollisionFlags &= ~COLLISION_FLAG_VIS; } } - void Enable_Camera_Collision(bool onoff) { if (onoff) { CollisionFlags |= COLLISION_FLAG_CAMERA; } else { CollisionFlags &= ~COLLISION_FLAG_CAMERA; } } - void Enable_Vehicle_Collision(bool onoff) { if (onoff) { CollisionFlags |= COLLISION_FLAG_VEHICLE; } else { CollisionFlags &= ~COLLISION_FLAG_VEHICLE; } } - - /* - ** Comparison - */ - bool operator == (const W3DAppData2Struct & that); - bool operator != (const W3DAppData2Struct & that) { return !(*this == that); } - bool Geometry_Options_Match(const W3DAppData2Struct & that); - - /* - ** Get the W3DAppData2Struct for a given INode and create one if - ** there isn't already one. - */ - static W3DAppData2Struct * Get_App_Data(INode * node,bool create_if_missing = true); - -protected: - - void Set_Version(int ver) { ExportFlags &= ~VERSION_MASK; ExportFlags |= (ver<>VERSION_SHIFT; } - - enum ExportFlagsEnum - { - EXPORT_TRANSFORM = 0x00000001, // Export flags bit-field - EXPORT_GEOMETRY = 0x00000002, - - VERSION_MASK = 0xFFFF0000, // upper 16bits is version number. - VERSION_SHIFT = 16, - }; - - enum GeometryFlagsEnum - { - GEOMETRY_FLAG_HIDDEN = 0x00000001, // Geometry Flags bitfield - GEOMETRY_FLAG_TWO_SIDED = 0x00000002, - GEOMETRY_FLAG_CAST_SHADOW = 0x00000004, - GEOMETRY_FLAG_VERTEX_ALPHA = 0x00000008, - GEOMETRY_FLAG_ZNORMALS = 0x00000010, - GEOMETRY_FLAG_SHATTERABLE = 0x00000020, - GEOMETRY_FLAG_NPATCHABLE = 0x00000040, - }; - - enum CollisionFlagsEnum - { - COLLISION_FLAG_PHYSICAL = 0x00000001, - COLLISION_FLAG_PROJECTILE = 0x00000002, - COLLISION_FLAG_VIS = 0x00000004, - COLLISION_FLAG_CAMERA = 0x00000008, - COLLISION_FLAG_VEHICLE = 0x00000010, - }; - - unsigned int ExportFlags; - unsigned int GeometryType; - unsigned int GeometryFlags; - unsigned int CollisionFlags; - - // future expansion, initialized to zeros - unsigned int UnUsed[4]; -}; - - - -/* -** W3D Utility Dazzle App Data -** ---------------------------------------------------- -** This app-data struct is used to contain parameters -** specific to dazzle render objects. It currently only -** contains a type name which is limited to 128 characters -** and some padding variables for future use. -*/ - -struct W3DDazzleAppDataStruct -{ - /* - ** Constructor, zeros everything, then initializes DazzleType to "DEFAULT" - */ - W3DDazzleAppDataStruct(void); - - /* - ** Get the W3DAppData2Struct for a given INode and create one if - ** there isn't already one. - */ - static W3DDazzleAppDataStruct * Get_App_Data(INode * node,bool create_if_missing = true); - - /* - ** Members - */ - unsigned int UnUsed[4]; - char DazzleType[128]; -}; - - -#endif - diff --git a/Generals/Code/Tools/WW3D/max2w3d/w3ddesc.cpp b/Generals/Code/Tools/WW3D/max2w3d/w3ddesc.cpp deleted file mode 100644 index 860c8b58560..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/w3ddesc.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/w3ddesc.cpp 3 3/04/99 1:58p Naty_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/w3ddesc.cpp $* - * * - * $Author:: Naty_h $* - * * - * $Modtime:: 3/03/99 11:29a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - -#include "w3ddesc.h" -#include "w3dexp.h" -#include "dllmain.h" - -/*********************************************************************************************** - * W3dClassDesc::Create -- Creates a W3dExportClass object * - * * - * MAX calls this method when it needs a pointer to a new instance of the plug-in class. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -void * W3dClassDesc::Create(BOOL) -{ - return new W3dExportClass; -} - -/*********************************************************************************************** - * W3dClassDesc::IsPublic -- Controls if the plug-in shows up in lists from the user to choose * - * * - * Controls if the plug-in shows up in lists from the user to choose from. * - * * - * INPUT: none * - * * - * OUTPUT: true! * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -int W3dClassDesc::IsPublic() -{ - return 1; -} - -/*********************************************************************************************** - * W3dClassDesc::ClassName -- returns the name of the class * - * * - * This method returns the name of the class. This name appears in the button for the * - * plug-in in the MAX user interface. * - * * - * INPUT: none * - * * - * OUTPUT: Name of the class * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -const TCHAR * W3dClassDesc::ClassName() -{ - return Get_String(IDS_W3D_SHORT_DESCRIPTION); -} - -/*********************************************************************************************** - * W3dClassDesc::SuperClassID -- returns the SuperClassID of the plug-in. * - * * - * INPUT: none * - * * - * OUTPUT: The SuperClassID of the plug-in. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -SClass_ID W3dClassDesc::SuperClassID() -{ - return SCENE_EXPORT_CLASS_ID; -} - -/*********************************************************************************************** - * W3dClassDesc::ClassID -- Returns the class ID * - * * - * This method must return the unique ID for the object. If two ClassIDs conflict, the * - * system will only load the first one it finds. The ClassID consists of two unsigned 32-bit * - * quantities. * - * * - * INPUT: none * - * * - * OUTPUT: The unique ClassID of the plug-in. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -Class_ID W3dClassDesc::ClassID() -{ - return W3D_EXPORTER_CLASS_ID; -} - -/*********************************************************************************************** - * W3dClassDesc::Category -- returns a string describing the category a plug-in fits into * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -const TCHAR * W3dClassDesc::Category() -{ - return Get_String(IDS_SCENE_EXPORT); -} - diff --git a/Generals/Code/Tools/WW3D/max2w3d/w3ddesc.h b/Generals/Code/Tools/WW3D/max2w3d/w3ddesc.h deleted file mode 100644 index 868cec24ac0..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/w3ddesc.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/w3ddesc.h 3 3/04/99 1:57p Naty_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/w3ddesc.h $* - * * - * $Author:: Naty_h $* - * * - * $Modtime:: 3/03/99 11:28a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef W3DDESC_H -#define W3DDESC_H - -#include "always.h" -#include - -/***************************************************************************** -* -* Class descriptors provide the system with information about the plug-in -* classes in the DLL. -* -*****************************************************************************/ -#define W3D_EXPORTER_CLASS_ID Class_ID(0x54d412df, 0x41466ae8) - -class W3dClassDesc : public ClassDesc -{ -public: - void * Create(BOOL); - int IsPublic(); - const TCHAR * ClassName(); - SClass_ID SuperClassID(); - Class_ID ClassID(); - const TCHAR * Category(); -}; - - -#endif \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/w3ddlg.cpp b/Generals/Code/Tools/WW3D/max2w3d/w3ddlg.cpp deleted file mode 100644 index 16feee0ead6..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/w3ddlg.cpp +++ /dev/null @@ -1,822 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/w3ddlg.cpp 24 11/07/00 5:40p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/w3ddlg.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 11/07/00 4:39p $* - * * - * $Revision:: 24 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "w3ddlg.h" -#include "resource.h" -#include "dllmain.h" -#include "w3dexp.h" -#include "util.h" -#include "rawfile.h" -#include -#include "units.h" -#include "presetexportoptionsdialog.h" - - -#define ENABLE_MESH_OPTIMIZING 0 - -/* -** Static functions -*/ -static BOOL CALLBACK _options_dialog_proc(HWND Hwnd,UINT message,WPARAM wParam,LPARAM lParam); -static void _init_ofn(void); - -/* -** Static data -*/ -static bool _OfnInited = false; -static OPENFILENAME _HierarchyFileOFN; - - -/*********************************************************************************************** - * W3dOptionsDialogClass::W3dOptionsDialogClass -- constructor for the options dialog object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/24/1997 GH : Created. * - *=============================================================================================*/ -W3dOptionsDialogClass::W3dOptionsDialogClass(Interface * maxinterface,ExpInterface * exportinterface) -{ - MaxInterface = maxinterface; - ExportInterface = exportinterface; - if (!_OfnInited) _init_ofn(); - GotHierarchyFilename = false; - - RangeLowSpin = NULL; - RangeHighSpin = NULL; - - GetMasterUnitInfo(&UnitsType, &UnitsScale); -} - -W3dOptionsDialogClass::~W3dOptionsDialogClass(void) -{ - ReleaseISpinner(RangeLowSpin); - ReleaseISpinner(RangeHighSpin); -} - -bool W3dOptionsDialogClass::Get_Export_Options(W3dExportOptionsStruct * options) -{ - Options = options; - - // Put up the options dialog box. - /*BOOL result = DialogBoxParam - ( - AppInstance, - MAKEINTRESOURCE (IDD_W3D_EXPORT_OPTIONS), - MaxInterface->GetMAXHWnd(), - (DLGPROC) _options_dialog_proc, - (LPARAM) this - );*/ - - PresetExportOptionsDialogClass dialog (MaxInterface, MaxInterface->GetMAXHWnd ()); - - dialog.Set_Options (Options); - int result = dialog.Do_Modal (); - - if (result == IDOK) { - return true; - } else { - return false; - } -} - - -/*********************************************************************************************** - * W3dOptionsDialogClass::Dialog_Proc -- Handles the windows message for the options dialog * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/24/1997 GH : Created. * - *=============================================================================================*/ -bool W3dOptionsDialogClass::Dialog_Proc -( - HWND hwnd, - UINT message, - WPARAM wParam, - LPARAM -) -{ - int code = HIWORD(wParam); - - switch (message ) { - - /******************************************************************* - * WM_INITDIALOG - * - * Initialize all of the custom controls for the dialog box - * - *******************************************************************/ - case WM_INITDIALOG: - - Dialog_Init(); - return 1; - - - /******************************************************************* - * WM_COMMAND - * - * - *******************************************************************/ - case WM_COMMAND: - - switch (LOWORD(wParam)) - { - case IDOK: - - if (Dialog_Ok() == FALSE) { - MessageBox(Hwnd,"You have not supplied a Base Pose hierarchy file!","Error",MB_OK); - return 1; - } - - SetCursor(LoadCursor (NULL, IDC_WAIT)); - EndDialog(Hwnd, 1); - break; - - case IDCANCEL: - EndDialog(Hwnd, 0); - break; - - case IDC_WHT_EXPORT_RADIO: - case IDC_WHT_LOAD_RADIO: - case IDC_WHT_NO_EXPORT_RADIO: - WHT_Export_Radio_Changed(); - break; - - case IDC_WHA_EXPORT_RADIO: - case IDC_WHA_NO_EXPORT_RADIO: - WHA_Export_Radio_Changed(); - break; - - case IDC_WTM_EXPORT_RADIO: - case IDC_WTM_NO_EXPORT_RADIO: - WTM_Export_Radio_Changed(); - break; - - case IDC_COMPRESS_ANIMATION_CHECK: - WHA_Compress_Animation_Check_Changed(); - break; - - case IDC_REDUCE_ANIMATION_CHECK: - WHA_Reduce_Animation_Check_Changed(); - break; - - case IDC_COMPRESS_ANIMATION_FLAVOR_COMBO: - WHA_Compression_Flavor_Changed(); - break; - - case IDC_WHT_BROWSE_BUTTON: - - // use the open file common dialog to get a hierarchy filename. - _HierarchyFileOFN.hwndOwner = Hwnd; - _HierarchyFileOFN.lpstrFileTitle = NULL; - _HierarchyFileOFN.lpstrFile = Options->HierarchyFilename; - - if (GetOpenFileName(&_HierarchyFileOFN)) { - - // Get the relative path between the current export path - // and the full file path to the hierarchy file: - Create_Relative_Path(Options->RelativeHierarchyFilename, - W3dExportClass::CurrentExportPath, - _HierarchyFileOFN.lpstrFile); - - // set window text to the relative path. - HWND butHwnd = GetDlgItem(hwnd,IDC_WHT_BROWSE_BUTTON); - if (Options->RelativeHierarchyFilename[0] != 0) { - SetWindowText(butHwnd, Options->RelativeHierarchyFilename); - } else { - SetWindowText(butHwnd, Options->HierarchyFilename); - } - GotHierarchyFilename = true; - - SetSaveRequiredFlag(true); - } - - _HierarchyFileOFN.lpstrFile = NULL; - break; - } - return 1; - - /******************************************************************* - * CC_SPINNER_CHANGE - * - * Max custom spinner controls - * - *******************************************************************/ - case CC_SPINNER_CHANGE: - - switch (LOWORD(wParam)) - { - case IDC_RANGE_LOW_SPIN: - if (RangeLowSpin->GetIVal() > RangeHighSpin->GetIVal()) - { - RangeHighSpin->SetValue (RangeLowSpin->GetIVal(),FALSE); - } - break; - - case IDC_RANGE_HIGH_SPIN: - if (RangeHighSpin->GetIVal() < RangeLowSpin->GetIVal()) - { - RangeLowSpin->SetValue(RangeHighSpin->GetIVal(),FALSE); - } - break; - - } - - } - return 0; -} - -void W3dOptionsDialogClass::Dialog_Init() -{ - CenterWindow(Hwnd, GetParent(Hwnd)); - SetCursor(LoadCursor (NULL, IDC_ARROW)); - - // initialize the export radio buttons - if (Options->ExportHierarchy) { - CheckDlgButton(Hwnd,IDC_WHT_EXPORT_RADIO,BST_CHECKED); - Enable_WHT_Export(); - } else { - if (Options->LoadHierarchy) { - CheckDlgButton(Hwnd,IDC_WHT_LOAD_RADIO,BST_CHECKED); - Enable_WHT_Load(); - - // If the relative path is a full path, just erase both paths - // This case happens with files which were exported using a previous, - // bugged version of the exporter which did not handle files on - // different drives correctly. - if (Is_Full_Path(Options->RelativeHierarchyFilename)) { - Options->RelativeHierarchyFilename[0] = 0; - Options->HierarchyFilename[0] = 0; - } - - // Honor the relative path if it is present - if (Options->RelativeHierarchyFilename[0] != 0) - { - - HWND butHwnd = GetDlgItem(Hwnd,IDC_WHT_BROWSE_BUTTON); - SetWindowText(butHwnd, Options->RelativeHierarchyFilename); - Create_Full_Path(Options->HierarchyFilename, - W3dExportClass::CurrentExportPath, - Options->RelativeHierarchyFilename); - GotHierarchyFilename = true; - - } else if (Options->HierarchyFilename[0] != 0) { - - HWND butHwnd = GetDlgItem(Hwnd,IDC_WHT_BROWSE_BUTTON); - SetWindowText(butHwnd, Options->HierarchyFilename); - GotHierarchyFilename = true; - - } - - } else { - CheckDlgButton(Hwnd,IDC_WHT_NO_EXPORT_RADIO,BST_CHECKED); - Disable_WHT_Export(); - } - } - - if (Options->ExportGeometry) { - CheckDlgButton(Hwnd,IDC_WTM_EXPORT_RADIO,BST_CHECKED); - Enable_WTM_Export(); - } else { - CheckDlgButton(Hwnd,IDC_WTM_NO_EXPORT_RADIO,BST_CHECKED); - Disable_WTM_Export(); - } - - if (Options->SmoothBetweenMeshes && Options->ExportGeometry) { - CheckDlgButton(Hwnd,IDC_EXPORT_MESH_SMOOTH_CHECK,BST_CHECKED); - } else { - CheckDlgButton(Hwnd,IDC_EXPORT_MESH_SMOOTH_CHECK,BST_UNCHECKED); - } - - SetCheckBox(Hwnd, IDC_TRANSLATION_ONLY_CHECK, Options->TranslationOnly); - SetCheckBox(Hwnd, IDC_TERRAIN_MODE_CHECK, Options->EnableTerrainMode); - - // Initialize additional Animation Options - - SetCheckBox(Hwnd, IDC_COMPRESS_ANIMATION_CHECK, Options->CompressAnimation); - SetCheckBox(Hwnd, IDC_REDUCE_ANIMATION_CHECK , Options->ReduceAnimation); - SetCheckBox(Hwnd, IDC_VIEWLOG_CHECK, Options->ReviewLog); - - char string[128]; // temp string buffer - - sprintf(string, "Current FPS: %d", GetFrameRate()); - - SetDlgItemText(Hwnd, IDC_ANIMATION_FPS_STATIC, string); - - - // initialize animation combo/list boxes - - HwndReduce = GetDlgItem(Hwnd, IDC_REDUCE_ANIMATION_COMBO); - HwndFlavor = GetDlgItem(Hwnd, IDC_COMPRESS_ANIMATION_FLAVOR_COMBO); - - ComboBox_ResetContent(HwndReduce); - ComboBox_ResetContent(HwndFlavor); - - for (int i=1; i<100; i++) { - sprintf(string, "%d", i); - ComboBox_AddString(HwndReduce, string); - } - - ComboBox_AddString(HwndFlavor, "TimeCoded"); - ComboBox_AddString(HwndFlavor, "Adaptive Delta"); - - - if ((Options->ReduceAnimationPercent < 1) || (Options->ReduceAnimationPercent > 99)) { - Options->ReduceAnimationPercent = 50; - - } - - if ((Options->CompressAnimationFlavor < 0) || (Options->CompressAnimationFlavor >= ANIM_FLAVOR_VALID)) { - Options->CompressAnimationFlavor = 0; - } - - ComboBox_SetCurSel(HwndReduce, Options->ReduceAnimationPercent-1); - ComboBox_SetCurSel(HwndFlavor, Options->CompressAnimationFlavor); - - - HwndTError = GetDlgItem(Hwnd, IDC_MAX_TRANS_ERROR_EDIT); - HwndRError = GetDlgItem(Hwnd, IDC_MAX_ROT_ERROR_EDIT); - - sprintf(string, "%f", Options->CompressAnimationTranslationError); - Edit_SetText(HwndTError, string); - - sprintf(string, "%f", Options->CompressAnimationRotationError); - Edit_SetText(HwndRError, string); - - - // Make sure everything under animations is properly active/inactive - - WHA_Compress_Animation_Check_Changed(); - - if (Options->ExportAnimation) { - CheckDlgButton(Hwnd,IDC_WHA_EXPORT_RADIO,BST_CHECKED); - Enable_WHA_Export(); - } else { - CheckDlgButton(Hwnd,IDC_WHA_NO_EXPORT_RADIO,BST_CHECKED); - Disable_WHA_Export(); - } - - - // initialize the frame-range spinners - int ticksperframe = GetTicksPerFrame(); - int startframe = MaxInterface->GetAnimRange().Start() / ticksperframe; - int endframe = MaxInterface->GetAnimRange().End() / ticksperframe; - - RangeLowSpin = SetupIntSpinner - ( - Hwnd, - IDC_RANGE_LOW_SPIN, - IDC_RANGE_LOW_EDIT, - startframe, - endframe, - Options->StartFrame - ); - - RangeHighSpin = SetupIntSpinner - ( - Hwnd, - IDC_RANGE_HIGH_SPIN, - IDC_RANGE_HIGH_EDIT, - startframe, - endframe, - Options->EndFrame - ); - - // initialize the 'DisableExportAABTrees' option - CheckDlgButton(Hwnd,IDC_EXPORT_MESH_AABTREES,!Options->DisableExportAABTrees); - - CheckDlgButton(Hwnd,IDC_EXPORT_MESH_MAT_TO_TEXTURE,Options->EnableMaterialColorToTextureConversion); - -#if ENABLE_MESH_OPTIMIZING - CheckDlgButton(Hwnd,IDC_EXPORT_MESH_OPTIMIZE,Options->EnableOptimizeMeshData); -#endif -} - -BOOL W3dOptionsDialogClass::Dialog_Ok() -{ - bool changed = false; - - // export options: - bool export_h = (IsDlgButtonChecked(Hwnd,IDC_WHT_EXPORT_RADIO) == BST_CHECKED); - changed = changed || (Options->ExportHierarchy != export_h); - Options->ExportHierarchy = export_h; - - bool load_h = (IsDlgButtonChecked(Hwnd,IDC_WHT_LOAD_RADIO) == BST_CHECKED); - changed = changed || (Options->LoadHierarchy != load_h); - Options->LoadHierarchy = load_h; - - bool export_a = (IsDlgButtonChecked(Hwnd,IDC_WHA_EXPORT_RADIO) == BST_CHECKED); - changed = changed || (Options->ExportAnimation != export_a); - Options->ExportAnimation = export_a; - - bool export_g = (IsDlgButtonChecked(Hwnd,IDC_WTM_EXPORT_RADIO) == BST_CHECKED); - changed = changed || (Options->ExportGeometry != export_g); - Options->ExportGeometry = export_g; - - if (export_g) { - bool smooth_meshes = (IsDlgButtonChecked(Hwnd,IDC_EXPORT_MESH_SMOOTH_CHECK) == BST_CHECKED); - changed = changed || (Options->SmoothBetweenMeshes != smooth_meshes); - Options->SmoothBetweenMeshes = smooth_meshes; - - bool disable_export_aabs = (IsDlgButtonChecked(Hwnd,IDC_EXPORT_MESH_AABTREES) != BST_CHECKED); - changed = changed || (Options->DisableExportAABTrees != disable_export_aabs); - Options->DisableExportAABTrees = disable_export_aabs; - - bool convert_materials = (IsDlgButtonChecked(Hwnd,IDC_EXPORT_MESH_MAT_TO_TEXTURE) == BST_CHECKED); - changed = changed || (Options->EnableMaterialColorToTextureConversion != convert_materials); - Options->EnableMaterialColorToTextureConversion = convert_materials; - -#if ENABLE_MESH_OPTIMIZING - bool optimize_mesh_data = (IsDlgButtonChecked(Hwnd,IDC_EXPORT_MESH_OPTIMIZE) == BST_CHECKED); - changed = changed || (Options->EnableOptimizeMeshData != optimize_mesh_data); - Options->EnableOptimizeMeshData = optimize_mesh_data; -#else - Options->EnableOptimizeMeshData = false; -#endif - - } else { - Options->SmoothBetweenMeshes = false; - Options->DisableExportAABTrees = false; - Options->EnableOptimizeMeshData = false; - Options->EnableMaterialColorToTextureConversion = false; - } - - // Hierarchy Options: - bool xlation_only = (IsDlgButtonChecked(Hwnd,IDC_TRANSLATION_ONLY_CHECK) == BST_CHECKED); - changed = changed || (Options->TranslationOnly != xlation_only); - Options->TranslationOnly = xlation_only; - - bool terrain_mode = (IsDlgButtonChecked(Hwnd,IDC_TERRAIN_MODE_CHECK) == BST_CHECKED); - changed = changed || (Options->EnableTerrainMode != terrain_mode); - Options->EnableTerrainMode = terrain_mode; - - if (Options->LoadHierarchy && (Options->ExportAnimation || Options->ExportGeometry)) { - if (!GotHierarchyFilename) { - MessageBox(Hwnd,"You have not supplied a Base Pose hierarchy file!","Error",MB_OK); - if (changed) SetSaveRequiredFlag(true); - return FALSE; - } - - RawFileClass file(Options->HierarchyFilename); - if (!file.Open()) { - char buf[100+_MAX_FNAME+_MAX_EXT]; - sprintf(buf,"Unable to load hierarchy file: %s\nIf this Max file has been moved, please re-select the hierarchy file.",Options->HierarchyFilename); - MessageBox(Hwnd,buf,"Error",MB_OK); - return FALSE; - } - file.Close(); - } - - // Animation options: - int start_frame = RangeLowSpin->GetIVal(); - changed = changed || (Options->StartFrame != start_frame); - Options->StartFrame = start_frame; - - int end_frame = RangeHighSpin->GetIVal(); - changed = changed || (Options->EndFrame != end_frame); - Options->EndFrame = end_frame; - - bool compress_animation = (IsDlgButtonChecked(Hwnd, IDC_COMPRESS_ANIMATION_CHECK) == BST_CHECKED); - changed = changed || (Options->CompressAnimation != compress_animation); - Options->CompressAnimation = compress_animation; - - bool reduce_animation = (IsDlgButtonChecked(Hwnd, IDC_REDUCE_ANIMATION_CHECK) == BST_CHECKED); - changed = changed || (Options->ReduceAnimation != reduce_animation); - Options->ReduceAnimation = reduce_animation; - - int reduce_percent = ComboBox_GetCurSel(HwndReduce) + 1; - changed = changed || (Options->ReduceAnimationPercent != reduce_percent); - Options->ReduceAnimationPercent = reduce_percent; - - int flavor = ComboBox_GetCurSel(HwndFlavor); - changed = changed || (Options->CompressAnimationFlavor != flavor); - Options->CompressAnimationFlavor = flavor; - - char string[128]; - Edit_GetText(HwndTError, string, 128); - float trans_error = atof(string); - changed = changed || (Options->CompressAnimationTranslationError != trans_error); - Options->CompressAnimationTranslationError = trans_error; - - Edit_GetText(HwndRError, string, 128); - float rot_error = atof(string); - changed = changed || (Options->CompressAnimationRotationError != rot_error); - Options->CompressAnimationRotationError = rot_error; - - bool review_log = (IsDlgButtonChecked(Hwnd, IDC_VIEWLOG_CHECK) == BST_CHECKED); - changed = changed || (Options->ReviewLog != review_log); - Options->ReviewLog = review_log; - - // Geometry options: - //Options->UseVoxelizer = (IsDlgButtonChecked(Hwnd,IDC_VOXELIZER_CHECK) == BST_CHECKED); - Options->UseVoxelizer = false; - - if (changed) SetSaveRequiredFlag(true); - return TRUE; -} - -void W3dOptionsDialogClass::Enable_WHT_Export(void) -{ - EnableWindow(GetDlgItem(Hwnd,IDC_TRANSLATION_ONLY_CHECK),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_TERRAIN_MODE_CHECK),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_WHT_BROWSE_BUTTON),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_WHA_EXPORT_RADIO),TRUE); -} - -void W3dOptionsDialogClass::Enable_WHT_Load(void) -{ - EnableWindow(GetDlgItem(Hwnd,IDC_TRANSLATION_ONLY_CHECK),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_TERRAIN_MODE_CHECK),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_WHT_BROWSE_BUTTON),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_WHA_EXPORT_RADIO),TRUE); -} - -void W3dOptionsDialogClass::Disable_WHT_Export(void) -{ - // since there will be no hierarchy tree, disable animation - CheckDlgButton(Hwnd,IDC_WHA_EXPORT_RADIO,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_WHA_NO_EXPORT_RADIO,BST_CHECKED); - Disable_WHA_Export(); - - EnableWindow(GetDlgItem(Hwnd,IDC_TRANSLATION_ONLY_CHECK),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_TERRAIN_MODE_CHECK),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_WHT_BROWSE_BUTTON),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_WHA_EXPORT_RADIO),FALSE); -} - -void W3dOptionsDialogClass::Enable_WHA_Export(void) -{ - EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_LOW_EDIT),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_LOW_SPIN),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_HIGH_EDIT),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_HIGH_SPIN),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_VIEWLOG_CHECK), TRUE); - - EnableWindow(GetDlgItem(Hwnd,IDC_COMPRESS_ANIMATION_CHECK),TRUE); - if (IsDlgButtonChecked(Hwnd, IDC_COMPRESS_ANIMATION_CHECK) == BST_CHECKED) { - Enable_CompressAnimationOptions_Export(); - - } -} - -void W3dOptionsDialogClass::Disable_WHA_Export(void) -{ - EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_LOW_EDIT),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_LOW_SPIN),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_HIGH_EDIT),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_RANGE_HIGH_SPIN),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_VIEWLOG_CHECK), FALSE); - - EnableWindow(GetDlgItem(Hwnd,IDC_COMPRESS_ANIMATION_CHECK),FALSE); - Disable_CompressAnimationOptions_Export(); -} - -void W3dOptionsDialogClass::Enable_ReduceAnimationOptions_Export(void) -{ - EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_COMBO), TRUE); -} - -void W3dOptionsDialogClass::Disable_ReduceAnimationOptions_Export(void) -{ - EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_COMBO), FALSE); -} - -void W3dOptionsDialogClass::Enable_CompressAnimationOptions_Export(void) -{ - EnableWindow(GetDlgItem(Hwnd,IDC_COMPRESS_ANIMATION_FLAVOR_COMBO), TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_MAX_TRANS_ERROR_EDIT), TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_MAX_ROT_ERROR_EDIT), TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_CHECK), TRUE); - WHA_Reduce_Animation_Check_Changed(); - WHA_Compression_Flavor_Changed(); -} - -void W3dOptionsDialogClass::Disable_CompressAnimationOptions_Export(void) -{ - EnableWindow(GetDlgItem(Hwnd,IDC_COMPRESS_ANIMATION_FLAVOR_COMBO), FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_MAX_TRANS_ERROR_EDIT), FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_MAX_ROT_ERROR_EDIT), FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_CHECK), FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_COMBO), FALSE); -} - -void W3dOptionsDialogClass::Enable_WTM_Export(void) -{ - ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_SMOOTH_CHECK),TRUE); - ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_AABTREES),TRUE); -#if ENABLE_MESH_OPTIMIZING - ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_OPTIMIZE),TRUE); -#endif -} - -void W3dOptionsDialogClass::Disable_WTM_Export(void) -{ - ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_SMOOTH_CHECK),FALSE); - ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_AABTREES),FALSE); -#if ENABLE_MESH_OPTIMIZING - ::EnableWindow(::GetDlgItem(Hwnd,IDC_EXPORT_MESH_OPTIMIZE),FALSE); -#endif -} - -void W3dOptionsDialogClass::WHT_Export_Radio_Changed(void) -{ - if (IsDlgButtonChecked(Hwnd, IDC_WHT_EXPORT_RADIO) == BST_CHECKED) { - Enable_WHT_Export(); - } else if (IsDlgButtonChecked(Hwnd,IDC_WHT_LOAD_RADIO) == BST_CHECKED) { - Enable_WHT_Load(); - } else if (IsDlgButtonChecked(Hwnd,IDC_WHT_NO_EXPORT_RADIO) == BST_CHECKED) { - Disable_WHT_Export(); - } -} - -void W3dOptionsDialogClass::WHA_Export_Radio_Changed(void) -{ - if (IsDlgButtonChecked(Hwnd, IDC_WHA_EXPORT_RADIO) == BST_CHECKED) { - Enable_WHA_Export(); - } else if (IsDlgButtonChecked(Hwnd,IDC_WHA_NO_EXPORT_RADIO) == BST_CHECKED) { - Disable_WHA_Export(); - } -} - -void W3dOptionsDialogClass::WTM_Export_Radio_Changed(void) -{ - if (IsDlgButtonChecked(Hwnd, IDC_WTM_EXPORT_RADIO) == BST_CHECKED) { - Enable_WTM_Export(); - } else if (IsDlgButtonChecked(Hwnd,IDC_WTM_NO_EXPORT_RADIO) == BST_CHECKED) { - Disable_WTM_Export(); - } -} - - -void W3dOptionsDialogClass::WHA_Compress_Animation_Check_Changed(void) -{ - if (IsDlgButtonChecked(Hwnd, IDC_COMPRESS_ANIMATION_CHECK) == BST_CHECKED) { - Enable_CompressAnimationOptions_Export(); - } else { - Disable_CompressAnimationOptions_Export(); - } -} - -void W3dOptionsDialogClass::WHA_Reduce_Animation_Check_Changed(void) -{ - if (IsDlgButtonChecked(Hwnd, IDC_REDUCE_ANIMATION_CHECK) == BST_CHECKED) { - Enable_ReduceAnimationOptions_Export(); - } else { - Disable_ReduceAnimationOptions_Export(); - } -} - -void W3dOptionsDialogClass::WHA_Compression_Flavor_Changed() -{ - int flavor = ComboBox_GetCurSel(HwndFlavor); - - switch (flavor) { - - - case ANIM_FLAVOR_TIMECODED: { - WHA_Reduce_Animation_Check_Changed(); - EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_CHECK), TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_MAX_TRANS_ERROR_EDIT), TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_MAX_ROT_ERROR_EDIT), TRUE); - - break; - } - - case ANIM_FLAVOR_ADAPTIVE_DELTA: { - // Disable Reduce animation controls - Disable_ReduceAnimationOptions_Export(); - EnableWindow(GetDlgItem(Hwnd,IDC_REDUCE_ANIMATION_CHECK), FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_MAX_TRANS_ERROR_EDIT), FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_MAX_ROT_ERROR_EDIT), FALSE); - - break; - } - - - default: - assert(0); // invalid compressed flavor setting - break; - - } - -} - - - -/*********************************************************************************************** - * _options_dialog_proc -- thunks into the Options dialog class's windows message handler * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/24/1997 GH : Created. * - *=============================================================================================*/ -BOOL CALLBACK _options_dialog_proc -( - HWND hwnd, - UINT message, - WPARAM wParam, - LPARAM lParam -) -{ - static W3dOptionsDialogClass * optdialog = NULL; - - if (message == WM_INITDIALOG) { - optdialog = (W3dOptionsDialogClass *) lParam; - optdialog->Hwnd = hwnd; - } - - if (optdialog) { - return optdialog->Dialog_Proc(hwnd, message, wParam, lParam); - } else { - return FALSE; - } -} - - -/*********************************************************************************************** - * _init_ofn -- initialize the OpenFilename struct. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/24/1997 GH : Created. * - *=============================================================================================*/ -void _init_ofn(void) -{ - static char _szhierarchyfilter[] = "W3D Files (*.W3D)\0*.W3D\0WHT Files (*.WHT)\0*.WHT\0\0"; - - _HierarchyFileOFN.lStructSize = sizeof(OPENFILENAME); - _HierarchyFileOFN.hwndOwner = NULL; - _HierarchyFileOFN.hInstance = NULL; - _HierarchyFileOFN.lpstrFilter = _szhierarchyfilter; - _HierarchyFileOFN.lpstrCustomFilter = NULL; - _HierarchyFileOFN.nMaxCustFilter = 0; - _HierarchyFileOFN.nFilterIndex = 0; - _HierarchyFileOFN.lpstrFile = NULL; - _HierarchyFileOFN.nMaxFile = _MAX_PATH; - _HierarchyFileOFN.lpstrFileTitle = NULL; - _HierarchyFileOFN.nMaxFileTitle = _MAX_FNAME + _MAX_EXT; - _HierarchyFileOFN.lpstrInitialDir = NULL; - _HierarchyFileOFN.lpstrTitle = NULL; - _HierarchyFileOFN.Flags = OFN_HIDEREADONLY | OFN_CREATEPROMPT; - _HierarchyFileOFN.nFileOffset = 0; - _HierarchyFileOFN.nFileExtension = 0; - _HierarchyFileOFN.lpstrDefExt = "wht"; - _HierarchyFileOFN.lCustData = 0L; - _HierarchyFileOFN.lpfnHook = NULL; - _HierarchyFileOFN.lpTemplateName = NULL; - - _OfnInited = true; -} \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/w3ddlg.h b/Generals/Code/Tools/WW3D/max2w3d/w3ddlg.h deleted file mode 100644 index 440fb26344e..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/w3ddlg.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/w3ddlg.h 9 2/10/00 5:45p Jason_a $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/w3ddlg.h $* - * * - * $Author:: Jason_a $* - * * - * $Modtime:: 2/09/00 9:50a $* - * * - * $Revision:: 9 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef W3DDLG_H -#define W3DDLG_H - -#include "always.h" -#include -#include "w3dutil.h" - - -class W3dOptionsDialogClass -{ -public: - - W3dOptionsDialogClass(Interface * maxinterface,ExpInterface * exportinterface); - ~W3dOptionsDialogClass(); - - bool Get_Export_Options(W3dExportOptionsStruct * options); - bool Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM); - -public: - - HWND Hwnd; - -private: - - void Dialog_Init(); - BOOL Dialog_Ok(); - void Enable_WHT_Export(); - void Enable_WHT_Load(); - void Disable_WHT_Export(); - void Enable_WHA_Export(); - void Disable_WHA_Export(); - void Enable_WTM_Export(); - void Disable_WTM_Export(); - - void Enable_ReduceAnimationOptions_Export(); - void Disable_ReduceAnimationOptions_Export(); - void Enable_CompressAnimationOptions_Export(); - void Disable_CompressAnimationOptions_Export(); - - void WHT_Export_Radio_Changed(); - void WHA_Export_Radio_Changed(); - void WTM_Export_Radio_Changed(); - - void WHA_Compress_Animation_Check_Changed(); - void WHA_Reduce_Animation_Check_Changed(); - - void WHA_Compression_Flavor_Changed(); - -private: - - W3dExportOptionsStruct * Options; - bool GotHierarchyFilename; - Interface * MaxInterface; - ExpInterface * ExportInterface; - - ISpinnerControl * RangeLowSpin; - ISpinnerControl * RangeHighSpin; - - HWND HwndReduce; - HWND HwndFlavor; - HWND HwndTError; - HWND HwndRError; - - int UnitsType; - float UnitsScale; -}; - - -#endif \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/w3dexp.cpp b/Generals/Code/Tools/WW3D/max2w3d/w3dexp.cpp deleted file mode 100644 index 7d1c0285226..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/w3dexp.cpp +++ /dev/null @@ -1,1292 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/w3dexp.cpp 78 1/03/01 11:06a Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/w3dexp.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 1/03/01 11:03a $* - * * - * $Revision:: 78 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * W3dExportClass::W3dExportClass -- constructor * - * W3dExportClass::~W3dExportClass -- destructor * - * W3dExportClass::Export_Hierarchy -- Export the hierarchy tree * - * W3dExportClass::Export_Animation -- Export animation data * - * W3dExportClass::Export_Damage_Animations -- Exports damage animations for the model * - * W3dExportClass::Export_Geometry -- Export the geometry data * - * W3dExportClass::get_hierarchy_tree -- get a pointer to the hierarchy tree * - * W3dExportClass::get_export_options -- get the export options * - * W3dExportClass::Start_Progress_Bar -- start the MAX progress meter * - * W3dExportClass::End_Progress_Bar -- end the progress meter * - * W3dExportClass::get_damage_root_list -- gets the list of damage root nodes * - * W3dExportClass::Export_HLod -- Export an HLOD description * - * W3dExportClass::Export_Collection -- exports a collection chunk * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "rawfile.h" -#include "chunkio.h" -#include "w3dexp.h" -#include "w3dutil.h" -#include "nodelist.h" -#include "meshsave.h" -#include "hiersave.h" -#include "hlodsave.h" -#include "meshcon.h" -#include "SnapPoints.h" -#include "w3ddlg.h" -#include "PROGRESS.H" -#include "errclass.h" -#include "motion.h" -#include "util.h" -#include "w3ddesc.h" -#include "colboxsave.h" -#include "nullsave.h" -#include "dazzlesave.h" -#include "maxworldinfo.h" -#include "exportlog.h" - -#include "geometryexporttask.h" -#include "geometryexportcontext.h" - -#include -#include "TARGA.H" - -// Used to communicate from the exporter to the dialog. -char W3dExportClass::CurrentExportPath[_MAX_DRIVE + _MAX_DIR + 1] = { '\000' }; - - -/* local functions */ -static DWORD WINAPI progress_callback( LPVOID arg); -static HierarchySaveClass * load_hierarchy_file(char * filename); -static bool dupe_check(const INodeListClass & list); -static bool check_lod_extensions (INodeListClass &list, INode *origin); - -/* -** Struct for export info (AppDataChunk hung off the scene pointer) -** This includes the export info struct and some padding. -** NOTE: to avoid file versioning issues, new data should be added after -** existing data in this struct, the padding array should be made smaller so -** the total size remains the same, and the new data should give reasonable -** results with a default content of zeros (which is what it will contain if -** an older file is loaded). -*/ -struct ExportInfoAppDataChunkStruct { - W3dExportOptionsStruct ExportOptions; - unsigned char Padding[89]; -}; - - - -/************************************************************************************************ -** -** GeometryFilterClass - filters out nodes which are not marked for W3D geometry export -** -************************************************************************************************/ -class GeometryFilterClass : public INodeFilterClass -{ -public: - virtual BOOL Accept_Node(INode * node, TimeValue time) - { - Object * obj = node->EvalWorldState(time).obj; - - if - ( - obj -// && !Is_Proxy (*node) - && !Is_Origin(node) - && !node->IsHidden() - && Is_Geometry(node) - ) - { - return TRUE; - } else { - return FALSE; - } - } -}; - - - - -/************************************************************************************************ -** -** OriginFilterClass - Filters out nodes which are not "origin" objects. Origins are MAX dummy -** objects whose parents are the scene root, and are named "origin.*" (ie. first 7 characters -** in the name are "origin.". These origin objects will be (0,0,0) for all of its descendants. -** This allows an artist to create multiple models within one MAX scene but still have each -** mesh's coordinates equal without needing to stack all the models on the world origin. -** We iterate through the origin objects when exporting a scene containing multiple LODs of -** one model. -** -************************************************************************************************/ -class OriginFilterClass : public INodeFilterClass -{ -public: - - virtual BOOL Accept_Node(INode * node, TimeValue time) { return Is_Origin(node); } -}; - - -/************************************************************************************************ -** -** DamageRootFilterClass - Filters out all nodes which are not "damage root" objects. These nodes -** are MAX dummy objects whose parents are the scene root, and are named "damage.*" (ie. first 7 -** characters in the name are "damage.". These damage roots mean that all of its children -** represent a damaged model. -** -************************************************************************************************/ -class DamageRootFilterClass : public INodeFilterClass -{ -public: - - virtual BOOL Accept_Node(INode * node, TimeValue time) { return Is_Damage_Root(node); } -}; - - -/************************************************************************************************ -** -** DamageRegionFilterClass - Filters out all node that are not a bone which is part of a certain -** deformation region. Pass the region ID to the constructor. -** -************************************************************************************************/ -class DamageRegionFilterClass : public INodeFilterClass -{ -public: - DamageRegionFilterClass(int region_id) { RegionId = region_id; } - - virtual BOOL Accept_Node(INode * node, TimeValue time) - { - if (!Is_Bone(node)) return FALSE; - - // Check it's damage region ID (if it has one). - AppDataChunk * appdata = node->GetAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,1); - if (!appdata) return FALSE; - W3DAppData1Struct *wdata = (W3DAppData1Struct*)(appdata->data); - return wdata->DamageRegion == RegionId; - } - -protected: - - int RegionId; -}; - - -/*********************************************************************************************** - * W3dExportClass::DoExport -- This method is called for the plug-in to perform it's file expo * - * * - * INPUT: * - * name - filename to use * - * export - A pointer the plug-in may use to call methods to enumerate the scene * - * max - An interface pointer the plug-in may use to call methods of MAX. * - * * - * OUTPUT: * - * Nonzero on successful export; otherwise 0. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - * 10/17/2000 gth : Removed the old export code-path, everything goes through an origin now * - *=============================================================================================*/ -int W3dExportClass::DoExport -( - const TCHAR *filename, - ExpInterface *do_export, - Interface *max, - BOOL suppressPrompts, - DWORD options -) -{ - ExportInterface = do_export; - MaxInterface = max; - RootNode = NULL; - OriginList = NULL; - DamageRootList = NULL; - HierarchyTree = NULL; - - try { - - CurTime = MaxInterface->GetTime(); - FrameRate = GetFrameRate(); - FixupType = HierarchySaveClass::MATRIX_FIXUP_TRANS_ROT; - - /* - ** The Animation and the Hierarchy will be named with the root portion of the W3D filename - ** and the path is used by the options dialog - */ - char rootname[_MAX_FNAME + 1]; - char drivename[_MAX_DRIVE + 1]; - char dirname[_MAX_DIR + 1]; - _splitpath(filename, drivename, dirname, rootname, NULL); - sprintf(CurrentExportPath, "%s%s", drivename, dirname); - - /* - ** The batch export process (suppressPrompt == TRUE) needs to know the directory of the - ** MAX file being exported. This is so that it can use the old relative pathname of the - ** W3D file containing the hierarchy. - */ - _splitpath(max->GetCurFilePath(), drivename, dirname, NULL, NULL); - sprintf(CurrentScenePath, "%s%s", drivename, dirname); - - /* - ** Get export options - */ - if (!get_export_options(suppressPrompts)) { - return 1; - } - - /* - ** If no data is going to be exported just bail - */ - if ((!ExportOptions.ExportHierarchy) && (!ExportOptions.ExportAnimation) && (!ExportOptions.ExportGeometry)) { - return 1; - } - - /* - ** Initialize the logging system - */ - ExportLog::Init(NULL); - - /* - ** Create a chunk saver to write the w3d file with - */ - RawFileClass stream(filename); - - if (!stream.Open(FileClass::WRITE)) { - MessageBox(NULL,"Unable to open file.","Error",MB_OK | MB_SETFOREGROUND); - return 1; - } - - ChunkSaveClass csave(&stream); - - /* - ** Export data from the scene. - ** - ** Are we doing an old export (one model/LOD per scene) or a new export (multiple LODs - ** for one model in a scene)? - */ - if (get_origin_list()) - { - DoOriginBasedExport(rootname, csave); - } - - /* - ** Done! - */ - stream.Close(); - - if (HierarchyTree != NULL) { - delete HierarchyTree; - HierarchyTree = NULL; - } - - if (OriginList != NULL) { - delete OriginList; - OriginList = NULL; - } - - if (DamageRootList != NULL) { - delete DamageRootList; - DamageRootList = NULL; - } - - } catch (ErrorClass error) { - - MessageBox(NULL,error.error_message,"Error",MB_OK | MB_SETFOREGROUND); - } - - ExportLog::Shutdown(ExportOptions.ReviewLog); - MaxInterface->RedrawViews(MaxInterface->GetTime()); - return 1; -} - - - -/*********************************************************************************************** - * W3dExportClass::DoOriginBasedExport -- New export codepath. Exports any objects linked to * - * an origin object. Assumes origins named "origin.01" and greater represent LODs of the * - * original object ("origin.00"). Also assumes "damage.01" and greater represent damaged * - * versions of the original object. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/13/1999 AJA : Created. * - * 9/21/1999 AJA : Added support for the new animation exporting process (damage-related). * - *=============================================================================================*/ -void W3dExportClass::DoOriginBasedExport(char *rootname,ChunkSaveClass &csave) -{ - /* - ** Build the damage root list. - */ - INodeListClass *damage_list = get_damage_root_list(); - assert(damage_list != NULL); - - /* - ** Start the progress meter - */ - Start_Progress_Bar(); - Progress_Meter_Class meter(MaxInterface,0.0f,100.0f); - - int steps = 0; - steps++; // Base Pose - steps+= OriginList->Num_Nodes(); // n Origins - steps++; // Basic Anim OR Damage Anims - steps++; // HLOD OR Collection - - meter.Finish_In_Steps(steps); - - /* - ** Find the base object's origin. - */ - bool is_base_object = false; - INodeListClass *origin_list = get_origin_list(); - unsigned int i, count = origin_list->Num_Nodes(); - INode *base_origin = NULL; - - for (i = 0; i < count; i++) - { - INode *node = (*origin_list)[i]; - if (Is_Base_Origin(node)) - { - base_origin = node; - break; - } - } - - /* - ** Write the Hierarchy Tree (if needed) - */ - Progress_Meter_Class treemeter(meter, meter.Increment); - if (!Export_Hierarchy(rootname, csave, treemeter, base_origin)) - { - MessageBox(NULL,"Hierarchy Export Failure!","Error",MB_OK | MB_SETFOREGROUND); - End_Progress_Bar(); - return; - } - meter.Add_Increment(); - - if (damage_list->Num_Nodes() <= 0) - { - /* - ** Write the Base Animation (if needed) - */ - Progress_Meter_Class animmeter(meter, meter.Increment); - if (!Export_Animation(rootname, csave, animmeter, base_origin)) - { - MessageBox(NULL,"Animation Export Failure!","Error",MB_OK | MB_SETFOREGROUND); - End_Progress_Bar(); - return; - } - meter.Add_Increment(); - } - else - { - /* - ** Write the damage animations. - */ - Progress_Meter_Class damagemeter(meter, meter.Increment); - for (i = 0; i < damage_list->Num_Nodes(); i++) - { - if (!Export_Damage_Animations(rootname, csave, damagemeter, (*damage_list)[i])) - { - MessageBox(NULL, "Damage Animation Export Failure!", "Error", MB_OK | MB_SETFOREGROUND); - End_Progress_Bar(); - return; - } - } - meter.Add_Increment(); - } - - /* - ** Create an array of pointers to MeshConnectionsClass objects. These objects - ** will be created below, and will be used to generate the HLOD with the - ** geometry of all models in the scene. - */ - MeshConnectionsClass **connections = new MeshConnectionsClass*[count]; - if (!connections) - { - MessageBox(NULL, "Memory allocation failure!", "Error", MB_OK | MB_SETFOREGROUND); - End_Progress_Bar(); - return; - } - memset(connections, 0, sizeof(MeshConnectionsClass*) * count); - - /* - ** For each model in the scene, write its animation and geometry (if needed). - ** All models share the above hierarchy tree. - */ - int idx = strlen(rootname); - rootname[idx+1] = '\0'; - - /* - ** If we're not exporting a hierarchical model, only export the "origin.00" - */ - if (!ExportOptions.LoadHierarchy && !ExportOptions.ExportHierarchy) { - count = 1; - } - - for (i = 0; i < count; i++) - { - /* - ** Get the current origin. - */ - INode *origin = (*origin_list)[i]; - - /* - ** Write each mesh (if needed) - */ - MeshConnectionsClass *meshcon = NULL; - Progress_Meter_Class meshmeter(meter, meter.Increment); - if (!Export_Geometry(rootname, csave, meshmeter, origin, &meshcon)) - { - MessageBox(NULL, "Geometry Export Failure!", "Error", MB_OK | MB_SETFOREGROUND); - End_Progress_Bar(); - return; - } - meter.Add_Increment(); - - /* - ** Put the MeshConnectionsClass object for this model into - ** the array in order of LOD (top-level last). - */ - int lod_level = Get_Lod_Level(origin); - if (lod_level >= count || connections[count - lod_level - 1] != NULL) - { - char text[256]; - sprintf(text, "Origin Naming Error! There are %d models defined in this " - "scene, therefore your origin names should be\n\"Origin.00\" through " - "\"Origin.%02d\", 00 being the high-poly model and %02d being the " - "lowest detail LOD.", count, count-1, count-1); - MessageBox(NULL, text, "Error", MB_OK | MB_SETFOREGROUND); - End_Progress_Bar(); - return; - } - connections[count - lod_level - 1] = meshcon; - } - - /* - ** Generate the HLOD based on all the mesh connections. - */ - if (ExportOptions.LoadHierarchy || ExportOptions.ExportHierarchy) { - rootname[idx] = '\0'; // remove the trailing character (signifies which lod level) - HierarchySaveClass *htree = get_hierarchy_tree(); - if (htree) - { - Progress_Meter_Class hlod_meter(meter, meter.Increment); - if (!Export_HLod(rootname, htree->Get_Name(), csave, hlod_meter, connections, count)) - { - MessageBox(NULL, "HLOD Generation Failure!", "Error", MB_OK | MB_SETFOREGROUND); - End_Progress_Bar(); - return; - } - meter.Add_Increment(); - } - } - - /* - ** Deallocate the array of mesh connections. - */ - for (i = 0; i < count; i++) - { - if (connections[i] != NULL) - delete connections[i]; - } - delete []connections; - - End_Progress_Bar(); -} - - -/*********************************************************************************************** - * W3dExportClass::Export_Hierarchy -- Export the hierarchy tree * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/16/1997 GH : Created. * - * 13/9/1999 AJA : Split into two calls, one that takes a node list and one that takes a * - * single root node. * - * 10/17/2000 gth : Removed the old code-path, we always use an origin now * - *=============================================================================================*/ -bool W3dExportClass::Export_Hierarchy(char *name,ChunkSaveClass & csave,Progress_Meter_Class & meter, - INode *root) -{ - if (!ExportOptions.ExportHierarchy) return true; - HierarchySaveClass::Enable_Terrain_Optimization(ExportOptions.EnableTerrainMode); - - if (root == NULL) return false; - - try { - HierarchyTree = new HierarchySaveClass(root,CurTime,meter,name,FixupType); - } catch (ErrorClass err) { - MessageBox(NULL, err.error_message,"Error!",MB_OK | MB_SETFOREGROUND); - return false; - } - - HierarchyTree->Save(csave); - - return true; -} - -/*********************************************************************************************** - * W3dExportClass::Export_Animation -- Export animation data * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/16/1997 GH : Created. * - * 13/9/1999 AJA : Split into two calls, one that takes a node list and one that takes a * - * single root node. * - * 10/17/2000 gth : Removed the old code-path, we always use an origin now * - *=============================================================================================*/ -bool W3dExportClass::Export_Animation(char * name,ChunkSaveClass & csave,Progress_Meter_Class & meter, - INode *root) -{ - if (!ExportOptions.ExportAnimation) return true; - HierarchySaveClass * htree = get_hierarchy_tree(); - - if ((root == NULL) || (htree == NULL)) { - return false; - } - - MotionClass * motion = NULL; - - try { - motion = new MotionClass( ExportInterface->theScene, - root, - htree, - ExportOptions, - FrameRate, - &meter, - MaxInterface->GetMAXHWnd(), - name); - } catch (ErrorClass err) { - MessageBox(NULL,err.error_message,"Error!",MB_OK | MB_SETFOREGROUND); - return false; - } - - motion->Save(csave); - - delete motion; - - return true; -} - - -/*********************************************************************************************** - * W3dExportClass::Export_Damage_Animations -- Exports damage animations for the model * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1999 AJA : Created. * - *=============================================================================================*/ -bool W3dExportClass::Export_Damage_Animations(char *name, ChunkSaveClass &csave, - Progress_Meter_Class &meter, - INode *damage_root) -{ - if (!ExportOptions.ExportAnimation) return true; - HierarchySaveClass *htree = get_hierarchy_tree(); - - if ((damage_root == NULL) || (htree == NULL)) - return false; - - int damage_state = Get_Damage_State(damage_root); - - /* - ** While exporting damage animations, we need the offset from our origin to the real - ** scene origin. - */ - Matrix3 originoffset = Inverse(damage_root->GetNodeTM(CurTime)); - - /* - ** For every damage region we find, export an animation. - */ - bool done = false; - int current_region = 0; - int num_damage_bones = 0; // number of bones assigned to a damage region - for (current_region = 0; current_region < MAX_DAMAGE_REGIONS; current_region++) - { - DamageRegionFilterClass region_filter(current_region); - INodeListClass bone_list(damage_root, CurTime, ®ion_filter); - - num_damage_bones += bone_list.Num_Nodes(); - - // Move to the next region if there aren't any bones in this one. - if (bone_list.Num_Nodes() <= 0) - continue; - - // Put together an animation name for this damage region. - char anim_name[W3D_NAME_LEN]; - sprintf(anim_name, "damage%d-%d", current_region, damage_state); - - // Export an animation for this damage region. - MotionClass *motion = NULL; - try - { - motion = new MotionClass( ExportInterface->theScene, - &bone_list, - htree, - ExportOptions, - FrameRate, - &meter, - MaxInterface->GetMAXHWnd(), - anim_name, - originoffset); - } - catch (ErrorClass err) - { - MessageBox(NULL, err.error_message, "Error!", MB_OK | MB_SETFOREGROUND); - return false; - } - - assert(motion != NULL); - motion->Save(csave); - - delete motion; - } - - if (num_damage_bones <= 0) - { - MessageBox(NULL, "Warning: Your damage bones need to be given damage region numbers. " - "You can do this in the W3D Tools panel.", name, MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND); - } - - return true; -} - -#define TEAM_COLOR_PALETTE_SIZE 16 -unsigned int houseColorScale[TEAM_COLOR_PALETTE_SIZE]= -{255,239,223,211,195,174,167,151,135,123,107,91,79,63,47,35}; - -/*********************************************************************************************** - * W3dExportClass::Export_Geometry -- Export the geometry data * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/16/1997 GH : Created. * - * 13/9/1999 AJA : Added an optional "root" parameter to export geometry of the node's * - * descendants. * - * 10/17/2000 gth : Made the "root" parameter a requirement, just pass in the scene root * - * if you want to export all geometry in the scene. * - * 10/30/2000 gth : If exporting only geometry, only export the first mesh * - *=============================================================================================*/ -bool W3dExportClass::Export_Geometry(char * name,ChunkSaveClass & csave,Progress_Meter_Class & meter, - INode *root,MeshConnectionsClass **out_connection) -{ - unsigned int i; - - assert(root != NULL); - if (!ExportOptions.ExportGeometry) return true; - - /* - ** If we're attaching the meshes to a hierarchy, get the tree - */ - HierarchySaveClass * htree = NULL; - if (ExportOptions.LoadHierarchy || ExportOptions.ExportHierarchy) { - htree = get_hierarchy_tree(); - if (htree == NULL) { - return false; - } - } - - DynamicVectorClass export_tasks; - INodeListClass *geometry_list = NULL; - - /* - ** Create the lists of nodes that we're going to work with - */ - GeometryFilterClass geometryfilter; - geometry_list = new INodeListClass(root,CurTime,&geometryfilter); - if (dupe_check(*geometry_list)) { - return false; - } - - MaxWorldInfoClass world_info(export_tasks); - world_info.Allow_Mesh_Smoothing (ExportOptions.SmoothBetweenMeshes); - unsigned int materialColors[16*16]; ///@todo: MW: Fix this to remove solid colors. - char materialColorFilename[_MAX_FNAME + 1]; - memset(materialColors,0,sizeof(materialColors)); - for (i=0; iNum_Nodes(); - if ((htree == NULL) && (geometry_list->Num_Nodes() > 1)) { - geometry_count = MIN(geometry_count,1); - ExportLog::printf("\nDiscarding extra meshes since we are not exporting a hierarchical model.\n"); - } - - for (i=0; iSet_Name(name); - export_tasks[0]->Set_Container_Name(""); - } - - /* - ** Generate the mesh-connections object to return to the caller - */ - MeshConnectionsClass * meshcon = NULL; - if (htree != NULL) { - Progress_Meter_Class mcmeter(meter,meter.Increment); - try { - meshcon = new MeshConnectionsClass(export_tasks,context); - } catch (ErrorClass err) { - MessageBox(NULL,err.error_message,"Error!",MB_OK | MB_SETFOREGROUND); - return false; - } - *out_connection = meshcon; - meter.Add_Increment(); - } - - /* - ** Export each piece of geometry - */ - for (i=0; iExport_Geometry(context); - } catch (ErrorClass err) { - MessageBox(MaxInterface->GetMAXHWnd(),err.error_message,"Error!",MB_OK | MB_SETFOREGROUND); - continue; - } - - meter.Add_Increment(); - } - - //Check if any textures need to be generated - if (context.numMaterialColors || context.numHouseColors) - { - Targa targ; - char imageBuffer[16*16*3]; - int px,py,buf_index; - unsigned int Diffuse; - - //clear to black - memset(imageBuffer,0,sizeof(imageBuffer)); - - for (i=0; i<(16+context.numMaterialColors); i++) - { - //get coordinates of this material within texture page - px=(i%16); ///@todo: MW: Remove hard-coded texture size - py=(i/16); - - Diffuse=context.materialColors[i]; - buf_index=(px+py*16)*3; - - imageBuffer[buf_index]=(Diffuse>>16)&0xff; - imageBuffer[buf_index+1]=(Diffuse>>8)&0xff; - imageBuffer[buf_index+2]=(Diffuse)&0xff; - } - - memset(&targ.Header,0,sizeof(targ.Header)); - targ.Header.Width=16; - targ.Header.Height=16; - targ.Header.PixelDepth=24; - targ.Header.ImageType=TGA_TRUECOLOR; - targ.SetImage(imageBuffer); - targ.YFlip(); - - if (context.numHouseColors) - sprintf(materialColorFilename,"%sZHCD_%s.tga",CurrentExportPath,name); - - targ.Save(materialColorFilename,TGAF_IMAGE,false); - } - - /* - ** Cleanup - */ - for (i=0; iGetMAXHWnd(),buf,"Error",MB_OK | MB_SETFOREGROUND); - return NULL; - } - } - - /* - ** Should never fall through to here... - ** This would only happen if ExportHierarchy was true and the Export_Hierarchy - ** function failed to create a hierarchy tree for us. - */ - assert(0); - return NULL; -} - - -/*********************************************************************************************** - * W3dExportClass::get_damage_root_list -- gets the list of damage root nodes * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/17/2000 gth : Created. * - *=============================================================================================*/ -INodeListClass * W3dExportClass::get_damage_root_list(void) -{ - if (DamageRootList != NULL) return DamageRootList; - - /* - ** Create a list of all damage root objects in the scene. - */ - DamageRootFilterClass nodefilter; - DamageRootList = new INodeListClass(ExportInterface->theScene, CurTime, &nodefilter); - return DamageRootList; -} - - -/*********************************************************************************************** - * get_origin_list -- get the list of origin nodes * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/13/1999 AJA : Created. * - *=============================================================================================*/ -INodeListClass * W3dExportClass::get_origin_list(void) -{ - if (OriginList != NULL) return OriginList; - - /* - ** Create a list of all origins in the scene. - */ - static OriginFilterClass originfilter; - OriginList = new INodeListClass (ExportInterface->theScene, CurTime, &originfilter); - - /* - ** If we didn't find any origins, add the scene root as an origin. - ** NOTE: it would also be a problem if the origin list contained both the scene root - ** and the user placed origins. Thats not happening now because the OriginList - ** does not collect the scene root... were that to change we'd have to update this - ** code as well. - */ - if (OriginList->Num_Nodes() == 0) { - OriginList->Insert(MaxInterface->GetRootNode()); - } - - return OriginList; -} - -/*********************************************************************************************** - * W3dExportClass::get_export_options -- get the export options * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/16/1997 GH : Created. * - * 9/30/1999 AJA : Added support for the MAX suppress_prompts flag. * - *=============================================================================================*/ -bool W3dExportClass::get_export_options(BOOL suppress_prompts) -{ - int ticksperframe = GetTicksPerFrame(); - - // Get the last export settings from the AppDataChunk attached to the - // scene pointer. If there is no such AppDataChunk create one and set it - // to default values. - - W3dExportOptionsStruct *options = NULL; - - AppDataChunk * appdata = MaxInterface->GetScenePointer()->GetAppDataChunk(W3D_EXPORTER_CLASS_ID,SCENE_EXPORT_CLASS_ID,0); - - if (appdata) { - options = &(((ExportInfoAppDataChunkStruct *)(appdata->data))->ExportOptions); - } else { - - ExportInfoAppDataChunkStruct *appdata_struct = - (ExportInfoAppDataChunkStruct *)malloc(sizeof(ExportInfoAppDataChunkStruct)); - - options = &(appdata_struct->ExportOptions); - - options->ExportHierarchy = true; - options->LoadHierarchy = false; - options->ExportAnimation = true; - options->EnableTerrainMode = false; - - options->ReduceAnimation = false; - options->ReduceAnimationPercent = 50; - - options->CompressAnimation = false; - options->CompressAnimationFlavor = ANIM_FLAVOR_TIMECODED; - options->CompressAnimationTranslationError = 0.001f; //DEFAULT_LOSSY_ERROR_TOLERANCE; - options->CompressAnimationRotationError = 0.050f; //DEFAULT_LOSSY_ERROR_TOLERANCE; - options->ReviewLog = false; - - options->ExportGeometry = true; - options->TranslationOnly = false; - options->SmoothBetweenMeshes = true; - - strcpy(options->HierarchyFilename,""); - strcpy(options->RelativeHierarchyFilename,""); - options->StartFrame = MaxInterface->GetAnimRange().Start() / ticksperframe; - options->EndFrame = MaxInterface->GetAnimRange().End() / ticksperframe; - options->UseVoxelizer = false; - options->DisableExportAABTrees = true; - options->EnableOptimizeMeshData = false; - options->EnableMaterialColorToTextureConversion = false; - - memset(&(appdata_struct->Padding), 0, sizeof(appdata_struct->Padding)); - - MaxInterface->GetScenePointer()->AddAppDataChunk(W3D_EXPORTER_CLASS_ID, - SCENE_EXPORT_CLASS_ID, 0, sizeof(ExportInfoAppDataChunkStruct), - appdata_struct); - - } - - // (gth) disabling the 'optimize mesh data' feature due to problems with external tools - options->EnableOptimizeMeshData = false; - - bool retval = true; - if (suppress_prompts == FALSE) - { - W3dOptionsDialogClass dialog(MaxInterface,ExportInterface); - retval = dialog.Get_Export_Options(options); - } - - if (suppress_prompts || retval) { - - ExportOptions = *options; - - if ( (suppress_prompts == TRUE) && (options->RelativeHierarchyFilename[0] != 0) ) - { - // Use the relative pathname WRT the max scene's directory to - // figure out the absolute directory where the hierarchy file - // is stored. - char curdir[_MAX_DRIVE + _MAX_DIR + 1]; - assert(_getcwd(curdir, sizeof(curdir))); - assert(_chdir(CurrentScenePath) != -1); - assert(_fullpath(HierarchyFilename, options->RelativeHierarchyFilename, - sizeof(HierarchyFilename))); - assert(_chdir(curdir) != -1); - } - else - strcpy(HierarchyFilename,options->HierarchyFilename); - - if (ExportOptions.TranslationOnly) { - FixupType = HierarchySaveClass::MATRIX_FIXUP_TRANS; - } else { - FixupType = HierarchySaveClass::MATRIX_FIXUP_TRANS_ROT; - } - } - - return retval; -} - - - - -/*********************************************************************************************** - * W3dExportClass::Start_Progress_Bar -- start the MAX progress meter * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/16/1997 GH : Created. * - *=============================================================================================*/ -void W3dExportClass::Start_Progress_Bar(void) -{ - MaxInterface->ProgressStart( - "Processing Triangle Mesh", - TRUE, - progress_callback, - NULL); -} - -/*********************************************************************************************** - * W3dExportClass::End_Progress_Bar -- end the progress meter * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/16/1997 GH : Created. * - *=============================================================================================*/ -void W3dExportClass::End_Progress_Bar(void) -{ - MaxInterface->ProgressUpdate( 100); - MaxInterface->ProgressEnd(); -} - -static bool dupe_check(const INodeListClass & list) -{ - for (unsigned i=0; iGetName(),list[j]->GetName()) == 0) { - char buf[256]; - sprintf(buf,"Geometry Nodes with duplicated names found!\nDuplicated Name: %s\n",list[i]->GetName()); - MessageBox(NULL,buf,"Error",MB_OK | MB_SETFOREGROUND); - return true; - } - } - } - } - return false; -} - -static bool check_lod_extensions (INodeListClass &list, INode *origin) -{ - /* - ** Assumptions: - ** - If origin == NULL, then we're just exporting a single model and don't need to - ** worry about lod extensions at all. - ** - If origin is the root of the scene, then we're just exporting a single model as well. - ** - Otherwise origin actually points to an Origin and not just any INode. - */ - if (origin == NULL) return true; - if (origin->IsRootNode()) return true; - - char *extension = strrchr(origin->GetName(), '.'); - int ext_len = strlen(extension); - for (unsigned i = 0; i < list.Num_Nodes(); i++) - { - char *this_ext = strrchr(list[i]->GetName(), '.'); - - // Check for the existance of an extension in this node. - if (this_ext == NULL) - return false; - - // Check that the extensions are the same. - if (strcmp(this_ext, extension) != 0) - return false; - } - - return true; -} - - -bool W3dExportClass::get_base_object_tm (Matrix3 &tm) -{ - INodeListClass *origin_list = get_origin_list(); - if (!origin_list) - return false; - - unsigned int i, count = origin_list->Num_Nodes(); - INode *base_origin = NULL; - for (i = 0; i < count; i++) - { - INode *node = (*origin_list)[i]; - if (Is_Base_Origin(node)) - { - // we found origin.00, fall through - base_origin = node; - break; - } - } - if (!base_origin) - return false; - - tm = base_origin->GetNodeTM(CurTime); - return true; -} - -static DWORD WINAPI progress_callback( LPVOID arg ) -{ - return 0; -} - - -static HierarchySaveClass * load_hierarchy_file(char * filename) -{ - HierarchySaveClass * hier = NULL; - - RawFileClass file(filename); - - if (!file.Open()) { - return NULL; - } - ChunkLoadClass cload(&file); - - cload.Open_Chunk(); - if (cload.Cur_Chunk_ID() == W3D_CHUNK_HIERARCHY) { - hier = new HierarchySaveClass(); - hier->Load(cload); - } else { - hier = NULL; - file.Close(); - return NULL; - } - - cload.Close_Chunk(); - file.Close(); - - return hier; -} - diff --git a/Generals/Code/Tools/WW3D/max2w3d/w3dexp.h b/Generals/Code/Tools/WW3D/max2w3d/w3dexp.h deleted file mode 100644 index 8f50c6f7d3f..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/w3dexp.h +++ /dev/null @@ -1,122 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/w3dexp.h 22 10/23/00 5:34p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/w3dexp.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/23/00 5:24p $* - * * - * $Revision:: 22 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef W3DEXP_H -#define W3DEXP_H - -#include "always.h" -#include -#include "dllmain.h" -#include "hiersave.h" -#include "w3dutil.h" -#include "resource.h" - - -class MeshConnectionsClass; -class GeometryExportTaskClass; - -class W3dExportClass : public SceneExport -{ - -public: - - W3dExportClass() {}; - ~W3dExportClass() {}; - - int ExtCount() { return 1; }; - const TCHAR * Ext(int n) { return Get_String(IDS_W3D_FILE_EXTEN); }; - const TCHAR * LongDesc() { return Get_String(IDS_W3D_LONG_DESCRIPTION); }; - const TCHAR * ShortDesc() { return Get_String(IDS_W3D_SHORT_DESCRIPTION); }; - const TCHAR * AuthorName() { return Get_String(IDS_AUTHOR_NAME); }; - const TCHAR * CopyrightMessage() { return Get_String(IDS_COPYRIGHT_NOTICE); }; - const TCHAR * OtherMessage1() { return _T(""); }; - const TCHAR * OtherMessage2() { return _T(""); }; - unsigned int Version() { return 100; }; - - void ShowAbout(HWND hWnd) {}; - int DoExport(const TCHAR *name,ExpInterface *ei,Interface *i, BOOL suppressPrompts=FALSE, DWORD options=0); // Export file - -protected: - - void DoOriginBasedExport(char *rootname, ChunkSaveClass &csave); - -public: - - friend BOOL CALLBACK ExportOptionsDlgProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam); - - static char CurrentExportPath[_MAX_DRIVE + _MAX_DIR + 1]; // Used to communicate from the exporter to the dialog. - char CurrentScenePath[_MAX_DRIVE + _MAX_DIR + 1]; // directory where the current .max file is stored - -private: - - ExpInterface * ExportInterface; - Interface * MaxInterface; - TimeValue CurTime; - int FrameRate; - - W3dExportOptionsStruct ExportOptions; - - char HierarchyFilename[_MAX_PATH]; - int FixupType; - INode * RootNode; - INodeListClass * RootList; - INodeListClass * OriginList; - INodeListClass * DamageRootList; - - HierarchySaveClass * HierarchyTree; - - bool get_export_options(BOOL suppress_prompts = FALSE); - INodeListClass * get_origin_list(void); - INodeListClass * get_damage_root_list(void); - HierarchySaveClass * get_hierarchy_tree(void); - - bool get_base_object_tm(Matrix3 &tm); - - bool Export_Hierarchy(char * name,ChunkSaveClass & csave,Progress_Meter_Class & meter,INode *root); - bool Export_Animation(char * name,ChunkSaveClass & csave,Progress_Meter_Class & meter,INode *root); - bool Export_Damage_Animations(char * name,ChunkSaveClass & csave,Progress_Meter_Class &meter,INode *damage_root); - bool Export_Geometry(char * name,ChunkSaveClass & csave,Progress_Meter_Class & meter,INode *root=NULL, MeshConnectionsClass **out_connection=NULL); - bool Export_HLod (char *name, const char *htree_name, ChunkSaveClass &csave, Progress_Meter_Class &meter, MeshConnectionsClass **connections, int lod_count); - bool Export_Collection(const char * name,ChunkSaveClass & csave,DynamicVectorClass & objlist,INodeListClass & placeholder_list,INodeListClass & transform_node_list); - - void Start_Progress_Bar(void); - void End_Progress_Bar(void); - -}; - - -#endif \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/w3dmtl.cpp b/Generals/Code/Tools/WW3D/max2w3d/w3dmtl.cpp deleted file mode 100644 index c14a3eea703..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/w3dmtl.cpp +++ /dev/null @@ -1,1239 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/w3dmtl.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 8/22/01 7:47a $* - * * - * $Revision:: 32 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "w3dmtl.h" -#include -#include -#include "gamemtl.h" -#include "realcrc.h" - -static W3dRGBStruct Color_To_W3d(Color & c) -{ - W3dRGBStruct wc; - wc.R = (c.r * 255.0f); - wc.G = (c.g * 255.0f); - wc.B = (c.b * 255.0f); - wc.pad = 0; - return wc; -} - -/* - - - Implementation of W3dMapClass - - - -*/ - -W3dMapClass::W3dMapClass(const W3dMapClass & that) -{ - Set_Filename(that.Filename); - if (that.AnimInfo) { - Set_Anim_Info(that.AnimInfo); - } -} - -W3dMapClass & W3dMapClass::operator = (const W3dMapClass & that) -{ - if (this != &that) { - Set_Filename(that.Filename); - Set_Anim_Info(that.AnimInfo); - } - return *this; -} - -W3dMapClass::~W3dMapClass(void) -{ - if (Filename) free(Filename); - if (AnimInfo) delete AnimInfo; -} - -void W3dMapClass::Reset(void) -{ - if (Filename) free(Filename); - if (AnimInfo) delete AnimInfo; - Filename = NULL; - AnimInfo = NULL; -} - -void W3dMapClass::Set_Filename(const char * fullpath) -{ - if (Filename) { - free(Filename); - } - if (fullpath) { - char name[_MAX_FNAME]; - char exten[_MAX_EXT]; - char fname[_MAX_FNAME+_MAX_EXT+2]; - - _splitpath(fullpath,NULL,NULL,name,exten); - _makepath(fname,NULL,NULL,name,exten); - //strupr(fname); (gth) need to preserve case since unix/PS2 is case sensitive... - Filename = strdup(fname); - } else { - Filename = NULL; - } -} - -void W3dMapClass::Set_Anim_Info(const W3dTextureInfoStruct * info) -{ - if (info == NULL) { - if (AnimInfo) { - delete AnimInfo; - AnimInfo = NULL; - return; - } - } else { - if (AnimInfo == NULL) { - AnimInfo = new W3dTextureInfoStruct; - } - *AnimInfo = *info; - } -} - -void W3dMapClass::Set_Anim_Info(int framecount,float framerate) -{ - if (AnimInfo == NULL) { - AnimInfo = new W3dTextureInfoStruct; - } - - AnimInfo->FrameCount = framecount; - AnimInfo->FrameRate = framerate; -} - - - -/* - - - Implementation of W3dMaterialClass - - -*/ - - -W3dMaterialClass::W3dMaterialClass(void) -{ - PassCount = 0; - SortLevel = SORT_LEVEL_NONE; - for (int pass = 0; pass < MAX_PASSES; pass++) { - Materials[pass] = NULL; - W3d_Shader_Reset(&(Shaders[pass])); - for (int stage = 0; stage < MAX_STAGES; stage++) { - Textures[pass][stage] = NULL; - MapChannel[pass][stage] = 1; - MapperArgs[pass][stage] = NULL; - } - } -} - -W3dMaterialClass::~W3dMaterialClass(void) -{ - Free(); -} - -void W3dMaterialClass::Free(void) -{ - for (int pass = 0; pass < MAX_PASSES; pass++) { - - if (Materials[pass]) { - delete Materials[pass]; - Materials[pass] = NULL; - } - - for (int stage = 0; stage < MAX_STAGES; stage++) { - if (Textures[pass][stage]) { - delete Textures[pass][stage]; - Textures[pass][stage] = NULL; - } - - if (MapperArgs[pass][stage]) { - delete [] MapperArgs[pass][stage]; - MapperArgs[pass][stage] = NULL; - } - } - } -} - -void W3dMaterialClass::Reset(void) -{ - Free(); - SortLevel = SORT_LEVEL_NONE; - for (int pass=0; pass < MAX_PASSES; pass++) { - W3d_Shader_Reset(&(Shaders[pass])); - - for (int stage=0; stage < MAX_STAGES; stage++) { - MapChannel[pass][stage] = 1; - } - } -} - -void W3dMaterialClass::Set_Surface_Type(unsigned int type) -{ - SurfaceType = type; -} - -void W3dMaterialClass::Set_Sort_Level(int level) -{ - assert(level <= MAX_SORT_LEVEL); - SortLevel = level; -} - -void W3dMaterialClass::Set_Pass_Count(int count) -{ - assert(count >= 0); - assert(count < MAX_PASSES); - PassCount = count; -} - -void W3dMaterialClass::Set_Vertex_Material(const W3dVertexMaterialStruct & vmat,int pass) -{ - assert(pass >= 0); - assert(pass < PassCount); - - if (Materials[pass] == NULL) { - Materials[pass] = new W3dVertexMaterialStruct; - } - *(Materials[pass]) = vmat; -} - -void W3dMaterialClass::Set_Mapper_Args(const char *args_buffer, int pass, int stage) -{ - assert(pass >= 0); - assert(pass < PassCount); - assert(stage >= 0); - assert(stage < MAX_STAGES); - - if (MapperArgs[pass][stage] != NULL) { - delete [] MapperArgs[pass][stage]; - MapperArgs[pass][stage] = NULL; - } - if (args_buffer) { - int len = strlen(args_buffer); - MapperArgs[pass][stage] = new char [len + 1]; - strcpy(MapperArgs[pass][stage], args_buffer); - } -} - -void W3dMaterialClass::Set_Shader(const W3dShaderStruct & shader,int pass) -{ - assert(pass >= 0); - assert(pass < PassCount); - - Shaders[pass] = shader; -} - -void W3dMaterialClass::Set_Texture(const W3dMapClass & map,int pass,int stage) -{ - assert(pass >= 0); - assert(pass < PassCount); - - if (Textures[pass][stage] == NULL) { - Textures[pass][stage] = new W3dMapClass; - } - *(Textures[pass][stage]) = map; -} - -void W3dMaterialClass::Set_Map_Channel(int pass,int stage,int channel) -{ - assert(pass >= 0); - assert(pass < PassCount); - MapChannel[pass][stage] = channel; -} - -unsigned int W3dMaterialClass::Get_Surface_Type(void) const -{ - return SurfaceType; -} - -int W3dMaterialClass::Get_Sort_Level(void) const -{ - return SortLevel; -} - -int W3dMaterialClass::Get_Pass_Count(void) const -{ - return PassCount; -} - -W3dVertexMaterialStruct * W3dMaterialClass::Get_Vertex_Material(int pass ) const -{ - assert(pass >= 0); - assert(pass < PassCount); - - return Materials[pass]; -} - -const char * W3dMaterialClass::Get_Mapper_Args(int pass, int stage) const -{ - assert(pass >= 0); - assert(pass < PassCount); - assert(stage >= 0); - assert(stage < MAX_STAGES); - - return MapperArgs[pass][stage]; -} - -W3dShaderStruct W3dMaterialClass::Get_Shader(int pass) const -{ - assert(pass >= 0); - assert(pass < PassCount); - return Shaders[pass]; -} - -W3dMapClass * W3dMaterialClass::Get_Texture(int pass,int stage) const -{ - assert(pass >= 0); - assert(pass < PassCount); - assert(stage >= 0); - assert(stage < MAX_STAGES); - - return Textures[pass][stage]; -} - -int W3dMaterialClass::Get_Map_Channel(int pass,int stage) const -{ - assert(pass >= 0); - assert(pass < PassCount); - assert(stage >= 0); - assert(stage < MAX_STAGES); - - return MapChannel[pass][stage]; -} - -void W3dMaterialClass::Init(Mtl * mtl, char *materialColorTexture) -{ - bool ps2_mat = false; - Reset(); - - if (mtl->ClassID() == PS2GameMaterialClassID) - { - ps2_mat = true; - } - - if ((mtl->ClassID() == GameMaterialClassID) || ps2_mat) { - Init((GameMtl*)mtl, materialColorTexture); ///@todo: Fix this for substituted textures. - return; - } - - Texmap * tmap; - PassCount = 1; - - tmap = mtl->GetSubTexmap(ID_RL); - if (tmap && tmap->ClassID() == Class_ID(BMTEX_CLASS_ID,0)) { - PassCount++; - } - - W3dVertexMaterialStruct mat; - W3dShaderStruct shader; - W3dMapClass tex; - - /* - ** Setting up the diffuse color pass - */ - W3d_Shader_Reset(&shader); - - mat.Attributes = 0; - mat.Emissive.R = mat.Emissive.G = mat.Emissive.B = 0; //(uint8)(255 .0f * mtl->GetSelfIllum()); - - Color diffuse = mtl->GetDiffuse(); - mat.Diffuse.R = (uint8)(diffuse.r * 255.0f); - mat.Diffuse.G = (uint8)(diffuse.g * 255.0f); - mat.Diffuse.B = (uint8)(diffuse.b * 255.0f); - mat.Ambient = mat.Diffuse; - - Color specular = mtl->GetSpecular(); - mat.Specular.R = (uint8)(specular.r * 255.0f); - mat.Specular.G = (uint8)(specular.g * 255.0f); - mat.Specular.B = (uint8)(specular.b * 255.0f); - - mat.Shininess = mtl->GetShininess(); - mat.Opacity = 1.0f - mtl->GetXParency(); - mat.Translucency = 0.0f; - - tmap = mtl->GetSubTexmap(ID_DI); - if (tmap && tmap->ClassID() == Class_ID(BMTEX_CLASS_ID,0)) { - - char * tname = ((BitmapTex *)tmap)->GetMapName(); - if (tname) { - tex.Set_Filename(tname); - mat.Diffuse.R = mat.Diffuse.G = mat.Diffuse.B = 255; - W3d_Shader_Set_Texturing(&shader,W3DSHADER_TEXTURING_ENABLE); - Set_Texture(tex,0,0); - } - } - - if (materialColorTexture && !mtl->GetSubTexmap(ID_DI) && !mtl->GetSubTexmap(ID_RL)) - { //no textures on material, substitute textures to improve rendering speed. - tex.Set_Filename(materialColorTexture); ///@todo: Fix this to procedural name/path - W3d_Shader_Set_Texturing(&shader,W3DSHADER_TEXTURING_ENABLE); - //This texture will hold solid pixels of material color, don't need any filtering. -// W3dTextureInfoStruct texinfo; -// memset(&texinfo,0,sizeof(texinfo)); -// texinfo.Attributes = texinfo.Attributes | /*W3DTEXTURE_NO_LOD|*/W3DTEXTURE_CLAMP_U | W3DTEXTURE_CLAMP_V; -// tex.Set_Anim_Info(&texinfo); - Set_Texture(tex,0,0); - } - - if (mat.Opacity != 1.0f) { - W3d_Shader_Set_Dest_Blend_Func(&shader,W3DSHADER_DESTBLENDFUNC_ONE_MINUS_SRC_ALPHA); - W3d_Shader_Set_Src_Blend_Func(&shader,W3DSHADER_SRCBLENDFUNC_SRC_ALPHA); - } - - Set_Vertex_Material(mat,0); - Set_Shader(shader,0); - - - /* - ** Setting up the reflection pass (envmap) - */ - if (PassCount == 2) { - - W3d_Shader_Reset(&shader); - if (ps2_mat) - { - W3d_Shader_Set_Pri_Gradient(&shader,PSS_PRIGRADIENT_MODULATE); - } - else - { - W3d_Shader_Set_Pri_Gradient(&shader,W3DSHADER_PRIGRADIENT_MODULATE); - } - W3d_Shader_Set_Sec_Gradient(&shader,W3DSHADER_SECGRADIENT_DISABLE); - W3d_Shader_Set_Depth_Mask(&shader,W3DSHADER_DEPTHMASK_WRITE_DISABLE); - W3d_Shader_Set_Dest_Blend_Func(&shader,W3DSHADER_DESTBLENDFUNC_ONE); - W3d_Shader_Set_Src_Blend_Func(&shader,W3DSHADER_SRCBLENDFUNC_ONE); - W3d_Shader_Set_Texturing(&shader,W3DSHADER_TEXTURING_ENABLE); - - // PS2 specific paramaters. - W3d_Shader_Set_PS2_Param_A(&shader, PSS_SRC); - W3d_Shader_Set_PS2_Param_B(&shader, PSS_ZERO); - W3d_Shader_Set_PS2_Param_B(&shader, PSS_ONE); - W3d_Shader_Set_PS2_Param_B(&shader, PSS_DEST); - - W3d_Vertex_Material_Reset(&mat); - mat.Diffuse.R = mat.Diffuse.G = mat.Diffuse.B = 128; - mat.Attributes &= W3DVERTMAT_STAGE0_MAPPING_MASK; - mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_ENVIRONMENT; - - tmap = mtl->GetSubTexmap(ID_RL); - if (tmap && tmap->ClassID() == Class_ID(BMTEX_CLASS_ID,0)) { - - char * tname = ((BitmapTex *)tmap)->GetMapName(); - if (tname) { - tex.Set_Filename(tname); - Set_Texture(tex,1); - } - } - - Set_Vertex_Material(mat,1); - Set_Shader(shader,1); - } -} - -void W3dMaterialClass::Init(GameMtl * gamemtl, char *materialColorTexture) -{ - Reset(); - PassCount = gamemtl->Get_Pass_Count(); - Set_Surface_Type (gamemtl->Get_Surface_Type ()); - Set_Sort_Level(gamemtl->Get_Sort_Level()); - - for (int pass=0;passGet_Pass_Count(); pass++) { - - /* - ** set up the shader - */ - W3dShaderStruct shader; - W3d_Shader_Reset(&shader); - shader.DepthCompare = gamemtl->Get_Depth_Compare(pass); - shader.DepthMask = gamemtl->Get_Depth_Mask(pass); - shader.AlphaTest = gamemtl->Get_Alpha_Test(pass); - shader.DestBlend = gamemtl->Get_Dest_Blend(pass); - shader.PriGradient = gamemtl->Get_Pri_Gradient(pass); - shader.SecGradient = gamemtl->Get_Sec_Gradient(pass); - shader.SrcBlend = gamemtl->Get_Src_Blend(pass); - shader.DetailColorFunc = gamemtl->Get_Detail_Color_Func(pass); - shader.DetailAlphaFunc = gamemtl->Get_Detail_Alpha_Func(pass); - shader.Texturing = W3DSHADER_TEXTURING_DISABLE; - shader.PostDetailColorFunc = gamemtl->Get_Detail_Color_Func(pass); // (gth) set up the post-detail options - shader.PostDetailAlphaFunc = gamemtl->Get_Detail_Alpha_Func(pass); - - // PS2 specific paramaters. - W3d_Shader_Set_PS2_Param_A(&shader, gamemtl->Get_PS2_Shader_Param_A(pass)); - W3d_Shader_Set_PS2_Param_B(&shader, gamemtl->Get_PS2_Shader_Param_B(pass)); - W3d_Shader_Set_PS2_Param_C(&shader, gamemtl->Get_PS2_Shader_Param_C(pass)); - W3d_Shader_Set_PS2_Param_D(&shader, gamemtl->Get_PS2_Shader_Param_D(pass)); - - /* - ** set up the vertex material - */ - W3dVertexMaterialStruct mat; - mat.Attributes = 0; - - if (gamemtl->Get_Copy_Specular_To_Diffuse(pass)) { - mat.Attributes |= W3DVERTMAT_COPY_SPECULAR_TO_DIFFUSE; - } - - // mapping type for stage 0 - switch(gamemtl->Get_Mapping_Type(pass, 0)) - { - case GAMEMTL_MAPPING_UV: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_UV; break; - case GAMEMTL_MAPPING_ENV: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_ENVIRONMENT; break; - case GAMEMTL_MAPPING_CHEAP_ENV: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_CHEAP_ENVIRONMENT; break; - case GAMEMTL_MAPPING_SCREEN: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_SCREEN; break; - case GAMEMTL_MAPPING_LINEAR_OFFSET: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_LINEAR_OFFSET; break; - case GAMEMTL_MAPPING_SILHOUETTE: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_SILHOUETTE; break; - - case GAMEMTL_MAPPING_SCALE: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_SCALE; break; - case GAMEMTL_MAPPING_GRID: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_GRID; break; - case GAMEMTL_MAPPING_ROTATE: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_ROTATE; break; - case GAMEMTL_MAPPING_SINE_LINEAR_OFFSET: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_SINE_LINEAR_OFFSET; break; - case GAMEMTL_MAPPING_STEP_LINEAR_OFFSET: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_STEP_LINEAR_OFFSET; break; - case GAMEMTL_MAPPING_ZIGZAG_LINEAR_OFFSET: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_ZIGZAG_LINEAR_OFFSET; break; - case GAMEMTL_MAPPING_WS_CLASSIC_ENV: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_WS_CLASSIC_ENV; break; - case GAMEMTL_MAPPING_WS_ENVIRONMENT: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_WS_ENVIRONMENT; break; - case GAMEMTL_MAPPING_GRID_CLASSIC_ENV: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_GRID_CLASSIC_ENV; break; - case GAMEMTL_MAPPING_GRID_ENVIRONMENT: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_GRID_ENVIRONMENT; break; - case GAMEMTL_MAPPING_RANDOM: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_RANDOM; break; - case GAMEMTL_MAPPING_EDGE: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_EDGE; break; - case GAMEMTL_MAPPING_BUMPENV: mat.Attributes |= W3DVERTMAT_STAGE0_MAPPING_BUMPENV; break; - }; - - // mapping type for stage 1 - switch(gamemtl->Get_Mapping_Type(pass, 1)) - { - case GAMEMTL_MAPPING_UV: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_UV; break; - case GAMEMTL_MAPPING_ENV: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_ENVIRONMENT; break; - case GAMEMTL_MAPPING_CHEAP_ENV: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_CHEAP_ENVIRONMENT; break; - case GAMEMTL_MAPPING_SCREEN: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_SCREEN; break; - case GAMEMTL_MAPPING_LINEAR_OFFSET: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_LINEAR_OFFSET; break; - case GAMEMTL_MAPPING_SILHOUETTE: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_SILHOUETTE; break; - - case GAMEMTL_MAPPING_SCALE: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_SCALE; break; - case GAMEMTL_MAPPING_GRID: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_GRID; break; - case GAMEMTL_MAPPING_ROTATE: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_ROTATE; break; - case GAMEMTL_MAPPING_SINE_LINEAR_OFFSET: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_SINE_LINEAR_OFFSET; break; - case GAMEMTL_MAPPING_STEP_LINEAR_OFFSET: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_STEP_LINEAR_OFFSET; break; - case GAMEMTL_MAPPING_ZIGZAG_LINEAR_OFFSET: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_ZIGZAG_LINEAR_OFFSET; break; - case GAMEMTL_MAPPING_WS_CLASSIC_ENV: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_WS_CLASSIC_ENV; break; - case GAMEMTL_MAPPING_WS_ENVIRONMENT: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_WS_ENVIRONMENT; break; - case GAMEMTL_MAPPING_GRID_CLASSIC_ENV: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_GRID_CLASSIC_ENV; break; - case GAMEMTL_MAPPING_GRID_ENVIRONMENT: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_GRID_ENVIRONMENT; break; - case GAMEMTL_MAPPING_RANDOM: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_RANDOM; break; - case GAMEMTL_MAPPING_EDGE: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_EDGE; break; - case GAMEMTL_MAPPING_BUMPENV: mat.Attributes |= W3DVERTMAT_STAGE1_MAPPING_BUMPENV; break; - }; - - switch(gamemtl->Get_PSX_Translucency(pass)) - { - case GAMEMTL_PSX_TRANS_NONE: mat.Attributes |= W3DVERTMAT_PSX_TRANS_NONE; break; - case GAMEMTL_PSX_TRANS_100: mat.Attributes |= W3DVERTMAT_PSX_TRANS_100; break; - case GAMEMTL_PSX_TRANS_50: mat.Attributes |= W3DVERTMAT_PSX_TRANS_50; break; - case GAMEMTL_PSX_TRANS_25: mat.Attributes |= W3DVERTMAT_PSX_TRANS_25; break; - case GAMEMTL_PSX_TRANS_MINUS_100:mat.Attributes |= W3DVERTMAT_PSX_TRANS_MINUS_100; break; - }; - - if (!gamemtl->Get_PSX_Lighting(pass)) { - mat.Attributes |= W3DVERTMAT_PSX_NO_RT_LIGHTING; - } - - mat.Ambient = Color_To_W3d(gamemtl->Get_Ambient(pass,0)); - mat.Diffuse = Color_To_W3d(gamemtl->Get_Diffuse(pass,0)); - mat.Specular = Color_To_W3d(gamemtl->Get_Specular(pass,0)); - mat.Emissive = Color_To_W3d(gamemtl->Get_Emissive(pass,0)); - mat.Shininess = gamemtl->Get_Shininess(pass,0); - mat.Opacity = gamemtl->Get_Opacity(pass,0); - mat.Translucency = gamemtl->Get_Translucency(pass,0); - - /* - ** install the two textures if present - */ - W3dMapClass w3dmap; - BitmapTex * tex = NULL; - - for (int stage=0; stage < MAX_STAGES; stage++) { - - if (gamemtl->Get_Texture_Enable(pass,stage) && gamemtl->Get_Texture(pass,stage)) { - - w3dmap.Reset(); - - // get the filename for the w3dmap texture - tex = (BitmapTex *)gamemtl->Get_Texture(pass,stage); - assert(tex->GetMapName()); - w3dmap.Set_Filename(tex->GetMapName()); - - // get the animation and flags for the w3dmap texture - W3dTextureInfoStruct texinfo; - memset(&texinfo,0,sizeof(texinfo)); - - texinfo.AnimType = gamemtl->Get_Texture_Anim_Type(pass,stage); - - if (gamemtl->Get_Texture_Publish(pass,stage)) { - texinfo.Attributes = texinfo.Attributes | W3DTEXTURE_PUBLISH; - } - if (gamemtl->Get_Texture_No_LOD(pass,stage)) { - texinfo.Attributes = texinfo.Attributes | W3DTEXTURE_NO_LOD; - } - if (gamemtl->Get_Texture_Clamp_U(pass,stage)) { - texinfo.Attributes = texinfo.Attributes | W3DTEXTURE_CLAMP_U; - } - if (gamemtl->Get_Texture_Clamp_V(pass,stage)) { - texinfo.Attributes = texinfo.Attributes | W3DTEXTURE_CLAMP_V; - } - if (gamemtl->Get_Texture_Alpha_Bitmap(pass,stage)) { - texinfo.Attributes = texinfo.Attributes | W3DTEXTURE_ALPHA_BITMAP; - } - texinfo.Attributes = texinfo.Attributes | ( - (gamemtl->Get_Texture_Hint(pass,stage) << W3DTEXTURE_HINT_SHIFT) - & W3DTEXTURE_HINT_MASK); - - // If the shader indicates bump-environment mapping mark this texture as a bumpmap. - if ((stage == 0) && (gamemtl->Get_Pri_Gradient (pass) == W3DSHADER_PRIGRADIENT_BUMPENVMAP)) { - texinfo.Attributes |= W3DTEXTURE_TYPE_BUMPMAP; - } - - texinfo.FrameCount = gamemtl->Get_Texture_Frame_Count(pass,stage); - texinfo.FrameRate = gamemtl->Get_Texture_Frame_Rate(pass,stage); - - if ((texinfo.FrameCount > 1) || (texinfo.Attributes != 0)) { - w3dmap.Set_Anim_Info(&texinfo); - } - - // plug it in and turn on texturing in the shader - Set_Texture(w3dmap,pass,stage); - shader.Texturing = W3DSHADER_TEXTURING_ENABLE; - - // copy over the mapping channel - Set_Map_Channel(pass,stage,gamemtl->Get_Map_Channel(pass,stage)); - - // copy over the mapper args - Set_Mapper_Args(gamemtl->Get_Mapping_Arg_Buffer(pass, stage), pass, stage); - - } else { - if (materialColorTexture) - { //no textures on material, substitute textures to improve rendering speed. - w3dmap.Reset(); - w3dmap.Set_Filename(materialColorTexture); - - // plug it in and turn on texturing in the shader - Set_Texture(w3dmap,pass,stage); - shader.Texturing = W3DSHADER_TEXTURING_ENABLE; - } - break; // break out of the loop (and dont put in stage 1 if stage 0 is missing...) - } - } - - Set_Shader(shader,pass); - Set_Vertex_Material(mat,pass); - } -} - - -bool W3dMaterialClass::Is_Multi_Pass_Transparent(void) const -{ - return ((PassCount >= 2) && (Get_Shader(0).DestBlend != W3DSHADER_DESTBLENDFUNC_ZERO)); -} - - -/* - - - Implementation of W3dMaterialDescClass::VertClass - - -*/ -W3dMaterialDescClass::VertMatClass::VertMatClass(void) : - PassIndex(-1), - Crc(0), - Name(NULL) -{ - for (int stage=0; stage < W3dMaterialClass::MAX_STAGES; ++stage) { - MapperArgs[stage] = NULL; - } -} - -W3dMaterialDescClass::VertMatClass::~VertMatClass(void) -{ - if (Name) free(Name); - - for (int stage=0; stage < W3dMaterialClass::MAX_STAGES; ++stage) { - if (MapperArgs[stage]) { - delete [] (MapperArgs[stage]); - MapperArgs[stage] = NULL; - } - } -} - -W3dMaterialDescClass::VertMatClass & -W3dMaterialDescClass::VertMatClass::operator = (const VertMatClass & that) -{ - if (this != &that) { - Material = that.Material; - PassIndex = that.PassIndex; - Crc = that.Crc; - Set_Name(that.Name); - for (int stage=0; stage < W3dMaterialClass::MAX_STAGES; stage++) { - Set_Mapper_Args(that.MapperArgs[stage], stage); - } - } - return *this; -} - -bool W3dMaterialDescClass::VertMatClass::operator != (const VertMatClass & that) -{ - return !(*this == that); -} - -bool W3dMaterialDescClass::VertMatClass::operator == (const VertMatClass & that) -{ - assert(0); return false; -} - -void W3dMaterialDescClass::VertMatClass::Set_Name(const char * name) -{ - if (Name) free(Name); - - if (name) { - Name = strdup(name); - } else { - Name = NULL; - } -} - -void W3dMaterialDescClass::VertMatClass::Set_Mapper_Args(const char * args, int stage) -{ - if (MapperArgs[stage]) { - delete [] (MapperArgs[stage]); - MapperArgs[stage] = NULL; - } - - if (args) { - int len = strlen(args); - MapperArgs[stage] = new char [len + 1]; - strcpy(MapperArgs[stage], args); - } else { - MapperArgs[stage] = NULL; - } -} - - -/* - - - Implementation of W3dMaterialDescClass - - -*/ -W3dMaterialDescClass::MaterialRemapClass::MaterialRemapClass(void) -{ - PassCount = -1; - for (int pass=0; pass= 0); - assert(vmat_index < VertexMaterials.Count()); - return &(VertexMaterials[vmat_index].Material); -} - -const char * W3dMaterialDescClass::Get_Mapper_Args(int vmat_index, int stage) -{ - assert(vmat_index >= 0); - assert(vmat_index < VertexMaterials.Count()); - assert(stage >= 0); - assert(stage < W3dMaterialClass::MAX_STAGES); - return VertexMaterials[vmat_index].MapperArgs[stage]; -} - -W3dShaderStruct * W3dMaterialDescClass::Get_Shader(int shader_index) -{ - assert(shader_index >= 0); - assert(shader_index < Shaders.Count()); - return &(Shaders[shader_index].Shader); -} - -W3dMapClass * W3dMaterialDescClass::Get_Texture(int texture_index) -{ - assert(texture_index >= 0); - assert(texture_index < Textures.Count()); - return &(Textures[texture_index].Map); -} - -int W3dMaterialDescClass::Get_Vertex_Material_Index(int mat_index,int pass) -{ - assert(mat_index >= 0); - assert(mat_index < MaterialRemaps.Count()); - assert(pass >= 0); - assert(pass < PassCount); - return MaterialRemaps[mat_index].VertexMaterialIdx[pass]; -} - -int W3dMaterialDescClass::Get_Shader_Index(int mat_index,int pass) -{ - assert(mat_index >= 0); - assert(mat_index < MaterialRemaps.Count()); - assert(pass >= 0); - assert(pass < PassCount); - return MaterialRemaps[mat_index].ShaderIdx[pass]; -} - -int W3dMaterialDescClass::Get_Texture_Index(int mat_index,int pass,int stage) -{ - assert(mat_index >= 0); - assert(mat_index < MaterialRemaps.Count()); - assert(pass >= 0); - assert(pass < PassCount); - assert(stage >= 0); - assert(stage < W3dMaterialClass::MAX_STAGES); - return MaterialRemaps[mat_index].TextureIdx[pass][stage]; -} - -W3dVertexMaterialStruct * W3dMaterialDescClass::Get_Vertex_Material(int mat_index,int pass) -{ - int index = Get_Vertex_Material_Index(mat_index,pass); - if (index == -1) { - return NULL; - } else { - return Get_Vertex_Material(index); - } -} - -const char * W3dMaterialDescClass::Get_Mapper_Args(int mat_index,int pass,int stage) -{ - int index = Get_Vertex_Material_Index(mat_index,pass); - if (index == -1) { - return NULL; - } else { - return Get_Mapper_Args(index,stage); - } -} - -W3dShaderStruct * W3dMaterialDescClass::Get_Shader(int mat_index,int pass) -{ - int index = Get_Shader_Index(mat_index,pass); - if (index == -1) { - return NULL; - } else { - return Get_Shader(index); - } -} - -W3dMapClass * W3dMaterialDescClass::Get_Texture(int mat_index,int pass,int stage) -{ - int index = Get_Texture_Index(mat_index,pass,stage); - if (index == -1) { - return NULL; - } else { - return Get_Texture(index); - } -} - -int W3dMaterialDescClass::Get_Map_Channel(int mat_index,int pass,int stage) -{ - return MaterialRemaps[mat_index].MapChannel[pass][stage]; -} - -const char * W3dMaterialDescClass::Get_Vertex_Material_Name(int mat_index,int pass) -{ - int index = Get_Vertex_Material_Index(mat_index,pass); - if (index == -1) { - return NULL; - } else { - return VertexMaterials[index].Name; - } -} - -const char * W3dMaterialDescClass::Get_Vertex_Material_Name(int vmat_index) -{ - return VertexMaterials[vmat_index].Name; -} - -bool W3dMaterialDescClass::Stage_Needs_Texture_Coordinates(int pass,int stage) -{ - for (int mi=0; miFilename == NULL)) { - return -1; - } - - int crc = Compute_Crc(*map); - for (int ti=0; tiAttributes,sizeof(map.AnimInfo->Attributes),crc); - crc = CRC_Memory((const unsigned char *)&map.AnimInfo->AnimType,sizeof(map.AnimInfo->AnimType),crc); - crc = CRC_Memory((const unsigned char *)&map.AnimInfo->FrameCount,sizeof(map.AnimInfo->FrameCount),crc); - crc = CRC_Memory((const unsigned char *)&map.AnimInfo->FrameRate,sizeof(map.AnimInfo->FrameRate),crc); - } - crc = CRC_Stringi(map.Filename, crc); - return crc; -} - -unsigned long W3dMaterialDescClass::Add_String_To_Crc(const char *str, unsigned long in_crc) -{ - unsigned long out_crc = in_crc; - if (str) { - int len = strlen(str); - char *temp = new char[len + 1]; - const char *p_in = str; - - // skip leading spaces, tabs, newlines - for (; *p_in == ' ' || *p_in == '\t' || *p_in == '\r' || *p_in == '\n'; p_in++); - - // copy string, skipping spaces and tabs - char * p_out = temp; - int count = 0; - for (; *p_in; p_in++) { - for (; *p_in == ' ' || *p_in == '\t'; p_in++); - if (!(*p_in)) break; - *p_out = *p_in; - p_out++; - count++; - } - *p_out = 0; - - // Erase any trailing newlines: - if (count) { - // p_out now points to the ending null - make it point to the - // character before it (the last character of the string proper) - p_out--; - - for (; *p_out == '\r' || *p_out == '\n'; p_out--) { - *p_out = '\000'; - count--; - } - } - - out_crc = CRC_Memory((const unsigned char *)temp,count,in_crc); - delete [] temp; - } - return out_crc; -} - - diff --git a/Generals/Code/Tools/WW3D/max2w3d/w3dmtl.h b/Generals/Code/Tools/WW3D/max2w3d/w3dmtl.h deleted file mode 100644 index 32d647a0b55..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/w3dmtl.h +++ /dev/null @@ -1,313 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Max2W3d * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/w3dmtl.h $* - * * - * $Author:: Andre_a $* - * * - * $Modtime:: 12/07/00 2:47p $* - * * - * $Revision:: 15 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef W3DMTL_H -#define W3DMTL_H - -#include "always.h" -#include "w3d_file.h" -#include "Vector.H" - -class GameMtl; -class Mtl; -class ChunkSaveClass; - - -/* -** W3dMapClass. -** This class simply ties together the map info and the map filename -*/ -class W3dMapClass -{ -public: - W3dMapClass(void) : Filename(NULL), AnimInfo(NULL) {}; - W3dMapClass(const W3dMapClass & that); - ~W3dMapClass(void); - - W3dMapClass & operator = (const W3dMapClass & that); - - void Reset(void); - void Set_Filename(const char * name); - void Set_Anim_Info(const W3dTextureInfoStruct * info); - void Set_Anim_Info(int framecount,float framerate); - - char * Filename; - W3dTextureInfoStruct * AnimInfo; -}; - - -/* -** W3dMaterialClass. -** This class ties together w3d structures for up to 'MAX_PASSES' material passes. -** It is typically plugged into the next class (W3dMaterialDescClass) so that -** duplicate members can detected and shared. -*/ -class W3dMaterialClass -{ -public: - - W3dMaterialClass(void); - ~W3dMaterialClass(void); - - enum { MAX_PASSES = 4, MAX_STAGES = 2 }; - - void Reset(void); - - /* - ** Construction from Max materials - */ - void Init(Mtl * mtl, char *materialColorTexture=NULL); - void Init(GameMtl * gamemtl, char *materialColorTexture=NULL); - - /* - ** Manual Construction - */ - void Set_Surface_Type(unsigned int type); - void Set_Sort_Level(int level); - void Set_Pass_Count(int count); - void Set_Vertex_Material(const W3dVertexMaterialStruct & vmat,int pass = 0); - void Set_Mapper_Args(const char *args_buffer, int pass = 0, int stage = 0); - void Set_Shader(const W3dShaderStruct & shader,int pass = 0); - void Set_Texture(const W3dMapClass & map,int pass = 0,int stage = 0); - void Set_Map_Channel(int pass,int stage,int channel); - - /* - ** Inspection - */ - unsigned int Get_Surface_Type(void) const; - int Get_Sort_Level(void) const; - int Get_Pass_Count(void) const; - W3dVertexMaterialStruct * Get_Vertex_Material(int pass = 0) const; - const char * Get_Mapper_Args(int pass /*= 0*/, int stage /*= 0*/) const; - W3dShaderStruct Get_Shader(int pass = 0) const; - W3dMapClass * Get_Texture(int pass = 0,int stage = 0) const; - int Get_Map_Channel(int pass = 0,int stage = 0) const; - - bool Is_Multi_Pass_Transparent(void) const; - -protected: - - void Free(void); - - unsigned int SurfaceType; - int SortLevel; - int PassCount; - - W3dShaderStruct Shaders[MAX_PASSES]; - W3dVertexMaterialStruct * Materials[MAX_PASSES]; - char * MapperArgs[MAX_PASSES][MAX_STAGES]; - W3dMapClass * Textures[MAX_PASSES][MAX_STAGES]; - int MapChannel[MAX_PASSES][MAX_STAGES]; - -}; - - -/* -** W3dMaterialDescClass -** This class's purpose is to process the set of w3dmaterials used by a mesh into a set -** of surrender passes with shaders, vertexmaterials, textures. Part of its job is -** to detect duplicated shaders and vertex materials and remove them. -*/ -class W3dMaterialDescClass -{ -public: - - typedef enum ErrorType - { - OK = 0, // material description was built successfully - INCONSISTENT_PASSES, // material doesn't have same number of passes - MULTIPASS_TRANSPARENT, // material is transparent and multi-pass (NO-NO!) - INCONSISTENT_SORT_LEVEL, // material doesn't have the same sort level! - }; - - W3dMaterialDescClass(void); - ~W3dMaterialDescClass(void); - - void Reset(void); - - /* - ** Interface for adding a material description. The material will be assigned - ** an index based on the order at which they are added. Add your materials in - ** order, then use their indices to find the remapped vertex materials, textures, - ** and shaders... - */ - ErrorType Add_Material(const W3dMaterialClass & mat,const char * name = NULL); - - /* - ** Global Information. These methods give access to all of the unique vertex materials, - ** shaders, and textures being used. - */ - int Material_Count(void); - int Pass_Count(void); - int Vertex_Material_Count(void); - int Shader_Count(void); - int Texture_Count(void); - int Get_Sort_Level(void); - - W3dVertexMaterialStruct * Get_Vertex_Material(int vmat_index); - const char * Get_Mapper_Args(int vmat_index, int stage); - W3dShaderStruct * Get_Shader(int shader_index); - W3dMapClass * Get_Texture(int texture_index); - - /* - ** Per-Pass Information. These methods convert a material index and pass index pair into - ** an index to the desired vertex material, texture or shader. - */ - int Get_Vertex_Material_Index(int mat_index,int pass); - int Get_Shader_Index(int mat_index,int pass); - int Get_Texture_Index(int mat_index,int pass,int stage); - W3dVertexMaterialStruct * Get_Vertex_Material(int mat_index,int pass); - const char * Get_Mapper_Args(int mat_index,int pass,int stage); - W3dShaderStruct * Get_Shader(int mat_index,int pass); - W3dMapClass * Get_Texture(int mat_index,int pass,int stage); - int Get_Map_Channel(int mat_index,int pass,int stage); - bool Stage_Needs_Texture_Coordinates(int pass,int stage); - bool Pass_Uses_Vertex_Alpha(int pass); - bool Pass_Uses_Alpha(int pass); - - /* - ** Vertex Material Names. It will be useful to have named vertex materials. I'll keep - ** the name of the first material which contained each vertex material as its name. Use - ** these functions to get the name associated with a vertex material - */ - const char * Get_Vertex_Material_Name(int mat_index,int pass); - const char * Get_Vertex_Material_Name(int vmat_index); - -private: - - int Add_Vertex_Material(W3dVertexMaterialStruct * vmat,const char *mapper_args0,const char *mapper_args1,int pass,const char * name); - int Add_Shader(const W3dShaderStruct & shader,int pass); - int Add_Texture(W3dMapClass * map,int pass,int stage); - unsigned long Compute_Crc(const W3dVertexMaterialStruct & vmat,const char *mapper_args0,const char *mapper_args1); - unsigned long Compute_Crc(const W3dShaderStruct & shader); - unsigned long Compute_Crc(const W3dMapClass & map); - unsigned long Add_String_To_Crc(const char *str, unsigned long crc); - - /* - ** MaterialRemapClass - ** When the user supplies a W3dMaterial to this material description class, - ** its sub-parts are installed and an instance of this class is created to - ** re-index to each one. - */ - class MaterialRemapClass - { - public: - MaterialRemapClass(void); - - bool operator != (const MaterialRemapClass & that); - bool operator == (const MaterialRemapClass & that); - - int PassCount; - int VertexMaterialIdx[W3dMaterialClass::MAX_PASSES]; - int ShaderIdx[W3dMaterialClass::MAX_PASSES]; - int TextureIdx[W3dMaterialClass::MAX_PASSES][W3dMaterialClass::MAX_STAGES]; - int MapChannel[W3dMaterialClass::MAX_PASSES][W3dMaterialClass::MAX_STAGES]; - }; - - /* - ** VertMatClass - ** This class encapsulates a vertex material structure and makes it extendable for - ** any purposes needed by the plugin code. For example, the pass index is stored - ** so that we can prevent "welding" of vertex materials in different passes (since - ** this may not be desireable...) - */ - class VertMatClass - { - public: - VertMatClass(void); - ~VertMatClass(void); - - VertMatClass & operator = (const VertMatClass & that); - bool operator != (const VertMatClass & that); - bool operator == (const VertMatClass & that); - void Set_Name(const char * name); - void Set_Mapper_Args(const char * args, int stage); - - W3dVertexMaterialStruct Material; - char * MapperArgs[W3dMaterialClass::MAX_STAGES]; // note: these strings are new'ed, not malloc'ed (unlike Name) - int PassIndex; // using this to prevent joining of vertmats in different passes. - int Crc; // crc, used for quick rejection when checking for matches. - char * Name; // material name associated with the first occurence of this vmat. - }; - - /* - ** ShadeClass - ** Again, simply here to make the shader extendable for any purposes needed by this - ** pre-processing code... - */ - class ShadeClass - { - public: - ShadeClass & operator = (const ShadeClass & that) { Shader = that.Shader; Crc = that.Crc; return *this;} - bool operator != (const ShadeClass & that) { return !(*this == that); } - bool operator == (const ShadeClass & that) { assert(0); return false; } - - W3dShaderStruct Shader; - int Crc; - }; - - /* - ** TexClass - ** Simply here to allow extra info to be stored with each texture, as needed by this - ** pre-processing code... - */ - class TexClass - { - public: - TexClass & operator = (const TexClass & that) { Map = that.Map; Crc = that.Crc; return *this; } - bool operator != (const TexClass & that) { return !(*this == that); } - bool operator == (const TexClass & that) { assert(0); return false; } - - W3dMapClass Map; - int Crc; - }; - - int PassCount; - int SortLevel; - DynamicVectorClass < MaterialRemapClass > MaterialRemaps; - DynamicVectorClass < ShadeClass > Shaders; - DynamicVectorClass < VertMatClass > VertexMaterials; - DynamicVectorClass < TexClass > Textures; - -}; - - - -#endif \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/max2w3d/w3dutil.cpp b/Generals/Code/Tools/WW3D/max2w3d/w3dutil.cpp deleted file mode 100644 index 584e336e8e0..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/w3dutil.cpp +++ /dev/null @@ -1,2047 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/w3dutil.cpp 45 8/21/01 10:28a Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/w3dutil.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 8/21/01 9:41a $* - * * - * $Revision:: 45 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "w3dutil.h" -#include "w3ddesc.h" -#include "rcmenu.h" -#include "util.h" -#include "nodelist.h" -#include "tchar.h" -#include "gamemtl.h" -#include "notify.h" -#include "gennamesdialog.h" -#include "genmtlnamesdialog.h" -#include "genlodextensiondialog.h" -#include "floaterdialog.h" -#include - - -#define DAZZLE_SETTINGS_FILENAME "dazzle.ini" -#define DAZZLE_TYPES_SECTION "Dazzles_List" -#define DAZZLE_SECTION_BUFFERSIZE 32767 - - -static BOOL CALLBACK _settings_form_dlg_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); -static BOOL CALLBACK _w3d_utility_tools_dlg_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - -static VisibleSelectedINodeFilter _INodeFilter; - - -/********************************************************************************************** -** -** MaterialReferenceMaker - Class to support Export Utilities in the W3D Tools panel. -** -**********************************************************************************************/ -class MaterialReferenceMaker : public ReferenceMaker -{ - public: - - ~MaterialReferenceMaker() {DeleteAllRefs();} - - virtual int NumRefs(); - virtual RefTargetHandle GetReference (int i); - virtual void SetReference (int i, RefTargetHandle rtarg); - RefResult NotifyRefChanged (Interval changeInt,RefTargetHandle hTarget,PartID& partID, RefMessage message); - - Mtl *MaterialPtr; - static int ReferenceCount; -}; - -int MaterialReferenceMaker::NumRefs() -{ - return (ReferenceCount); -} - -RefTargetHandle MaterialReferenceMaker::GetReference (int i) -{ - assert (i < ReferenceCount); - return (MaterialPtr); -} - -void MaterialReferenceMaker::SetReference (int i, RefTargetHandle rtarg) -{ - assert (i < ReferenceCount); - MaterialPtr = (Mtl*) rtarg; -} - -RefResult MaterialReferenceMaker::NotifyRefChanged(Interval changeInt,RefTargetHandle hTarget,PartID& partID, RefMessage message) -{ - return (REF_SUCCEED); -} - -int MaterialReferenceMaker::ReferenceCount; - - -/********************************************************************************************** -** -** SettingsFormClass - code for the W3DUTILITY_SETTINGS_DIALOG. Used in the command panel -** and in the floating settings dialog. -** -**********************************************************************************************/ -class SettingsFormClass -{ -public: - - SettingsFormClass(HWND hwnd); - ~SettingsFormClass(void); - - bool Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM); - void Selection_Changed(void); - - static void Update_All_Instances(void); - -private: - - void Init(void); - void Destroy(void); - void Disable_Controls(void); - void Update_Controls(INodeListClass * nodelist = NULL); - - HWND Hwnd; - ISpinnerControl * RegionSpin; - SettingsFormClass * Next; - - static SettingsFormClass * ActiveList; - -}; - - -/********************************************************************************************** -** -** W3DUtilityClass - Utility plugin which presents windows controls for setting all of -** the W3D export options for the currently selected nodes -** -**********************************************************************************************/ -class W3DUtilityClass : public UtilityObj -{ -public: - - W3DUtilityClass(); - ~W3DUtilityClass(); - - void BeginEditParams(Interface *ip,IUtil *iu); - void EndEditParams(Interface *ip,IUtil *iu); - void SelectionSetChanged(Interface *ip,IUtil *iu); - void DeleteThis() {} - - void Select_Hierarchy(void); - void Select_Geometry(void); - void Select_Alpha(void); - void Select_Physical(void); - void Select_Projectile(void); - void Select_Vis(void); - -public: - - Interface * InterfacePtr; - FloaterDialogClass SettingsFloater; - HWND SettingsPanelHWND; - HWND ToolsPanelHWND; - bool UpdateSpinnerValue; - - GenNamesDialogClass::OptionsStruct NameOptions; - GenMtlNamesDialogClass::OptionsStruct MtlNameOptions; - GenLodExtensionDialogClass::OptionsStruct LodExtensionOptions; - - int WorkingNameIndex; - - enum { - NONE = 0, - HIDE, - SELECT_GEOM, - SELECT_HIER, - SELECT_ALPHA, - SELECT_PHYSICAL, - SELECT_PROJECTILE, - SELECT_VIS, - GENERATE_NAME, - GENERATE_MATERIAL_NAME, - GENERATE_LOD_EXTENSION - }; - - enum MaterialConversionEnum { - GAME_REFERENCE_COUNT, - GAME_TO_STANDARD, - STANDARD_TO_GAME - }; - - struct NodeStatesStruct - { - int ExportHierarchy; - int ExportGeometry; - int GeometryTwoSided; - int GeometryHidden; - int GeometryZNormals; - int GeometryVertexAlpha; - int GeometryCastShadow; - int GeometryShatterable; - int GeometryNPatch; - int CollisionPhysical; - int CollisionProjectile; - int CollisionVis; - int CollisionCamera; - int CollisionVehicle; - bool GeometryCameraAligned; - bool GeometryCameraOriented; - bool GeometryNormal; - bool GeometryAABox; - bool GeometryOBBox; - bool GeometryNull; - bool GeometryDazzle; - bool GeometryAggregate; - - int DamageRegion; - int DazzleCount; - char DazzleType[128]; - }; - - /* - ** Evaluate the status of nodes in the given list - */ - static int eval_tri_state(int totalcount,int oncount); - static void eval_node_states(INodeListClass * node_list,NodeStatesStruct * ns); - - /* - ** Update the controls in any active settings panels - */ - static void update_settings_controls(INodeListClass * node_list = NULL); - - /* - ** Modify the state of all selected nodes - */ - static void set_hierarchy_in_all_selected(INodeListClass * list,bool onoff); - static void set_geometry_in_all_selected(INodeListClass * list,bool onoff); - static void enable_hidden_in_all_selected(INodeListClass * list,bool onoff); - static void enable_two_sided_in_all_selected(INodeListClass * list,bool onoff); - static void enable_znormals_in_all_selected(INodeListClass * list,bool onoff); - static void enable_vertex_alpha_in_all_selected(INodeListClass * list,bool onoff); - static void enable_shadow_in_all_selected(INodeListClass * list,bool onoff); - static void enable_shatterable_in_all_selected(INodeListClass * list,bool onoff); - static void enable_npatches_in_all_selected(INodeListClass * list,bool onoff); - static void enable_physical_collision_in_all_selected(INodeListClass * list,bool onoff); - static void enable_projectile_collision_in_all_selected(INodeListClass * list,bool onoff); - static void enable_vis_collision_in_all_selected(INodeListClass * list,bool onoff); - static void enable_camera_collision_in_all_selected(INodeListClass * list,bool onoff); - static void enable_vehicle_collision_in_all_selected(INodeListClass * list,bool onoff); - - static void set_geometry_type_in_all_selected(INodeListClass * list,int geotype); - static void set_dazzle_type_in_all_selected(INodeListClass * list,char * dazzletype); - - static void set_region_in_all_selected(INodeListClass * list,char region); - - /* - ** Functions used by the tools rollup in the command panel - */ - void descend_tree(INode * node,int action); - void hide_node(INode * node); - void select_geometry_node(INode * node); - void select_hierarchy_node(INode * node); - void select_alpha_node(INode * node); - void select_physical_node(INode * node); - void select_projectile_node(INode * node); - void select_vis_node(INode * node); - bool is_alpha_material(Mtl * nodemtl); - bool is_alpha_mesh(INode * node,Mtl * nodemtl); - - void generate_names(void); - void generate_node_name(INode * node); - void generate_material_names(void); - void generate_material_names_for_node(INode * node); - void generate_material_names(Mtl * mtl); - void generate_lod_extensions(void); - void generate_lod_ext(INode * node); - - void create_floater(void); - - void export_with_standard_materials(); - int convert_materials (MaterialConversionEnum conversion, MaterialReferenceMaker *gamenodematerials); - StdMat * new_standard_material (GameMtl *gamemtl); - - static W3DAppData0Struct * get_app_data_0(INode * node); - static W3DAppData1Struct * get_app_data_1(INode * node); - static W3DAppData2Struct * get_app_data_2(INode * node); - static W3DDazzleAppDataStruct * get_dazzle_app_data(INode * node); -}; - -static W3DUtilityClass TheW3DUtility; - - -/********************************************************************************************** -** -** W3DUtilityClassDesc - Class Descriptor for the W3D Utility -** -**********************************************************************************************/ -class W3DUtilityClassDesc:public ClassDesc -{ -public: - - int IsPublic() { return 1; } - void * Create(BOOL loading = FALSE) { return &TheW3DUtility; } - const TCHAR * ClassName() { return Get_String(IDS_W3D_UTILITY_CLASS_NAME); } - SClass_ID SuperClassID() { return UTILITY_CLASS_ID; } - Class_ID ClassID() { return W3DUtilityClassID; } - const TCHAR* Category() { return Get_String(IDS_W3DMENU_CATEGORY); } -}; - -static W3DUtilityClassDesc W3DUtilityDesc; - -ClassDesc * Get_W3D_Utility_Desc(void) -{ - return &W3DUtilityDesc; -} - -/********************************************************************************************** -** -** W3DUtilityClass Implementation -** -**********************************************************************************************/ -W3DUtilityClass::W3DUtilityClass(void) -{ - InterfacePtr = NULL; - SettingsPanelHWND = NULL; - ToolsPanelHWND = NULL; - UpdateSpinnerValue = true; -} - -W3DUtilityClass::~W3DUtilityClass(void) -{ -} - -void W3DUtilityClass::BeginEditParams(Interface *ip,IUtil *iu) -{ - InterfacePtr = ip; - - SettingsPanelHWND = InterfacePtr->AddRollupPage( - AppInstance, - MAKEINTRESOURCE(IDD_W3DUTILITY_SETTINGS_DIALOG), - _settings_form_dlg_proc, - Get_String(IDS_W3DUTILITY_SETTINGS), - 0); - - ToolsPanelHWND = InterfacePtr->AddRollupPage( - AppInstance, - MAKEINTRESOURCE(IDD_W3DUTILITY_TOOLS_DIALOG), - _w3d_utility_tools_dlg_proc, - Get_String(IDS_W3DUTILITY_TOOLS), - 0); - - -// TheRCMenu.Bind(TheW3DUtility.InterfacePtr,&TheW3DUtility); -// RightClickMenuManager *rcm = ip->GetRightClickMenuManager(); -// if (TheRCMenu.Installed!=TRUE) { -// rcm->Register(&TheRCMenu); -// } - - SettingsFormClass::Update_All_Instances(); -} - -void W3DUtilityClass::EndEditParams(Interface *ip,IUtil *iu) -{ - InterfacePtr = NULL; - - ip->DeleteRollupPage(SettingsPanelHWND); - ip->DeleteRollupPage(ToolsPanelHWND); - - SettingsPanelHWND = NULL; - ToolsPanelHWND = NULL; -} - -void W3DUtilityClass::SelectionSetChanged(Interface *ip,IUtil *iu) -{ - // (gth) the settings panels which need to respond to the selection set changing - // are now registered directly with MAX and don't need to be updated here - // update_dialog(); -} - -int W3DUtilityClass::eval_tri_state(int totalcount,int oncount) -{ - if (oncount == 0) { - return 0; - } - if (oncount == totalcount) { - return 1; - } - return 2; -} - -void W3DUtilityClass::eval_node_states(INodeListClass * list,NodeStatesStruct * ns) -{ - // initialize the counters and booleans - ns->ExportHierarchy = 0; - ns->ExportGeometry = 0; - ns->GeometryHidden = 0; - ns->GeometryTwoSided = 0; - ns->GeometryZNormals = 0; - ns->GeometryVertexAlpha = 0; - ns->GeometryCastShadow = 0; - ns->GeometryShatterable = 0; - ns->GeometryNPatch = 0; - ns->CollisionPhysical = 0; - ns->CollisionProjectile = 0; - ns->CollisionVis = 0; - ns->CollisionCamera = 0; - ns->CollisionVehicle = 0; - - ns->GeometryCameraAligned = false; - ns->GeometryCameraOriented = false; - ns->GeometryNormal = false; - ns->GeometryAABox = false; - ns->GeometryOBBox = false; - ns->GeometryNull = false; - ns->GeometryDazzle = false; - ns->GeometryAggregate = false; - - /* - ** ns->DamageRegion will be MAX_DAMAGE_REGIONS if not all - ** of the selected nodes are in the same damage region. If - ** they are, then ns->DamageRegion will be the region they - ** share. - */ - if (list->Num_Nodes() > 0) - { - // Use the first damage region for comparing to the others. - W3DAppData1Struct *wdata = get_app_data_1((*list)[0]); - ns->DamageRegion = wdata->DamageRegion; - } - else - ns->DamageRegion = MAX_DAMAGE_REGIONS; - - /* - ** ns->DazzleType will be DEFAULT if not all of the selected - ** nodes are the same. If they are the same, it will be the - ** dazzle type that they all share - */ - ns->DazzleCount = 0; - if (list->Num_Nodes() > 0) { - W3DDazzleAppDataStruct * dazzledata = get_dazzle_app_data((*list)[0]); - strncpy(ns->DazzleType,dazzledata->DazzleType,sizeof(ns->DazzleType)); - } else { - strcpy(ns->DazzleType,"DEFAULT"); - } - - /* - ** evaluate each node - */ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - - W3DAppData2Struct * wdata = get_app_data_2((*list)[ni]); - assert(wdata); - - ns->ExportHierarchy += (wdata->Is_Bone() ? 1 : 0); - ns->ExportGeometry += (wdata->Is_Geometry() ? 1 : 0); - ns->GeometryHidden += (wdata->Is_Hidden_Enabled() ? 1 : 0); - ns->GeometryTwoSided += (wdata->Is_Two_Sided_Enabled() ? 1 : 0); - ns->GeometryZNormals += (wdata->Is_ZNormals_Enabled() ? 1 : 0); - ns->GeometryVertexAlpha += (wdata->Is_Vertex_Alpha_Enabled() ? 1 : 0); - ns->GeometryCastShadow += (wdata->Is_Shadow_Enabled() ? 1 : 0); - ns->GeometryShatterable += (wdata->Is_Shatterable_Enabled() ? 1 : 0); - ns->GeometryNPatch += (wdata->Is_NPatchable_Enabled() ? 1 : 0); - ns->CollisionPhysical += (wdata->Is_Physical_Collision_Enabled() ? 1 : 0); - ns->CollisionProjectile += (wdata->Is_Projectile_Collision_Enabled() ? 1 : 0); - ns->CollisionVis += (wdata->Is_Vis_Collision_Enabled() ? 1 : 0); - ns->CollisionCamera += (wdata->Is_Camera_Collision_Enabled() ? 1 : 0); - ns->CollisionVehicle += (wdata->Is_Vehicle_Collision_Enabled() ? 1 : 0); - - switch (wdata->Get_Geometry_Type()) { - case W3DAppData2Struct::GEO_TYPE_CAMERA_ALIGNED: ns->GeometryCameraAligned = true; break; - case W3DAppData2Struct::GEO_TYPE_CAMERA_ORIENTED: ns->GeometryCameraOriented = true; break; - case W3DAppData2Struct::GEO_TYPE_NORMAL_MESH: ns->GeometryNormal = true; break; - case W3DAppData2Struct::GEO_TYPE_AABOX: ns->GeometryAABox = true; break; - case W3DAppData2Struct::GEO_TYPE_OBBOX: ns->GeometryOBBox = true; break; - case W3DAppData2Struct::GEO_TYPE_NULL: ns->GeometryNull = true; break; - case W3DAppData2Struct::GEO_TYPE_DAZZLE: ns->GeometryDazzle = true; ns->DazzleCount++; break; - case W3DAppData2Struct::GEO_TYPE_AGGREGATE: ns->GeometryAggregate = true; break; - } - - // Compare this damage region to our existing one. If it's not the same, - // use MAX_DAMAGE_REGION (an invalid value) as a sentinel value. - if (ns->DamageRegion != MAX_DAMAGE_REGIONS) - { - W3DAppData1Struct *wdata1 = get_app_data_1((*list)[ni]); - assert(wdata1); - if (wdata1->DamageRegion != ns->DamageRegion) - ns->DamageRegion = MAX_DAMAGE_REGIONS; - } - - // compare this objects dazzle type to our existing one. If its not - // the same, use 'DEFAULT'. - W3DDazzleAppDataStruct * dazzledata = get_dazzle_app_data((*list)[ni]); - if (strcmp(ns->DazzleType,dazzledata->DazzleType) != 0) { - strcpy(ns->DazzleType,"DEFAULT"); - } - } - - // If any of the counters are zero, that means none of the objects had that - // bit set. If any of them are equal to the number of objects, then they - // all had that bit set. Otherwise, there was a mix and we should use the - // third state for the checkbox (greyed out check). - int count = list->Num_Nodes(); - ns->ExportHierarchy = eval_tri_state(count, ns->ExportHierarchy); - ns->ExportGeometry = eval_tri_state(count, ns->ExportGeometry); - ns->GeometryHidden = eval_tri_state(count, ns->GeometryHidden); - ns->GeometryTwoSided = eval_tri_state(count, ns->GeometryTwoSided); - ns->GeometryZNormals = eval_tri_state(count, ns->GeometryZNormals); - ns->GeometryVertexAlpha = eval_tri_state(count, ns->GeometryVertexAlpha); - ns->GeometryCastShadow = eval_tri_state(count, ns->GeometryCastShadow); - ns->GeometryShatterable = eval_tri_state(count, ns->GeometryShatterable); - ns->GeometryNPatch = eval_tri_state(count, ns->GeometryNPatch); - ns->CollisionPhysical = eval_tri_state(count, ns->CollisionPhysical); - ns->CollisionProjectile = eval_tri_state(count, ns->CollisionProjectile); - ns->CollisionVis = eval_tri_state(count, ns->CollisionVis); - ns->CollisionCamera = eval_tri_state(count, ns->CollisionCamera); - ns->CollisionVehicle = eval_tri_state(count, ns->CollisionVehicle); - -} - -void W3DUtilityClass::update_settings_controls(INodeListClass * node_list) -{ - SettingsFormClass::Update_All_Instances(); -} - -void W3DUtilityClass::set_hierarchy_in_all_selected(INodeListClass * node_list,bool onoff) -{ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]); - wdata->Enable_Export_Transform(onoff); - } - update_settings_controls(node_list); -} - -void W3DUtilityClass::set_geometry_in_all_selected(INodeListClass * node_list,bool onoff) -{ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]); - wdata->Enable_Export_Geometry(onoff); - } - update_settings_controls(node_list); -} - -void W3DUtilityClass::enable_hidden_in_all_selected(INodeListClass * node_list,bool onoff) -{ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]); - wdata->Enable_Hidden(onoff); - } - update_settings_controls(node_list); -} - -void W3DUtilityClass::enable_two_sided_in_all_selected(INodeListClass * node_list,bool onoff) -{ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]); - wdata->Enable_Two_Sided(onoff); - } - update_settings_controls(node_list); -} - -void W3DUtilityClass::enable_znormals_in_all_selected(INodeListClass * node_list,bool onoff) -{ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]); - wdata->Enable_ZNormals(onoff); - } - update_settings_controls(node_list); -} - -void W3DUtilityClass::enable_vertex_alpha_in_all_selected(INodeListClass * node_list,bool onoff) -{ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]); - wdata->Enable_Vertex_Alpha(onoff); - } - update_settings_controls(node_list); -} - -void W3DUtilityClass::enable_shadow_in_all_selected(INodeListClass * node_list,bool onoff) -{ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]); - wdata->Enable_Shadow(onoff); - } - update_settings_controls(node_list); -} - -void W3DUtilityClass::enable_shatterable_in_all_selected(INodeListClass * node_list,bool onoff) -{ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]); - wdata->Enable_Shatterable(onoff); - } - update_settings_controls(node_list); -} - -void W3DUtilityClass::enable_npatches_in_all_selected(INodeListClass * node_list,bool onoff) -{ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]); - wdata->Enable_NPatchable(onoff); - } - update_settings_controls(node_list); -} - -void W3DUtilityClass::enable_physical_collision_in_all_selected(INodeListClass * node_list,bool onoff) -{ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]); - wdata->Enable_Physical_Collision(onoff); - } - update_settings_controls(node_list); -} - -void W3DUtilityClass::enable_projectile_collision_in_all_selected(INodeListClass * node_list,bool onoff) -{ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]); - wdata->Enable_Projectile_Collision(onoff); - } - update_settings_controls(node_list); -} - -void W3DUtilityClass::enable_vis_collision_in_all_selected(INodeListClass * node_list,bool onoff) -{ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]); - wdata->Enable_Vis_Collision(onoff); - } - update_settings_controls(node_list); -} - -void W3DUtilityClass::enable_camera_collision_in_all_selected(INodeListClass * node_list,bool onoff) -{ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]); - wdata->Enable_Camera_Collision(onoff); - } - update_settings_controls(node_list); -} - -void W3DUtilityClass::enable_vehicle_collision_in_all_selected(INodeListClass * node_list,bool onoff) -{ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]); - wdata->Enable_Vehicle_Collision(onoff); - } - update_settings_controls(node_list); -} - -void W3DUtilityClass::set_geometry_type_in_all_selected(INodeListClass * node_list,int geotype) -{ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - W3DAppData2Struct * wdata = get_app_data_2((*node_list)[ni]); - wdata->Set_Geometry_Type((W3DAppData2Struct::GeometryTypeEnum)geotype); - } - update_settings_controls(node_list); -} - -void W3DUtilityClass::set_dazzle_type_in_all_selected(INodeListClass * node_list,char * dazzle_type) -{ - for (unsigned int ni=0; niNum_Nodes(); ni++) { - W3DDazzleAppDataStruct * dazzledata = get_dazzle_app_data((*node_list)[ni]); - strncpy(dazzledata->DazzleType,dazzle_type,sizeof(dazzledata->DazzleType) - 1); - } - update_settings_controls(node_list); -} - -void W3DUtilityClass::set_region_in_all_selected(INodeListClass * list,char region) -{ - if (list->Num_Nodes() == 0) return; - - // Damage regions are stored in each node's AppData1. - for (int i = 0; i < list->Num_Nodes(); i++) - { - W3DAppData1Struct *wdata = get_app_data_1((*list)[i]); - wdata->DamageRegion = region; - } - update_settings_controls(list); -} - -void W3DUtilityClass::generate_names(void) -{ - GenNamesDialogClass dialog(InterfacePtr); - bool retval = dialog.Get_Options(&NameOptions); - WorkingNameIndex = NameOptions.NameIndex; - - if (retval) { - descend_tree(InterfacePtr->GetRootNode(),GENERATE_NAME); - } -} - -void W3DUtilityClass::generate_material_names(void) -{ - GenMtlNamesDialogClass dialog(InterfacePtr); - bool retval = dialog.Get_Options(&MtlNameOptions); - WorkingNameIndex = MtlNameOptions.NameIndex; - - if (retval) { - descend_tree(InterfacePtr->GetRootNode(),GENERATE_MATERIAL_NAME); - } -} - -void W3DUtilityClass::generate_lod_extensions(void) -{ - GenLodExtensionDialogClass dialog(InterfacePtr); - bool retval = dialog.Get_Options(&LodExtensionOptions); - - if (retval) { - descend_tree(InterfacePtr->GetRootNode(),GENERATE_LOD_EXTENSION); - } -} - -void W3DUtilityClass::generate_lod_ext(INode * node) -{ - /* - ** Only works on selected nodes. - */ - if (!node->Selected()) - return; - - /* - ** If this node already has an LOD extension, we'll replace it - ** with the new LOD index. Otherwise we'll tack it on the end. - ** Display a error message if the name is too long to append - ** the extension, and skip the node without changing the name. - */ - char msg[256]; - char newname[W3D_NAME_LEN]; - char *oldname = node->GetName(); - char *ext = strrchr(oldname, '.'); - int old_lod; - if ( (ext != NULL) && (sscanf(ext, ".%d", &old_lod) == 1) ) - { - /* - ** An existing LOD index. If it's different than the new - ** one, replace it. - */ - if (old_lod == LodExtensionOptions.LodIndex) - return; // same lod index - - /* - ** Room for the new extension? (2 because when we export, the extension will, - ** be replaced by a single character [A..Z] to indicate the LOD level. - ** ie. 2==strlen("A")+1) - */ - if (ext - oldname + 2 <= W3D_NAME_LEN) - { - *ext = '\0'; - sprintf(newname, "%s.%02d", oldname, LodExtensionOptions.LodIndex); - *ext = '.'; - node->SetName(newname); - } - else - { - *ext = '\0'; - sprintf(msg, "The maximum W3D object name is %d characters. Adding the LOD " - "extension to \"%s\" will pass this limit! Please shorten its name.", - W3D_NAME_LEN - 1, oldname); - *ext = '.'; - MessageBox(NULL, msg, "Error", MB_OK); - } - } - else - { - /* - ** Room for the new extension? (2 because when we export, the extension will, - ** be replaced by a single character [A..Z] to indicate the LOD level. - ** ie. 2==strlen("A")+1) - */ - if (strlen(oldname) + 2 <= W3D_NAME_LEN) - { - sprintf(newname, "%s.%02d", oldname, LodExtensionOptions.LodIndex); - node->SetName(newname); - } - else - { - sprintf(msg, "The maximum W3D object name is %d characters. Adding the LOD " - "extension to \"%s\" will pass this limit! Please shorten its name.", - W3D_NAME_LEN - 1, oldname); - MessageBox(NULL, msg, "Error", MB_OK); - } - } -} - -void W3DUtilityClass::create_floater(void) -{ - SettingsFloater.Create(InterfacePtr,IDD_W3DUTILITY_SETTINGS_DIALOG,_settings_form_dlg_proc); - SettingsFormClass::Update_All_Instances(); -} - -void W3DUtilityClass::export_with_standard_materials() -{ - char *convertingmessage = "Converting materials..."; - - // Count the no. of references to game materials. - MaterialReferenceMaker::ReferenceCount = convert_materials (GAME_REFERENCE_COUNT, NULL); - - MaterialReferenceMaker *gamenodematerials = NULL; - - if (MaterialReferenceMaker::ReferenceCount > 0) { - gamenodematerials = new MaterialReferenceMaker [MaterialReferenceMaker::ReferenceCount]; - assert (gamenodematerials != NULL); - } - - InterfacePtr->PushPrompt (convertingmessage); - SetCursor (LoadCursor (NULL, IDC_WAIT)); - convert_materials (GAME_TO_STANDARD, gamenodematerials); - InterfacePtr->PopPrompt(); - InterfacePtr->FileExport(); - UpdateWindow (InterfacePtr->GetMAXHWnd()); - InterfacePtr->PushPrompt (convertingmessage); - SetCursor (LoadCursor (NULL, IDC_WAIT)); - convert_materials (STANDARD_TO_GAME, gamenodematerials); - InterfacePtr->PopPrompt(); - - // Clean-up. - if (gamenodematerials != NULL) delete [] gamenodematerials; -} - -int W3DUtilityClass::convert_materials (MaterialConversionEnum conversion, MaterialReferenceMaker *gamenodematerials) -{ - int gamenodematerialindex = 0; - - INode *rootnode = InterfacePtr->GetRootNode(); - if (rootnode != NULL) { - - INodeListClass *meshlist = new INodeListClass (rootnode, 0); - if (meshlist != NULL) { - - for (unsigned nodeindex = 0; nodeindex < meshlist->Num_Nodes(); nodeindex++) { - - Mtl *nodemtl = ((*meshlist) [nodeindex])->GetMtl(); - - // Is this a non-null material? - if (nodemtl != NULL) { - - // Is this not a multi-material? - if (!nodemtl->IsMultiMtl()) { - - switch (conversion) { - - case GAME_REFERENCE_COUNT: - if (nodemtl->ClassID() == GameMaterialClassID) { - assert (((GameMtl*) nodemtl)->Substitute_Material() == NULL); - } - break; - - case GAME_TO_STANDARD: - - if (nodemtl->ClassID() == GameMaterialClassID) { - - // Make a reference to the game material to ensure that it is not deleted by the system. - gamenodematerials [gamenodematerialindex].MakeRefByID (FOREVER, gamenodematerialindex, nodemtl); - - // Does this material already have an equivalent standard material? - if (((GameMtl*) nodemtl)->Substitute_Material() == NULL) { - ((GameMtl*) nodemtl)->Set_Substitute_Material (new_standard_material ((GameMtl*) nodemtl)); - } - ((*meshlist) [nodeindex])->SetMtl (((GameMtl*) nodemtl)->Substitute_Material()); - - } else { - gamenodematerials [gamenodematerialindex].MaterialPtr = NULL; - } - break; - - case STANDARD_TO_GAME: - - // Change materials to game materials if they were previously game materials before being - // converted to standard materials. - if (gamenodematerials [gamenodematerialindex].MaterialPtr != NULL) { - ((*meshlist) [nodeindex])->SetMtl (gamenodematerials [gamenodematerialindex].MaterialPtr); - ((GameMtl*) gamenodematerials [gamenodematerialindex].MaterialPtr)->Set_Substitute_Material (NULL); - } - break; - } - gamenodematerialindex++; - - } else { - - // For each sub-material... - for (int materialindex = 0; materialindex < nodemtl->NumSubMtls(); materialindex++) { - - Mtl *submaterial = nodemtl->GetSubMtl (materialindex); - - // Is this a non-null submaterial? - if (submaterial != NULL) { - - switch (conversion) { - - case GAME_REFERENCE_COUNT: - if (submaterial->ClassID() == GameMaterialClassID) { - assert (((GameMtl*) submaterial)->Substitute_Material() == NULL); - } - break; - - case GAME_TO_STANDARD: - - if (submaterial->ClassID() == GameMaterialClassID) { - - // Make a reference to the game material to ensure that it is not deleted by the system. - gamenodematerials [gamenodematerialindex].MakeRefByID (FOREVER, gamenodematerialindex, submaterial); - - // Does this material already have an equivalent standard material? - if (((GameMtl*) submaterial)->Substitute_Material() == NULL) { - ((GameMtl*) submaterial)->Set_Substitute_Material (new_standard_material ((GameMtl*) submaterial)); - } - nodemtl->SetSubMtl (materialindex, ((GameMtl*) submaterial)->Substitute_Material()); - - } else { - gamenodematerials [gamenodematerialindex].MaterialPtr = NULL; - } - break; - - case STANDARD_TO_GAME: - - // Change materials to game materials if they were previously game materials before being - // converted to standard materials. - if (gamenodematerials [gamenodematerialindex].MaterialPtr != NULL) { - nodemtl->SetSubMtl (materialindex, gamenodematerials [gamenodematerialindex].MaterialPtr); - ((GameMtl*) gamenodematerials [gamenodematerialindex].MaterialPtr)->Set_Substitute_Material (NULL); - } - break; - } - gamenodematerialindex++; - } - } - } - } - } - - // Clean-up. - delete meshlist; - } - } - - return (gamenodematerialindex); -} - -StdMat *W3DUtilityClass::new_standard_material (GameMtl *gamemtl) -{ - Color emissive; - - // Create a new standard material. - StdMat *stdmtl = NewDefaultStdMat(); - - // Set its properties by translating the supplied game material. - // NOTE 0: Only consider pass 0 in the game material - ignore all other passes. - // NOTE 1: Use defaults for all standard material attributes that cannot be - // converted from the game material in a meaningful way. - stdmtl->SetName (gamemtl->GetName()); - stdmtl->SetAmbient (gamemtl->GetAmbient(), 0); - stdmtl->SetDiffuse (gamemtl->GetDiffuse(), 0); - stdmtl->SetSpecular (gamemtl->GetSpecular(), 0); - stdmtl->SetOpacity (gamemtl->Get_Opacity (0, 0), 0); - stdmtl->SetShininess (gamemtl->Get_Shininess (0, 0), 0); - stdmtl->SetShinStr (gamemtl->GetShinStr(), 0); - stdmtl->SetSubTexmap (ID_DI, gamemtl->Get_Texture (0, 0)); - emissive = gamemtl->Get_Emissive (0, 0); - stdmtl->SetSelfIllum ((emissive.r + emissive.g + emissive.b) / 3.0f, 0); - - return (stdmtl); -} - -void W3DUtilityClass::Select_Hierarchy(void) -{ - InterfacePtr->SelectNode(NULL); - INode * root = InterfacePtr->GetRootNode(); - descend_tree(root,SELECT_HIER); - InterfacePtr->ForceCompleteRedraw(); -} - -void W3DUtilityClass::Select_Geometry(void) -{ - InterfacePtr->SelectNode(NULL); - INode * root = InterfacePtr->GetRootNode(); - descend_tree(root,SELECT_GEOM); - InterfacePtr->ForceCompleteRedraw(); -} - -void W3DUtilityClass::Select_Alpha(void) -{ - InterfacePtr->SelectNode(NULL); - INode * root = InterfacePtr->GetRootNode(); - descend_tree(root,SELECT_ALPHA); - InterfacePtr->ForceCompleteRedraw(); -} - -void W3DUtilityClass::Select_Physical(void) -{ - InterfacePtr->SelectNode(NULL); - INode * root = InterfacePtr->GetRootNode(); - descend_tree(root,SELECT_PHYSICAL); - InterfacePtr->ForceCompleteRedraw(); -} - -void W3DUtilityClass::Select_Projectile(void) -{ - InterfacePtr->SelectNode(NULL); - INode * root = InterfacePtr->GetRootNode(); - descend_tree(root,SELECT_PROJECTILE); - InterfacePtr->ForceCompleteRedraw(); -} - -void W3DUtilityClass::Select_Vis(void) -{ - InterfacePtr->SelectNode(NULL); - INode * root = InterfacePtr->GetRootNode(); - descend_tree(root,SELECT_VIS); - InterfacePtr->ForceCompleteRedraw(); -} - -void W3DUtilityClass::descend_tree(INode * node,int func) -{ - if (!node) return; - - switch (func) - { - case HIDE: - hide_node(node); - break; - - case SELECT_GEOM: - select_geometry_node(node); - break; - - case SELECT_HIER: - select_hierarchy_node(node); - break; - - case SELECT_ALPHA: - select_alpha_node(node); - break; - - case SELECT_PHYSICAL: - select_physical_node(node); - break; - - case SELECT_PROJECTILE: - select_projectile_node(node); - break; - - case SELECT_VIS: - select_vis_node(node); - break; - - case GENERATE_NAME: - generate_node_name(node); - break; - - case GENERATE_MATERIAL_NAME: - generate_material_names_for_node(node); - break; - - case GENERATE_LOD_EXTENSION: - generate_lod_ext(node); - break; - - default: - break; - }; - - for (int i=0; iNumberOfChildren(); i++) { - INode * child = node->GetChildNode(i); - descend_tree(child,func); - } -} - -void W3DUtilityClass::hide_node(INode * node) -{ - if (!node->IsHidden()) node->Hide(TRUE); - InterfacePtr->NodeInvalidateRect(node); -} - -void W3DUtilityClass::select_geometry_node(INode * node) -{ - if (Is_Geometry(node) && !node->IsHidden()) { - InterfacePtr->SelectNode(node,0); - } -} - -void W3DUtilityClass::select_hierarchy_node(INode * node) -{ - if (Is_Bone(node) && !node->IsHidden()) { - InterfacePtr->SelectNode(node,0); - } -} - -void W3DUtilityClass::select_alpha_node(INode * node) -{ - if (node->IsHidden() || !Is_Geometry(node)) { - return; - } - - Mtl * nodemtl = node->GetMtl(); - if (is_alpha_material(nodemtl)) { - if (is_alpha_mesh(node,nodemtl)) { - InterfacePtr->SelectNode(node,0); - } - } -} - -void W3DUtilityClass::select_physical_node(INode * node) -{ - if (!node->IsHidden() && Is_Geometry(node) && Is_Physical_Collision(node)) { - InterfacePtr->SelectNode(node,0); - } -} - -void W3DUtilityClass::select_projectile_node(INode * node) -{ - if (!node->IsHidden() && Is_Geometry(node) && Is_Projectile_Collision(node)) { - InterfacePtr->SelectNode(node,0); - } -} - -void W3DUtilityClass::select_vis_node(INode * node) -{ - if (!node->IsHidden() && Is_Geometry(node) && Is_Vis_Collision(node)) { - InterfacePtr->SelectNode(node,0); - } -} - -bool W3DUtilityClass::is_alpha_material(Mtl * nodemtl) -{ - if (nodemtl == NULL) { - return false; - } - - bool is_alpha = false; - if (nodemtl->IsMultiMtl()) { - for (int mi=0; miNumSubMtls(); mi++) { - is_alpha |= is_alpha_material(nodemtl->GetSubMtl(mi)); - } - } else { - if (nodemtl->ClassID() == GameMaterialClassID) { - GameMtl * gamemtl = (GameMtl *)nodemtl; - - if ( (gamemtl->Get_Dest_Blend(0) == W3DSHADER_DESTBLENDFUNC_SRC_ALPHA) || - (gamemtl->Get_Dest_Blend(0) == W3DSHADER_DESTBLENDFUNC_ONE_MINUS_SRC_ALPHA) || - (gamemtl->Get_Src_Blend(0) == W3DSHADER_SRCBLENDFUNC_SRC_ALPHA) || - (gamemtl->Get_Src_Blend(0) == W3DSHADER_SRCBLENDFUNC_ONE_MINUS_SRC_ALPHA) || - (gamemtl->Get_Alpha_Test(0) == W3DSHADER_ALPHATEST_ENABLE) ) - { - is_alpha = true; - } - } - } - return is_alpha; -} - -bool W3DUtilityClass::is_alpha_mesh(INode * node,Mtl * nodemtl) -{ - Object * obj = node->EvalWorldState(0).obj; - TriObject * tri = (TriObject *)obj->ConvertToType(0, triObjectClassID); - - if (tri != NULL) { - Mesh & mesh = tri->mesh; - - int face_index; - int mat_index; - - if (nodemtl == NULL) { - - return false; - - } else if (nodemtl->NumSubMtls() <= 1) { - - return is_alpha_material(nodemtl); - - } else { - - int sub_mtl_count = nodemtl->NumSubMtls(); - bool * sub_mtl_flags = new bool[sub_mtl_count]; - - // Initialize each sub-material flag to false (indicates that the material is un-used) - for (mat_index=0; mat_indexGetSubMtl(mat_index))) { - return true; - } - } - } - } - } - return false; -} - -void W3DUtilityClass::generate_node_name(INode * node) -{ - TCHAR temp_string[256]; - - if (NameOptions.OnlyAffectSelected && !node->Selected()) { - return; - } - - if (!Is_Bone(node) && !Is_Geometry(node)) { - return; - } - - if (NameOptions.AssignNames) { - _stprintf(temp_string,"%s%03d",NameOptions.RootName,WorkingNameIndex); - node->SetName(temp_string); - WorkingNameIndex++; - } - - if (NameOptions.AssignPrefix) { - _stprintf(temp_string,"%s%s",NameOptions.PrefixName,node->GetName()); - node->SetName(temp_string); - } - - if (NameOptions.AssignSuffix) { - _stprintf(temp_string,"%s%s",node->GetName(),NameOptions.SuffixName); - node->SetName(temp_string); - } - - if (NameOptions.AssignCollisionBits) { - - W3DAppData2Struct * wdata = W3DAppData2Struct::Get_App_Data(node); - assert(wdata); - - wdata->Enable_Physical_Collision(NameOptions.PhysicalCollision); - wdata->Enable_Projectile_Collision(NameOptions.ProjectileCollision); - wdata->Enable_Vis_Collision(NameOptions.VisCollision); - wdata->Enable_Camera_Collision(NameOptions.CameraCollision); - wdata->Enable_Vehicle_Collision(NameOptions.VehicleCollision); - } -} - -void W3DUtilityClass::generate_material_names_for_node(INode * node) -{ - if (MtlNameOptions.OnlyAffectSelected && !node->Selected()) { - return; - } - generate_material_names(node->GetMtl()); -} - -void W3DUtilityClass::generate_material_names(Mtl * mtl) -{ - if (mtl == NULL) { - return; - } - - // set the name of this material and increment the index - TCHAR newname[GenMtlNamesDialogClass::MAX_MATERIAL_NAME_LEN]; - _stprintf(newname,"%s%03d",MtlNameOptions.RootName,WorkingNameIndex); - mtl->SetName(newname); - WorkingNameIndex++; - - // recurse into children - if (mtl->IsMultiMtl()) { - for (int mi=0; miNumSubMtls(); mi++) { - generate_material_names(mtl->GetSubMtl(mi)); - } - } -} - - -W3DAppData0Struct * W3DUtilityClass::get_app_data_0(INode * node) -{ - /* - ** Try to get our AppData which has the export flags - */ - W3DAppData0Struct * wdata = NULL; - AppDataChunk * appdata = node->GetAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,0); - - /* - ** If there wasn't one, return NULL since this app data chunk is obsolete now. - ** If there was one, get the data from it - */ - if (appdata) { - wdata = (W3DAppData0Struct *)(appdata->data); - } - - return wdata; -} - - -W3DAppData1Struct * W3DUtilityClass::get_app_data_1(INode * node) -{ - // Try to get our AppData which has the damage region - W3DAppData1Struct * wdata = NULL; - AppDataChunk * appdata = node->GetAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,1); - - // If there wasn't one, add one. If there was one, get the data from it - if (appdata) { - wdata = (W3DAppData1Struct *)(appdata->data); - } else { - wdata = new W3DAppData1Struct; - node->AddAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,1,sizeof(W3DAppData1Struct),wdata); - - appdata = node->GetAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,1); - assert(appdata); - } - - return wdata; -} - - -W3DAppData2Struct * W3DUtilityClass::get_app_data_2(INode * node) -{ - return W3DAppData2Struct::Get_App_Data(node); -} - - -W3DDazzleAppDataStruct * W3DUtilityClass::get_dazzle_app_data(INode * node) -{ - return W3DDazzleAppDataStruct::Get_App_Data(node); -} - - -/********************************************************************************************** -** -** Dialog procs for the W3DUtilityClass -** -**********************************************************************************************/ -static BOOL CALLBACK _w3d_utility_tools_dlg_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) { - - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MOUSEMOVE: - TheW3DUtility.InterfacePtr->RollupMouseMessage(hWnd,msg,wParam,lParam); - break; - - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - /* - ** Buttons - */ - case IDC_SELECT_GEOMETRY: - TheW3DUtility.Select_Geometry(); - break; - - case IDC_SELECT_HIERARCHY: - TheW3DUtility.Select_Hierarchy(); - break; - - case IDC_SELECT_ALPHA_MESHES: - TheW3DUtility.Select_Alpha(); - break; - - case IDC_SELECT_PHYSICAL: - TheW3DUtility.Select_Physical(); - break; - - case IDC_SELECT_PROJECTILE: - TheW3DUtility.Select_Projectile(); - break; - - case IDC_SELECT_VIS: - TheW3DUtility.Select_Vis(); - break; - - case IDC_COLLECTION_NAMES_GENERATE: - TheW3DUtility.generate_names(); - TheW3DUtility.update_settings_controls(); - break; - - case IDC_MATERIAL_NAMES_GENERATE: - TheW3DUtility.generate_material_names(); - TheW3DUtility.update_settings_controls(); - break; - - case IDC_LOD_EXTENSION_GENERATE: - TheW3DUtility.generate_lod_extensions(); - TheW3DUtility.update_settings_controls(); - break; - - case IDC_EXPORT_STANDARD_MATERIALS: - TheW3DUtility.export_with_standard_materials(); - break; - - case IDC_CREATE_SETTINGS_FLOATER: - TheW3DUtility.create_floater(); - break; - } - return TRUE; - } - - default: - return FALSE; - } - return TRUE; -} - - - -/********************************************************************************************** -** -** SettingsFormClass Implementation -** NOTE: When you use the _settings_form_dlg_proc, a SettingsFormClass will automatically -** be allocated and attached to the dialog. You can cause all of the active forms to -** refresh their status by calling Update_All_Instances. The forms will be destroyed when -** the window is destroyed. -** -**********************************************************************************************/ -SettingsFormClass * SettingsFormClass::ActiveList = NULL; - -BOOL CALLBACK _settings_form_dlg_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - if (msg == WM_INITDIALOG) { - SettingsFormClass * form = new SettingsFormClass(hWnd); - ::SetProp(hWnd,"SettingsFormClass",(HANDLE)form); - } - - SettingsFormClass * form = (SettingsFormClass *)::GetProp(hWnd,"SettingsFormClass"); - if (form) { - return form->Dialog_Proc(hWnd,msg,wParam,lParam); - } else { - return FALSE; - } -} - -static void _settings_form_selection_changed_callback(void * param,NotifyInfo * info) -{ - ((SettingsFormClass*)param)->Selection_Changed(); -} - -SettingsFormClass::SettingsFormClass(HWND hwnd) : - Hwnd(hwnd), - RegionSpin(NULL) -{ - /* - ** Link into the active list - */ - Next = ActiveList; - ActiveList = this; - - /* - ** Register with MAX - */ - ::RegisterNotification(_settings_form_selection_changed_callback, this, NOTIFY_SELECTIONSET_CHANGED); -} - -SettingsFormClass::~SettingsFormClass(void) -{ - /* - ** Unregister from MAX - */ - ::UnRegisterNotification(_settings_form_selection_changed_callback, this, NOTIFY_SELECTIONSET_CHANGED); - - /* - ** Unlink from the active list - */ - if (ActiveList == this) { - ActiveList = Next; - } else { - - SettingsFormClass * prev = ActiveList; - SettingsFormClass * cur = ActiveList->Next; - - while ((cur != this) && (cur != NULL)) { - cur = cur->Next; - prev = prev->Next; - } - - assert(cur == this); - if (cur == this) { - prev->Next = cur->Next; - } - } - - Hwnd = NULL; -} - - -void SettingsFormClass::Update_All_Instances(void) -{ - if (ActiveList == NULL) { - return; - } - - /* - ** Build a list of the selected nodes - */ - INodeListClass node_list( ::GetCOREInterface()->GetRootNode(), - ::GetCOREInterface()->GetTime(), - &_INodeFilter ); - - /* - ** Update all settings forms - */ - SettingsFormClass * form = ActiveList; - while (form != NULL) { - form->Update_Controls(&node_list); - form = form->Next; - } -} - - -void SettingsFormClass::Init(void) -{ - // Initialize the contents of the dazzle combo - // Reset the dazzle combo - HWND dazzle_combo = GetDlgItem(Hwnd,IDC_DAZZLE_COMBO); - assert(dazzle_combo != NULL); - SendMessage(dazzle_combo,CB_RESETCONTENT,0,0); - - // Load the section of Dazzle.INI that defines all of the types. The windows function - // that I'm using here, reads in a NULL-terminated string for each entry in the section. Each - // string is of the form 'key=value'. Based on my testing, it appears that windows removes any white - // space before or after the equal sign as well. - char dllpath[_MAX_PATH]; - ::GetModuleFileName(AppInstance,dllpath,sizeof(dllpath)); - char * last_slash = strrchr(dllpath,'\\'); - last_slash++; - strcpy(last_slash,DAZZLE_SETTINGS_FILENAME); - - char * dazzle_types_buffer = new char[DAZZLE_SECTION_BUFFERSIZE]; // max size of a section for Win95 - - ::GetPrivateProfileSection( DAZZLE_TYPES_SECTION, dazzle_types_buffer, DAZZLE_SECTION_BUFFERSIZE, dllpath); - - // Now we need to handle each string in the section buffer; skipping the 'key=' and adding - // the dazzle type name into the combo box. - char * entry = dazzle_types_buffer; - if (entry != NULL) { - while (*entry != NULL) { - entry = strchr(entry,'='); - if (entry != NULL) { - entry++; - ::SendMessage(dazzle_combo,CB_ADDSTRING,0,(LPARAM)entry); - entry += strlen(entry) + 1; - } - } - } else { - ::SendMessage(dazzle_combo,CB_ADDSTRING,0,(LPARAM)"Default"); - } - - ::SendMessage(dazzle_combo,CB_SETCURSEL,(WPARAM)0,0); - - delete dazzle_types_buffer; - - /* - ** Setup the damage region spinner control. - */ - RegionSpin = SetupIntSpinner - ( - Hwnd, - IDC_DAMREG_INDEX_SPIN, - IDC_DAMREG_INDEX_EDIT, - NO_DAMAGE_REGION, MAX_DAMAGE_REGIONS-1, NO_DAMAGE_REGION - ); - -} - -void SettingsFormClass::Destroy(void) -{ - ReleaseISpinner(RegionSpin); - RegionSpin = NULL; -} - -bool SettingsFormClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) -{ - int check; - - switch (message) { - case WM_INITDIALOG: - Init(); - break; - - case WM_DESTROY: - Destroy(); - delete this; - break; - - case WM_COMMAND: - { - /* - ** handle the tri-state checkboxes. - ** MAKE SURE YOU PUT ANY NEW CHECKBOX ID's IN HERE!!! - */ - int control_id = LOWORD(wParam); - if ( (control_id == IDC_HIERARCHY_CHECK) || - (control_id == IDC_GEOMETRY_CHECK) || - (control_id == IDC_GEOMETRY_HIDE) || - (control_id == IDC_GEOMETRY_TWO_SIDED) || - (control_id == IDC_GEOMETRY_ZNORMALS) || - (control_id == IDC_GEOMETRY_VERTEX_ALPHA) || - (control_id == IDC_GEOMETRY_CAST_SHADOW) || - (control_id == IDC_GEOMETRY_SHATTERABLE) || - (control_id == IDC_GEOMETRY_NPATCH) || - (control_id == IDC_COLLISION_PHYSICAL) || - (control_id == IDC_COLLISION_PROJECTILE) || - (control_id == IDC_COLLISION_VIS) || - (control_id == IDC_COLLISION_CAMERA) || - (control_id == IDC_COLLISION_VEHICLE)) - { - check = !SendDlgItemMessage(hWnd,LOWORD(wParam),BM_GETCHECK,0,0L); - SendDlgItemMessage(hWnd,LOWORD(wParam),BM_SETCHECK,check,0L); - } - - INodeListClass node_list( ::GetCOREInterface()->GetRootNode(), - ::GetCOREInterface()->GetTime(), - &_INodeFilter ); - - - switch (LOWORD(wParam)) - { - /* - ** Tri-State Checkboxes, make sure that the ID of all checkboxes is present - ** in the 'if' statement above! - */ - case IDC_HIERARCHY_CHECK: - W3DUtilityClass::set_hierarchy_in_all_selected(&node_list,check == BST_CHECKED); - break; - - case IDC_GEOMETRY_CHECK: - W3DUtilityClass::set_geometry_in_all_selected(&node_list,check == BST_CHECKED); - break; - - case IDC_GEOMETRY_HIDE: - W3DUtilityClass::enable_hidden_in_all_selected(&node_list,check == BST_CHECKED); - break; - - case IDC_GEOMETRY_TWO_SIDED: - W3DUtilityClass::enable_two_sided_in_all_selected(&node_list,check == BST_CHECKED); - break; - - case IDC_GEOMETRY_ZNORMALS: - W3DUtilityClass::enable_znormals_in_all_selected(&node_list,check == BST_CHECKED); - break; - - case IDC_GEOMETRY_VERTEX_ALPHA: - W3DUtilityClass::enable_vertex_alpha_in_all_selected(&node_list,check == BST_CHECKED); - break; - - case IDC_GEOMETRY_CAST_SHADOW: - W3DUtilityClass::enable_shadow_in_all_selected(&node_list,check == BST_CHECKED); - break; - - case IDC_GEOMETRY_SHATTERABLE: - W3DUtilityClass::enable_shatterable_in_all_selected(&node_list,check == BST_CHECKED); - break; - - case IDC_GEOMETRY_NPATCH: - W3DUtilityClass::enable_npatches_in_all_selected(&node_list,check == BST_CHECKED); - break; - - case IDC_COLLISION_PHYSICAL: - W3DUtilityClass::enable_physical_collision_in_all_selected(&node_list,check == BST_CHECKED); - break; - - case IDC_COLLISION_PROJECTILE: - W3DUtilityClass::enable_projectile_collision_in_all_selected(&node_list,check == BST_CHECKED); - break; - - case IDC_COLLISION_VIS: - W3DUtilityClass::enable_vis_collision_in_all_selected(&node_list,check == BST_CHECKED); - break; - - case IDC_COLLISION_CAMERA: - W3DUtilityClass::enable_camera_collision_in_all_selected(&node_list,check == BST_CHECKED); - break; - - case IDC_COLLISION_VEHICLE: - W3DUtilityClass::enable_vehicle_collision_in_all_selected(&node_list,check == BST_CHECKED); - break; - - /* - ** Radio buttons for the Geometry type - */ - case IDC_GEOMETRY_NORMAL: - W3DUtilityClass::set_geometry_type_in_all_selected(&node_list,W3DAppData2Struct::GEO_TYPE_NORMAL_MESH); - break; - - case IDC_GEOMETRY_CAMERA_ALIGNED: - W3DUtilityClass::set_geometry_type_in_all_selected(&node_list,W3DAppData2Struct::GEO_TYPE_CAMERA_ALIGNED); - break; - - case IDC_GEOMETRY_CAMERA_ORIENTED: - W3DUtilityClass::set_geometry_type_in_all_selected(&node_list,W3DAppData2Struct::GEO_TYPE_CAMERA_ORIENTED); - break; - - case IDC_GEOMETRY_NULL: - W3DUtilityClass::set_geometry_type_in_all_selected(&node_list,W3DAppData2Struct::GEO_TYPE_NULL); - break; - - case IDC_GEOMETRY_AABOX: - W3DUtilityClass::set_geometry_type_in_all_selected(&node_list,W3DAppData2Struct::GEO_TYPE_AABOX); - break; - - case IDC_GEOMETRY_OBBOX: - W3DUtilityClass::set_geometry_type_in_all_selected(&node_list,W3DAppData2Struct::GEO_TYPE_OBBOX); - break; - - case IDC_GEOMETRY_AGGREGATE: - W3DUtilityClass::set_geometry_type_in_all_selected(&node_list,W3DAppData2Struct::GEO_TYPE_AGGREGATE); - break; - - case IDC_GEOMETRY_DAZZLE: - W3DUtilityClass::set_geometry_type_in_all_selected(&node_list,W3DAppData2Struct::GEO_TYPE_DAZZLE); - break; - - /* - ** Dazzle type setting. Whenever the user changes the selected dazzle type, apply - ** the new setting to all selected nodes. - */ - case IDC_DAZZLE_COMBO: - if (HIWORD(wParam) == CBN_SELCHANGE) { - - HWND dazzle_combo = GetDlgItem(hWnd,IDC_DAZZLE_COMBO); - if (dazzle_combo != NULL) { - - char dazzle_type[128]; - int cursel = ::SendMessage(dazzle_combo,CB_GETCURSEL,0,0); - int len = ::SendMessage(dazzle_combo,CB_GETLBTEXTLEN,cursel,0); - if (len < 128) { - ::SendMessage(dazzle_combo,CB_GETLBTEXT,(WPARAM)cursel,(LPARAM)dazzle_type); - W3DUtilityClass::set_dazzle_type_in_all_selected(&node_list,dazzle_type); - } - } - } - break; - - } - return TRUE; - } - - /* - ** Spinners - */ - case CC_SPINNER_CHANGE: - { - INodeListClass node_list( ::GetCOREInterface()->GetRootNode(), - ::GetCOREInterface()->GetTime(), - &_INodeFilter ); - - W3DUtilityClass::set_region_in_all_selected(&node_list,RegionSpin->GetIVal()); - break; - } - - /* - ** Max Custom Edit boxes - */ - case WM_CUSTEDIT_ENTER: - { - INodeListClass node_list( ::GetCOREInterface()->GetRootNode(), - ::GetCOREInterface()->GetTime(), - &_INodeFilter ); - - ICustEdit * edit_ctrl = GetICustEdit(GetDlgItem(hWnd,wParam)); - if (wParam == IDC_OBJ_NAME) { - if (edit_ctrl && node_list.Num_Nodes() == 1) { - char buffer[64]; - edit_ctrl->GetText(buffer,sizeof(buffer)); - node_list[0]->SetName(buffer); - Update_All_Instances(); - } - } - ReleaseICustEdit(edit_ctrl); - break; - } - - - default: - return FALSE; - } - return TRUE; -} - -void SettingsFormClass::Selection_Changed(void) -{ - INodeListClass node_list( ::GetCOREInterface()->GetRootNode(), - ::GetCOREInterface()->GetTime(), - &_INodeFilter ); - - Update_Controls(&node_list); -} - -void SettingsFormClass::Update_Controls(INodeListClass * node_list) -{ - /* - ** Update name of currently selected object - ** "Multiple" if more than one, "None" if no selected objs... - */ - ICustEdit * edit_ctrl = GetICustEdit(GetDlgItem(Hwnd,IDC_OBJ_NAME)); - if (edit_ctrl != NULL) { - if (node_list->Num_Nodes() == 0) { - edit_ctrl->Enable(FALSE); - edit_ctrl->SetText(Get_String(IDS_NO_OBJECT)); - } else if (node_list->Num_Nodes() == 1) { - edit_ctrl->Enable(TRUE); - edit_ctrl->SetText((*node_list)[0]->GetName()); - } else { - edit_ctrl->Enable(FALSE); - edit_ctrl->SetText(Get_String(IDS_MULTIPLE_OBJECTS)); - } - - ReleaseICustEdit(edit_ctrl); - } - - if (node_list->Num_Nodes() == 0) { - Disable_Controls(); - return; - } - - W3DUtilityClass::NodeStatesStruct ns; - W3DUtilityClass::eval_node_states(node_list,&ns); - - /* - ** Enable hierarchy and geometry checks since they are always available - */ - EnableWindow(GetDlgItem(Hwnd,IDC_HIERARCHY_CHECK),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CHECK),TRUE); - - /* - ** Enable/Disable the geometry controls - */ - if (ns.ExportGeometry == 1) { - - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAMERA_ALIGNED),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAMERA_ORIENTED),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NORMAL),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NULL),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_AABOX),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_OBBOX),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_AGGREGATE),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_DAZZLE),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_HIDE),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_TWO_SIDED),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_ZNORMALS),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_VERTEX_ALPHA),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAST_SHADOW),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_SHATTERABLE),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NPATCH),TRUE); - - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_PHYSICAL),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_PROJECTILE),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_VIS),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_CAMERA),TRUE); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_VEHICLE),TRUE); - - } else { - - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAMERA_ALIGNED),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAMERA_ORIENTED),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NORMAL),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NULL),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_AABOX),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_OBBOX),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_AGGREGATE),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_DAZZLE),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_HIDE),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_TWO_SIDED),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_ZNORMALS),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_VERTEX_ALPHA),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAST_SHADOW),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_SHATTERABLE),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NPATCH),FALSE); - - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_PHYSICAL),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_PROJECTILE),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_VIS),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_CAMERA),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_VEHICLE),FALSE); - } - - /* - ** Set the checks based on the nodes states: - ** no check - none of the selected nodes had this setting - ** check - all of the selected nodes had this setting - ** grey check - some of the selected nodes had this setting - */ - SendDlgItemMessage(Hwnd,IDC_HIERARCHY_CHECK,BM_SETCHECK,ns.ExportHierarchy,0L); - SendDlgItemMessage(Hwnd,IDC_GEOMETRY_CHECK,BM_SETCHECK,ns.ExportGeometry,0L); - SendDlgItemMessage(Hwnd,IDC_GEOMETRY_HIDE,BM_SETCHECK,ns.GeometryHidden,0L); - SendDlgItemMessage(Hwnd,IDC_GEOMETRY_TWO_SIDED,BM_SETCHECK,ns.GeometryTwoSided,0L); - SendDlgItemMessage(Hwnd,IDC_GEOMETRY_ZNORMALS,BM_SETCHECK,ns.GeometryZNormals,0L); - SendDlgItemMessage(Hwnd,IDC_GEOMETRY_VERTEX_ALPHA,BM_SETCHECK,ns.GeometryVertexAlpha,0L); - SendDlgItemMessage(Hwnd,IDC_GEOMETRY_CAST_SHADOW,BM_SETCHECK,ns.GeometryCastShadow,0L); - SendDlgItemMessage(Hwnd,IDC_GEOMETRY_SHATTERABLE,BM_SETCHECK,ns.GeometryShatterable,0L); - SendDlgItemMessage(Hwnd,IDC_GEOMETRY_NPATCH,BM_SETCHECK,ns.GeometryNPatch,0L); - SendDlgItemMessage(Hwnd,IDC_COLLISION_PHYSICAL,BM_SETCHECK,ns.CollisionPhysical,0L); - SendDlgItemMessage(Hwnd,IDC_COLLISION_PROJECTILE,BM_SETCHECK,ns.CollisionProjectile,0L); - SendDlgItemMessage(Hwnd,IDC_COLLISION_VIS,BM_SETCHECK,ns.CollisionVis,0L); - SendDlgItemMessage(Hwnd,IDC_COLLISION_CAMERA,BM_SETCHECK,ns.CollisionCamera,0L); - SendDlgItemMessage(Hwnd,IDC_COLLISION_VEHICLE,BM_SETCHECK,ns.CollisionVehicle,0L); - - /* - ** The damage region spinner should only be enabled if - ** Export Hierarchy is checked for all selected nodes. - */ - BOOL spinner_enable = false; - if (ns.ExportHierarchy == 1) - { - if (ns.DamageRegion != MAX_DAMAGE_REGIONS) - { - // Show the damage region in the spinner. - RegionSpin->SetIndeterminate(FALSE); - RegionSpin->SetValue(ns.DamageRegion, FALSE); - } - else - { - // The selected objects aren't all in the same region. - RegionSpin->SetIndeterminate(TRUE); - } - - spinner_enable = true; - } - EnableWindow(GetDlgItem(Hwnd,IDC_DAMREG_INDEX_EDIT),spinner_enable); - EnableWindow(GetDlgItem(Hwnd,IDC_DAMREG_INDEX_SPIN),spinner_enable); - - /* - ** The dazzle combo box should only be enabled if - ** Export Geometry, and geometry type dazzle is set for all - ** selected nodes. - */ - bool dazzle_combo_enable = false; - if (ns.ExportGeometry == 1) { - if (ns.DazzleCount == node_list->Num_Nodes()) { - dazzle_combo_enable = true; - } - } - HWND dazzle_combo = GetDlgItem(Hwnd,IDC_DAZZLE_COMBO); - EnableWindow(dazzle_combo,dazzle_combo_enable); - int selindex = ::SendMessage(dazzle_combo,CB_FINDSTRING,(WPARAM)0,(LPARAM)ns.DazzleType); - if (selindex != CB_ERR) { - ::SendMessage(dazzle_combo,CB_SETCURSEL,(WPARAM)selindex,(LPARAM)0); - } else { - ::SendMessage(dazzle_combo,CB_SETCURSEL,(WPARAM)0,(LPARAM)0); - } - - /* - ** Set any radio buttons present - */ - CheckDlgButton(Hwnd,IDC_GEOMETRY_CAMERA_ALIGNED,(ns.GeometryCameraAligned ? BST_CHECKED : BST_UNCHECKED)); - CheckDlgButton(Hwnd,IDC_GEOMETRY_CAMERA_ORIENTED,(ns.GeometryCameraOriented ? BST_CHECKED : BST_UNCHECKED)); - CheckDlgButton(Hwnd,IDC_GEOMETRY_NORMAL,(ns.GeometryNormal ? BST_CHECKED : BST_UNCHECKED)); - CheckDlgButton(Hwnd,IDC_GEOMETRY_NULL,(ns.GeometryNull ? BST_CHECKED : BST_UNCHECKED)); - CheckDlgButton(Hwnd,IDC_GEOMETRY_AABOX,(ns.GeometryAABox ? BST_CHECKED : BST_UNCHECKED)); - CheckDlgButton(Hwnd,IDC_GEOMETRY_OBBOX,(ns.GeometryOBBox ? BST_CHECKED : BST_UNCHECKED)); - CheckDlgButton(Hwnd,IDC_GEOMETRY_AGGREGATE,(ns.GeometryAggregate ? BST_CHECKED : BST_UNCHECKED)); - CheckDlgButton(Hwnd,IDC_GEOMETRY_DAZZLE,(ns.GeometryDazzle ? BST_CHECKED : BST_UNCHECKED)); -} - - -void SettingsFormClass::Disable_Controls(void) -{ - EnableWindow(GetDlgItem(Hwnd,IDC_OBJ_NAME),FALSE); - - EnableWindow(GetDlgItem(Hwnd,IDC_HIERARCHY_CHECK),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CHECK),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_DAMREG_INDEX_EDIT),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_DAMREG_INDEX_SPIN),FALSE); - - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NORMAL),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAMERA_ALIGNED),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAMERA_ORIENTED),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_AABOX),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_OBBOX),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NULL),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_AGGREGATE),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_DAZZLE),FALSE); - - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_HIDE),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_TWO_SIDED),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_ZNORMALS),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_VERTEX_ALPHA),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_CAST_SHADOW),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_SHATTERABLE),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_GEOMETRY_NPATCH),FALSE); - - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_PHYSICAL),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_PROJECTILE),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_VIS),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_CAMERA),FALSE); - EnableWindow(GetDlgItem(Hwnd,IDC_COLLISION_VEHICLE),FALSE); - - EnableWindow(GetDlgItem(Hwnd,IDC_DAZZLE_COMBO),FALSE); - - CheckDlgButton(Hwnd,IDC_HIERARCHY_CHECK,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_GEOMETRY_CHECK,BST_UNCHECKED); - - CheckDlgButton(Hwnd,IDC_GEOMETRY_CAMERA_ALIGNED,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_GEOMETRY_CAMERA_ORIENTED,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_GEOMETRY_NORMAL,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_GEOMETRY_AABOX,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_GEOMETRY_OBBOX,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_GEOMETRY_NULL,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_GEOMETRY_AGGREGATE,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_GEOMETRY_DAZZLE,BST_UNCHECKED); - - CheckDlgButton(Hwnd,IDC_GEOMETRY_HIDE,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_GEOMETRY_TWO_SIDED,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_GEOMETRY_ZNORMALS,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_GEOMETRY_VERTEX_ALPHA,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_GEOMETRY_CAST_SHADOW,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_GEOMETRY_SHATTERABLE,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_GEOMETRY_NPATCH,BST_UNCHECKED); - - CheckDlgButton(Hwnd,IDC_COLLISION_PHYSICAL,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_COLLISION_PROJECTILE,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_COLLISION_VIS,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_COLLISION_CAMERA,BST_UNCHECKED); - CheckDlgButton(Hwnd,IDC_COLLISION_VEHICLE,BST_UNCHECKED); -} - - -/* -** Functions to access the W3D AppData of any INode. -*/ -W3DAppData0Struct * GetW3DAppData0 (INode *node) -{ - return TheW3DUtility.get_app_data_0(node); -} - -W3DAppData1Struct * GetW3DAppData1 (INode *node) -{ - return TheW3DUtility.get_app_data_1(node); -} - -W3DAppData2Struct * GetW3DAppData2 (INode *node) -{ - return TheW3DUtility.get_app_data_2(node); -} - -W3DDazzleAppDataStruct * GetW3DDazzleAppData(INode *node) -{ - return TheW3DUtility.get_dazzle_app_data(node); -} diff --git a/Generals/Code/Tools/WW3D/max2w3d/w3dutil.h b/Generals/Code/Tools/WW3D/max2w3d/w3dutil.h deleted file mode 100644 index 005ba6230d1..00000000000 --- a/Generals/Code/Tools/WW3D/max2w3d/w3dutil.h +++ /dev/null @@ -1,130 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/w3dutil.h 29 10/26/00 5:59p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/w3dutil.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/26/00 4:40p $* - * * - * $Revision:: 29 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef W3DUTIL_H -#define W3DUTIL_H - -#include -#include "utilapi.h" -#include "dllmain.h" -#include "resource.h" -#include "util.h" -#include "w3dappdata.h" - -#define W3DUtilityClassID Class_ID(0x3c362c97, 0x5fc73ab0) - -ClassDesc * Get_W3D_Utility_Desc(void); - - - -/* -** W3dExportOptionsStruct - This structure is AppData that is attached -** not to an INode, but to the exporter class itself. It stores the -** export settings so that they come up the same next time, which -** facilitates batch exporting (just use the stored settings). -** -** WWScript.dlx uses this structure to tell if a scene depends on -** the HTree exported by another scene. -*/ -struct W3dExportOptionsStruct -{ - bool ExportHierarchy; - bool LoadHierarchy; - bool ExportAnimation; - bool ExportGeometry; - - // Hierarchy Export options: - bool TranslationOnly; - char HierarchyFilename[_MAX_PATH]; - char RelativeHierarchyFilename[_MAX_PATH]; // For storing in MAX file - - // Animation Export options: - int StartFrame; - int EndFrame; - - // Geometry Export options; - bool UseVoxelizer; - - // Option to apply smoothing between mesh boundaries - bool SmoothBetweenMeshes; - - int space[10]; // blank space, so compression options default proper - - // More Animation Options - bool CompressAnimation; - bool ReduceAnimation; - int ReduceAnimationPercent; - int CompressAnimationFlavor; - float CompressAnimationTranslationError; - float CompressAnimationRotationError; - bool ReviewLog; - - // Option to prevent the exporter from exporting AABTrees with the meshes - // Defined with the "inverse" sense so that older Max files default to having - // AABTrees exported with their meshes. - bool DisableExportAABTrees; - - // Option to cause the exporter to optimize mesh data. Defaulting to zero - // causes older Max files to default to not messing with their mesh data. - bool EnableOptimizeMeshData; - - // Option to cause the exporter to ignore the Export_Transform setting for - // all meshes. Terrains should have all meshes exported in world space. - bool EnableTerrainMode; - - // Option to cause the exporter to generate textures from all materials using - // only diffuse color (no textures). All such material colors will be placed - // into one texture page to improve batch rendering of models. - bool EnableMaterialColorToTextureConversion; -}; - - - - -/* -** Functions to access the W3D AppData of any INode. -** An accessor function for each AppData we define is required. -** Our extensions to the MAXScript language (wwCopyAppData) -** uses these accessors. -*/ -W3DAppData0Struct * GetW3DAppData0 (INode *node); -W3DAppData1Struct * GetW3DAppData1 (INode *node); -W3DAppData2Struct * GetW3DAppData2 (INode *node); -W3DDazzleAppDataStruct * GetW3DDazzleAppData(INode *node); - -#endif diff --git a/Generals/Code/Tools/WW3D/pluglib/BITTYPE.H b/Generals/Code/Tools/WW3D/pluglib/BITTYPE.H deleted file mode 100644 index 4188157216b..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/BITTYPE.H +++ /dev/null @@ -1,46 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/***************************************************************** -* -* Project: 3DTEST1 (3d Test Program) -* -* File: bittype.h -* -* Start Date: Dec 18, 1996 -* -* Programmer: Greg Hjelstrom -* -*****************************************************************/ - -#ifndef BITTYPE_H -#define BITTYPE_H - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned long uint32; - -typedef signed char sint8; -typedef signed short sint16; -typedef signed long sint32; - -typedef float float32; -typedef double float64; - - -#endif //BITTYPE_H \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/pluglib/EULER.CPP b/Generals/Code/Tools/WW3D/pluglib/EULER.CPP deleted file mode 100644 index 281baf84a6c..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/EULER.CPP +++ /dev/null @@ -1,334 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/EULER.CPP 5 12/02/97 10:14p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Engine * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/EULER.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 11/13/97 7:16p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "EULER.H" -#include - - -/********************************************************************* - - There are 24 possible conventions for Euler angles. They can - be designated by: - - EulerAxis = Axis used initially - EulerParity = parity of axis permutation (even = x,y,z) - EulerRepeat = is last axis a repeat of the initial axis? - EulerFrame = frame from which axes are taken (rotating or static) - -*********************************************************************/ - -#define EULER_FRAME_STATIC 0x00000000 -#define EULER_FRAME_ROTATING 0x00000001 -#define EULER_FRAME(order) ((unsigned)(order) & 1) - -#define EULER_REPEAT_NO 0x00000000 -#define EULER_REPEAT_YES 0x00000001 -#define EULER_REPEAT(order) (((unsigned)(order) >> 1) & 1) - -#define EULER_PARITY_EVEN 0x00000000 -#define EULER_PARITY_ODD 0x00000001 -#define EULER_PARITY(order) (((unsigned)(order) >> 2) & 1) - -#define EULER_BUILD_ORDER(i,p,r,f) (((((((i) << 1) + (p)) << 1) + (r)) << 1) + (f)) - - -/* static axes */ -int EulerOrderXYZs = EULER_BUILD_ORDER(0, EULER_PARITY_EVEN, EULER_REPEAT_NO, EULER_FRAME_STATIC); -int EulerOrderXYXs = EULER_BUILD_ORDER(0, EULER_PARITY_EVEN, EULER_REPEAT_YES, EULER_FRAME_STATIC); -int EulerOrderXZYs = EULER_BUILD_ORDER(0, EULER_PARITY_ODD, EULER_REPEAT_NO, EULER_FRAME_STATIC); -int EulerOrderXZXs = EULER_BUILD_ORDER(0, EULER_PARITY_ODD, EULER_REPEAT_YES, EULER_FRAME_STATIC); -int EulerOrderYZXs = EULER_BUILD_ORDER(1, EULER_PARITY_EVEN, EULER_REPEAT_NO, EULER_FRAME_STATIC); -int EulerOrderYZYs = EULER_BUILD_ORDER(1, EULER_PARITY_EVEN, EULER_REPEAT_YES, EULER_FRAME_STATIC); -int EulerOrderYXZs = EULER_BUILD_ORDER(1, EULER_PARITY_ODD, EULER_REPEAT_NO, EULER_FRAME_STATIC); -int EulerOrderYXYs = EULER_BUILD_ORDER(1, EULER_PARITY_ODD, EULER_REPEAT_YES, EULER_FRAME_STATIC); -int EulerOrderZXYs = EULER_BUILD_ORDER(2, EULER_PARITY_EVEN, EULER_REPEAT_NO, EULER_FRAME_STATIC); -int EulerOrderZXZs = EULER_BUILD_ORDER(2, EULER_PARITY_EVEN, EULER_REPEAT_YES, EULER_FRAME_STATIC); -int EulerOrderZYXs = EULER_BUILD_ORDER(2, EULER_PARITY_ODD, EULER_REPEAT_NO, EULER_FRAME_STATIC); -int EulerOrderZYZs = EULER_BUILD_ORDER(2, EULER_PARITY_ODD, EULER_REPEAT_YES, EULER_FRAME_STATIC); - -/* rotating axes */ -int EulerOrderZYXr = EULER_BUILD_ORDER(0, EULER_PARITY_EVEN, EULER_REPEAT_NO, EULER_FRAME_ROTATING); -int EulerOrderXYXr = EULER_BUILD_ORDER(0, EULER_PARITY_EVEN, EULER_REPEAT_YES, EULER_FRAME_ROTATING); -int EulerOrderYZXr = EULER_BUILD_ORDER(0, EULER_PARITY_ODD, EULER_REPEAT_NO, EULER_FRAME_ROTATING); -int EulerOrderXZXr = EULER_BUILD_ORDER(0, EULER_PARITY_ODD, EULER_REPEAT_YES, EULER_FRAME_ROTATING); -int EulerOrderXZYr = EULER_BUILD_ORDER(1, EULER_PARITY_EVEN, EULER_REPEAT_NO, EULER_FRAME_ROTATING); -int EulerOrderYZYr = EULER_BUILD_ORDER(1, EULER_PARITY_EVEN, EULER_REPEAT_YES, EULER_FRAME_ROTATING); -int EulerOrderZXYr = EULER_BUILD_ORDER(1, EULER_PARITY_ODD, EULER_REPEAT_NO, EULER_FRAME_ROTATING); -int EulerOrderYXYr = EULER_BUILD_ORDER(1, EULER_PARITY_ODD, EULER_REPEAT_YES, EULER_FRAME_ROTATING); -int EulerOrderYXZr = EULER_BUILD_ORDER(2, EULER_PARITY_EVEN, EULER_REPEAT_NO, EULER_FRAME_ROTATING); -int EulerOrderZXZr = EULER_BUILD_ORDER(2, EULER_PARITY_EVEN, EULER_REPEAT_YES, EULER_FRAME_ROTATING); -int EulerOrderXYZr = EULER_BUILD_ORDER(2, EULER_PARITY_ODD, EULER_REPEAT_NO, EULER_FRAME_ROTATING); -int EulerOrderZYZr = EULER_BUILD_ORDER(2, EULER_PARITY_ODD, EULER_REPEAT_YES, EULER_FRAME_ROTATING); - -/* local functions */ -static void _euler_unpack_order(int order,int &i,int &j,int &k,int &h,int &n,int &s,int &f); -static int _euler_axis_i(int order); -static int _euler_axis_j(int order); -static int _euler_axis_k(int order); -static int _euler_axis_h(int order); -static void _mat_to_array(const Matrix3 & tm, float M[3][4]); -static void _array_to_mat(float M[3][4], Matrix3 & tm); - - - -EulerAnglesClass::EulerAnglesClass(const Matrix3 & M,int order) -{ - this->From_Matrix(M,order); -} - -double EulerAnglesClass::Get_Angle(int i) -{ - return Angle[i]; -} - -void EulerAnglesClass::From_Matrix(const Matrix3 & tm, int order) -{ - float M[3][4]; - _mat_to_array(tm,M); - - int i,j,k,h,n,s,f; - - Order = order; - _euler_unpack_order(order,i,j,k,h,n,s,f); - - if (s == EULER_REPEAT_YES) { - double sy = sqrt(M[i][j]*M[i][j] + M[i][k]*M[i][k]); - - if (sy > 16*FLT_EPSILON) { - - Angle[0] = atan2(M[i][j],M[i][k]); - Angle[1] = atan2(sy,M[i][i]); - Angle[2] = atan2(M[j][i],-M[k][i]); - - } else { - - Angle[0] = atan2(-M[j][k],M[j][j]); - Angle[1] = atan2(sy,M[i][i]); - Angle[2] = 0.0; - } - - } else { - - double cy = sqrt(M[i][i]*M[i][i] + M[j][i]*M[j][i]); - - if (cy > 16*FLT_EPSILON) { - - Angle[0] = atan2(M[k][j],M[k][k]); - Angle[1] = atan2(-M[k][i],cy); - Angle[2] = atan2(M[j][i],M[i][i]); - - } else { - - Angle[0] = atan2(-M[j][k],M[j][j]); - Angle[1] = atan2(-M[k][i],cy); - Angle[2] = 0; - } - } - - if (n==EULER_PARITY_ODD) { Angle[0] = -Angle[0]; Angle[1] = -Angle[1]; Angle[2] = -Angle[2]; } - if (f==EULER_FRAME_ROTATING) { double t = Angle[0]; Angle[0] = Angle[2]; Angle[2] = t; } - - // Trying to "clean" up the eulers, special cased for XYZr - if (order == EulerOrderXYZr) { - - double x2 = PI + Angle[0]; - double y2 = PI - Angle[1]; - double z2 = PI + Angle[2]; - - if (x2 > PI) { - x2 = x2 - 2*PI; - } - - if (y2 > PI) { - y2 = y2 - 2*PI; - } - - if (z2 > PI) { - z2 = z2 - 2*PI; - } - - double mag0 = Angle[0]*Angle[0] + Angle[1]*Angle[1] + Angle[2]*Angle[2]; - double mag1 = x2*x2 + y2*y2 + z2*z2; - - if (mag1 < mag0) { - Angle[0] = x2; - Angle[1] = y2; - Angle[2] = z2; - } - } -} - - - -void EulerAnglesClass::To_Matrix(Matrix3 & tm) -{ - float M[3][4] = { - { 1.0f, 0.0f, 0.0f, 0.0f }, - { 0.0f, 1.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 1.0f, 0.0f } - }; - - double a0,a1,a2; - double ti,tj,th,ci,cj,ch,si,sj,sh,cc,cs,sc,ss; - int i,j,k,h,n,s,f; - - a0 = Angle[0]; - a1 = Angle[1]; - a2 = Angle[2]; - - _euler_unpack_order(Order,i,j,k,h,n,s,f); - if (f == EULER_FRAME_ROTATING) { - double t = a0; a0 = a2; a2 = t; - } - - if (n == EULER_PARITY_ODD) { - a0 = -a0; a1 = -a1; a2 = -a2; - } - - ti = a0; tj = a1; th = a2; - ci = cos(ti); cj = cos(tj); ch = cos(th); - si = sin(ti); sj = sin(tj); sh = sin(th); - - cc = ci*ch; - cs = ci*sh; - sc = si*ch; - ss = si*sh; - - if (s == EULER_REPEAT_YES) { - - M[i][i] = (float)(cj); M[i][j] = (float)(sj*si); M[i][k] = (float)(sj*ci); - M[j][i] = (float)(sj*sh); M[j][j] = (float)(-cj*ss+cc); M[j][k] = (float)(-cj*cs-sc); - M[k][i] = (float)(-sj*ch); M[k][j] = (float)(cj*sc+cs); M[k][k] = (float)(cj*cc-ss); - - } else { - - M[i][i] = (float)(cj*ch); M[i][j] = (float)(sj*sc-cs); M[i][k] = (float)(sj*cc+ss); - M[j][i] = (float)(cj*sh); M[j][j] = (float)(sj*ss+cc); M[j][k] = (float)(sj*cs-sc); - M[k][i] = (float)(-sj); M[k][j] = (float)(cj*si); M[k][k] = (float)(cj*ci); - - } - _array_to_mat(M,tm); -} - - -static int _euler_safe[] = { 0,1,2,0 }; -static int _euler_next[] = { 1,2,0,1 }; - -int _euler_axis_i(int order) -{ - return _euler_safe[ (order>>3) & 3 ]; -} - -int _euler_axis_j(int order) -{ - int index = _euler_axis_i(order); - if (EULER_PARITY(order) == 1) { - index++; - } - - return _euler_next[ index ]; -} - -int _euler_axis_k(int order) -{ - int index = _euler_axis_i(order); - if (EULER_PARITY(order) != 1) { - index++; - } - - return _euler_next[ index ]; -} - -int _euler_axis_h(int order) -{ - if (EULER_REPEAT(order) == 1) { - return _euler_axis_k(order); - } else { - return _euler_axis_i(order); - } -} - -void _euler_unpack_order(int order,int &i,int &j,int &k,int &h,int &n,int &s,int &f) -{ - - f = order & 1; - order >>= 1; - - s = order & 1; - order >>= 1; - - n = order & 1; - order >>= 1; - - i = _euler_safe[order & 3]; - j = _euler_next[i+n]; - k = _euler_next[i+1-n]; - h = (s ? k : i); -} - -void _mat_to_array(const Matrix3 & tm, float M[3][4]) -{ - // Translation vector - Point3 trans = tm.GetRow(3); - M[0][3] = trans.x; - M[1][3] = trans.y; - M[2][3] = trans.z; - - // Rotation matrix - for (int k=0; k<3; k++) { - Point3 v = tm.GetRow(k); - M[0][k] = v.x; - M[1][k] = v.y; - M[2][k] = v.z; - } -} - -void _array_to_mat(float M[3][4], Matrix3 & tm) -{ - // translation - Point3 row(M[3][0],M[3][1],M[3][2]); - tm.SetRow(3, row); - - // rotation - for (int k=0; k<3; k++) { - row = Point3(M[0][k],M[1][k],M[2][k]); - tm.SetRow(k, row); - } -} - - diff --git a/Generals/Code/Tools/WW3D/pluglib/EULER.H b/Generals/Code/Tools/WW3D/pluglib/EULER.H deleted file mode 100644 index da992b5adda..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/EULER.H +++ /dev/null @@ -1,119 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/EULER.H 3 10/28/97 6:08p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Engine * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/EULER.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/14/97 3:08p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef EULER_H -#define EULER_H - -#include - - -/********************************************************************* - - Euler Order Types - - When creating an EulerAngles object, use one of the below - constants to describe the axis convention. - - XYZ - order of the axes - s/r - whether the rotations are applied to the static or - rotating frame. - -*********************************************************************/ - -/* static axes */ -extern int EulerOrderXYZs; -extern int EulerOrderXYXs; -extern int EulerOrderXZYs; -extern int EulerOrderXZXs; -extern int EulerOrderYZXs; -extern int EulerOrderYZYs; -extern int EulerOrderYXZs; -extern int EulerOrderYXYs; -extern int EulerOrderZXYs; -extern int EulerOrderZXZs; -extern int EulerOrderZYXs; -extern int EulerOrderZYZs; - -/* rotating axes */ -extern int EulerOrderXYZr; -extern int EulerOrderXYXr; -extern int EulerOrderXZYr; -extern int EulerOrderXZXr; -extern int EulerOrderYZXr; -extern int EulerOrderYZYr; -extern int EulerOrderYXZr; -extern int EulerOrderYXYr; -extern int EulerOrderZXYr; -extern int EulerOrderZXZr; -extern int EulerOrderZYXr; -extern int EulerOrderZYZr; - - -/********************************************************************* - - EulerAnglesClass - - The purpose for this class is mainly for conversion. You can - choose a convention for the order of your rotations and then - convert matrices into a set of euler angles. - - This implementation is based on the code in Graphics Gems IV - by Ken Shoemake. The original article is on page 222. - -*********************************************************************/ -class EulerAnglesClass -{ - -public: - - EulerAnglesClass(void) : Order(0) { Angle[0] = 0.0; Angle[1] = 0.0; Angle[2] = 0.0; }; - EulerAnglesClass(const Matrix3 & from,int order); - void From_Matrix(const Matrix3 & from,int order); - void To_Matrix(Matrix3 & M); - - double Get_Angle(int i); - -private: - - double Angle[3]; - int Order; - -}; - - -#endif /*EULER_H*/ \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/pluglib/PROGRESS.H b/Generals/Code/Tools/WW3D/pluglib/PROGRESS.H deleted file mode 100644 index f25dd1362b0..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/PROGRESS.H +++ /dev/null @@ -1,125 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/PROGRESS.H 5 10/28/97 6:08p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D engine * - * * - * File Name : PROGRESS.H * - * * - * Programmer : James McNeil * - * * - * Start Date : 06/19/97 * - * * - * Last Update : June 19, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef PROGRESS_H -#define PROGRESS_H - -#include "always.h" - -class Progress_Meter_Class -{ -public: - - Progress_Meter_Class - ( - Interface * gi, - float base, - float range - ): - Max ( gi ), - Base ( base ), - Range ( range ), - Amount_Done ( 0.0f ), - Increment ( 0.0f ), - Accum( 0.0f ), - Cancel_Requested ( FALSE ) - { - } - - Progress_Meter_Class ( Progress_Meter_Class & other, float sub_amount ): - Max ( other.Max ), - Base ( other.Base + other.Amount_Done * other.Range ), - Range ( other.Range * sub_amount ), - Amount_Done ( 0.0f ), - Increment ( 0.0f ), - Accum ( other.Accum ), - Cancel_Requested ( other.Cancel_Requested ) - { - } - - void Finish_In_Steps ( int number_of_steps ) - { - Increment = (1.0f - Amount_Done) / number_of_steps; - } - - void Add_Increment () - { - Set_Amount_Done ( Amount_Done + Increment ); - } - - void Set_Amount_Done ( float percentage ) - { - Accum += percentage; - Amount_Done = percentage; - if (Accum > 0.01f) { - Max->ProgressUpdate ( (int) (Amount_Done * Range + Base) ); - Accum = 0.0f; - } - - if (Max->GetCancel()) - { - int choice = MessageBox - ( - Max->GetMAXHWnd(), - _T("Do you really want to cancel the export?"), - _T("Cancel Export?"), MB_ICONQUESTION | MB_YESNO - ); - - if ( choice == IDYES ) - Cancel_Requested = TRUE; - else - Max->SetCancel ( FALSE ); - } - } - - BOOL Cancelled () { return Cancel_Requested; } - - float Increment; - -private: - - Interface * Max; - - float Base; - float Range; - float Amount_Done; - float Accum; - - BOOL Cancel_Requested; -}; - -#endif /* PROGRESS_H */ diff --git a/Generals/Code/Tools/WW3D/pluglib/Vector.CPP b/Generals/Code/Tools/WW3D/pluglib/Vector.CPP deleted file mode 100644 index 7db77d1a697..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/Vector.CPP +++ /dev/null @@ -1,355 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Tools/pluglib/Vector.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 3/29/98 10:42a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * BooleanVectorClass::BooleanVectorClass -- Copy constructor for boolean array. * - * BooleanVectorClass::BooleanVectorClass -- Explicit data buffer constructor. * - * BooleanVectorClass::Clear -- Resets boolean vector to empty state. * - * BooleanVectorClass::Fixup -- Updates the boolean vector to a known state. * - * BooleanVectorClass::Reset -- Clear all boolean values in array. * - * BooleanVectorClass::Resize -- Resizes a boolean vector object. * - * BooleanVectorClass::Set -- Forces all boolean elements to true. * - * BooleanVectorClass::operator = -- Assignment operator. * - * BooleanVectorClass::operator == -- Comparison operator for boolean vector. * - * VectorClass::Clear -- Frees and clears the vector. * - * VectorClass::ID -- Finds object ID based on value. * - * VectorClass::ID -- Pointer based conversion to index number. * - * VectorClass::Resize -- Changes the size of the vector. * - * VectorClass::VectorClass -- Constructor for vector class. * - * VectorClass::VectorClass -- Copy constructor for vector object. * - * VectorClass::operator = -- The assignment operator. * - * VectorClass::operator == -- Equality operator for vector objects. * - * VectorClass::~VectorClass -- Default destructor for vector class. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "Vector.H" -#include - -/* -** The following template function can be located here ONLY if all the instantiations are -** declared in a header file this module includes. By placing the template functions here, -** it speeds up compiler operation and reduces object module size. -*/ - -//---------------------------------------------------------------------------------------------- - -/*********************************************************************************************** - * BooleanVectorClass::BooleanVectorClass -- Explicit data buffer constructor. * - * * - * This is the constructor for a boolean array. This constructor takes the memory pointer * - * provided as assigns that as the array data pointer. * - * * - * INPUT: size -- The size of the array (in bits). * - * * - * array -- Pointer to the memory that the array is to use. * - * * - * OUTPUT: none * - * * - * WARNINGS: You must make sure that the memory specified is large enough to contain the * - * bits specified. * - * * - * HISTORY: * - * 07/18/1995 JLB : Created. * - *=============================================================================================*/ -BooleanVectorClass::BooleanVectorClass(unsigned size, unsigned char * array) : - BitCount(size), - Copy(false), - LastIndex(-1), - BitArray(0, 0) -{ - BitArray.Resize(((size + (8-1)) / 8), array); -// LastIndex = -1; -// BitCount = size; -} - - -/*********************************************************************************************** - * BooleanVectorClass::BooleanVectorClass -- Copy constructor of boolean array. * - * * - * This is the copy constructor for a boolean array. It is used to make a duplicate of the * - * boolean array. * - * * - * INPUT: vector -- Reference to the vector to be duplicated. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/18/1995 JLB : Created. * - *=============================================================================================*/ -BooleanVectorClass::BooleanVectorClass(BooleanVectorClass const & vector) -{ - LastIndex = -1; - *this = vector; -} - - -/*********************************************************************************************** - * BooleanVectorClass::operator = -- Assignment operator. * - * * - * This routine will make a copy of the specified boolean vector array. The vector is * - * copied into an already constructed existing vector. The values from the existing vector * - * are destroyed by this copy. * - * * - * INPUT: vector -- Reference to the vector to make a copy of. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/18/1995 JLB : Created. * - *=============================================================================================*/ -BooleanVectorClass & BooleanVectorClass::operator =(BooleanVectorClass const & vector) -{ - Fixup(); - Copy = vector.Copy; - LastIndex = vector.LastIndex; - BitArray = vector.BitArray; - BitCount = vector.BitCount; - return(*this); -} - - -/*********************************************************************************************** - * BooleanVectorClass::operator == -- Comparison operator for boolean vector. * - * * - * This is the comparison operator for a boolean vector class. Boolean vectors are equal * - * if the bit count and bit values are identical. * - * * - * INPUT: vector -- Reference to the vector to compare to. * - * * - * OUTPUT: Are the boolean vectors identical? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/18/1995 JLB : Created. * - *=============================================================================================*/ -bool BooleanVectorClass::operator == (const BooleanVectorClass & vector) -{ - Fixup(LastIndex); - return(BitCount == vector.BitCount && BitArray == vector.BitArray); -} - - -/*********************************************************************************************** - * BooleanVectorClass::Resize -- Resizes a boolean vector object. * - * * - * This routine will resize the boolean vector object. An index value used with a boolean * - * vector must be less than the value specified in as the new size. * - * * - * INPUT: size -- The new maximum size of this boolean vector. * - * * - * OUTPUT: Was the boolean vector sized successfully? * - * * - * WARNINGS: The boolean array might be reallocated or even deleted by this routine. * - * * - * HISTORY: * - * 07/18/1995 JLB : Created. * - *=============================================================================================*/ -int BooleanVectorClass::Resize(unsigned size) -{ - Fixup(); - - if (size > 0) { - - /* - ** Record the previous bit count of the boolean vector. This is used - ** to determine if the array has grown in size and thus clearing is - ** necessary. - */ - unsigned oldsize = BitCount; - - /* - ** Actually resize the bit array. Since this is a bit packed array, - ** there are 8 elements per byte (rounded up). - */ - int success = BitArray.Resize(((size + (8-1)) / 8)); - - /* - ** Since there is no default constructor for bit packed integers, a manual - ** clearing of the bits is required. - */ - BitCount = size; - if (success && oldsize < size) { - for (unsigned index = oldsize; index < size; index++) { - (*this)[index] = 0; - } - } - - return(success); - } - - /* - ** Resizing to zero is the same as clearing and deallocating the array. - ** This is always successful. - */ - Clear(); - return(true); -} - - -/*********************************************************************************************** - * BooleanVectorClass::Clear -- Resets boolean vector to empty state. * - * * - * This routine will clear out the boolean array. This will free any allocated memory and * - * result in the boolean vector being unusable until the Resize function is subsequently * - * called. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: The boolean vector cannot be used until it is resized to a non null condition. * - * * - * HISTORY: * - * 07/18/1995 JLB : Created. * - *=============================================================================================*/ -void BooleanVectorClass::Clear(void) -{ - Fixup(); - BitCount = 0; - BitArray.Clear(); -} - - -/*********************************************************************************************** - * BooleanVectorClass::Reset -- Clear all boolean values in array. * - * * - * This is the preferred (and quick) method to clear the boolean array to a false condition.* - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/18/1995 JLB : Created. * - *=============================================================================================*/ -void BooleanVectorClass::Reset(void) -{ - LastIndex = -1; - if (BitArray.Length() > 0) { - memset(&BitArray[0], '\0', BitArray.Length()); - } -} - - -/*********************************************************************************************** - * BooleanVectorClass::Set -- Forces all boolean elements to true. * - * * - * This is the preferred (and fast) way to set all boolean elements to true. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/18/1995 JLB : Created. * - *=============================================================================================*/ -void BooleanVectorClass::Set(void) -{ - LastIndex = -1; - if (BitArray.Length() > 0) { - memset(&BitArray[0], '\xFF', BitArray.Length()); - } -} - - -/*********************************************************************************************** - * BooleanVectorClass::Fixup -- Updates the boolean vector to a known state. * - * * - * Use this routine to set the boolean value copy to match the appropriate bit in the * - * boolean array. The boolean array will be updated with any changes from the last time * - * a value was fetched from the boolean vector. By using this update method, the boolean * - * array can be treated as a normal array even though the elements are composed of * - * otherwise inaccessible bits. * - * * - * INPUT: index -- The index to set the new copy value to. If the index is -1, then the * - * previous value will be updated into the vector array, but no new value * - * will be fetched from it. * - * * - * OUTPUT: none * - * * - * WARNINGS: Always call this routine with "-1" if any direct manipulation of the bit * - * array is to occur. This ensures that the bit array is accurate. * - * * - * HISTORY: * - * 07/18/1995 JLB : Created. * - *=============================================================================================*/ -void BooleanVectorClass::Fixup(int index) const -{ - /* - ** If the requested index value is illegal, then force the index - ** to be -1. This is the default non-index value. - */ - if ((unsigned)index >= (unsigned)BitCount) { - index = -1; - } - - /* - ** If the new index is different than the previous index, there might - ** be some fixing up required. - */ - if (index != LastIndex) { - - /* - ** If the previously fetched boolean value was changed, then update - ** the boolean array accordingly. - */ - if (LastIndex != -1) { - assert(unsigned(LastIndex) < unsigned(BitCount)); - Set_Bit((void*)&BitArray[0], LastIndex, Copy); - } - - /* - ** If this new current index is valid, then fill in the reference boolean - ** value with the appropriate data from the bit array. - */ - if (index != -1) { - assert(unsigned(index) < unsigned(BitCount)); - ((unsigned char &)Copy) = (unsigned char)Get_Bit((void*)&BitArray[0], index); -// ((unsigned char&)Copy) = Get_Bit((void*)&BitArray[0], index); - } - - ((BooleanVectorClass *)this)->LastIndex = index; - } -} - - diff --git a/Generals/Code/Tools/WW3D/pluglib/Vector.H b/Generals/Code/Tools/WW3D/pluglib/Vector.H deleted file mode 100644 index 38057cf85a8..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/Vector.H +++ /dev/null @@ -1,1006 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Library/Vector.H $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 3/12/98 2:09p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * VectorClass::VectorClass -- Constructor for vector class. * - * VectorClass::~VectorClass -- Default destructor for vector class. * - * VectorClass::VectorClass -- Copy constructor for vector object. * - * VectorClass::operator = -- The assignment operator. * - * VectorClass::operator == -- Equality operator for vector objects. * - * VectorClass::Clear -- Frees and clears the vector. * - * VectorClass::Resize -- Changes the size of the vector. * - * DynamicVectorClass::DynamicVectorClass -- Constructor for dynamic vector. * - * DynamicVectorClass::Resize -- Changes the size of a dynamic vector. * - * DynamicVectorClass::Add -- Add an element to the vector. * - * DynamicVectorClass::Delete -- Remove the specified object from the vector. * - * DynamicVectorClass::Delete -- Deletes the specified index from the vector. * - * VectorClass::ID -- Pointer based conversion to index number. * - * VectorClass::ID -- Finds object ID based on value. * - * DynamicVectorClass::ID -- Find matching value in the dynamic vector. * - * DynamicVectorClass::Uninitialized_Add -- Add an empty place to the vector. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef VECTOR_H -#define VECTOR_H - -#include "noinit.h" -#include -#include -#include -#include -#include - - -/************************************************************************** -** This is a general purpose vector class. A vector is defined by this -** class, as an array of arbitrary objects where the array can be dynamically -** sized. Because is deals with arbitrary object types, it can handle everything. -** As a result of this, it is not terribly efficient for integral objects (such -** as char or int). It will function correctly, but the copy constructor and -** equality operator could be highly optimized if the integral type were known. -** This efficiency can be implemented by deriving an integral vector template -** from this one in order to supply more efficient routines. -*/ - -// Why, oh why does Visual C need this!!! It's bugged. -#pragma warning(disable : 4505) - - -template -class VectorClass -{ - public: - VectorClass(NoInitClass const &) {}; - VectorClass(int size=0, T const * array=0); - VectorClass(VectorClass const &); // Copy constructor. - virtual ~VectorClass(void); - - T & operator[](int index) {assert(unsigned(index) < unsigned(VectorMax));return(Vector[index]);}; - T const & operator[](int index) const {assert(unsigned(index) < unsigned(VectorMax));return(Vector[index]);}; - VectorClass & operator = (VectorClass const &); // Assignment operator. - - virtual bool operator == (VectorClass const &) const; // Equality operator. - - virtual bool Resize(int newsize, T const * array=0); - virtual void Clear(void); - int Length(void) const {return VectorMax;}; - virtual int ID(T const * ptr); // Pointer based identification. - virtual int ID(T const & ptr); // Value based identification. - - protected: - - /* - ** This is a pointer to the allocated vector array of elements. - */ - T * Vector; - - /* - ** This is the maximum number of elements allowed in this vector. - */ - int VectorMax; - - /* - ** This indicates if the vector is in a valid (even if empty) state. - */ - bool IsValid; - - /* - ** Does the vector data pointer refer to memory that this class has manually - ** allocated? If so, then this class is responsible for deleting it. - */ - bool IsAllocated; -}; - - -/*********************************************************************************************** - * VectorClass::VectorClass -- Constructor for vector class. * - * * - * This constructor for the vector class is passed the initial size of the vector and an * - * optional pointer to a preallocated block of memory that the vector will be placed in. * - * If this optional pointer is NULL (or not provided), then the vector is allocated out * - * of free store (with the "new" operator). * - * * - * INPUT: size -- The number of elements to initialize this vector to. * - * * - * array -- Optional pointer to a previously allocated memory block to hold the * - * vector. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1995 JLB : Created. * - *=============================================================================================*/ -template -VectorClass::VectorClass(int size, T const * array) : - Vector(0), - VectorMax(size), - IsValid(true), - IsAllocated(false) -{ - /* - ** Allocate the vector. The default constructor will be called for every - ** object in this vector. - */ - if (size) { - if (array) { - Vector = new((void*)array) T[size]; - } else { - Vector = new T[size]; - IsAllocated = true; - } - } -} - - -/*********************************************************************************************** - * VectorClass::~VectorClass -- Default destructor for vector class. * - * * - * This is the default destructor for the vector class. It will deallocate any memory * - * that it may have allocated. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1995 JLB : Created. * - *=============================================================================================*/ -template -VectorClass::~VectorClass(void) -{ - VectorClass::Clear(); -} - - -/*********************************************************************************************** - * VectorClass::VectorClass -- Copy constructor for vector object. * - * * - * This is the copy constructor for the vector class. It will duplicate the provided * - * vector into the new vector being created. * - * * - * INPUT: vector -- Reference to the vector to use as a copy. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1995 JLB : Created. * - *=============================================================================================*/ -template -VectorClass::VectorClass(VectorClass const & vector) : - Vector(0), - VectorMax(0), - IsValid(true), - IsAllocated(false) -{ - *this = vector; -} - - -/*********************************************************************************************** - * VectorClass::operator = -- The assignment operator. * - * * - * This the the assignment operator for vector objects. It will alter the existing lvalue * - * vector to duplicate the rvalue one. * - * * - * INPUT: vector -- The rvalue vector to copy into the lvalue one. * - * * - * OUTPUT: Returns with reference to the newly copied vector. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1995 JLB : Created. * - *=============================================================================================*/ -template -VectorClass & VectorClass::operator =(VectorClass const & vector) -{ - if (this != &vector) { - Clear(); - VectorMax = vector.Length(); - if (VectorMax) { - Vector = new T[VectorMax]; - if (Vector) { - IsAllocated = true; - for (int index = 0; index < VectorMax; index++) { - Vector[index] = vector[index]; - } - } - } else { - Vector = 0; - IsAllocated = false; - } - } - return(*this); -} - - -/*********************************************************************************************** - * VectorClass::operator == -- Equality operator for vector objects. * - * * - * This operator compares two vectors for equality. It does this by performing an object * - * by object comparison between the two vectors. * - * * - * INPUT: vector -- The right vector expression. * - * * - * OUTPUT: bool; Are the two vectors essentially equal? (do they contain comparable elements * - * in the same order?) * - * * - * WARNINGS: The equality operator must exist for the objects that this vector contains. * - * * - * HISTORY: * - * 03/10/1995 JLB : Created. * - *=============================================================================================*/ -template -bool VectorClass::operator == (VectorClass const & vector) const -{ - if (VectorMax == vector.Length()) { - for (int index = 0; index < VectorMax; index++) { - if (Vector[index] != vector[index]) { - return(false); - } - } - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * VectorClass::ID -- Pointer based conversion to index number. * - * * - * Use this routine to convert a pointer to an element in the vector back into the index * - * number of that object. This routine ONLY works with actual pointers to object within * - * the vector. For "equivalent" object index number (such as with similar integral values) * - * then use the "by value" index number ID function. * - * * - * INPUT: pointer -- Pointer to an actual object in the vector. * - * * - * OUTPUT: Returns with the index number for the object pointed to by the parameter. * - * * - * WARNINGS: This routine is only valid for actual pointers to object that exist within * - * the vector. All other object pointers will yield undefined results. * - * * - * HISTORY: * - * 03/13/1995 JLB : Created. * - *=============================================================================================*/ -template -inline int VectorClass::ID(T const * ptr) -{ - if (!IsValid) return(0); - return(((unsigned long)ptr - (unsigned long)&(*this)[0]) / sizeof(T)); -} - - -/*********************************************************************************************** - * VectorClass::ID -- Finds object ID based on value. * - * * - * Use this routine to find the index value of an object with equivalent value in the * - * vector. Typical use of this would be for integral types. * - * * - * INPUT: object -- Reference to the object that is to be looked up in the vector. * - * * - * OUTPUT: Returns with the index number of the object that is equivalent to the one * - * specified. If no matching value could be found then -1 is returned. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/13/1995 JLB : Created. * - *=============================================================================================*/ -template -int VectorClass::ID(T const & object) -{ - if (!IsValid) return(0); - - for (int index = 0; index < VectorMax; index++) { - if ((*this)[index] == object) { - return(index); - } - } - return(-1); -} - - -/*********************************************************************************************** - * VectorClass::Clear -- Frees and clears the vector. * - * * - * Use this routine to reset the vector to an empty (non-allocated) state. A vector will * - * free all allocated memory when this routine is called. In order for the vector to be * - * useful after this point, the Resize function must be called to give it element space. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1995 JLB : Created. * - *=============================================================================================*/ -template -void VectorClass::Clear(void) -{ - if (Vector && IsAllocated) { - delete[] Vector; - Vector = 0; - } - IsAllocated = false; - VectorMax = 0; -} - - -/*********************************************************************************************** - * VectorClass::Resize -- Changes the size of the vector. * - * * - * This routine is used to change the size (usually to increase) the size of a vector. This * - * is the only way to increase the vector's working room (number of elements). * - * * - * INPUT: newsize -- The desired size of the vector. * - * * - * array -- Optional pointer to a previously allocated memory block that the * - * array will be located in. If this parameter is not supplied, then * - * the array will be allocated from free store. * - * * - * OUTPUT: bool; Was the array resized successfully? * - * * - * WARNINGS: Failure to succeed could be the result of running out of memory. * - * * - * HISTORY: * - * 03/10/1995 JLB : Created. * - *=============================================================================================*/ -template -bool VectorClass::Resize(int newsize, T const * array) -{ - if (newsize) { - - /* - ** Allocate a new vector of the size specified. The default constructor - ** will be called for every object in this vector. - */ - T * newptr; - - /* - ** Either create a new memory block for the object array or initialize - ** an existing block as indicated by the array parameter. When creating a new - ** memory block, flag that the vector object is currently in an invalid - ** state. This is necessary because the default constructor for the object - ** elements may look to the vector to fetch their ID number. - */ - IsValid = false; - if (!array) { - newptr = new T[newsize]; - } else { - newptr = new((void*)array) T[newsize]; - } - IsValid = true; - if (!newptr) { - return(false); - } - - /* - ** If there is an old vector, then it must be copied (as much as is feasible) - ** to the new vector. - */ - if (Vector != NULL) { - - /* - ** Copy as much of the old vector into the new vector as possible. This - ** presumes that there is a functional assignment operator for each - ** of the objects in the vector. - */ - int copycount = (newsize < VectorMax) ? newsize : VectorMax; - for (int index = 0; index < copycount; index++) { - newptr[index] = Vector[index]; - } - - /* - ** Delete the old vector. This might cause the destructors to be called - ** for all of the old elements. This makes the implementation of suitable - ** assignment operator very important. The default assignment operator will - ** only work for the simplest of objects. - */ - if (IsAllocated) { - delete[] Vector; - Vector = 0; - } - } - - /* - ** Assign the new vector data to this class. - */ - Vector = newptr; - VectorMax = newsize; - IsAllocated = (Vector && !array); - - } else { - - /* - ** Resizing to zero is the same as clearing the vector. - */ - Clear(); - } - return(true); -} - - - -/************************************************************************** -** This derivative vector class adds the concept of adding and deleting -** objects. The objects are packed to the beginning of the vector array. -** If this is instantiated for a class object, then the assignment operator -** and the equality operator must be supported. If the vector allocates its -** own memory, then the vector can grow if it runs out of room adding items. -** The growth rate is controlled by setting the growth step rate. A growth -** step rate of zero disallows growing. -*/ -template -class DynamicVectorClass : public VectorClass -{ -protected: - using VectorClass::IsAllocated; - using VectorClass::Vector; - using VectorClass::VectorMax; - public: - using VectorClass::Length; - - public: - DynamicVectorClass(unsigned size=0, T const * array=0); - - // Change maximum size of vector. - virtual bool Resize(int newsize, T const * array=0); - - // Resets and frees the vector array. - virtual void Clear(void) {ActiveCount = 0;VectorClass::Clear();}; - - // Fetch number of "allocated" vector objects. - int Count(void) const {return(ActiveCount);}; - - // Add object to vector (growing as necessary). - bool Add(T const & object); - bool Add_Head(T const & object); - - // Delete object just like this from vector. - bool Delete(T const & object); - - // Delete object at this vector index. - bool Delete(int index); - - // Deletes all objects in the vector. - void Delete_All(void) {ActiveCount = 0;}; - - // Set amount that vector grows by. - int Set_Growth_Step(int step) {return(GrowthStep = step);}; - - // Fetch current growth step rate. - int Growth_Step(void) {return GrowthStep;}; - - virtual int ID(T const * ptr) {return(VectorClass::ID(ptr));}; - virtual int ID(T const & ptr); - - DynamicVectorClass & operator =(DynamicVectorClass const & rvalue) { - VectorClass::operator = (rvalue); - ActiveCount = rvalue.ActiveCount; - GrowthStep = rvalue.GrowthStep; - return(*this); - } - - // Uninitialized Add - does everything an Add does, except copying an - // object into the 'new' spot in the array. It returns a pointer to - // the 'new' spot. (NULL if the Add failed). NOTE - you must then fill - // this memory area with a valid object (e.g. by using placement new), - // or chaos will result! - T * Uninitialized_Add(void); - - protected: - - /* - ** This is a count of the number of active objects in this - ** vector. The memory array often times is bigger than this - ** value. - */ - int ActiveCount; - - /* - ** If there is insufficient room in the vector array for a new - ** object to be added, then the vector will grow by the number - ** of objects specified by this value. This is controlled by - ** the Set_Growth_Step() function. - */ - int GrowthStep; -}; - - -/*********************************************************************************************** - * DynamicVectorClass::DynamicVectorClass -- Constructor for dynamic vector. * - * * - * This is the normal constructor for the dynamic vector class. It is similar to the normal * - * vector class constructor. The vector is initialized to contain the number of elements * - * specified in the "size" parameter. The memory is allocated from free store unless the * - * optional array parameter is provided. In this case it will place the vector at the * - * memory location specified. * - * * - * INPUT: size -- The maximum number of objects allowed in this vector. * - * * - * array -- Optional pointer to the memory area to place the vector at. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1995 JLB : Created. * - *=============================================================================================*/ -template -DynamicVectorClass::DynamicVectorClass(unsigned size, T const * array) - : VectorClass(size, array) -{ - GrowthStep = 10; - ActiveCount = 0; -} - - -/*********************************************************************************************** - * DynamicVectorClass::Resize -- Changes the size of a dynamic vector. * - * * - * Use this routine to change the size of the vector. The size changed is the maximum * - * number of allocated objects within this vector. If a memory buffer is provided, then * - * the vector will be located there. Otherwise, the memory will be allocated out of free * - * store. * - * * - * INPUT: newsize -- The desired maximum size of this vector. * - * * - * array -- Optional pointer to a previously allocated memory array. * - * * - * OUTPUT: bool; Was vector successfully resized according to specifications? * - * * - * WARNINGS: Failure to resize the vector could be the result of lack of free store. * - * * - * HISTORY: * - * 03/10/1995 JLB : Created. * - *=============================================================================================*/ -template -bool DynamicVectorClass::Resize(int newsize, T const * array) -{ - if (VectorClass::Resize(newsize, array)) { - if (Length() < ActiveCount) ActiveCount = Length(); - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * DynamicVectorClass::ID -- Find matching value in the dynamic vector. * - * * - * Use this routine to find a matching object (by value) in the vector. Unlike the base * - * class ID function of similar name, this one restricts the scan to the current number * - * of valid objects. * - * * - * INPUT: object -- A reference to the object that a match is to be found in the * - * vector. * - * * - * OUTPUT: Returns with the index number of the object that is equivalent to the one * - * specified. If no equivalent object could be found then -1 is returned. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/13/1995 JLB : Created. * - *=============================================================================================*/ -template -int DynamicVectorClass::ID(T const & object) -{ - for (int index = 0; index < Count(); index++) { - if ((*this)[index] == object) return(index); - } - return(-1); -} - - -/*********************************************************************************************** - * DynamicVectorClass::Add -- Add an element to the vector. * - * * - * Use this routine to add an element to the vector. The vector will automatically be * - * resized to accomodate the new element IF the vector was allocated previously and the * - * growth rate is not zero. * - * * - * INPUT: object -- Reference to the object that will be added to the vector. * - * * - * OUTPUT: bool; Was the object added successfully? If so, the object is added to the end * - * of the vector. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1995 JLB : Created. * - *=============================================================================================*/ -template -bool DynamicVectorClass::Add(T const & object) -{ - if (ActiveCount >= Length()) { - if ((IsAllocated || !VectorMax) && GrowthStep > 0) { - if (!Resize(Length() + GrowthStep)) { - - /* - ** Failure to increase the size of the vector is an error condition. - ** Return with the error flag. - */ - return(false); - } - } else { - - /* - ** Increasing the size of this vector is not allowed! Bail this - ** routine with the error code. - */ - return(false); - } - } - - /* - ** There is room for the new object now. Add it to the end of the object vector. - */ - (*this)[ActiveCount++] = object; - return(true); -} - - -/*********************************************************************************************** - * DynamicVectorClass::Add_Head -- Adds element to head of the list. * - * * - * This routine will add the specified element to the head of the vector. If necessary, * - * the vector will be expanded accordingly. * - * * - * INPUT: object -- Reference to the object to add to the head of this vector. * - * * - * OUTPUT: bool; Was the object added without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/21/1995 JLB : Created. * - *=============================================================================================*/ -template -bool DynamicVectorClass::Add_Head(T const & object) -{ - if (ActiveCount >= Length()) { - if ((IsAllocated || !VectorMax) && GrowthStep > 0) { - if (!Resize(Length() + GrowthStep)) { - - /* - ** Failure to increase the size of the vector is an error condition. - ** Return with the error flag. - */ - return(false); - } - } else { - - /* - ** Increasing the size of this vector is not allowed! Bail this - ** routine with the error code. - */ - return(false); - } - } - - /* - ** There is room for the new object now. Add it to the end of the object vector. - */ - if (ActiveCount) { - memmove(&(*this)[1], &(*this)[0], ActiveCount * sizeof(T)); - } - (*this)[0] = object; - ActiveCount++; -// (*this)[ActiveCount++] = object; - return(true); -} - - -/*********************************************************************************************** - * DynamicVectorClass::Delete -- Remove the specified object from the vector. * - * * - * This routine will delete the object referenced from the vector. All objects in the * - * vector that follow the one deleted will be moved "down" to fill the hole. * - * * - * INPUT: object -- Reference to the object in this vector that is to be deleted. * - * * - * OUTPUT: bool; Was the object deleted successfully? This should always be true. * - * * - * WARNINGS: Do no pass a reference to an object that is NOT part of this vector. The * - * results of this are undefined and probably catastrophic. * - * * - * HISTORY: * - * 03/10/1995 JLB : Created. * - *=============================================================================================*/ -template -bool DynamicVectorClass::Delete(T const & object) -{ - int id = ID(object); - if (id != -1) { - return(Delete(id)); - } - return(false); -} - - -/*********************************************************************************************** - * DynamicVectorClass::Delete -- Deletes the specified index from the vector. * - * * - * Use this routine to delete the object at the specified index from the objects in the * - * vector. This routine will move all the remaining objects "down" in order to fill the * - * hole. * - * * - * INPUT: index -- The index number of the object in the vector that is to be deleted. * - * * - * OUTPUT: bool; Was the object index deleted successfully? Failure might mean that the index * - * specified was out of bounds. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1995 JLB : Created. * - *=============================================================================================*/ -template -bool DynamicVectorClass::Delete(int index) -{ - if (index < ActiveCount) { - ActiveCount--; - - /* - ** If there are any objects past the index that was deleted, copy those - ** objects down in order to fill the hole. A simple memory copy is - ** not sufficient since the vector could contain class objects that - ** need to use the assignment operator for movement. - */ - for (int i = index; i < ActiveCount; i++) { - (*this)[i] = (*this)[i+1]; - } - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * DynamicVectorClass::Uninitialized_Add -- Add an empty place to the vector. * - * * - * To avoid copying when creating an object and adding it to the vector, use this and * - * immediately fill the area that the return value points to with a valid object (by hand * - * for a struct or by using placement new for a class object). * - * This function does everything Add does except copying an object into the new space, * - * thus leaving an uninitialized area of memory. * - * * - * INPUT: none. * - * * - * OUTPUT: T *; Points to the empty space where the new object is to be created. (If the * - * space was not added succesfully, returns NULL). * - * * - * WARNINGS: If memory area is left uninitialized, Very Bad Things will happen. * - * * - * HISTORY: * - * 03/04/1998 NH : Created. * - *=============================================================================================*/ -template -T * DynamicVectorClass::Uninitialized_Add(void) -{ - if (ActiveCount >= Length()) { - if ((IsAllocated || !VectorMax) && GrowthStep > 0) { - if (!Resize(Length() + GrowthStep)) { - - /* - ** Failure to increase the size of the vector is an error condition. - ** Return with the error value. - */ - return(NULL); - } - } else { - - /* - ** Increasing the size of this vector is not allowed! Bail this - ** routine with the error value. - */ - return(NULL); - } - } - - /* - ** There is room for the new space now. Add it to the end of the object - ** vector. and return a pointer to it. - */ - return &((*this)[ActiveCount++]); -} - - -void Set_Bit(void * array, int bit, int value); -int Get_Bit(void const * array, int bit); -int First_True_Bit(void const * array); -int First_False_Bit(void const * array); - - -/************************************************************************** -** This is a derivative of a vector class that supports boolean flags. Since -** a boolean flag can be represented by a single bit, this class packs the -** array of boolean flags into an array of bytes containing 8 boolean values -** each. For large boolean arrays, this results in an 87.5% savings. Although -** the indexing "[]" operator is supported, DO NOT pass pointers to sub elements -** of this bit vector class. A pointer derived from the indexing operator is -** only valid until the next call. Because of this, only simple -** direct use of the "[]" operator is allowed. -*/ -class BooleanVectorClass -{ - public: - BooleanVectorClass(unsigned size=0, unsigned char * array=0); - BooleanVectorClass(BooleanVectorClass const & vector); - - // Assignment operator. - BooleanVectorClass & operator =(BooleanVectorClass const & vector); - - // Equivalency operator. - bool operator == (BooleanVectorClass const & vector); - - // Fetch number of boolean objects in vector. - int Length(void) {return BitCount;}; - - // Set all boolean values to false; - void Reset(void); - - // Set all boolean values to true. - void Set(void); - - // Resets vector to zero length (frees memory). - void Clear(void); - - // Change size of this boolean vector. - int Resize(unsigned size); - - // Fetch reference to specified index. - bool const & operator[](int index) const { - if (LastIndex != index) Fixup(index); - return(Copy); - }; - bool & operator[](int index) { - if (LastIndex != index) Fixup(index); - return(Copy); - }; - - // Quick check on boolean state. - bool Is_True(int index) const { - if (index == LastIndex) return(Copy); - return(Get_Bit(&BitArray[0], index) != 0); - }; - - // Find first index that is false. - int First_False(void) const { - if (LastIndex != -1) Fixup(-1); - - int retval = First_False_Bit(&BitArray[0]); - if (retval < BitCount) return(retval); - - /* - ** Failure to find a false boolean value in the vector. Return this - ** fact in the form of an invalid index number. - */ - return(-1); - } - - // Find first index that is true. - int First_True(void) const { - if (LastIndex != -1) Fixup(-1); - - int retval = First_True_Bit(&BitArray[0]); - if (retval < BitCount) return(retval); - - /* - ** Failure to find a true boolean value in the vector. Return this - ** fact in the form of an invalid index number. - */ - return(-1); - } - - private: - void Fixup(int index=-1) const; - - /* - ** This is the number of boolean values in the vector. This value is - ** not necessarily a multiple of 8, even though the underlying character - ** vector contains a multiple of 8 bits. - */ - int BitCount; - - /* - ** This is a referential copy of an element in the bit vector. The - ** purpose of this copy is to allow normal reference access to this - ** object (for speed reasons). This hides the bit packing scheme from - ** the user of this class. - */ - bool Copy; - - /* - ** This records the index of the value last fetched into the reference - ** boolean variable. This index is used to properly restore the value - ** when the reference copy needs updating. - */ - int LastIndex; - - /* - ** This points to the allocated bitfield array. - */ - VectorClass BitArray; -}; - - -template -int Pointer_Vector_Add(T * ptr, VectorClass & vec) -{ - int id = 0; - bool foundspot = false; - for (int index = 0; index < vec.Length(); index++) { - if (vec[index] == NULL) { - id = index; - foundspot = true; - break; - } - } - if (!foundspot) { - id = vec.Length(); - vec.Resize((vec.Length()+1) * 2); - for (int index = id; index < vec.Length(); index++) { - vec[index] = NULL; - } - } - vec[id] = ptr; - return(id); -} - - -template -bool Pointer_Vector_Remove(T const * ptr, VectorClass & vec) -{ - int id = vec.ID((T *)ptr); - if (id != -1) { - vec[id] = NULL; - return(true); - } - return(false); -} - - -#endif - diff --git a/Generals/Code/Tools/WW3D/pluglib/WWmatrix3.cpp b/Generals/Code/Tools/WW3D/pluglib/WWmatrix3.cpp deleted file mode 100644 index 1a9fbb4d7e3..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/WWmatrix3.cpp +++ /dev/null @@ -1,404 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WWMath * - * * - * $Archive:: /Commando/Code/Tools/max2w3d/WWmatrix3.cpp $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 2/02/00 2:05p $* - * * - * $Revision:: 17 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "WWmatrix3.h" -#include "matrix3d.h" -#include "matrix4.h" -#include "w3dquat.h" - - -/* -** Some pre-initialized Matrix3's -*/ -const Matrix3 Matrix3::Identity -( - 1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0 -); - -const Matrix3 Matrix3::RotateX90 -( - 1.0, 0.0, 0.0, - 0.0, 0.0, -1.0, - 0.0, 1.0, 0.0 -); - -const Matrix3 Matrix3::RotateX180 -( - 1.0, 0.0, 0.0, - 0.0, -1.0, 0.0, - 0.0, 0.0, -1.0 -); - -const Matrix3 Matrix3::RotateX270 -( - 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, - 0.0, -1.0, 0.0 -); - -const Matrix3 Matrix3::RotateY90 -( - 0.0, 0.0, 1.0, - 0.0, 1.0, 0.0, - -1.0, 0.0, 0.0 -); - -const Matrix3 Matrix3::RotateY180 -( - -1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, -1.0 -); - -const Matrix3 Matrix3::RotateY270 -( - 0.0, 0.0, -1.0, - 0.0, 1.0, 0.0, - 1.0, 0.0, 0.0 -); - -const Matrix3 Matrix3::RotateZ90 -( - 0.0, -1.0, 0.0, - 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0 -); - -const Matrix3 Matrix3::RotateZ180 -( - -1.0, 0.0, 0.0, - 0.0, -1.0, 0.0, - 0.0, 0.0, 1.0 -); - -const Matrix3 Matrix3::RotateZ270 -( - 0.0, 1.0, 0.0, - -1.0, 0.0, 0.0, - 0.0, 0.0, 1.0 -); - - - -/*********************************************************************************************** - * Matrix3::Matrix3 -- Convert a Matrix3D (fake 4x4) to a Matrix3 * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -Matrix3::Matrix3(const Matrix3D & m) -{ - Row[0].Set(m[0][0],m[0][1],m[0][2]); - Row[1].Set(m[1][0],m[1][1],m[1][2]); - Row[2].Set(m[2][0],m[2][1],m[2][2]); -} - -Matrix3::Matrix3(const Matrix4 & m) -{ - Row[0].Set(m[0][0],m[0][1],m[0][2]); - Row[1].Set(m[1][0],m[1][1],m[1][2]); - Row[2].Set(m[2][0],m[2][1],m[2][2]); -} - -void Matrix3::Set(const Matrix3D & m) -{ - Row[0].Set(m[0][0],m[0][1],m[0][2]); - Row[1].Set(m[1][0],m[1][1],m[1][2]); - Row[2].Set(m[2][0],m[2][1],m[2][2]); -} - -void Matrix3::Set(const Matrix4 & m) -{ - Row[0].Set(m[0][0],m[0][1],m[0][2]); - Row[1].Set(m[1][0],m[1][1],m[1][2]); - Row[2].Set(m[2][0],m[2][1],m[2][2]); -} - -void Matrix3::Set(const Quaternion & q) -{ - Row[0][0] = (float)(1.0 - 2.0 * (q[1] * q[1] + q[2] * q[2])); - Row[0][1] = (float)(2.0 * (q[0] * q[1] - q[2] * q[3])); - Row[0][2] = (float)(2.0 * (q[2] * q[0] + q[1] * q[3])); - - Row[1][0] = (float)(2.0 * (q[0] * q[1] + q[2] * q[3])); - Row[1][1] = (float)(1.0 - 2.0f * (q[2] * q[2] + q[0] * q[0])); - Row[1][2] = (float)(2.0 * (q[1] * q[2] - q[0] * q[3])); - - Row[2][0] = (float)(2.0 * (q[2] * q[0] - q[1] * q[3])); - Row[2][1] = (float)(2.0 * (q[1] * q[2] + q[0] * q[3])); - Row[2][2] =(float)(1.0 - 2.0 * (q[1] * q[1] + q[0] * q[0])); -} - - -Matrix3 & Matrix3::operator = (const Matrix3D & m) -{ - Row[0].Set(m[0][0],m[0][1],m[0][2]); - Row[1].Set(m[1][0],m[1][1],m[1][2]); - Row[2].Set(m[2][0],m[2][1],m[2][2]); - return *this; -} - -Matrix3 & Matrix3::operator = (const Matrix4 & m) -{ - Row[0].Set(m[0][0],m[0][1],m[0][2]); - Row[1].Set(m[1][0],m[1][1],m[1][2]); - Row[2].Set(m[2][0],m[2][1],m[2][2]); - return *this; -} - -void Matrix3::Multiply(const Matrix3D & a, const Matrix3 & b,Matrix3 * res) -{ - #define ROWCOL(i,j) a[i][0]*b[0][j] + a[i][1]*b[1][j] + a[i][2]*b[2][j] - - (*res)[0][0] = ROWCOL(0,0); - (*res)[0][1] = ROWCOL(0,1); - (*res)[0][2] = ROWCOL(0,2); - - (*res)[1][0] = ROWCOL(1,0); - (*res)[1][1] = ROWCOL(1,1); - (*res)[1][2] = ROWCOL(1,2); - - (*res)[2][0] = ROWCOL(2,0); - (*res)[2][1] = ROWCOL(2,1); - (*res)[2][2] = ROWCOL(2,2); - - #undef ROWCOL -} - -void Matrix3::Multiply(const Matrix3 & a, const Matrix3D & b,Matrix3 * res) -{ - #define ROWCOL(i,j) a[i][0]*b[0][j] + a[i][1]*b[1][j] + a[i][2]*b[2][j] - - (*res)[0][0] = ROWCOL(0,0); - (*res)[0][1] = ROWCOL(0,1); - (*res)[0][2] = ROWCOL(0,2); - - (*res)[1][0] = ROWCOL(1,0); - (*res)[1][1] = ROWCOL(1,1); - (*res)[1][2] = ROWCOL(1,2); - - (*res)[2][0] = ROWCOL(2,0); - (*res)[2][1] = ROWCOL(2,1); - (*res)[2][2] = ROWCOL(2,2); - - #undef ROWCOL -} - -Matrix3 operator * (const Matrix3D & a, const Matrix3 & b) -{ - #define ROWCOL(i,j) a[i][0]*b[0][j] + a[i][1]*b[1][j] + a[i][2]*b[2][j] - - return Matrix3( - Vector3(ROWCOL(0,0), ROWCOL(0,1), ROWCOL(0,2) ), - Vector3(ROWCOL(1,0), ROWCOL(1,1), ROWCOL(1,2) ), - Vector3(ROWCOL(2,0), ROWCOL(2,1), ROWCOL(2,2) ) - ); - - #undef ROWCOL -} - -Matrix3 operator * (const Matrix3 & a, const Matrix3D & b) -{ - #define ROWCOL(i,j) a[i][0]*b[0][j] + a[i][1]*b[1][j] + a[i][2]*b[2][j] - - return Matrix3( - Vector3(ROWCOL(0,0), ROWCOL(0,1), ROWCOL(0,2) ), - Vector3(ROWCOL(1,0), ROWCOL(1,1), ROWCOL(1,2) ), - Vector3(ROWCOL(2,0), ROWCOL(2,1), ROWCOL(2,2) ) - ); - - #undef ROWCOL -} - - -#if 0 - -void Matrix3::Compute_Jacobi_Rotation(int i,int j,Matrix3 * r,Matrix3 * rinv) -{ - -} - -void Matrix3::Symmetric_Eigen_Solve(void) -{ - Matrix3 eigen_vals = *this; - Matrix3 eigen_vecs(1); - - Matrix3 jr,jrinv; - - while (!done) { - eigen_vals.Compute_Jacobi_Rotation(i,j,&jr,&jrinv); - eigen_vals = jr * (eigenvals) * jrinv; - eigen_vecs = eigen_vecs * jr; - } - - /* - ** Done! Eigen values are the diagonals of - ** the eigen_vals matrix and the eigen vectors - ** are the columns of the eigen_vecs matrix - */ - -} - -#endif - - -void Matrix3::Multiply(const Matrix3 & A,const Matrix3 & B,Matrix3 * set_res) -{ - Matrix3 tmp; - Matrix3 * Aptr; - float tmp1,tmp2,tmp3; - - // Check for aliased parameters, copy the 'A' matrix into a temporary if the - // result is going into 'A'. (in this case, this function is no better than - // the overloaded C++ operator...) - if (set_res == &A) { - tmp = A; - Aptr = &tmp; - } else { - Aptr = (Matrix3 *)&A; - } - - tmp1 = B[0][0]; - tmp2 = B[1][0]; - tmp3 = B[2][0]; - - (*set_res)[0][0] = (float)((*Aptr)[0][0]*tmp1 + (*Aptr)[0][1]*tmp2 + (*Aptr)[0][2]*tmp3); - (*set_res)[1][0] = (float)((*Aptr)[1][0]*tmp1 + (*Aptr)[1][1]*tmp2 + (*Aptr)[1][2]*tmp3); - (*set_res)[2][0] = (float)((*Aptr)[2][0]*tmp1 + (*Aptr)[2][1]*tmp2 + (*Aptr)[2][2]*tmp3); - - tmp1 = B[0][1]; - tmp2 = B[1][1]; - tmp3 = B[2][1]; - - (*set_res)[0][1] = (float)((*Aptr)[0][0]*tmp1 + (*Aptr)[0][1]*tmp2 + (*Aptr)[0][2]*tmp3); - (*set_res)[1][1] = (float)((*Aptr)[1][0]*tmp1 + (*Aptr)[1][1]*tmp2 + (*Aptr)[1][2]*tmp3); - (*set_res)[2][1] = (float)((*Aptr)[2][0]*tmp1 + (*Aptr)[2][1]*tmp2 + (*Aptr)[2][2]*tmp3); - - tmp1 = B[0][2]; - tmp2 = B[1][2]; - tmp3 = B[2][2]; - - (*set_res)[0][2] = (float)((*Aptr)[0][0]*tmp1 + (*Aptr)[0][1]*tmp2 + (*Aptr)[0][2]*tmp3); - (*set_res)[1][2] = (float)((*Aptr)[1][0]*tmp1 + (*Aptr)[1][1]*tmp2 + (*Aptr)[1][2]*tmp3); - (*set_res)[2][2] = (float)((*Aptr)[2][0]*tmp1 + (*Aptr)[2][1]*tmp2 + (*Aptr)[2][2]*tmp3); -} - -int Matrix3::Is_Orthogonal(void) const -{ - Vector3 x(Row[0].X,Row[0].Y,Row[0].Z); - Vector3 y(Row[1].X,Row[1].Y,Row[1].Z); - Vector3 z(Row[2].X,Row[2].Y,Row[2].Z); - - if (Vector3::Dot_Product(x,y) > WWMATH_EPSILON) return 0; - if (Vector3::Dot_Product(y,z) > WWMATH_EPSILON) return 0; - if (Vector3::Dot_Product(z,x) > WWMATH_EPSILON) return 0; - - if (WWMath::Fabs(x.Length() - 1.0f) > WWMATH_EPSILON) return 0; - if (WWMath::Fabs(y.Length() - 1.0f) > WWMATH_EPSILON) return 0; - if (WWMath::Fabs(z.Length() - 1.0f) > WWMATH_EPSILON) return 0; - - return 1; -} - -void Matrix3::Re_Orthogonalize(void) -{ - Vector3 x(Row[0][0],Row[0][1],Row[0][2]); - Vector3 y(Row[1][0],Row[1][1],Row[1][2]); - Vector3 z; - - Vector3::Cross_Product(x,y,&z); - Vector3::Cross_Product(z,x,&y); - - float len = x.Length(); - if (len < WWMATH_EPSILON) { - Make_Identity(); - return; - } else { - x /= len; - } - - len = y.Length(); - if (len < WWMATH_EPSILON) { - Make_Identity(); - return; - } else { - y /= len; - } - - len = z.Length(); - if (len < WWMATH_EPSILON) { - Make_Identity(); - return; - } else { - z /= len; - } - - Row[0][0] = x.X; - Row[0][1] = x.Y; - Row[0][2] = x.Z; - - Row[1][0] = y.X; - Row[1][1] = y.Y; - Row[1][2] = y.Z; - - Row[2][0] = z.X; - Row[2][1] = z.Y; - Row[2][2] = z.Z; -} - -void Matrix3::Rotate_AABox_Extent(const Vector3 & extent,Vector3 * set_extent) -{ - // push each extent out to the projections of the original extents - for (int i=0; i<3; i++) { - - // start the center out at the translation portion of the matrix - // and the extent at zero - (*set_extent)[i] = 0.0f; - - for (int j=0; j<3; j++) { - (*set_extent)[i] += WWMath::Fabs(Row[i][j] * extent[j]); - } - } -} diff --git a/Generals/Code/Tools/WW3D/pluglib/WWmatrix3.h b/Generals/Code/Tools/WW3D/pluglib/WWmatrix3.h deleted file mode 100644 index 754140cbdba..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/WWmatrix3.h +++ /dev/null @@ -1,1011 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/WWmatrix3.h 33 2/03/00 4:55p Jason_a $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * File Name : MATRIX3.H * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 06/02/97 * - * * - * Last Update : June 2, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Matrix3::Matrix3 -- Constructor, optionally initialize to Identitiy matrix * - * Matrix3::Matrix3 -- Copy Constructor * - * Matrix3::Matrix3 -- Convert a Matrix3D (fake 4x4) to a Matrix3 * - * Matrix3::Matrix3 -- Constructor * - * Matrix3::Transpose -- Returns transpose of the matrix * - * Matrix3::Inverse -- returns the inverse of the matrix * - * Matrix3::Determinant -- returns the determinant of the matrix * - * Matrix3::operator = -- assignment operator * - * Matrix3::operator += -- "plus equals" operator * - * Matrix3::operator-= -- "minus equals" operator * - * Matrix3::operator *= -- "times equals" operator * - * Matrix3::operator /= -- "divide equals" operator * - * Create_X_Rotation_Matrix3 -- creates a matrix3 which is a rotation about X * - * Create_Y_Rotation_Matrix3 -- Creates a Matrix3 which is a rotation about Y * - * Create_Z_Rotation_Matrix3 -- Creates a matrix3 which is a rotation about Z * - * Matrix3::Rotate_X -- Post-mutiplies an x rotation onto the current matrix * - * Matrix3::Rotate_Y -- Post-multiplies the matrix with a rotation about Y * - * Matrix3::Rotate_Z -- Post-multiplies the matrix with a rotation about Z * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef Matrix3_H -#define Matrix3_H - -#include "always.h" -#include "vector3.h" -//#include "wwdebug.h" - - -class Matrix3D; -class Matrix4; -class Quaternion; - -class Matrix3 -{ -public: - - /* - ** Constructors - */ - Matrix3(void) {}; - Matrix3(const Matrix3 & m); - - explicit Matrix3(bool identity); - explicit Matrix3(const Vector3 & v0, const Vector3 & v1, const Vector3 & v2); - explicit Matrix3(const Matrix3D & m); - explicit Matrix3(const Matrix4 & m); - explicit Matrix3( - float m11,float m12,float m13, - float m21,float m22,float m23, - float m31,float m32,float m33 - ); - explicit Matrix3(const Vector3 & axis,float angle); - explicit Matrix3(const Vector3 & axis,float s_angle,float c_angle); - explicit Matrix3(const Quaternion & q); - - /* - ** 'Set' functions - */ - void Set(const Matrix3D & m); - void Set(const Matrix4 & m); - void Set(const Vector3 & v0, const Vector3 & v1, const Vector3 & v2); - void Set( - float m11,float m12,float m13, - float m21,float m22,float m23, - float m31,float m32,float m33 - ); - void Set(const Vector3 & axis,float angle); - void Set(const Vector3 & axis,float s_angle,float c_angle); - void Set(const Quaternion & q); - - /* - ** Access operators - */ - Vector3 & operator [] (int i) { return Row[i]; } - const Vector3 & operator [] (int i) const { return Row[i]; } - - /* - ** Transpose and Inverse - */ - Matrix3 Transpose (void) const; - Matrix3 Inverse (void) const; - float Determinant (void) const; - - /* - ** Assignment operators - */ - Matrix3 & operator = (const Matrix3 & m); - Matrix3 & operator = (const Matrix3D & m); - Matrix3 & operator = (const Matrix4 & m); - - Matrix3 & operator += (const Matrix3 & m); - Matrix3 & operator -= (const Matrix3 & m); - Matrix3 & operator *= (float d); - Matrix3 & operator /= (float d); - - void Make_Identity(void); - - /* - ** Automatically concatenate a rotation onto the current matrix - */ - void Rotate_X(float theta); - void Rotate_X(float s,float c); - - void Rotate_Y(float theta); - void Rotate_Y(float s,float c); - - void Rotate_Z(float theta); - void Rotate_Z(float s,float c); - - /* - ** These functions will give you the approximate amount that the - ** matrix has been rotated about a given axis. These functions - ** cannot be used to re-build a matrx. Use the EulerAnglesClass - ** to convert a matrix into a set of three Euler angles. - */ - float Get_X_Rotation(void) const; - float Get_Y_Rotation(void) const; - float Get_Z_Rotation(void) const; - - /* - ** These functions return a vector representing the direction an - ** axis is pointing. - */ - Vector3 Get_X_Vector(void) const; - Vector3 Get_Y_Vector(void) const; - Vector3 Get_Z_Vector(void) const; - void Get_X_Vector(Vector3 * set_x) const; - void Get_Y_Vector(Vector3 * set_y) const; - void Get_Z_Vector(Vector3 * set_z) const; - - /* - ** Negation - */ - friend Matrix3 operator - (const Matrix3& a); - - /* - ** Scalar multiplication and division - */ - friend Matrix3 operator * (const Matrix3& a,float d); - friend Matrix3 operator * (float d,const Matrix3& a); - friend Matrix3 operator / (const Matrix3& a,float d); - - /* - ** matrix addition - */ - friend Matrix3 operator + (const Matrix3& a, const Matrix3& b); - static void Add(const Matrix3 & a, const Matrix3 & b,Matrix3 * res); - - /* - ** matrix subtraction - */ - friend Matrix3 operator - (const Matrix3 & a, const Matrix3 & b); - static void Subtract(const Matrix3 & a, const Matrix3 & b,Matrix3 * res); - - /* - ** matrix multiplication - */ - friend Matrix3 operator * (const Matrix3 & a, const Matrix3 & b); - friend Matrix3 operator * (const Matrix3D & a, const Matrix3 & b); - friend Matrix3 operator * (const Matrix3 & a, const Matrix3D & b); - - static void Multiply(const Matrix3 & a, const Matrix3 & b,Matrix3 * res); - static void Multiply(const Matrix3D & a, const Matrix3 & b,Matrix3 * res); - static void Multiply(const Matrix3 & a, const Matrix3D & b,Matrix3 * res); - - /* - ** Matrix-Vector multiplication - */ - friend Vector3 operator * (const Matrix3 & a, const Vector3 & v); - static void Rotate_Vector(const Matrix3 & tm,const Vector3 & in,Vector3 * out); - static void Transpose_Rotate_Vector(const Matrix3 & tm,const Vector3 & in,Vector3 * out); - - /* - ** Comparison operators - */ - friend int operator == (const Matrix3 & a, const Matrix3 & b); - friend int operator != (const Matrix3 & a, const Matrix3 & b); - - /* - ** Swap two matrices in place - */ - friend void Swap(Matrix3 & a,Matrix3 & b); - - /* - ** Check whether a matrix is orthogonal, make it orthogonal - */ - int Is_Orthogonal(void) const; - void Re_Orthogonalize(void); - - /* - ** Miscellaneous - */ - void Rotate_AABox_Extent(const Vector3 & extent,Vector3 * new_extent); - - /* - ** Some useful pre-initialized Matrix3's - */ - static const Matrix3 Identity; - static const Matrix3 RotateX90; - static const Matrix3 RotateX180; - static const Matrix3 RotateX270; - static const Matrix3 RotateY90; - static const Matrix3 RotateY180; - static const Matrix3 RotateY270; - static const Matrix3 RotateZ90; - static const Matrix3 RotateZ180; - static const Matrix3 RotateZ270; - -protected: - - Vector3 Row[3]; - -}; - - -/*********************************************************************************************** - * Matrix3::Matrix3 -- Constructor, optionally initialize to Identitiy matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix3::Matrix3(bool identity) -{ - if (identity) { - Row[0].Set(1.0,0.0,0.0); - Row[1].Set(0.0,1.0,0.0); - Row[2].Set(0.0,0.0,1.0); - } -} - -/*********************************************************************************************** - * Matrix3::Matrix3 -- Copy Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix3::Matrix3(const Matrix3 & m) -{ - Row[0] = m.Row[0]; Row[1] = m.Row[1]; Row[2] = m.Row[2]; -} - -/*********************************************************************************************** - * Matrix3::Matrix3 -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix3::Matrix3(const Vector3 & r0, const Vector3 & r1, const Vector3 & r2) -{ - Row[0] = r0; - Row[1] = r1; - Row[2] = r2; -} - -inline void Matrix3::Set(const Vector3 & r0, const Vector3 & r1, const Vector3 & r2) -{ - Row[0] = r0; - Row[1] = r1; - Row[2] = r2; -} - -inline void Matrix3::Make_Identity(void) -{ - Row[0].Set(1.0f,0.0f,0.0f); - Row[1].Set(0.0f,1.0f,0.0f); - Row[2].Set(0.0f,0.0f,1.0f); -} - - -inline Matrix3::Matrix3 -( - float m11,float m12,float m13, - float m21,float m22,float m23, - float m31,float m32,float m33 -) -{ - Row[0].Set(m11,m12,m13); - Row[1].Set(m21,m22,m23); - Row[2].Set(m31,m32,m33); -} - -inline void Matrix3::Set -( - float m11,float m12,float m13, - float m21,float m22,float m23, - float m31,float m32,float m33 -) -{ - Row[0].Set(m11,m12,m13); - Row[1].Set(m21,m22,m23); - Row[2].Set(m31,m32,m33); -} - -inline Matrix3::Matrix3(const Vector3 & axis,float angle) -{ - Set(axis,angle); -} - -inline Matrix3::Matrix3(const Vector3 & axis,float s_angle,float c_angle) -{ - Set(axis,s_angle,c_angle); -} - -inline void Matrix3::Set(const Vector3 & axis,float angle) -{ - Set(axis,sinf(angle),cosf(angle)); -} - -inline void Matrix3::Set(const Vector3 & axis,float s,float c) -{ - assert(WWMath::Fabs(axis.Length2() - 1.0f) < 0.001f); - - Row[0].Set( - (float)(axis[0]*axis[0] + c*(1.0f - axis[0]*axis[0])), - (float)(axis[0]*axis[1]*(1.0f - c) - axis[2]*s), - (float)(axis[2]*axis[0]*(1.0f - c) + axis[1]*s) - ); - - Row[1].Set( - (float)(axis[0]*axis[1]*(1.0f - c) + axis[2]*s), - (float)(axis[1]*axis[1] + c*(1.0f - axis[1]*axis[1])), - (float)(axis[1]*axis[2]*(1.0f - c) - axis[0]*s) - ); - - Row[2].Set( - (float)(axis[2]*axis[0]*(1.0f - c) - axis[1]*s), - (float)(axis[1]*axis[2]*(1.0f - c) + axis[0]*s), - (float)(axis[2]*axis[2] + c*(1 - axis[2]*axis[2])) - ); -} - -inline Matrix3::Matrix3(const Quaternion & q) -{ - this->Set(q); -} - -/*********************************************************************************************** - * Matrix3::Transpose -- Returns transpose of the matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix3 Matrix3::Transpose() const -{ - return Matrix3( - Vector3(Row[0][0], Row[1][0], Row[2][0]), - Vector3(Row[0][1], Row[1][1], Row[2][1]), - Vector3(Row[0][2], Row[1][2], Row[2][2]) - ); -} - -/*********************************************************************************************** - * Matrix3::Inverse -- returns the inverse of the matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix3 Matrix3::Inverse() const // Gauss-Jordan elimination with partial pivoting -{ - Matrix3 a(*this); // As a evolves from original mat into identity - Matrix3 b(true); // b evolves from identity into inverse(a) - int i, j, i1; - - // Loop over cols of a from left to right, eliminating above and below diagonal - for (j=0; j<3; j++) { - - // Find largest pivot in column j among rows j..3 - i1 = j; - for (i=j+1; i<3; i++) { - if (WWMath::Fabs(a[i][j]) > WWMath::Fabs(a[i1][j])) { - i1 = i; - } - } - - // Swap rows i1 and j in a and b to put pivot on diagonal - Swap(a.Row[i1], a.Row[j]); - Swap(b.Row[i1], b.Row[j]); - - // Scale row j to have a unit diagonal - if (a[j][j]==0.) { - //Matrix3::inverse: singular matrix; can't invert - } - b.Row[j] /= a.Row[j][j]; - a.Row[j] /= a.Row[j][j]; - - // Eliminate off-diagonal elems in col j of a, doing identical ops to b - for (i=0; i<3; i++) { - if (i != j) { - b.Row[i] -= a[i][j] * b.Row[j]; - a.Row[i] -= a[i][j] * a.Row[j]; - } - } - } - return b; -} - - -/*********************************************************************************************** - * Matrix3::Determinant -- returns the determinant of the matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/7/20 DRM : Created. * - *=============================================================================================*/ -inline float Matrix3::Determinant(void) const -{ - return Row[0][0] * (Row[1][1] * Row[2][2] - Row[1][2] * Row[2][1]) - - Row[0][1] * (Row[1][0] * Row[2][2] - Row[1][2] * Row[2][0]) - - Row[0][2] * (Row[1][0] * Row[2][1] - Row[1][1] * Row[2][0]); -} - -/*********************************************************************************************** - * Matrix3::operator = -- assignment operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix3 & Matrix3::operator = (const Matrix3 & m) -{ - Row[0] = m.Row[0]; Row[1] = m.Row[1]; Row[2] = m.Row[2]; - return *this; -} - -/*********************************************************************************************** - * Matrix3::operator += -- "plus equals" operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix3& Matrix3::operator += (const Matrix3 & m) -{ - Row[0] += m.Row[0]; Row[1] += m.Row[1]; Row[2] += m.Row[2]; - return *this; -} - -/*********************************************************************************************** - * Matrix3::operator-= -- "minus equals" operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix3& Matrix3::operator -= (const Matrix3 & m) -{ - Row[0] -= m.Row[0]; Row[1] -= m.Row[1]; Row[2] -= m.Row[2]; - return *this; -} - -/*********************************************************************************************** - * Matrix3::operator *= -- "times equals" operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix3& Matrix3::operator *= (float d) -{ - Row[0] *= d; Row[1] *= d; Row[2] *= d; - return *this; -} - -/*********************************************************************************************** - * Matrix3::operator /= -- "divide equals" operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix3& Matrix3::operator /= (float d) -{ - Row[0] /= d; Row[1] /= d; Row[2] /= d; - return *this; -} - -/*********************************************************************************************** - * Matrix3::Get_X_Rotation -- approximates the rotation about the X axis * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -inline float Matrix3::Get_X_Rotation(void) const -{ - Vector3 v = (*this) * Vector3(0.0,1.0,0.0); - return atan2(v[2], v[1]); -} - -/*********************************************************************************************** - * Matrix3::Get_Y_Rotation -- approximates the rotation about the Y axis * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -inline float Matrix3::Get_Y_Rotation(void) const -{ - Vector3 v = (*this) * Vector3(0.0,0.0,1.0); - return atan2(v[0],v[2]); -} - -/*********************************************************************************************** - * Matrix3::Get_Z_Rotation -- approximates the rotation about the Z axis * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -inline float Matrix3::Get_Z_Rotation(void) const -{ - Vector3 v = (*this) * Vector3(1.0,0.0,0.0); - return atan2(v[1],v[0]); -} - -inline Vector3 Matrix3::Get_X_Vector(void) const -{ - return Vector3(Row[0][0], Row[1][0], Row[2][0]); -} - -inline Vector3 Matrix3::Get_Y_Vector(void) const -{ - return Vector3(Row[0][1], Row[1][1], Row[2][1]); -} - -inline Vector3 Matrix3::Get_Z_Vector(void) const -{ - return Vector3(Row[0][2], Row[1][2], Row[2][2]); -} - -inline void Matrix3::Get_X_Vector(Vector3 * set) const -{ - set->Set(Row[0][0], Row[1][0], Row[2][0]); -} - -inline void Matrix3::Get_Y_Vector(Vector3 * set) const -{ - set->Set(Row[0][1], Row[1][1], Row[2][1]); -} - -inline void Matrix3::Get_Z_Vector(Vector3 * set) const -{ - set->Set(Row[0][2], Row[1][2], Row[2][2]); -} - -inline Matrix3 operator - (const Matrix3 & a) -{ - return Matrix3(-a.Row[0], -a.Row[1], -a.Row[2]); -} - -inline Matrix3 operator * (const Matrix3 & a, float d) -{ - return Matrix3(a.Row[0] * d, a.Row[1] * d, a.Row[2] * d); -} - -inline Matrix3 operator * (float d, const Matrix3 & a) -{ - return a*d; -} - -inline Matrix3 operator / (const Matrix3 & a, float d) -{ - float ood = 1.0f / d; - return Matrix3(a.Row[0] * ood, a.Row[1] * ood, a.Row[2] * ood); -} - -/* -** matrix addition -*/ -inline Matrix3 operator + (const Matrix3 & a, const Matrix3 & b) -{ - return Matrix3( - a.Row[0] + b.Row[0], - a.Row[1] + b.Row[1], - a.Row[2] + b.Row[2] - ); -} - -inline void Matrix3::Add(const Matrix3 & a, const Matrix3 & b,Matrix3 * c) -{ - assert(c); - Vector3::Add(a.Row[0],b.Row[0],&(c->Row[0])); - Vector3::Add(a.Row[1],b.Row[1],&(c->Row[1])); - Vector3::Add(a.Row[2],b.Row[2],&(c->Row[2])); -} - -/* -** matrix subtraction -*/ -inline Matrix3 operator - (const Matrix3 & a, const Matrix3 & b) -{ - return Matrix3( - a.Row[0] - b.Row[0], - a.Row[1] - b.Row[1], - a.Row[2] - b.Row[2] - ); -} - -inline void Matrix3::Subtract(const Matrix3 & a, const Matrix3 & b,Matrix3 * c) -{ - assert(c); - Vector3::Subtract(a.Row[0],b.Row[0],&(c->Row[0])); - Vector3::Subtract(a.Row[1],b.Row[1],&(c->Row[1])); - Vector3::Subtract(a.Row[2],b.Row[2],&(c->Row[2])); -} - -/* -** matrix multiplication -*/ -inline Matrix3 operator * (const Matrix3 & a, const Matrix3 & b) -{ - #define ROWCOL(i,j) a[i][0]*b[0][j] + a[i][1]*b[1][j] + a[i][2]*b[2][j] - - return Matrix3( - Vector3(ROWCOL(0,0), ROWCOL(0,1), ROWCOL(0,2) ), - Vector3(ROWCOL(1,0), ROWCOL(1,1), ROWCOL(1,2) ), - Vector3(ROWCOL(2,0), ROWCOL(2,1), ROWCOL(2,2) ) - ); - - #undef ROWCOL -} - - -/* -** Multiply a Matrix3 by a Vector3. Yeilds a Vector3 result -*/ -inline Vector3 operator * (const Matrix3 & a, const Vector3 & v) -{ - return Vector3( - a[0][0] * v[0] + a[0][1] * v[1] + a[0][2] * v[2], - a[1][0] * v[0] + a[1][1] * v[1] + a[1][2] * v[2], - a[2][0] * v[0] + a[2][1] * v[1] + a[2][2] * v[2] - ); -} - - -inline int operator == (const Matrix3 & a, const Matrix3 & b) -{ - return ((a [0] == b [0]) && (a [1] == b [1]) && (a [2] == b [2])); -} - - -inline int operator != (const Matrix3 & a, const Matrix3 & b) -{ - return (!(a == b)); -} - - -/*********************************************************************************************** - * Matrix3::Rotate_X -- Post-mutiplies an x rotation onto the current matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/26/1997 GH : Created. * - *=============================================================================================*/ -inline void Matrix3::Rotate_X(float theta) -{ - Rotate_X(sinf(theta),cosf(theta)); -} - -inline void Matrix3::Rotate_X(float s,float c) -{ - float tmp1,tmp2; - - tmp1 = Row[0][1]; tmp2 = Row[0][2]; - Row[0][1] = (float)( c*tmp1 + s*tmp2); - Row[0][2] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[1][1]; tmp2 = Row[1][2]; - Row[1][1] = (float)( c*tmp1 + s*tmp2); - Row[1][2] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[2][1]; tmp2 = Row[2][2]; - Row[2][1] = (float)( c*tmp1 + s*tmp2); - Row[2][2] = (float)(-s*tmp1 + c*tmp2); -} - -/*********************************************************************************************** - * Matrix3::Rotate_Y -- Post-multiplies the matrix with a rotation about Y * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/26/1997 GH : Created. * - *=============================================================================================*/ -inline void Matrix3::Rotate_Y(float theta) -{ - Rotate_Y(sinf(theta),cosf(theta)); -} - -inline void Matrix3::Rotate_Y(float s,float c) -{ - float tmp1,tmp2; - - tmp1 = Row[0][0]; tmp2 = Row[0][2]; - Row[0][0] = (float)(c*tmp1 - s*tmp2); - Row[0][2] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[1][0]; tmp2 = Row[1][2]; - Row[1][0] = (float)(c*tmp1 - s*tmp2); - Row[1][2] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[2][0]; tmp2 = Row[2][2]; - Row[2][0] = (float)(c*tmp1 - s*tmp2); - Row[2][2] = (float)(s*tmp1 + c*tmp2); -} - - -/*********************************************************************************************** - * Matrix3::Rotate_Z -- Post-multiplies the matrix with a rotation about Z * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/26/1997 GH : Created. * - *=============================================================================================*/ -inline void Matrix3::Rotate_Z(float theta) -{ - Rotate_Z(sinf(theta),cosf(theta)); -} - -inline void Matrix3::Rotate_Z(float s,float c) -{ - float tmp1,tmp2; - - tmp1 = Row[0][0]; tmp2 = Row[0][1]; - Row[0][0] = (float)( c*tmp1 + s*tmp2); - Row[0][1] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[1][0]; tmp2 = Row[1][1]; - Row[1][0] = (float)( c*tmp1 + s*tmp2); - Row[1][1] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[2][0]; tmp2 = Row[2][1]; - Row[2][0] = (float)( c*tmp1 + s*tmp2); - Row[2][1] = (float)(-s*tmp1 + c*tmp2); -} - - -/*********************************************************************************************** - * Create_X_Rotation_Matrix3 -- creates a matrix3 which is a rotation about X * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/26/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix3 Create_X_Rotation_Matrix3(float s,float c) -{ - Matrix3 mat; - - mat[0][0] = 1.0f; - mat[0][1] = 0.0f; - mat[0][2] = 0.0f; - - mat[1][0] = 0.0f; - mat[1][1] = c; - mat[1][2] = -s; - - mat[2][0] = 0.0f; - mat[2][1] = s; - mat[2][2] = c; - - return mat; -} - -inline Matrix3 Create_X_Rotation_Matrix3(float rad) -{ - return Create_X_Rotation_Matrix3(sinf(rad),cosf(rad)); -} - -/*********************************************************************************************** - * Create_Y_Rotation_Matrix3 -- Creates a Matrix3 which is a rotation about Y * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/26/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix3 Create_Y_Rotation_Matrix3(float s,float c) -{ - Matrix3 mat; - - mat[0][0] = c; - mat[0][1] = 0.0f; - mat[0][2] = s; - - mat[1][0] = 0.0f; - mat[1][1] = 1.0f; - mat[1][2] = 0.0f; - - mat[2][0] = -s; - mat[2][1] = 0.0f; - mat[2][2] = c; - - return mat; -} - -inline Matrix3 Create_Y_Rotation_Matrix3(float rad) -{ - return Create_Y_Rotation_Matrix3(sinf(rad),cosf(rad)); -} - -/*********************************************************************************************** - * Create_Z_Rotation_Matrix3 -- Creates a matrix3 which is a rotation about Z * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/26/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix3 Create_Z_Rotation_Matrix3(float s,float c) -{ - Matrix3 mat; - - mat[0][0] = c; - mat[0][1] = -s; - mat[0][2] = 0.0f; - - mat[1][0] = s; - mat[1][1] = c; - mat[1][2] = 0.0f; - - mat[2][0] = 0.0f; - mat[2][1] = 0.0f; - mat[2][2] = 1.0f; - - return mat; -} - -inline Matrix3 Create_Z_Rotation_Matrix3(float rad) -{ - return Create_Z_Rotation_Matrix3(sinf(rad),cosf(rad)); -} - -inline void Matrix3::Rotate_Vector(const Matrix3 & A,const Vector3 & in,Vector3 * out) -{ - Vector3 tmp; - Vector3 * v; - - // check for aliased parameters - if (out == &in) { - tmp = in; - v = &tmp; - } else { - v = (Vector3 *)∈ // whats the right way to do this... - } - - out->X = (A[0][0] * v->X + A[0][1] * v->Y + A[0][2] * v->Z); - out->Y = (A[1][0] * v->X + A[1][1] * v->Y + A[1][2] * v->Z); - out->Z = (A[2][0] * v->X + A[2][1] * v->Y + A[2][2] * v->Z); -} - -inline void Matrix3::Transpose_Rotate_Vector(const Matrix3 & A,const Vector3 & in,Vector3 * out) -{ - Vector3 tmp; - Vector3 * v; - - // check for aliased parameters - if (out == &in) { - tmp = in; - v = &tmp; - } else { - v = (Vector3 *)∈ - } - out->X = (A[0][0] * v->X + A[1][0] * v->Y + A[2][0] * v->Z); - out->Y = (A[0][1] * v->X + A[1][1] * v->Y + A[2][1] * v->Z); - out->Z = (A[0][2] * v->X + A[1][2] * v->Y + A[2][2] * v->Z); -} - -#endif /*Matrix3_H*/ \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/pluglib/aaplane.h b/Generals/Code/Tools/WW3D/pluglib/aaplane.h deleted file mode 100644 index 2f52f7633f9..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/aaplane.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WWMath * - * * - * $Archive:: /Commando/Code/wwmath/aaplane.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 5/19/00 3:12p $* - * * - * $Revision:: 8 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef AAPLANE_H -#define AAPLANE_H - -#include "always.h" -#include "vector3.h" - - -/* -** This class is used to describe an "axis-aligned" plane. I.e, the normal -** of the plane is one of the three coordinate axes. -*/ -class AAPlaneClass -{ -public: - - enum AxisEnum { XNORMAL = 0, YNORMAL = 1, ZNORMAL = 2 }; - - AAPlaneClass(void) { } - AAPlaneClass(AxisEnum normal,float dist) : Normal(normal),Dist(dist) { } - - void Set(AxisEnum normal,float dist); - void Get_Normal(Vector3 * normal) const; - -public: - - AxisEnum Normal; - float Dist; - -}; - -inline void AAPlaneClass::Set(AxisEnum normal,float dist) -{ - Normal = normal; - Dist = dist; -} - -inline void AAPlaneClass::Get_Normal(Vector3 * normal) const -{ - normal->Set(0,0,0); - (*normal)[Normal] = 1.0f; -} - -#endif diff --git a/Generals/Code/Tools/WW3D/pluglib/always.h b/Generals/Code/Tools/WW3D/pluglib/always.h deleted file mode 100644 index 37b236dc834..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/always.h +++ /dev/null @@ -1,170 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/always.h $* - * * - * $Author:: Steve_t $* - * * - * $Modtime:: 8/28/01 3:21p $* - * * - * $Revision:: 13 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef ALWAYS_H -#define ALWAYS_H - -// Disable warning about exception handling not being enabled. It's used as part of STL - in a part of STL we don't use. -#pragma warning(disable : 4530) - -/* -** Define for debug memory allocation to include __FILE__ and __LINE__ for every memory allocation. -** This helps find leaks. -*/ -//#define STEVES_NEW_CATCHER -#ifdef _DEBUG -#ifdef _MSC_VER -#ifdef STEVES_NEW_CATCHER - -#include -#include -#include - -#define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) -#define calloc(c, s) _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__) -#define realloc(p, s) _realloc_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__) -#define _expand(p, s) _expand_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__) -#define free(p) _free_dbg(p, _NORMAL_BLOCK) -#define _msize(p) _msize_dbg(p, _NORMAL_BLOCK) - -void* __cdecl operator new(unsigned int s); - -#endif //STEVES_NEW_CATCHER -#endif //_MSC_VER -#endif //_DEBUG - - -// Jani: Intel's C++ compiler issues too many warnings in WW libraries when using warning level 4 -#if defined (__ICL) // Detect Intel compiler -#pragma warning (3) -#pragma warning ( disable: 981 ) // parameters defined in unspecified order -#pragma warning ( disable: 279 ) // controlling expressaion is constant -#pragma warning ( disable: 271 ) // trailing comma is nonstandard -#pragma warning ( disable: 171 ) // invalid type conversion -#pragma warning ( disable: 1 ) // last line of file ends without a newline -#endif - -// Jani: MSVC doesn't necessarily inline code with inline keyword. Using __forceinline results better inlining -// and also prints out a warning if inlining wasn't possible. __forceinline is MSVC specific. -#if defined(_MSC_VER) -#define WWINLINE __forceinline -#else -#define WWINLINE inline -#endif - -/* -** Define the MIN and MAX macros. -** NOTE: Joe used to #include in the various compiler header files. This -** header defines 'min' and 'max' macros which conflict with the surrender code so -** I'm relpacing all occurances of 'min' and 'max with 'MIN' and 'MAX'. For code which -** is out of our domain (e.g. Max sdk) I'm declaring template functions for 'min' and 'max' -*/ -#define NOMINMAX - -#ifndef MAX -#define MAX(a,b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) -#endif - -#ifdef min -#undef min -#endif - -#ifdef max -#undef max -#endif - -template T min(T a,T b) -{ - if (a T max(T a,T b) -{ - if (a>b) { - return a; - } else { - return b; - } -} - - -/* -** This includes the minimum set of compiler defines and pragmas in order to bring the -** various compilers to a common behavior such that the C&C engine will compile without -** error or warning. -*/ -#if defined(__BORLANDC__) -#include "borlandc.h" -#endif - -#if defined(_MSC_VER) -#include "visualc.h" -#endif - -#if defined(__WATCOMC__) -#include "watcom.h" -#endif - - -#ifndef NULL - #define NULL 0 -#endif - -/********************************************************************** -** This macro serves as a general way to determine the number of elements -** within an array. -*/ -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) int(sizeof(x)/sizeof(x[0])) -#endif - -#ifndef size_of -#define size_of(typ,id) sizeof(((typ*)0)->id) -#endif - - -#endif \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/pluglib/bool.h b/Generals/Code/Tools/WW3D/pluglib/bool.h deleted file mode 100644 index ff6e3e41674..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/bool.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/bool.h $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 9/23/99 1:46p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#if !defined(TRUE_FALSE_DEFINED) && !defined(__BORLANDC__) && (_MSC_VER < 1100) && !defined(__WATCOMC__) -#define TRUE_FALSE_DEFINED - -/********************************************************************** -** The "bool" integral type was defined by the C++ comittee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#ifdef _MSC_VER - -#include "yvals.h" -#define bool unsigned - -#elif defined(_UNIX) - -/////#define bool unsigned - -#else - -enum {false=0,true=1}; -typedef int bool; - -#endif - -#endif diff --git a/Generals/Code/Tools/WW3D/pluglib/borlandc.h b/Generals/Code/Tools/WW3D/pluglib/borlandc.h deleted file mode 100644 index efde2536699..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/borlandc.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/borlandc.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 11:57a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#if !defined(BORLANDC_H) && defined(__BORLANDC__) -#define BORLANDC_H - -/* -** Funny, but there are no required overrides to make Borland C match C++ standards. This -** is because Borland C more closely matches the C++ standard than the other compilers. -*/ - -#endif \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/pluglib/chunkio.cpp b/Generals/Code/Tools/WW3D/pluglib/chunkio.cpp deleted file mode 100644 index 983fa998253..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/chunkio.cpp +++ /dev/null @@ -1,796 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/wwlib/chunkio.cpp 11 7/12/01 7:44p Jani_p $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Tiberian Sun / Commando / G Library * - * * - * $Archive:: /Commando/Code/wwlib/chunkio.cpp $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 7/10/01 7:38p $* - * * - * $Revision:: 11 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * ChunkSaveClass::ChunkSaveClass -- Constructor * - * ChunkSaveClass::Begin_Chunk -- Begin a new chunk in the file * - * ChunkSaveClass::End_Chunk -- Close a chunk, computes the size and adds to the header * - * ChunkSaveClass::Begin_Micro_Chunk -- begins a new "micro-chunk" * - * ChunkSaveClass::End_Micro_Chunk -- close a micro-chunk * - * ChunkSaveClass::Write -- Write data into the current chunk * - * ChunkSaveClass::Write -- write an IOVector2Struct * - * ChunkSaveClass::Write -- write an IOVector3Struct * - * ChunkSaveClass::Write -- write an IOVector4Struct * - * ChunkSaveClass::Write -- write an IOQuaternionStruct * - * ChunkSaveClass::Cur_Chunk_Depth -- returns the current chunk recursion depth (debugging) * - * ChunkLoadClass::ChunkLoadClass -- Constructor * - * ChunkLoadClass::Open_Chunk -- Open a chunk in the file, reads in the chunk header * - * ChunkLoadClass::Close_Chunk -- Close a chunk, seeks to the end if needed * - * ChunkLoadClass::Cur_Chunk_ID -- Returns the ID of the current chunk * - * ChunkLoadClass::Cur_Chunk_Length -- Returns the current length of the current chunk * - * ChunkLoadClass::Cur_Chunk_Depth -- returns the current chunk recursion depth * - * ChunkLoadClass::Contains_Chunks -- Test whether the current chunk contains chunks (or dat * - * ChunkLoadClass::Open_Micro_Chunk -- reads in a micro-chunk header * - * ChunkLoadClass::Close_Micro_Chunk -- closes a micro-chunk * - * ChunkLoadClass::Cur_Micro_Chunk_ID -- returns the ID of the current micro-chunk (asserts * - * ChunkLoadClass::Cur_Micro_Chunk_Length -- returns the size of the current micro chunk * - * ChunkLoadClass::Read -- Read data from the file * - * ChunkLoadClass::Read -- read an IOVector2Struct * - * ChunkLoadClass::Read -- read an IOVector3Struct * - * ChunkLoadClass::Read -- read an IOVector4Struct * - * ChunkLoadClass::Read -- read an IOQuaternionStruct * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "chunkio.h" -#include -#include - - -/*********************************************************************************************** - * ChunkSaveClass::ChunkSaveClass -- Constructor * - * * - * INPUT: * - * file - pointer to a FileClass object to write to * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/17/1997 GH : Created. * - *=============================================================================================*/ -ChunkSaveClass::ChunkSaveClass(FileClass * file) : - File(file), - StackIndex(0), - InMicroChunk(false), - MicroChunkPosition(0) -{ - memset(PositionStack,0,sizeof(PositionStack)); - memset(HeaderStack,0,sizeof(HeaderStack)); - memset(&MCHeader,0,sizeof(MCHeader)); -} - - -/*********************************************************************************************** - * ChunkSaveClass::Begin_Chunk -- Begin a new chunk in the file * - * * - * INPUT: * - * id - id of the chunk * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/17/1997 GH : Created. * - *=============================================================================================*/ -bool ChunkSaveClass::Begin_Chunk(uint32 id) -{ - ChunkHeader chunkh; - int filepos; - - // If we have a parent chunk, set its 'Contains_Chunks' flag - if (StackIndex > 0) { - HeaderStack[StackIndex-1].Set_Sub_Chunk_Flag(true); - } - - // Save the current file position and chunk header - // for the call to End_Chunk. - chunkh.Set_Type(id); - chunkh.Set_Size(0); - filepos = File->Seek(0); - - PositionStack[StackIndex] = filepos; - HeaderStack[StackIndex] = chunkh; - StackIndex++; - - // write a temporary chunk header (size = 0) - if (File->Write(&chunkh,sizeof(chunkh)) != sizeof(chunkh)) { - return false; - } - return true; -} - - -/*********************************************************************************************** - * ChunkSaveClass::End_Chunk -- Close a chunk, computes the size and adds to the header * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/17/1997 GH : Created. * - *=============================================================================================*/ -bool ChunkSaveClass::End_Chunk(void) -{ - // If the user didn't close his micro chunks bad things are gonna happen - assert(!InMicroChunk); - - // Save the current position - int curpos = File->Seek(0); - - // Pop the position and chunk header off the stacks - StackIndex--; - int chunkpos = PositionStack[StackIndex]; - ChunkHeader chunkh = HeaderStack[StackIndex]; - - // write the completed header - File->Seek(chunkpos,SEEK_SET); - if (File->Write(&chunkh,sizeof(chunkh)) != sizeof(chunkh)) { - return false; - } - - // Add the total bytes written to any encompasing chunk - if (StackIndex != 0) { - HeaderStack[StackIndex-1].Add_Size(chunkh.Get_Size() + sizeof(chunkh)); - } - - // Go back to the end of the file - File->Seek(curpos,SEEK_SET); - - return true; -} - - -/*********************************************************************************************** - * ChunkSaveClass::Begin_Micro_Chunk -- begins a new "micro-chunk" * - * * - * Micro chunks are used to wrap individual variables. They aren't hierarchical so if you * - * attempt to open a micro chunk while already in one, an assert will occur. * - * * - * INPUT: * - * id - 8bit id * - * * - * OUTPUT: * - * * - * WARNINGS: * - * id is asserted to be between 0 and 255 * - * cannot nest micro chunks so it asserts that you are currently not in another micro-chunk * - * * - * HISTORY: * - * 9/3/99 GTH : Created. * - *=============================================================================================*/ -bool ChunkSaveClass::Begin_Micro_Chunk(uint32 id) -{ - assert(id < 256); - assert(!InMicroChunk); - - // Save the current file position and chunk header - // for the call to End_Micro_Chunk. - MCHeader.Set_Type(id); - MCHeader.Set_Size(0); - MicroChunkPosition = File->Seek(0); - - // Write a temporary chunk header - // NOTE: I'm calling the ChunkSaveClass::Write method so that the bytes for - // this header are tracked in the wrapping chunk. This is because micro-chunks - // are simply data inside the normal chunks... - if (Write(&MCHeader,sizeof(MCHeader)) != sizeof(MCHeader)) { - return false; - } - - InMicroChunk = true; - return true; -} - - -/*********************************************************************************************** - * ChunkSaveClass::End_Micro_Chunk -- close a micro-chunk * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/3/99 GTH : Created. * - *=============================================================================================*/ -bool ChunkSaveClass::End_Micro_Chunk(void) -{ - assert(InMicroChunk); - - // Save the current position - int curpos = File->Seek(0); - - // Seek back and write the micro chunk header - File->Seek(MicroChunkPosition,SEEK_SET); - if (File->Write(&MCHeader,sizeof(MCHeader)) != sizeof(MCHeader)) { - return false; - } - - // Go back to the end of the file - File->Seek(curpos,SEEK_SET); - InMicroChunk = false; - return true; -} - -/*********************************************************************************************** - * ChunkSaveClass::Write -- Write data into the current chunk * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/17/1997 GH : Created. * - *=============================================================================================*/ -uint32 ChunkSaveClass::Write(const void * buf, uint32 nbytes) -{ - // If this assert hits, you mixed data and chunks within the same chunk NO NO! - assert(HeaderStack[StackIndex-1].Get_Sub_Chunk_Flag() == 0); - - // If this assert hits, you didnt open any chunks yet - assert(StackIndex > 0); - - // write the bytes into the file - if (File->Write(buf,nbytes) != (int)nbytes) return 0; - - // track them in the wrapping chunk - HeaderStack[StackIndex-1].Add_Size(nbytes); - - // track them if you are using a micro-chunk too. - if (InMicroChunk) { - assert(MCHeader.Get_Size() < 255 - nbytes); // micro chunks can only be 255 bytes - MCHeader.Add_Size(nbytes); - } - - return nbytes; -} - - -/*********************************************************************************************** - * ChunkSaveClass::Write -- write an IOVector2Struct * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/4/99 GTH : Created. * - *=============================================================================================*/ -uint32 ChunkSaveClass::Write(const IOVector2Struct & v) -{ - return Write(&v,sizeof(v)); -} - - -/*********************************************************************************************** - * ChunkSaveClass::Write -- write an IOVector3Struct * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/4/99 GTH : Created. * - *=============================================================================================*/ -uint32 ChunkSaveClass::Write(const IOVector3Struct & v) -{ - return Write(&v,sizeof(v)); -} - - -/*********************************************************************************************** - * ChunkSaveClass::Write -- write an IOVector4Struct * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/4/99 GTH : Created. * - *=============================================================================================*/ -uint32 ChunkSaveClass::Write(const IOVector4Struct & v) -{ - return Write(&v,sizeof(v)); -} - -/*********************************************************************************************** - * ChunkSaveClass::Write -- write an IOQuaternionStruct * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/4/99 GTH : Created. * - *=============================================================================================*/ -uint32 ChunkSaveClass::Write(const IOQuaternionStruct & q) -{ - return Write(&q,sizeof(q)); -} - -/*********************************************************************************************** - * ChunkSaveClass::Cur_Chunk_Depth -- returns the current chunk recursion depth (debugging) * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/17/1997 GH : Created. * - *=============================================================================================*/ -int ChunkSaveClass::Cur_Chunk_Depth(void) -{ - return StackIndex; -} - - -/*********************************************************************************************** - * ChunkLoadClass::ChunkLoadClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/17/1997 GH : Created. * - *=============================================================================================*/ -ChunkLoadClass::ChunkLoadClass(FileClass * file) : - File(file), - StackIndex(0), - InMicroChunk(false), - MicroChunkPosition(0) -{ - memset(PositionStack,0,sizeof(PositionStack)); - memset(HeaderStack,0,sizeof(HeaderStack)); - memset(&MCHeader,0,sizeof(MCHeader)); -} - - -/*********************************************************************************************** - * ChunkLoadClass::Open_Chunk -- Open a chunk in the file, reads in the chunk header * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/17/1997 GH : Created. * - *=============================================================================================*/ -bool ChunkLoadClass::Open_Chunk() -{ - // if user didn't close any micro chunks that he opened, bad things could happen - assert(InMicroChunk == false); - - // check for stack overflow - assert(StackIndex < MAX_STACK_DEPTH-1); - - // if the parent chunk has been completely eaten, return false - if ((StackIndex > 0) && (PositionStack[StackIndex-1] == HeaderStack[StackIndex-1].Get_Size())) { - return false; - } - - // read the chunk header - if (File->Read(&HeaderStack[StackIndex],sizeof(ChunkHeader)) != sizeof(ChunkHeader)) { - return false; - } - - PositionStack[StackIndex] = 0; - StackIndex++; - return true; -} - - -/*********************************************************************************************** - * ChunkLoadClass::Close_Chunk -- Close a chunk, seeks to the end if needed * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/17/1997 GH : Created. * - *=============================================================================================*/ -bool ChunkLoadClass::Close_Chunk() -{ - // if user didn't close any micro chunks that he opened, bad things could happen - assert(InMicroChunk == false); - - // check for stack overflow - assert(StackIndex > 0); - - int csize = HeaderStack[StackIndex-1].Get_Size(); - int pos = PositionStack[StackIndex-1]; - - if (pos < csize) { - File->Seek(csize - pos,SEEK_CUR); - } - - StackIndex--; - if (StackIndex > 0) { - PositionStack[StackIndex - 1] += csize + sizeof(ChunkHeader); - } - - return true; -} - - -/*********************************************************************************************** - * ChunkLoadClass::Cur_Chunk_ID -- Returns the ID of the current chunk * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/17/1997 GH : Created. * - *=============================================================================================*/ -uint32 ChunkLoadClass::Cur_Chunk_ID() -{ - assert(StackIndex >= 1); - return HeaderStack[StackIndex-1].Get_Type(); -} - - -/*********************************************************************************************** - * ChunkLoadClass::Cur_Chunk_Length -- Returns the current length of the current chunk * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/17/1997 GH : Created. * - *=============================================================================================*/ -uint32 ChunkLoadClass::Cur_Chunk_Length() -{ - assert(StackIndex >= 1); - return HeaderStack[StackIndex-1].Get_Size(); -} - - -/*********************************************************************************************** - * ChunkLoadClass::Cur_Chunk_Depth -- returns the current chunk recursion depth * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/17/1997 GH : Created. * - *=============================================================================================*/ -int ChunkLoadClass::Cur_Chunk_Depth() -{ - return StackIndex; -} - - -/*********************************************************************************************** - * ChunkLoadClass::Contains_Chunks -- Test whether the current chunk contains chunks (or data) * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/24/99 GTH : Created. * - *=============================================================================================*/ -int ChunkLoadClass::Contains_Chunks() -{ - return HeaderStack[StackIndex-1].Get_Sub_Chunk_Flag(); -} - -/*********************************************************************************************** - * ChunkLoadClass::Open_Micro_Chunk -- reads in a micro-chunk header * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/3/99 GTH : Created. * - *=============================================================================================*/ -bool ChunkLoadClass::Open_Micro_Chunk() -{ - assert(!InMicroChunk); - - // read the chunk header - // calling the ChunkLoadClass::Read fn so that if we exhaust the chunk, the read will fail - if (Read(&MCHeader,sizeof(MCHeader)) != sizeof(MCHeader)) { - return false; - } - - InMicroChunk = true; - MicroChunkPosition = 0; - return true; -} - - -/*********************************************************************************************** - * ChunkLoadClass::Close_Micro_Chunk -- closes a micro-chunk (seeks to end) * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/3/99 GTH : Created. * - *=============================================================================================*/ -bool ChunkLoadClass::Close_Micro_Chunk() -{ - assert(InMicroChunk); - InMicroChunk = false; - - int csize = MCHeader.Get_Size(); - int pos = MicroChunkPosition; - - // seek the file past this micro chunk - if (pos < csize) { - - File->Seek(csize - pos,SEEK_CUR); - - // update the tracking variables for where we are in the normal chunk. - if (StackIndex > 0) { - PositionStack[StackIndex-1] += csize - pos; - } - } - - return true; -} - - -/*********************************************************************************************** - * ChunkLoadClass::Cur_Micro_Chunk_ID -- returns the ID of the current micro-chunk (asserts if * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Asserts if you are not currently inside a micro-chunk * - * Micro chunks have an id between 0 and 255 * - * * - * HISTORY: * - * 9/3/99 GTH : Created. * - *=============================================================================================*/ -uint32 ChunkLoadClass::Cur_Micro_Chunk_ID() -{ - assert(InMicroChunk); - return MCHeader.Get_Type(); -} - - -/*********************************************************************************************** - * ChunkLoadClass::Cur_Micro_Chunk_Length -- returns the size of the current micro chunk * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Asserts if you are not currently inside a micro-chunk * - * Micro chunks have a maximum size of 255 bytes * - * * - * HISTORY: * - * 9/3/99 GTH : Created. * - *=============================================================================================*/ -uint32 ChunkLoadClass::Cur_Micro_Chunk_Length() -{ - assert(InMicroChunk); - return MCHeader.Get_Size(); -} - -// Seek over nbytes in the stream -uint32 ChunkLoadClass::Seek(uint32 nbytes) -{ - assert(StackIndex >= 1); - - // Don't seek if we would go past the end of the current chunk - if (PositionStack[StackIndex-1] + nbytes > (int)HeaderStack[StackIndex-1].Get_Size()) { - return 0; - } - - // Don't read if we are in a micro chunk and would go past the end of it - if (InMicroChunk && MicroChunkPosition + nbytes > MCHeader.Get_Size()) { - return 0; - } - - uint32 curpos=File->Tell(); - if (File->Seek(nbytes,SEEK_CUR)-curpos != (int)nbytes) { - return 0; - } - - // Update our position in the chunk - PositionStack[StackIndex-1] += nbytes; - - // Update our position in the micro chunk if we are in one - if (InMicroChunk) { - MicroChunkPosition += nbytes; - } - - return nbytes; -} - -/*********************************************************************************************** - * ChunkLoadClass::Read -- Read data from the file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/17/1997 GH : Created. * - *=============================================================================================*/ -uint32 ChunkLoadClass::Read(void * buf,uint32 nbytes) -{ - assert(StackIndex >= 1); - - // Don't read if we would go past the end of the current chunk - if (PositionStack[StackIndex-1] + nbytes > (int)HeaderStack[StackIndex-1].Get_Size()) { - return 0; - } - - // Don't read if we are in a micro chunk and would go past the end of it - if (InMicroChunk && MicroChunkPosition + nbytes > MCHeader.Get_Size()) { - return 0; - } - - if (File->Read(buf,nbytes) != (int)nbytes) { - return 0; - } - - // Update our position in the chunk - PositionStack[StackIndex-1] += nbytes; - - // Update our position in the micro chunk if we are in one - if (InMicroChunk) { - MicroChunkPosition += nbytes; - } - - return nbytes; -} - - -/*********************************************************************************************** - * ChunkLoadClass::Read -- read an IOVector2Struct * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/4/99 GTH : Created. * - *=============================================================================================*/ -uint32 ChunkLoadClass::Read(IOVector2Struct * v) -{ - assert(v != NULL); - return Read(v,sizeof(v)); -} - - -/*********************************************************************************************** - * ChunkLoadClass::Read -- read an IOVector3Struct * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/4/99 GTH : Created. * - *=============================================================================================*/ -uint32 ChunkLoadClass::Read(IOVector3Struct * v) -{ - assert(v != NULL); - return Read(v,sizeof(v)); -} - - -/*********************************************************************************************** - * ChunkLoadClass::Read -- read an IOVector4Struct * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/4/99 GTH : Created. * - *=============================================================================================*/ -uint32 ChunkLoadClass::Read(IOVector4Struct * v) -{ - assert(v != NULL); - return Read(v,sizeof(v)); -} - - -/*********************************************************************************************** - * ChunkLoadClass::Read -- read an IOQuaternionStruct * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/4/99 GTH : Created. * - *=============================================================================================*/ -uint32 ChunkLoadClass::Read(IOQuaternionStruct * q) -{ - assert(q != NULL); - return Read(q,sizeof(q)); -} - diff --git a/Generals/Code/Tools/WW3D/pluglib/chunkio.h b/Generals/Code/Tools/WW3D/pluglib/chunkio.h deleted file mode 100644 index 5ff2f9fe587..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/chunkio.h +++ /dev/null @@ -1,380 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/wwlib/chunkio.h 21 7/31/01 6:41p Patrick $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Tiberian Sun / Commando / G Library * - * * - * $Archive:: /Commando/Code/wwlib/chunkio.h $* - * * - * $Author:: Patrick $* - * * - * $Modtime:: 7/27/01 2:47p $* - * * - * $Revision:: 21 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef CHUNKIO_H -#define CHUNKIO_H - -#ifndef ALWAYS_H -#include "always.h" -#endif - -#ifndef BITTYPE_H -#include "BITTYPE.H" -#endif - -#ifndef WWFILE_H -#include "wwfile.h" -#endif - -#ifndef IOSTRUCT_H -#include "iostruct.h" -#endif - - -/************************************************************************************ - - ChunkIO - - (gth) This module provides classes for reading and writing chunk-based files. - For example, all of the w3d files are stored in a hierarchical-chunk format. - Basically the format is similar to IFF. All data in the file has chunk headers - wrapped around it. A chunk header contains an ID, and a Size. The size - is the number of bytes in the chunk (not including the header). The - contents of a chunk may be either: more "sub-chunks" or raw data. These classes - will automatically keep track of your positions within all of the sub and parent - chunks (to some maximum recursion depth). - - Sept 3, 1999 - (gth) Adding the new concept of "micro-chunks". Instead of filling the contents of a - chunk with data, you can fill it with "micro-chunks" which contain a single byte - id and a single byte size. Micro-chunks are used for storing simple variables - in a form that can survive revisions to the file format without paying the price - for a full chunk header. You CANNOT recursively embed micro-chunks due to their - size limitations.... - - Sept 24, 1999 - (gth) Using the MSB of the chunksize to indicate whether a chunk contains other - chunks or pure data. If the MSB is 0, the chunk contains data (so that the reader - I'm going to write doesn't break on older files) and if it is 1 then it is - assumed to contain other chunks. This does not apply to micro-chunks as they - are considered data. - -**************************************************************************************/ - -struct ChunkHeader -{ - // Functions. - ChunkHeader() : ChunkType(0), ChunkSize(0) {} - ChunkHeader(uint32 type, uint32 size) {ChunkType = type; ChunkSize = size;} - - // Use these accessors to ensure you correctly deal with the data in the chunk header - void Set_Type(uint32 type) { ChunkType = type; } - uint32 Get_Type(void) { return ChunkType; } - void Set_Size(uint32 size) { ChunkSize &= 0x80000000; ChunkSize |= (size & 0x7FFFFFFF); } - void Add_Size(uint32 add) { Set_Size(Get_Size() + add); } - uint32 Get_Size(void) { return (ChunkSize & 0x7FFFFFFF); } - void Set_Sub_Chunk_Flag(bool onoff) { if (onoff) { ChunkSize |= 0x80000000; } else { ChunkSize &= 0x7FFFFFFF; } } - int Get_Sub_Chunk_Flag(void) { return (ChunkSize & 0x80000000); } - - // Chunk type and size. - // Note: MSB of ChunkSize is used to indicate whether this chunk - // contains other chunks or data. - uint32 ChunkType; - uint32 ChunkSize; -}; - -struct MicroChunkHeader -{ - MicroChunkHeader() {} - MicroChunkHeader(uint8 type, uint8 size) { ChunkType = type, ChunkSize = size; } - - void Set_Type(uint8 type) { ChunkType = type; } - uint8 Get_Type(void) { return ChunkType; } - void Set_Size(uint8 size) { ChunkSize = size; } - void Add_Size(uint8 add) { Set_Size(Get_Size() + add); } - uint8 Get_Size(void) { return ChunkSize; } - - uint8 ChunkType; - uint8 ChunkSize; -}; - - -/************************************************************************************** -** -** ChunkSaveClass -** Wrap an instance of this class around an opened file for easy chunk -** creation. -** -**************************************************************************************/ -class ChunkSaveClass -{ -public: - ChunkSaveClass(FileClass * file); - - // Chunk methods - bool Begin_Chunk(uint32 id); - bool End_Chunk(); - int Cur_Chunk_Depth(); - - // Micro chunk methods - bool Begin_Micro_Chunk(uint32 id); - bool End_Micro_Chunk(); - - // Write data into the file - uint32 Write(const void *buf, uint32 nbytes); - uint32 Write(const IOVector2Struct & v); - uint32 Write(const IOVector3Struct & v); - uint32 Write(const IOVector4Struct & v); - uint32 Write(const IOQuaternionStruct & q); - -private: - - enum { MAX_STACK_DEPTH = 256 }; - - FileClass * File; - - // Chunk building support - int StackIndex; - int PositionStack[MAX_STACK_DEPTH]; - ChunkHeader HeaderStack[MAX_STACK_DEPTH]; - - // MicroChunk building support - bool InMicroChunk; - int MicroChunkPosition; - MicroChunkHeader MCHeader; -}; - - -/************************************************************************************** -** -** ChunkLoadClass -** wrap an instance of one of these objects around an opened file -** to easily parse the chunks in the file -** -**************************************************************************************/ -class ChunkLoadClass -{ -public: - - ChunkLoadClass(FileClass * file); - - // Chunk methods - bool Open_Chunk(); - bool Close_Chunk(); - uint32 Cur_Chunk_ID(); - uint32 Cur_Chunk_Length(); - int Cur_Chunk_Depth(); - int Contains_Chunks(); - - // Micro Chunk methods - bool Open_Micro_Chunk(); - bool Close_Micro_Chunk(); - uint32 Cur_Micro_Chunk_ID(); - uint32 Cur_Micro_Chunk_Length(); - - // Read a block of bytes from the output stream. - uint32 Read(void *buf, uint32 nbytes); - uint32 Read(IOVector2Struct * v); - uint32 Read(IOVector3Struct * v); - uint32 Read(IOVector4Struct * v); - uint32 Read(IOQuaternionStruct * q); - - // Seek over a block of bytes in the stream (same as Read but don't copy the data to a buffer) - uint32 Seek(uint32 nbytes); - -private: - - enum { MAX_STACK_DEPTH = 256 }; - - FileClass * File; - - // Chunk reading support - int StackIndex; - uint32 PositionStack[MAX_STACK_DEPTH]; - ChunkHeader HeaderStack[MAX_STACK_DEPTH]; - - // Micro-chunk reading support - bool InMicroChunk; - int MicroChunkPosition; - MicroChunkHeader MCHeader; - -}; - -/* -** WRITE_WWSTRING_CHUNK - use this one-line macro to easily create a chunk to save a potentially -** long string. Note: This macro does NOT create a micro chunk... -** Example: -** -** csave.Begin_Chunk(CHUNKID_PARENT); -** ParentClass::Save (csave); -** csave.End_Chunk(); -** -** WRITE_WWSTRING_CHUNK(csave, CHUNKID_NAME, string); -** WRITE_WIDESTRING_CHUNK(csave, CHUNKID_WIDE_NAME, wide_string); -** -** csave.Begin_Chunk(PHYSGRID_CHUNK_VARIABLES); -** WRITE_MICRO_CHUNK(csave,PHYSGRID_VARIABLE_VERSION,version); -** WRITE_MICRO_CHUNK(csave,PHYSGRID_VARIABLE_DUMMYVISID,DummyVisId); -** WRITE_MICRO_CHUNK(csave,PHYSGRID_VARIABLE_BASEVISID,BaseVisId); -** csave.End_Chunk(); -** -*/ -#define WRITE_WWSTRING_CHUNK(csave,id,var) { \ - csave.Begin_Chunk(id); \ - csave.Write((const TCHAR *)var, var.Get_Length () + 1); \ - csave.End_Chunk(); } - -#define WRITE_WIDESTRING_CHUNK(csave,id,var) { \ - csave.Begin_Chunk(id); \ - csave.Write((const WCHAR *)var, (var.Get_Length () + 1) * 2); \ - csave.End_Chunk(); } - - -/* -** READ_WWSTRING_CHUNK - use this macro in a switch statement to read the contents -** of a chunk into a string object. -** Example: -** -** while (cload.Open_Chunk()) { -** -** switch(cload.Cur_Chunk_ID()) { -** READ_WWSTRING_CHUNK(cload,CHUNKID_NAME,string); -** READ_WIDESTRING_CHUNK(cload,CHUNKID_WIDE_NAME,wide_string); -** } -** cload.Close_Chunk(); -** } -** -*/ -#define READ_WWSTRING_CHUNK(cload,id,var) \ - case (id): cload.Read(var.Get_Buffer(cload.Cur_Chunk_Length()),cload.Cur_Chunk_Length()); break; \ - -#define READ_WIDESTRING_CHUNK(cload,id,var) \ - case (id): cload.Read(var.Get_Buffer((cload.Cur_Chunk_Length()+1)/2),cload.Cur_Chunk_Length()); break; \ - - -/* -** WRITE_MICRO_CHUNK - use this one-line macro to easily make a micro chunk for an individual variable. -** Note that you should always wrap your micro-chunks inside a normal chunk. -** Example: -** -** csave.Begin_Chunk(PHYSGRID_CHUNK_VARIABLES); -** WRITE_MICRO_CHUNK(csave,PHYSGRID_VARIABLE_VERSION,version); -** WRITE_MICRO_CHUNK(csave,PHYSGRID_VARIABLE_DUMMYVISID,DummyVisId); -** WRITE_MICRO_CHUNK(csave,PHYSGRID_VARIABLE_BASEVISID,BaseVisId); -** csave.End_Chunk(); -*/ -#define WRITE_MICRO_CHUNK(csave,id,var) { \ - csave.Begin_Micro_Chunk(id); \ - csave.Write(&var,sizeof(var)); \ - csave.End_Micro_Chunk(); } - -#define WRITE_SAFE_MICRO_CHUNK(csave,id,var,type) { \ - csave.Begin_Micro_Chunk(id); \ - type data = (type)var; \ - csave.Write(&data,sizeof(data)); \ - csave.End_Micro_Chunk(); } - -#define WRITE_MICRO_CHUNK_STRING(csave,id,var) { \ - csave.Begin_Micro_Chunk(id); \ - csave.Write(var, strlen(var) + 1); \ - csave.End_Micro_Chunk(); } - -#define WRITE_MICRO_CHUNK_WWSTRING(csave,id,var) { \ - csave.Begin_Micro_Chunk(id); \ - csave.Write((const TCHAR *)var, var.Get_Length () + 1); \ - csave.End_Micro_Chunk(); } - -#define WRITE_MICRO_CHUNK_WIDESTRING(csave,id,var) { \ - csave.Begin_Micro_Chunk(id); \ - csave.Write((const WCHAR *)var, (var.Get_Length () + 1) * 2); \ - csave.End_Micro_Chunk(); } - - -/* -** READ_MICRO_CHUNK - use this macro in a switch statement to read a micro chunk into a variable -** Example: -** -** while (cload.Open_Micro_Chunk()) { -** -** switch(cload.Cur_Micro_Chunk_ID()) { -** READ_MICRO_CHUNK(cload,PHYSGRID_VARIABLE_VERSION,version); -** READ_MICRO_CHUNK(cload,PHYSGRID_VARIABLE_DUMMYVISID,DummyVisId); -** READ_MICRO_CHUNK(cload,PHYSGRID_VARIABLE_BASEVISID,BaseVisId); -** } -** cload.Close_Micro_Chunk(); -** } -*/ -#define READ_MICRO_CHUNK(cload,id,var) \ - case (id): cload.Read(&var,sizeof(var)); break; \ - -/* -** Like READ_MICRO_CHUNK but reads items straight into the data safe. -*/ -#define READ_SAFE_MICRO_CHUNK(cload,id,var,type) \ - case (id): { \ - void *temp_read_buffer_on_the_stack = _alloca(sizeof(var)); \ - cload.Read(temp_read_buffer_on_the_stack, sizeof(var)); \ - var = *((type*)temp_read_buffer_on_the_stack); \ - break; \ - } - -#define READ_MICRO_CHUNK_STRING(cload,id,var,size) \ - case (id): WWASSERT(cload.Cur_Micro_Chunk_Length() <= size); cload.Read(var,cload.Cur_Micro_Chunk_Length()); break; \ - -#define READ_MICRO_CHUNK_WWSTRING(cload,id,var) \ - case (id): cload.Read(var.Get_Buffer(cload.Cur_Micro_Chunk_Length()),cload.Cur_Micro_Chunk_Length()); break; \ - -#define READ_MICRO_CHUNK_WIDESTRING(cload,id,var) \ - case (id): cload.Read(var.Get_Buffer((cload.Cur_Micro_Chunk_Length()+1)/2),cload.Cur_Micro_Chunk_Length()); break; \ - -/* -** These load macros make it easier to add extra code to a specifc case -*/ -#define LOAD_MICRO_CHUNK(cload,var) \ - cload.Read(&var,sizeof(var)); \ - -#define LOAD_MICRO_CHUNK_WWSTRING(cload,var) \ - cload.Read(var.Get_Buffer(cload.Cur_Micro_Chunk_Length()),cload.Cur_Micro_Chunk_Length()); \ - -#define LOAD_MICRO_CHUNK_WIDESTRING(cload,var) \ - cload.Read(var.Get_Buffer((cload.Cur_Micro_Chunk_Length()+1)/2),cload.Cur_Micro_Chunk_Length()); \ - - -/* -** OBSOLETE_MICRO_CHUNK - use this macro in a switch statement when you want your code -** to skip a given micro chunk but not fall through to your 'default' case statement which -** prints an "unrecognized chunk" warning message. -*/ -#define OBSOLETE_MICRO_CHUNK(id) \ - case (id): break; - - - -#endif // CHUNKIO_H diff --git a/Generals/Code/Tools/WW3D/pluglib/errclass.h b/Generals/Code/Tools/WW3D/pluglib/errclass.h deleted file mode 100644 index 98c4dcbd6d9..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/errclass.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/pluglib/errclass.h 5 6/25/99 10:46a Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando Tools - W3D export * - * * - * $Archive:: /Commando/Code/Tools/pluglib/errclass.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 6/24/99 3:38p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef ERRCLASS_H -#define ERRCLASS_H - -#include - - -class ErrorClass -{ -public: - ErrorClass(char * format,...); - ErrorClass(const ErrorClass & that); - ~ErrorClass(void) { if (error_message != NULL) free(error_message); } - - ErrorClass & operator = (const ErrorClass & that); - - char * error_message; -}; - -inline ErrorClass::ErrorClass(char * format,...) -{ - va_list va; - char tmp[1024]; - va_start(va,format); - vsprintf(tmp,format,va); - assert(strlen(tmp) < 1024); - va_end(va); - error_message = strdup(tmp); -} - -inline ErrorClass::ErrorClass(const ErrorClass & that) : - error_message(NULL) -{ - *this = that; -} - -inline ErrorClass & ErrorClass::operator = (const ErrorClass & that) -{ - if (error_message != NULL) { - free(error_message); - error_message = NULL; - } - - if (that.error_message != NULL) { - error_message = strdup(that.error_message); - } - - return *this; -} - - -#endif //ERRCLASS_H \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/pluglib/hashcalc.h b/Generals/Code/Tools/WW3D/pluglib/hashcalc.h deleted file mode 100644 index 5a3e992eb39..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/hashcalc.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Westwood Library * - * * - * $Archive:: /G/wwlib/hashcalc.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 4/02/99 11:59a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - - -#ifndef HASHCALC_H -#define HASHCALC_H - - -/* -** HashCalculatorClass -** The hash calculator is used to abstract the process of computing a hash -** value for an object. Also, when dealing with floating point values, you -** may need to have a fudge factor and therefore have several valid hash -** values for a particular object (generated by adding and subtracting an -** epsilon to the number(s)). This class lets you define any number -** of hash values. This class is used by the UniqueArrayClass and the HashTableClass -** templates. Basically, you give one of these to the UniqueArrayClass at -** construction time. It will call the Num_Hash_Bits function in order to -** properly allocate its hash table. Then, for each object you pass into the -** Add function, it will call Compute_Hash, then it will loop through -** Num_Hash_Values, calling Get_Hash_Value for each index and see if the object -** is found in the indicated slot. Also, when it is checking to see if it has -** the object you "Added", the Items_Match function is called. This again -** allows you to do epsilon tests. Make sense? -*/ -template class HashCalculatorClass -{ -public: - virtual bool Items_Match(const T & a, const T & b) = 0; - virtual void Compute_Hash(const T & item) = 0; - virtual int Num_Hash_Bits(void) = 0; - virtual int Num_Hash_Values(void) = 0; - virtual int Get_Hash_Value(int index = 0) = 0; -}; - - - -#endif diff --git a/Generals/Code/Tools/WW3D/pluglib/hsv.cpp b/Generals/Code/Tools/WW3D/pluglib/hsv.cpp deleted file mode 100644 index 81a7e6bffef..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/hsv.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/HSV.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * HSVClass::Adjust -- Adjust an HSV color toward specified color. * - * HSVClass::Difference -- Finds the difference between two HSV color objects. * - * HSVClass::operator RGBClass -- Conversion operator for RGBClass object. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "always.h" -#include "hsv.h" -#include "rgb.h" - -HSVClass const HSVClass::BlackColor(0, 0, 0); - - -/*********************************************************************************************** - * HSVClass::Adjust -- Adjust an HSV color toward specified color. * - * * - * This routine will adjust the HSV color object toward the color of the specified HSV * - * object. Typical users of this would be palette morphing or fading routines. * - * * - * INPUT: ratio -- The ratio to move the HSV object toward the color specified. A value * - * of zero means no movement at all. A value of 255 means move completely * - * toward the specified color (changed completely). * - * * - * hsv -- A reference to the color that the current HSV object is to change * - * toward. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/20/1996 JLB : Created. * - *=============================================================================================*/ -void HSVClass::Adjust(int ratio, HSVClass const & hsv) -{ - /* - ** Ratio conversion is limited to 0 through 100%. This is - ** the range of 0 to 255. - */ - ratio &= 0x00FF; - - /* - ** Adjust the color guns by the ratio specified toward the - ** destination color. - */ - int value = hsv.Get_Value() - Get_Value(); - Value = (unsigned char)(Get_Value() + (value * ratio) / 256); - - int saturation = hsv.Get_Saturation() - Get_Saturation(); - Saturation = (unsigned char)(Get_Saturation() + (saturation * ratio) / 256); - - int hue = hsv.Get_Hue() - Get_Hue(); - Hue = (unsigned char)(Get_Hue() + (hue * ratio) / 256); -} - - -/*********************************************************************************************** - * HSVClass::Difference -- Finds the difference between two HSV color objects. * - * * - * This routine will determine a color difference between two HSV objects. The difference * - * has no particular meaning other that larger numbers meaning greater difference. * - * * - * INPUT: hsv -- The other HSV object to compare this HSV object to. * - * * - * OUTPUT: Returns with a relative distance (in arbitrary units) between this HSV object and * - * the HSV object supplied. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/20/1996 JLB : Created. * - *=============================================================================================*/ -int HSVClass::Difference(HSVClass const & hsv) const -{ - int hue = (int)Hue - (int)hsv.Hue; - if (hue < 0) hue = -hue; - - int saturation = (int)Saturation - (int)hsv.Saturation; - if (saturation < 0) saturation = -saturation; - - int value = (int)Value - (int)hsv.Value; - if (value < 0) value = -value; - - return(hue*hue + saturation*saturation + value*value); -} - - -/*********************************************************************************************** - * HSVClass::operator RGBClass -- Conversion operator for RGBClass object. * - * * - * This conversion operator will convert the HSV object into an RGB object. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with a reference (implied) of the RGBClass object that most closely * - * matches this HSVClass object. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/20/1996 JLB : Created. * - *=============================================================================================*/ -HSVClass::operator RGBClass (void) const -{ - unsigned int i; // Integer part. - unsigned int f; // Fractional or remainder part. f/HSV_BASE gives fraction. - unsigned int tmp; // Temporary variable to help with calculations. - unsigned int values[7]; // Possible rgb values. Don't use zero. - - int hue = Get_Hue(); - int saturation = Get_Saturation(); - int value = Get_Value(); - int red, green, blue; - - - hue *= 6; - f = hue % 255; - - // Set up possible red, green and blue values. - values[1] = - values[2] = value; - - // - // The following lines of code change - // values[3] = (v * (255 - ( (s * f) / 255) )) / 255; - // values[4] = values[5] = (v * (255 - s)) / 255; - // values[6] = (v * (255 - (s * (255 - f)) / 255)) / 255; - // so that the are rounded divides. - // - - tmp = (saturation * f) / 255; - values[3] = (value * (255 - tmp)) / 255; - - values[4] = - values[5] = (value * (255 - saturation)) / 255; - - tmp = 255 - (saturation * (255 - f)) / 255; - values[6] = (value * tmp) / 255; - - - // This should not be rounded. - i = hue / 255; - - i += (i > 4) ? -4 : 2; - red = values[i]; - - i += (i > 4) ? -4 : 2; - blue = values[i]; - - i += (i > 4) ? -4 : 2; - green = values[i]; - - RGBClass rgb((unsigned char)red, (unsigned char)green, (unsigned char)blue); - return(rgb); -} - - diff --git a/Generals/Code/Tools/WW3D/pluglib/hsv.h b/Generals/Code/Tools/WW3D/pluglib/hsv.h deleted file mode 100644 index ed57918d334..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/hsv.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/HSV.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef HSV_H -#define HSV_H - -class RGBClass; -class HSVClass; - -/* -** Each color entry is represented by this class. It holds the values for the color -** attributes. The values are recorded in a range from 0 to 255 with 255 being the -** maximum. -*/ -class HSVClass -{ - private: - static HSVClass const BlackColor; - - public: - HSVClass(void) : Hue(0), Saturation(0), Value(0) {}; - HSVClass(unsigned char hue, unsigned char saturation, unsigned char value) : - Hue(hue), - Saturation(saturation), - Value(value) - {}; - operator RGBClass (void) const; - - enum { - MAX_VALUE=255 - }; - - void Adjust(int ratio, HSVClass const & hsv); - int Difference(HSVClass const & hsv) const; - int Get_Hue(void) const {return(Hue);}; - int Get_Saturation(void) const {return(Saturation);}; - int Get_Value(void) const {return(Value);}; - void Set_Hue(unsigned char value) {Hue = value;} - void Set_Saturation(unsigned char value) {Saturation = value;} - void Set_Value(unsigned char value) {Value = value;} - - private: - unsigned char Hue; - unsigned char Saturation; - unsigned char Value; -}; - -#endif diff --git a/Generals/Code/Tools/WW3D/pluglib/iostruct.h b/Generals/Code/Tools/WW3D/pluglib/iostruct.h deleted file mode 100644 index 1d1565fdf62..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/iostruct.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WWLib * - * * - * $Archive:: /G/wwlib/iostruct.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 4/02/99 11:59a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef IOSTRUCT_H -#define IOSTRUCT_H - -#ifndef BITTYPE_H -#include "BITTYPE.H" -#endif - -/* -** Some useful structures for writing/writing (safe from changes). -** The chunk IO classes contain code for reading and writing these. -*/ -struct IOVector2Struct -{ - float32 X; - float32 Y; -}; - -struct IOVector3Struct -{ - float32 X; // X,Y,Z coordinates - float32 Y; - float32 Z; -}; - -struct IOVector4Struct -{ - float32 X; - float32 Y; - float32 Z; - float32 W; -}; - -struct IOQuaternionStruct -{ - float32 Q[4]; -}; - - - -#endif - diff --git a/Generals/Code/Tools/WW3D/pluglib/jshell.cpp b/Generals/Code/Tools/WW3D/pluglib/jshell.cpp deleted file mode 100644 index 8f2ba0e54e1..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/jshell.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Tools/pluglib/jshell.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 11/07/00 2:32p $* - * * - * $Revision:: 28 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Fatal -- General purpose fatal error handler. * - * Set_Bit -- Set bit in a bit array. * - * Get_Bit -- Fetch the bit value from a bit array. * - * First_True_Bit -- Return with the first true bit index. * - * First_False_Bit -- Find the first false bit in the bit array. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" - - -/*********************************************************************************************** - * Set_Bit -- Set bit in a bit array. * - * * - * This routine is used to set (or clear) a bit in a bit array. * - * * - * INPUT: array -- Pointer to the bit array. * - * * - * bit -- The bit number to set. I.e., bit 32 is the first bit in the second * - * long word of memory. * - * * - * value -- The value to set the bit. The only values supported are 0 and 1. * - * * - * OUTPUT: none * - * * - * WARNINGS: Be sure that the array is big enough to set the specified bit. * - * * - * HISTORY: * - * 10/06/1997 JLB : Created. * - *=============================================================================================*/ -void Set_Bit(void * array, int bit, int value) -{ - unsigned char mask = (unsigned char)(1 << (bit % 8)); - - if (value != 0) { - *((unsigned char *)array + (bit/8)) |= mask; - } else { - *((unsigned char *)array + (bit/8)) &= (unsigned char)~mask; - } -} - - -/*********************************************************************************************** - * Get_Bit -- Fetch the bit value from a bit array. * - * * - * This routine will fetch the specified bit value from the bit array. This is the * - * counterpart function to the Set_Bit() function. * - * * - * INPUT: array -- Pointer to the bit array to fetch the bit value from. * - * * - * bit -- The bit number to fetch. * - * * - * OUTPUT: Returns with the value of the bit. This return value will be either 1 or 0. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/06/1997 JLB : Created. * - *=============================================================================================*/ -int Get_Bit(void const * array, int bit) -{ - unsigned char mask = (unsigned char)(1 << (bit % 8)); - return((*((unsigned char *)array + (bit/8)) & mask) != 0); -} - - -/*********************************************************************************************** - * First_True_Bit -- Return with the first true bit index. * - * * - * This routine will scan the bit array and return with the index for the first true bit * - * in the array. * - * * - * INPUT: array -- Pointer to the bit array to scan. * - * * - * OUTPUT: Returns with the index of the first true (set to 1) bit in the array. * - * * - * WARNINGS: This routine does not stop at the end of the array (it doesn't know where the * - * end is) so there must be at least one true bit in the array or else it will * - * end up scanning past the end (undefined results in that case). * - * * - * HISTORY: * - * 10/06/1997 JLB : Created. * - *=============================================================================================*/ -int First_True_Bit(void const * array) -{ - int index = 0; - while (*((unsigned char *)array) == 0) { - index++; - array = ((char*)array) + 1; - } - int subindex; - for (subindex = 0; subindex < 8; subindex++) { - if (Get_Bit(array, subindex)) break; - } - return(index * 8 + subindex); -} - - -/*********************************************************************************************** - * First_False_Bit -- Find the first false bit in the bit array. * - * * - * This routine will scan the bit array and return with the index of the first false (set * - * to 0) bit found. * - * * - * INPUT: array -- Pointer to the bit array to scan. * - * * - * OUTPUT: Returns with the index of the first false bit found in the array. * - * * - * WARNINGS: This routine will not stop scanning until a false bit was found. This means * - * that there must be at least one false bit in the array or else it will scan * - * past the end of the array. * - * * - * HISTORY: * - * 10/06/1997 JLB : Created. * - *=============================================================================================*/ -int First_False_Bit(void const * array) -{ - int index = 0; - while (*((unsigned char *)array) == 0xFF) { - index++; - array = ((char*)array) + 1; - } - int subindex; - for (subindex = 0; subindex < 8; subindex++) { - if (!Get_Bit(array, subindex)) break; - } - return(index * 8 + subindex); -} - diff --git a/Generals/Code/Tools/WW3D/pluglib/matrix3d.cpp b/Generals/Code/Tools/WW3D/pluglib/matrix3d.cpp deleted file mode 100644 index 324b8c8f9bf..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/matrix3d.cpp +++ /dev/null @@ -1,841 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/matrix3d.cpp 39 2/03/00 4:55p Jason_a $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Voxel Technology * - * * - * File Name : MATRIX3D.CPP * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 02/24/97 * - * * - * Last Update : February 28, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Matrix3D::Set_Rotation -- Sets the rotation part of the matrix * - * Matrix3D::Set_Rotation -- Sets the rotation part of the matrix * - * Matrix3D::Set -- Init a matrix3D from a matrix3 and a position * - * Matrix3D::Set -- Init a matrix3D from a quaternion and a position * - * Matrix3D::Get_X_Rotation -- approximates the rotation about the X axis * - * Matrix3D::Get_Y_Rotation -- approximates the rotation about the Y axis * - * Matrix3D::Get_Z_Rotation -- approximates the rotation about the Z axis * - * Matrix3D::Multiply -- matrix multiplication without temporaries. * - * Matrix3D::Inverse_Rotate_Vector -- rotates a vector by the inverse of the 3x3 sub-matrix * - * Matrix3D::Transform_Min_Max_AABox -- compute transformed axis-aligned box * - * Matrix3D::Transform_Center_Extent_AABox -- compute transformed axis-aligned box * - * Matrix3D::Get_Inverse -- calculate the inverse of this matrix * - * Matrix3D::Get_Orthogonal_Inverse -- Returns the inverse of the matrix * - * Matrix3D::Re_Orthogonalize -- makes this matrix orthogonal. * - * Matrix3D::Is_Orthogonal -- checks whether this matrix is orthogonal * - * Lerp - linearly interpolate matrices (orientation is slerped) * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "matrix3d.h" - -#include -#include -#include -//#include -#include "vector3.h" -#include "WWmatrix3.h" -#include "matrix4.h" -#include "w3dquat.h" - -// some static matrices which are sometimes useful -const Matrix3D Matrix3D::Identity -( - 1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0 -); - -const Matrix3D Matrix3D::RotateX90 -( - 1.0, 0.0, 0.0, 0.0, - 0.0, 0.0, -1.0, 0.0, - 0.0, 1.0, 0.0, 0.0 -); - -const Matrix3D Matrix3D::RotateX180 -( - 1.0, 0.0, 0.0, 0.0, - 0.0, -1.0, 0.0, 0.0, - 0.0, 0.0, -1.0, 0.0 -); - -const Matrix3D Matrix3D::RotateX270 -( - 1.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, -1.0, 0.0, 0.0 -); - -const Matrix3D Matrix3D::RotateY90 -( - 0.0, 0.0, 1.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - -1.0, 0.0, 0.0, 0.0 -); - -const Matrix3D Matrix3D::RotateY180 -( - -1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, -1.0, 0.0 -); - -const Matrix3D Matrix3D::RotateY270 -( - 0.0, 0.0, -1.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 1.0, 0.0, 0.0, 0.0 -); - -const Matrix3D Matrix3D::RotateZ90 -( - 0.0, -1.0, 0.0, 0.0, - 1.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0 -); - -const Matrix3D Matrix3D::RotateZ180 -( - -1.0, 0.0, 0.0, 0.0, - 0.0, -1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0 -); - -const Matrix3D Matrix3D::RotateZ270 -( - 0.0, 1.0, 0.0, 0.0, - -1.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0 -); - - -/*********************************************************************************************** - * Matrix3D::Set -- Init a matrix3D from a matrix3 and a position * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -void Matrix3D::Set(const Matrix3 & rot,const Vector3 & pos) -{ - Row[0].Set( rot[0][0], rot[0][1], rot[0][2], pos[0]); - Row[1].Set( rot[1][0], rot[1][1], rot[1][2], pos[1]); - Row[2].Set( rot[2][0], rot[2][1], rot[2][2], pos[2]); -} - - -/*********************************************************************************************** - * Matrix3D::Set -- Init a matrix3D from a quaternion and a position * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -void Matrix3D::Set(const Quaternion & rot,const Vector3 & pos) -{ - Set_Rotation(rot); - Set_Translation(pos); -} - - -/*********************************************************************************************** - * Matrix3D::Set_Rotation -- Sets the rotation part of the matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/11/98 GTH : Created. * - *=============================================================================================*/ -void Matrix3D::Set_Rotation(const Matrix3 & m) -{ - Row[0][0] = m[0][0]; - Row[0][1] = m[0][1]; - Row[0][2] = m[0][2]; - - Row[1][0] = m[1][0]; - Row[1][1] = m[1][1]; - Row[1][2] = m[1][2]; - - Row[2][0] = m[2][0]; - Row[2][1] = m[2][1]; - Row[2][2] = m[2][2]; -} - - -/*********************************************************************************************** - * Matrix3D::Set_Rotation -- Sets the rotation part of the matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/11/98 GTH : Created. * - *=============================================================================================*/ -void Matrix3D::Set_Rotation(const Quaternion & q) -{ - Row[0][0] = (float)(1.0 - 2.0 * (q[1] * q[1] + q[2] * q[2])); - Row[0][1] = (float)(2.0 * (q[0] * q[1] - q[2] * q[3])); - Row[0][2] = (float)(2.0 * (q[2] * q[0] + q[1] * q[3])); - - Row[1][0] = (float)(2.0 * (q[0] * q[1] + q[2] * q[3])); - Row[1][1] = (float)(1.0 - 2.0f * (q[2] * q[2] + q[0] * q[0])); - Row[1][2] = (float)(2.0 * (q[1] * q[2] - q[0] * q[3])); - - Row[2][0] = (float)(2.0 * (q[2] * q[0] - q[1] * q[3])); - Row[2][1] = (float)(2.0 * (q[1] * q[2] + q[0] * q[3])); - Row[2][2] =(float)(1.0 - 2.0 * (q[1] * q[1] + q[0] * q[0])); -} - - -/*********************************************************************************************** - * Matrix3D::Get_X_Rotation -- approximates the rotation about the X axis * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -float Matrix3D::Get_X_Rotation(void) const -{ - return atan2(Row[2][1], Row[1][1]); -} - - -/*********************************************************************************************** - * Matrix3D::Get_Y_Rotation -- approximates the rotation about the Y axis * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -float Matrix3D::Get_Y_Rotation(void) const -{ - return atan2(Row[0][2], Row[2][2]); -} - - -/*********************************************************************************************** - * Matrix3D::Get_Z_Rotation -- approximates the rotation about the Z axis * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -float Matrix3D::Get_Z_Rotation(void) const -{ - return atan2(Row[1][0], Row[0][0]); -} - - -/*********************************************************************************************** - * M3DC::Rotate_Vector -- Uses the 3x3 sub-matrix to rotate a vector * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -Vector3 Matrix3D::Rotate_Vector(const Vector3 &vect) const -{ - return Vector3( - (Row[0][0]*vect[0] + Row[0][1]*vect[1] + Row[0][2]*vect[2]), - (Row[1][0]*vect[0] + Row[1][1]*vect[1] + Row[1][2]*vect[2]), - (Row[2][0]*vect[0] + Row[2][1]*vect[1] + Row[2][2]*vect[2]) - ); -} - - -/*********************************************************************************************** - * Matrix3D::Inverse_Rotate_Vector -- rotates a vector by the inverse of the 3x3 sub-matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/27/98 GTH : Created. * - *=============================================================================================*/ -Vector3 Matrix3D::Inverse_Rotate_Vector(const Vector3 &vect) const -{ - return Vector3( - (Row[0][0]*vect[0] + Row[1][0]*vect[1] + Row[2][0]*vect[2]), - (Row[0][1]*vect[0] + Row[1][1]*vect[1] + Row[2][1]*vect[2]), - (Row[0][2]*vect[0] + Row[1][2]*vect[1] + Row[2][2]*vect[2]) - ); -} - -/*********************************************************************************************** - * M3DC::Look_At -- Creates a "look at" transformation. * - * * - * Builds a transformation matrix which positions the origin at p, * - * points the negative z-axis towards a target t, and rolls about the z-axis * - * by the angle specified by roll. * - * * - * This can be useful for creating a camera matrix, just invert * - * the matrix after initializing it with this function... * - * * - * INPUT: * - * p - position of the coordinate system * - * t - target of the coordinate system * - * roll - roll angle (in radians) * - * * - * OUTPUT: * - * * - * WARNINGS: * - * This function is written assuming the convention that the "ground" is the X-Y plane and * - * Z is altitude. * - * * - * HISTORY: * - *=============================================================================================*/ -void Matrix3D::Look_At(const Vector3 &p,const Vector3 &t,float roll) -{ - float dx,dy,dz; //vector from p to t - float len1,len2; - float sinp,cosp; //sine and cosine of the pitch ("up-down" tilt about x) - float siny,cosy; //sine and cosine of the yaw ("left-right"tilt about z) - - dx = (t[0] - p[0]); - dy = (t[1] - p[1]); - dz = (t[2] - p[2]); - - len1 = (float)WWMath::Sqrt(dx*dx + dy*dy + dz*dz); - len2 = (float)WWMath::Sqrt(dx*dx + dy*dy); - - if (len1 != 0.0f) { - sinp = dz/len1; - cosp = len2/len1; - } else { - sinp = 0.0f; - cosp = 1.0f; - } - - if (len2 != 0.0f) { - siny = dy/len2; - cosy = dx/len2; - } else { - siny = 0.0f; - cosy = 1.0f; - } - - // init the matrix with position p and -z pointing down +x and +y up - Row[0].X = 0.0f; Row[0].Y = 0.0f; Row[0].Z = -1.0f; - Row[1].X = -1.0f; Row[1].Y = 0.0f; Row[1].Z = 0.0f; - Row[2].X = 0.0f; Row[2].Y = 1.0f; Row[2].Z = 0.0f; - - Row[0].W = p.X; - Row[1].W = p.Y; - Row[2].W = p.Z; - - // Yaw rotation to make the matrix look at the projection of the target - // into the x-y plane - Rotate_Y(siny,cosy); - - // rotate about local x axis to pitch up to the targets position - Rotate_X(sinp,cosp); - - // roll about the local z axis (negate since we look down -z) - Rotate_Z(-roll); -} - - -/*********************************************************************************************** - * M3DC::Obj_Look_At -- Commando Object "look at" transformation. * - * * - * Builds a transformation matrix which positions the origin at p, * - * points the positive X axis towards a target t, and rolls about the X axis * - * by the angle specified by roll. * - * * - * The object convention used by Commando and G is Forward = +X, Left = +Y, Up = +Z. The * - * world is basically the x-y plane with z as altitude and +x is the default "forward". * - * * - * INPUT: * - * p - position of the coordinate system * - * t - target of the coordinate system * - * roll - roll angle (in radians) * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -void Matrix3D::Obj_Look_At(const Vector3 &p,const Vector3 &t,float roll) -{ - float dx,dy,dz; //vector from p to t - float len1,len2; - float sinp,cosp; //sine and cosine of the pitch ("up-down" tilt about y) - float siny,cosy; //sine and cosine of the yaw ("left-right"tilt about z) - - dx = (t[0] - p[0]); - dy = (t[1] - p[1]); - dz = (t[2] - p[2]); - - len1 = (float)sqrt(dx*dx + dy*dy + dz*dz); - len2 = (float)sqrt(dx*dx + dy*dy); - - if (len1 != 0.0f) { - sinp = dz/len1; - cosp = len2/len1; - } else { - sinp = 0.0f; - cosp = 1.0f; - } - - if (len2 != 0.0f) { - siny = dy/len2; - cosy = dx/len2; - } else { - siny = 0.0f; - cosy = 1.0f; - } - - Make_Identity(); - Translate(p); - - // Yaw rotation to projection of target in x-y plane - Rotate_Z(siny,cosy); - - // Pitch rotation - Rotate_Y(-sinp,cosp); - - // Roll rotation - Rotate_X(roll); -} - - -/*********************************************************************************************** - * Matrix3D::Get_Inverse -- calculate the inverse of this matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 8/7/98 GTH : Created. * - *=============================================================================================*/ -void Matrix3D::Get_Inverse(Matrix3D & inv) const -{ - // TODO: Implement the general purpose inverse function here (once we need it :-) - Get_Orthogonal_Inverse(inv); -} - -/*********************************************************************************************** - * Matrix3D::Get_Orthogonal_Inverse -- Returns the inverse of the matrix * - * * - * NOTE!!! This only works if the matrix is really ORTHOGONAL!!! * - * * - *********************************************************************************************** - * Inverting an orthogonal Matrix3D * - * * - * M is the original transform, * - * R is rotation submatrix, * - * T is translation vector in M. * - * * - * To build MINV * - * * - * R' = transpose of R (inverse of orthogonal 3x3 matrix is transpose) * - * T' = -R'T * - * * - * Build MINV with R'and T' * - * MINV is the inverse of M * - * * - *********************************************************************************************** - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -void Matrix3D::Get_Orthogonal_Inverse(Matrix3D & inv) const -{ - // Transposing the rotation submatrix - inv.Row[0][0] = Row[0][0]; - inv.Row[0][1] = Row[1][0]; - inv.Row[0][2] = Row[2][0]; - - inv.Row[1][0] = Row[0][1]; - inv.Row[1][1] = Row[1][1]; - inv.Row[1][2] = Row[2][1]; - - inv.Row[2][0] = Row[0][2]; - inv.Row[2][1] = Row[1][2]; - inv.Row[2][2] = Row[2][2]; - - // Now, calculate translation portion of matrix: - // T' = -R'T - Vector3 trans = Get_Translation(); - trans = inv.Rotate_Vector(trans); - trans = -trans; - - inv.Row[0][3] = trans[0]; - inv.Row[1][3] = trans[1]; - inv.Row[2][3] = trans[2]; -} - -/*********************************************************************************************** - * Copy_3x3_Matrix(float *matrix) -- Copies a 3x3 (float[9]) matrix into this matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/16/98 EHC : Created. * - *=============================================================================================*/ -void Matrix3D::Copy_3x3_Matrix(float matrix[3][3]) -{ - Row[0][0] = matrix[0][0]; - Row[0][1] = matrix[0][1]; - Row[0][2] = matrix[0][2]; - Row[0][3] = 0; - Row[1][0] = matrix[1][0]; - Row[1][1] = matrix[1][1]; - Row[1][2] = matrix[1][2]; - Row[1][3] = 0; - Row[2][0] = matrix[2][0]; - Row[2][1] = matrix[2][1]; - Row[2][2] = matrix[2][2]; - Row[2][3] = 0; -} - - - -/*********************************************************************************************** - * Matrix3D::Multiply -- matrix multiplication without temporaries. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/22/98 GTH : Created. * - *=============================================================================================*/ -//void print_matrix(const Matrix3D & m); -void Matrix3D::Multiply(const Matrix3D & A,const Matrix3D & B,Matrix3D * set_res) -{ - assert(set_res != NULL); - - Matrix3D tmp; - Matrix3D * Aptr; - float tmp1,tmp2,tmp3; - - // Check for aliased parameters, copy the 'A' matrix into a temporary if the - // result is going into 'A'. (in this case, this function is no better than - // the overloaded C++ operator...) - if (set_res == &A) { - tmp = A; - Aptr = &tmp; - } else { - Aptr = (Matrix3D *)&A; - } - - tmp1 = B[0][0]; - tmp2 = B[1][0]; - tmp3 = B[2][0]; - - (*set_res)[0][0] = (*Aptr)[0][0]*tmp1 + (*Aptr)[0][1]*tmp2 + (*Aptr)[0][2]*tmp3; - (*set_res)[1][0] = (*Aptr)[1][0]*tmp1 + (*Aptr)[1][1]*tmp2 + (*Aptr)[1][2]*tmp3; - (*set_res)[2][0] = (*Aptr)[2][0]*tmp1 + (*Aptr)[2][1]*tmp2 + (*Aptr)[2][2]*tmp3; - - tmp1 = B[0][1]; - tmp2 = B[1][1]; - tmp3 = B[2][1]; - - (*set_res)[0][1] = (*Aptr)[0][0]*tmp1 + (*Aptr)[0][1]*tmp2 + (*Aptr)[0][2]*tmp3; - (*set_res)[1][1] = (*Aptr)[1][0]*tmp1 + (*Aptr)[1][1]*tmp2 + (*Aptr)[1][2]*tmp3; - (*set_res)[2][1] = (*Aptr)[2][0]*tmp1 + (*Aptr)[2][1]*tmp2 + (*Aptr)[2][2]*tmp3; - - tmp1 = B[0][2]; - tmp2 = B[1][2]; - tmp3 = B[2][2]; - - (*set_res)[0][2] = (*Aptr)[0][0]*tmp1 + (*Aptr)[0][1]*tmp2 + (*Aptr)[0][2]*tmp3; - (*set_res)[1][2] = (*Aptr)[1][0]*tmp1 + (*Aptr)[1][1]*tmp2 + (*Aptr)[1][2]*tmp3; - (*set_res)[2][2] = (*Aptr)[2][0]*tmp1 + (*Aptr)[2][1]*tmp2 + (*Aptr)[2][2]*tmp3; - - tmp1 = B[0][3]; - tmp2 = B[1][3]; - tmp3 = B[2][3]; - - (*set_res)[0][3] = (*Aptr)[0][0]*tmp1 + (*Aptr)[0][1]*tmp2 + (*Aptr)[0][2]*tmp3 + (*Aptr)[0][3]; - (*set_res)[1][3] = (*Aptr)[1][0]*tmp1 + (*Aptr)[1][1]*tmp2 + (*Aptr)[1][2]*tmp3 + (*Aptr)[1][3]; - (*set_res)[2][3] = (*Aptr)[2][0]*tmp1 + (*Aptr)[2][1]*tmp2 + (*Aptr)[2][2]*tmp3 + (*Aptr)[2][3]; - -} - - -/*********************************************************************************************** - * Matrix3D::Transform_Min_Max_AABox -- compute transformed axis-aligned box * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 7/17/98 GTH : Created. * - *=============================================================================================*/ -void Matrix3D::Transform_Min_Max_AABox -( - const Vector3 & min, - const Vector3 & max, - Vector3 * set_min, - Vector3 * set_max -) const -{ - assert(set_min != &min); - assert(set_max != &max); - - float tmp0,tmp1; - - // init the min and max to the translation of the transform - set_min->X = set_max->X = Row[0][3]; - set_min->Y = set_max->Y = Row[1][3]; - set_min->Z = set_max->Z = Row[2][3]; - - // now push them both out by the projections of the original intervals - for (int i=0; i<3; i++) { - - for (int j=0; j<3; j++) { - - tmp0 = Row[i][j] * min[j]; - tmp1 = Row[i][j] * max[j]; - - if (tmp0 < tmp1) { - - (*set_min)[i] += tmp0; - (*set_max)[i] += tmp1; - - } else { - - (*set_min)[i] += tmp1; - (*set_max)[i] += tmp0; - - } - } - } -} - - -/*********************************************************************************************** - * Matrix3D::Transform_Center_Extent_AABox -- compute transformed axis-aligned box * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 7/17/98 GTH : Created. * - *=============================================================================================*/ -void Matrix3D::Transform_Center_Extent_AABox -( - const Vector3 & center, - const Vector3 & extent, - Vector3 * set_center, - Vector3 * set_extent -) const -{ - assert(set_center != ¢er); - assert(set_extent != &extent); - - // push each extent out to the projections of the original extents - for (int i=0; i<3; i++) { - - // start the center out at the translation portion of the matrix - // and the extent at zero - (*set_center)[i] = Row[i][3]; - (*set_extent)[i] = 0.0f; - - for (int j=0; j<3; j++) { - - (*set_center)[i] += Row[i][j] * center[j]; - (*set_extent)[i] += WWMath::Fabs(Row[i][j] * extent[j]); - - } - } -} - - -/*********************************************************************************************** - * Matrix3D::Is_Orthogonal -- checks whether this matrix is orthogonal * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 9/16/98 GTH : Created. * - *=============================================================================================*/ -int Matrix3D::Is_Orthogonal(void) const -{ - Vector3 x(Row[0].X,Row[0].Y,Row[0].Z); - Vector3 y(Row[1].X,Row[1].Y,Row[1].Z); - Vector3 z(Row[2].X,Row[2].Y,Row[2].Z); - - if (Vector3::Dot_Product(x,y) > WWMATH_EPSILON) return 0; - if (Vector3::Dot_Product(y,z) > WWMATH_EPSILON) return 0; - if (Vector3::Dot_Product(z,x) > WWMATH_EPSILON) return 0; - - if (WWMath::Fabs(x.Length() - 1.0f) > WWMATH_EPSILON) return 0; - if (WWMath::Fabs(y.Length() - 1.0f) > WWMATH_EPSILON) return 0; - if (WWMath::Fabs(z.Length() - 1.0f) > WWMATH_EPSILON) return 0; - - return 1; -} - -/*********************************************************************************************** - * Matrix3D::Re_Orthogonalize -- makes this matrix orthogonal. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * This function is rather expensive, should only be used if you *know* numerical error is * - * killing you. * - * * - * HISTORY: * - * 9/16/98 GTH : Created. * - *=============================================================================================*/ -void Matrix3D::Re_Orthogonalize(void) -{ - Vector3 x(Row[0][0],Row[0][1],Row[0][2]); - Vector3 y(Row[1][0],Row[1][1],Row[1][2]); - Vector3 z; - - Vector3::Cross_Product(x,y,&z); - Vector3::Cross_Product(z,x,&y); - - float len = x.Length(); - if (len < WWMATH_EPSILON) { - Make_Identity(); - return; - } else { - x *= 1.0f/len; - } - - len = y.Length(); - if (len < WWMATH_EPSILON) { - Make_Identity(); - return; - } else { - y *= 1.0f/len; - } - - len = z.Length(); - if (len < WWMATH_EPSILON) { - Make_Identity(); - return; - } else { - z *= 1.0f/len; - } - - Row[0][0] = x.X; - Row[0][1] = x.Y; - Row[0][2] = x.Z; - - Row[1][0] = y.X; - Row[1][1] = y.Y; - Row[1][2] = y.Z; - - Row[2][0] = z.X; - Row[2][1] = z.Y; - Row[2][2] = z.Z; -} - - -/*********************************************************************************************** - * Lerp - linearly interpolate matrices (orientation is slerped) * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/05/1998 NH : Created. * - *=============================================================================================*/ -Matrix3D Lerp(const Matrix3D &A, const Matrix3D &B, float factor) -{ - assert(factor >= 0.0f); - assert(factor <= 1.0f); - - // Lerp position - Vector3 pos = Lerp(A.Get_Translation(), B.Get_Translation(), factor); - Quaternion rot = Slerp(Build_Quaternion(A), Build_Quaternion(B), factor); - return Matrix3D(rot, pos); -} - diff --git a/Generals/Code/Tools/WW3D/pluglib/matrix3d.h b/Generals/Code/Tools/WW3D/pluglib/matrix3d.h deleted file mode 100644 index 8b91fa13ea8..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/matrix3d.h +++ /dev/null @@ -1,1516 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /G/WWMath/matrix3d.h 49 1/13/00 2:57p Naty_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Voxel Technology * - * * - * File Name : MATRIX3D.H * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 02/24/97 * - * * - * Last Update : February 24, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Matrix3D::Matrix3D -- Constructors for Matrix3D * - * Matrix3D::Set -- init a Matrix3D from an arrray of 12 floats * - * Matrix3D::Set -- Init a Matrix3D from 12 individual floats * - * Matrix3D::Set -- Init a matrix from 3 axis vectors and a position * - * Matrix3D::Set -- init a matrix to be a rotation about the given axis * - * Matrix3D::Set -- init a matrix to be a rotation about the given axis * - * Matrix3D::Set -- Init a matrix to be a pure translation * - * Matrix3D::Make_Identity -- Initializes the matrix to be the identity matrix * - * Matrix3D::Translate -- Post-Multiplies by a Translation Matrix * - * Matrix3D::Translate -- Post-Multiplies the matrix by a translation matrix * - * M3DC::Translate_X -- Post-Multiplies the matrix by a translation matrix with X only * - * M3DC::Translate_Y -- Post-Multiplies the matrix by a translation matrix with Y only * - * M3DC::Translate_Z -- Post-Multiplies the matrix by a translation matrix with Z only * - * Matrix3D::Rotate_X -- Post-Multiplies the matrix by a rotation about the X axis * - * Matrix3D::Rotate_X -- Post-Multiplies the matrix by a rotation about the X axis * - * Matrix3D::Rotate_Y -- Post-multiplies the matrix by a rotation about the Y axis * - * Matrix3D::Rotate_Y -- Post-Multiplies the matrix by a rotation about Y * - * Matrix3D::Rotate_Z -- Post-multiplies the matrix by a rotation about Z * - * Matrix3D::Rotate_Z -- Post-multiplies the matrix by a rotation about Z * - * M3DC::Pre_Rotate_X -- Pre-multiplies the matrix by a rotation about X * - * M3DC::Pre_Rotate_Y -- Pre-multiplies the matrix by a rotation about Y * - * M3DC::Pre_Rotate_Z -- Pre-multiplies the matrix by a rotation about Z * - * M3DC::Pre_Rotate_X -- Pre-multiplies the matrix by a rotation about X * - * M3DC::Pre_Rotate_Y -- Pre-multiplies the matrix by a rotation about Y * - * M3DC::Pre_Rotate_Z -- Pre-multiplies the matrix by a rotation about Z * - * M3DC::In_Place_Pre_Rotate_X -- Pre-multiplies rotation part of matrix by rotation about X * - * M3DC::In_Place_Pre_Rotate_Y -- Pre-multiplies rotation part of matrix by rotation about Y * - * M3DC::In_Place_Pre_Rotate_Z -- Pre-multiplies rotation part of matrix by rotation about Z * - * M3DC::In_Place_Pre_Rotate_X -- Pre-multiplies rotation part of matrix by rotation about X * - * M3DC::In_Place_Pre_Rotate_Y -- Pre-multiplies rotation part of matrix by rotation about Y * - * M3DC::In_Place_Pre_Rotate_Z -- Pre-multiplies rotation part of matrix by rotation about Z * - * operator * -- Matrix multiplication * - * operator * -- Matrix - vector multiplication * - * operator == -- Matrix equality operator * - * operator != -- Matrix inequality operator * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef MATRIX3D_H -#define MATRIX3D_H - -#ifdef _UNIX -#include "osdep.h" -#endif - -#include "always.h" -#include -#include "vector2.h" -#include "vector3.h" -#include "vector4.h" - -class Matrix3; -class Matrix4; -class Quaternion; - -/******************************************************************************* - - Matrix3D - - Three important notes: - - I use *column-vectors* - - I use a *right-handed* coordinate system - - These matrices are *orthogonal* - - 3D Transformation matrices. This class is really a 4x4 homogeneous - matrix where the last row is assumed to always be 0 0 0 1. However, - since I don't store the last row, you cant do some things that you can - do with a real 4x4 homogeneous matrix. - - I use column-vectors so normally transformations are post-multiplied - and camera transformations should be pre-multiplied. The methods of - this class called Translate, Rotate_X, etc. all perform post-multiplication - with the current matix. These methods (Translate, Rotate_X, etc) also - have been hand-coded to only perform the necessary arithmetic. The - * operator can be used for general purpose matrix multiplication or to - transform a vector by a matrix. - - Some operations in this class assume that the matrix is orthogonal. - -*********************************************************************************/ - -class Matrix3D -{ -public: - - // Constructors - Matrix3D(void) {} - - explicit Matrix3D(bool init) { if (init) Make_Identity(); } - - explicit Matrix3D(float m[12]); - - explicit Matrix3D( - float m11,float m12,float m13,float m14, - float m21,float m22,float m23,float m24, - float m31,float m32,float m33,float m34 - ); - - explicit Matrix3D( - const Vector3 &x, // x-axis unit vector - const Vector3 &y, // y-axis unit vector - const Vector3 &z, // z-axis unit vector - const Vector3 &pos // position - ); - - explicit Matrix3D( - const Vector3 &axis, - float angle - ); - - explicit Matrix3D( - const Vector3 &axis, - float sine, - float cosine - ); - - explicit Matrix3D( - const Matrix3 & rotation, - const Vector3 & position - ); - - explicit Matrix3D( - const Quaternion & rotation, - const Vector3 & position - ); - - // Creates identity rotation w. given position. - explicit Matrix3D(const Vector3 & position); - - // Copy constructor - Matrix3D(const Matrix3D & m); - - // Assignment operator - Matrix3D & operator = (const Matrix3D & m); - - // Init functions - void Set(float m[12]); - - void Set( - float m11,float m12,float m13,float m14, - float m21,float m22,float m23,float m24, - float m31,float m32,float m33,float m34 - ); - - void Set( - const Vector3 &x, // x-axis unit vector - const Vector3 &y, // y-axis unit vector - const Vector3 &z, // z-axis unit vector - const Vector3 &pos // position - ); - - void Set(const Vector3 & axis,float angle); - - void Set(const Vector3 & axis,float sine,float cosine); - - void Set(const Matrix3 & rotation,const Vector3 & position); - - void Set(const Quaternion & rotation,const Vector3 & position); - - // Creates identity rotation w. given position. - void Set(const Vector3 & position); - - // access functions: - Vector4 & operator [] (int i) { return Row[i]; } - const Vector4 & operator [] (int i) const { return Row[i]; } - - Vector3 Get_Translation(void) const { return Vector3(Row[0][3],Row[1][3],Row[2][3]); } - void Get_Translation(Vector3 * set) const { set->X = Row[0][3]; set->Y = Row[1][3]; set->Z = Row[2][3]; } - void Set_Translation(const Vector3 & t) { Row[0][3] = t[0]; Row[1][3] = t[1];Row[2][3] = t[2]; } - - void Set_Rotation(const Matrix3 & m); - void Set_Rotation(const Quaternion & q); - - float Get_X_Translation(void) const { return Row[0][3]; }; - float Get_Y_Translation(void) const { return Row[1][3]; }; - float Get_Z_Translation(void) const { return Row[2][3]; }; - - void Set_X_Translation(float x) { Row[0][3] = x; }; - void Set_Y_Translation(float y) { Row[1][3] = y; }; - void Set_Z_Translation(float z) { Row[2][3] = z; }; - - void Adjust_Translation(const Vector3 & t) { Row[0][3] += t[0]; Row[1][3] += t[1]; Row[2][3] += t[2]; }; - void Adjust_X_Translation(float x) { Row[0][3] += x; }; - void Adjust_Y_Translation(float y) { Row[1][3] += y; }; - void Adjust_Z_Translation(float z) { Row[2][3] += z; }; - - // These functions will give you the approximate amount that the - // matrix has been rotated about a given axis. These functions - // cannot be used to re-build a matrx. Use the EulerAnglesClass - // to convert a matrix into a set of three Euler angles. - float Get_X_Rotation(void) const; - float Get_Y_Rotation(void) const; - float Get_Z_Rotation(void) const; - - // Each of the transformation methods performs an - // "optimized" post-multiplication with the current matrix. - // All angles are assumed to be radians. - void Make_Identity(void); - void Translate(float x,float y,float z); - void Translate(const Vector3 &t); - void Translate_X(float x); - void Translate_Y(float y); - void Translate_Z(float z); - void Rotate_X(float theta); - void Rotate_Y(float theta); - void Rotate_Z(float theta); - void Rotate_X(float s,float c); - void Rotate_Y(float s,float c); - void Rotate_Z(float s,float c); - - // Each of these performs an "optimized" pre-multiplication with the - // current matrix. All angles are assumed to be radians. The "In_Place" - // versions do not affect the translation part of the matrix, - void Pre_Rotate_X(float theta); - void Pre_Rotate_Y(float theta); - void Pre_Rotate_Z(float theta); - void Pre_Rotate_X(float s,float c); - void Pre_Rotate_Y(float s,float c); - void Pre_Rotate_Z(float s,float c); - void In_Place_Pre_Rotate_X(float theta); - void In_Place_Pre_Rotate_Y(float theta); - void In_Place_Pre_Rotate_Z(float theta); - void In_Place_Pre_Rotate_X(float s,float c); - void In_Place_Pre_Rotate_Y(float s,float c); - void In_Place_Pre_Rotate_Z(float s,float c); - - // Points the negative Z axis at the target t. Assumes that - // the "world" uses x-y as the ground and z as altitude. - // Used for pointing cameras at targets. - void Look_At(const Vector3 &p,const Vector3 &t,float roll); - - // Previous look_at function follows the camera coordinate convention. - // This one follows the object convention used in Commando and G. I - // special cased this convention since it is used so much by us rather - // than supporting every one of the 24(?) possible conventions... - void Obj_Look_At(const Vector3 &p,const Vector3 &t,float roll); - - // use the 3x3 sub-matrix only (ignore translation) - Vector3 Rotate_Vector(const Vector3 &vect) const; - Vector3 Inverse_Rotate_Vector(const Vector3 &vect) const; - - // these get the a vector representing the direction an axis is pointing - Vector3 Get_X_Vector() const { return Vector3(Row[0][0], Row[1][0], Row[2][0]); } - Vector3 Get_Y_Vector() const { return Vector3(Row[0][1], Row[1][1], Row[2][1]); } - Vector3 Get_Z_Vector() const { return Vector3(Row[0][2], Row[1][2], Row[2][2]); } - void Get_X_Vector(Vector3 * set_x) const { set_x->Set(Row[0][0], Row[1][0], Row[2][0]); } - void Get_Y_Vector(Vector3 * set_y) const { set_y->Set(Row[0][1], Row[1][1], Row[2][1]); } - void Get_Z_Vector(Vector3 * set_z) const { set_z->Set(Row[0][2], Row[1][2], Row[2][2]); } - - // Get the inverse of the matrix. - // TODO: currently the "intended-to-be" general inverse function just calls - // the special case Orthogonal inverse functions. Also, when we implement - // general case, check where we were using Get_Inverse since usually it should - // be changed to Get_Orthogonal_Inverse... - void Get_Inverse(Matrix3D & set_inverse) const; - void Get_Orthogonal_Inverse(Matrix3D & set_inverse) const; - - // used for importing SurRender matrices - void Copy_3x3_Matrix(float matrix[3][3]); - - // Optimized Axis-Aligned Box transforms. One for each of the common forms of - // axis aligned box: min,max vectors and center,extent vectors. - void Transform_Min_Max_AABox(const Vector3 & min,const Vector3 & max,Vector3 * set_min,Vector3 * set_max) const; - void Transform_Center_Extent_AABox(const Vector3 & center,const Vector3 & extent,Vector3 * set_center,Vector3 * set_extent) const; - - // matrix multiplication without temporaries - static void Multiply(const Matrix3D &A,const Matrix3D &B,Matrix3D * set_result); - static void Transform_Vector(const Matrix3D & tm,const Vector3 & in,Vector3 * out); - static void Rotate_Vector(const Matrix3D & tm,const Vector3 & in,Vector3 * out); - - // transform a vector by the inverse of this matrix (note: assumes the matrix - // is orthogonal; if you've manually scaled or sheared the matrix this function - // will not give correct results) - static void Inverse_Transform_Vector(const Matrix3D & tm,const Vector3 & in,Vector3 * out); - static void Inverse_Rotate_Vector(const Matrix3D & tm,const Vector3 & in,Vector3 * out); - - // Check whether a matrix is orthogonal or FORCE it to be :-) - int Is_Orthogonal(void) const; - void Re_Orthogonalize(void); - - // some static matrices which are sometimes useful - static const Matrix3D Identity; - static const Matrix3D RotateX90; - static const Matrix3D RotateX180; - static const Matrix3D RotateX270; - static const Matrix3D RotateY90; - static const Matrix3D RotateY180; - static const Matrix3D RotateY270; - static const Matrix3D RotateZ90; - static const Matrix3D RotateZ180; - static const Matrix3D RotateZ270; - -protected: - - Vector4 Row[3]; - - friend Vector3 operator * (const Matrix3D &A,const Vector3 &a); -}; - - - -/* --------------------------------------------------------------- - Vector Transformation, Matrix concatenation ---------------------------------------------------------------- */ -Vector3 operator * (const Matrix3D &A,const Vector3 &v); -Matrix3D operator * (const Matrix3D &A,const Matrix3D &B); - -/* --------------------------------------------------------------- - Equality and inequality operators ---------------------------------------------------------------- */ -bool operator == (const Matrix3D &A, const Matrix3D &B); -bool operator != (const Matrix3D &A, const Matrix3D &B); - -/* --------------------------------------------------------------- - Matrix interpolation ---------------------------------------------------------------- */ -Matrix3D Lerp(const Matrix3D &A, const Matrix3D &B, float factor); - - -/*********************************************************************************************** - * M3DC::Matrix3D -- Constructors for Matrix3D * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix3D::Matrix3D(float m[12]) -{ - Row[0].Set(m[0],m[1],m[2],m[3]); - Row[1].Set(m[4],m[5],m[6],m[7]); - Row[2].Set(m[8],m[9],m[10],m[11]); -} - -inline Matrix3D::Matrix3D -( - float m11,float m12,float m13,float m14, - float m21,float m22,float m23,float m24, - float m31,float m32,float m33,float m34 -) -{ - Row[0].Set(m11,m12,m13,m14); - Row[1].Set(m21,m22,m23,m24); - Row[2].Set(m31,m32,m33,m34); -} - -inline Matrix3D::Matrix3D -( - const Vector3 &x, // x-axis unit vector - const Vector3 &y, // y-axis unit vector - const Vector3 &z, // z-axis unit vector - const Vector3 &pos // position -) -{ - Set(x,y,z,pos); -} - -inline Matrix3D::Matrix3D(const Vector3 & axis,float angle) -{ - Set(axis,angle); -} - -inline Matrix3D::Matrix3D(const Vector3 & axis,float sine,float cosine) -{ - Set(axis,sine,cosine); -} - -inline Matrix3D::Matrix3D(const Matrix3 & rot,const Vector3 & pos) -{ - Set(rot,pos); -} - -inline Matrix3D::Matrix3D(const Quaternion & rot,const Vector3 & pos) -{ - Set(rot,pos); -} - -inline Matrix3D::Matrix3D(const Vector3 & position) -{ - Set(position); -} - -// Copy Constructor -inline Matrix3D::Matrix3D(const Matrix3D & m) -{ - Row[0] = m.Row[0]; - Row[1] = m.Row[1]; - Row[2] = m.Row[2]; -} - -// Assignment operator -inline Matrix3D & Matrix3D::operator = (const Matrix3D & m) -{ - Row[0] = m.Row[0]; - Row[1] = m.Row[1]; - Row[2] = m.Row[2]; - return *this; -} - - -/*********************************************************************************************** - * Matrix3D::Set -- init a Matrix3D from an arrray of 12 floats * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/24/98 GTH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Set(float m[12]) -{ - Row[0].Set(m[0],m[1],m[2],m[3]); - Row[1].Set(m[4],m[5],m[6],m[7]); - Row[2].Set(m[8],m[9],m[10],m[11]); -} - - -/*********************************************************************************************** - * Matrix3D::Set -- Init a Matrix3D from 12 individual floats * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/24/98 GTH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Set( float m11,float m12,float m13,float m14, - float m21,float m22,float m23,float m24, - float m31,float m32,float m33,float m34) -{ - Row[0].Set(m11,m12,m13,m14); - Row[1].Set(m21,m22,m23,m24); - Row[2].Set(m31,m32,m33,m34); -} - - -/*********************************************************************************************** - * Matrix3D::Set -- Init a matrix from 3 axis vectors and a position * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/24/98 GTH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Set( const Vector3 &x, // x-axis unit vector - const Vector3 &y, // y-axis unit vector - const Vector3 &z, // z-axis unit vector - const Vector3 &pos) // position -{ - Row[0].Set(x[0],y[0],z[0],pos[0]); - Row[1].Set(x[1],y[1],z[1],pos[1]); - Row[2].Set(x[2],y[2],z[2],pos[2]); -} - - -/*********************************************************************************************** - * Matrix3D::Set -- init a matrix to be a rotation about the given axis * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/24/98 GTH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Set(const Vector3 & axis,float angle) -{ - float c = cosf(angle); - float s = sinf(angle); - - Set(axis,s,c); -} - -/*********************************************************************************************** - * Matrix3D::Set -- init a matrix to be a rotation about the given axis * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/24/98 GTH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Set(const Vector3 & axis,float s,float c) -{ - assert(WWMath::Fabs(axis.Length2() - 1.0f) < 0.001f); - - Row[0].Set( - (float)(axis[0]*axis[0] + c*(1.0f - axis[0]*axis[0])), - (float)(axis[0]*axis[1]*(1.0f - c) - axis[2]*s), - (float)(axis[2]*axis[0]*(1.0f - c) + axis[1]*s), - 0.0f - ); - - Row[1].Set( - (float)(axis[0]*axis[1]*(1.0f - c) + axis[2]*s), - (float)(axis[1]*axis[1] + c*(1.0f - axis[1]*axis[1])), - (float)(axis[1]*axis[2]*(1.0f - c) - axis[0]*s), - 0.0f - ); - - Row[2].Set( - (float)(axis[2]*axis[0]*(1.0f - c) - axis[1]*s), - (float)(axis[1]*axis[2]*(1.0f - c) + axis[0]*s), - (float)(axis[2]*axis[2] + c*(1 - axis[2]*axis[2])), - 0.0f - ); -} - - -/*********************************************************************************************** - * Matrix3D::Set -- Init a matrix to be a pure translation * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/24/98 GTH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Set(const Vector3 & position) -{ - Row[0].Set(1.0f,0.0f,0.0f,position[0]); - Row[1].Set(0.0f,1.0f,0.0f,position[1]); - Row[2].Set(0.0f,0.0f,1.0f,position[2]); -} - - -/*********************************************************************************************** - * M3DC::Make_Identity -- Initializes the matrix to be the identity matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Make_Identity(void) -{ - Row[0].Set(1.0f,0.0f,0.0f,0.0f); - Row[1].Set(0.0f,1.0f,0.0f,0.0f); - Row[2].Set(0.0f,0.0f,1.0f,0.0f); -} - - -/*********************************************************************************************** - * M3DC::Translate -- Post-Multiplies by a Translation Matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Translate(float x,float y,float z) -{ - Row[0][3] += (float)(Row[0][0]*x + Row[0][1]*y + Row[0][2]*z); - Row[1][3] += (float)(Row[1][0]*x + Row[1][1]*y + Row[1][2]*z); - Row[2][3] += (float)(Row[2][0]*x + Row[2][1]*y + Row[2][2]*z); -} - - -/*********************************************************************************************** - * M3DC::Translate -- Post-Multiplies the matrix by a translation matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Translate(const Vector3 &t) -{ - Row[0][3] += Row[0][0]*t[0] + Row[0][1]*t[1] + Row[0][2]*t[2]; - Row[1][3] += Row[1][0]*t[0] + Row[1][1]*t[1] + Row[1][2]*t[2]; - Row[2][3] += Row[2][0]*t[0] + Row[2][1]*t[1] + Row[2][2]*t[2]; -} - - -/*********************************************************************************************** - * M3DC::Translate_X -- Post-Multiplies the matrix by a translation matrix with X only * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/06/1998 NH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Translate_X(float x) -{ - Row[0][3] += (float)(Row[0][0]*x); - Row[1][3] += (float)(Row[1][0]*x); - Row[2][3] += (float)(Row[2][0]*x); -} - - -/*********************************************************************************************** - * M3DC::Translate_Y -- Post-Multiplies the matrix by a translation matrix with Y only * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/06/1998 NH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Translate_Y(float y) -{ - Row[0][3] += (float)(Row[0][1]*y); - Row[1][3] += (float)(Row[1][1]*y); - Row[2][3] += (float)(Row[2][1]*y); -} - - -/*********************************************************************************************** - * M3DC::Translate_Z -- Post-Multiplies the matrix by a translation matrix with Z only * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/06/1998 NH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Translate_Z(float z) -{ - Row[0][3] += (float)(Row[0][2]*z); - Row[1][3] += (float)(Row[1][2]*z); - Row[2][3] += (float)(Row[2][2]*z); -} - - -/*********************************************************************************************** - * M3DC::Rotate_X -- Post-Multiplies the matrix by a rotation about the X axis * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Rotate_X(float theta) -{ - float tmp1,tmp2; - float s,c; - - s = sinf(theta); - c = cosf(theta); - - tmp1 = Row[0][1]; tmp2 = Row[0][2]; - Row[0][1] = (float)( c*tmp1 + s*tmp2); - Row[0][2] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[1][1]; tmp2 = Row[1][2]; - Row[1][1] = (float)( c*tmp1 + s*tmp2); - Row[1][2] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[2][1]; tmp2 = Row[2][2]; - Row[2][1] = (float)( c*tmp1 + s*tmp2); - Row[2][2] = (float)(-s*tmp1 + c*tmp2); - -} - - -/*********************************************************************************************** - * M3DC::Rotate_X -- Post-Multiplies the matrix by a rotation about the X axis * - * * - * INPUT: * - * s - sine of the angle * - * c - cosine of the angle * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Rotate_X(float s,float c) -{ - float tmp1,tmp2; - - tmp1 = Row[0][1]; tmp2 = Row[0][2]; - Row[0][1] = (float)( c*tmp1 + s*tmp2); - Row[0][2] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[1][1]; tmp2 = Row[1][2]; - Row[1][1] = (float)( c*tmp1 + s*tmp2); - Row[1][2] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[2][1]; tmp2 = Row[2][2]; - Row[2][1] = (float)( c*tmp1 + s*tmp2); - Row[2][2] = (float)(-s*tmp1 + c*tmp2); -} - - -/*********************************************************************************************** - * M3DC::Rotate_Y -- Post-multiplies the matrix by a rotation about the Y axis * - * * - * INPUT: * - * theta - angle (in radians) to rotate * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Rotate_Y(float theta) -{ - float tmp1,tmp2; - float s,c; - - s = sinf(theta); - c = cosf(theta); - - tmp1 = Row[0][0]; tmp2 = Row[0][2]; - Row[0][0] = (float)(c*tmp1 - s*tmp2); - Row[0][2] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[1][0]; tmp2 = Row[1][2]; - Row[1][0] = (float)(c*tmp1 - s*tmp2); - Row[1][2] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[2][0]; tmp2 = Row[2][2]; - Row[2][0] = (float)(c*tmp1 - s*tmp2); - Row[2][2] = (float)(s*tmp1 + c*tmp2); -} - - -/*********************************************************************************************** - * M3DC::Rotate_Y -- Post-Multiplies the matrix by a rotation about Y * - * * - * INPUT: * - * s - sine of the angle * - * c - cosine of the angle * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Rotate_Y(float s,float c) -{ - float tmp1,tmp2; - - tmp1 = Row[0][0]; tmp2 = Row[0][2]; - Row[0][0] = (float)(c*tmp1 - s*tmp2); - Row[0][2] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[1][0]; tmp2 = Row[1][2]; - Row[1][0] = (float)(c*tmp1 - s*tmp2); - Row[1][2] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[2][0]; tmp2 = Row[2][2]; - Row[2][0] = (float)(c*tmp1 - s*tmp2); - Row[2][2] = (float)(s*tmp1 + c*tmp2); -} - - -/*********************************************************************************************** - * M3DC::Rotate_Z -- Post-multiplies the matrix by a rotation about Z * - * * - * INPUT: * - * theta - angle (in radians) to rotate * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Rotate_Z(float theta) -{ - float tmp1,tmp2; - float c,s; - - c = cosf(theta); - s = sinf(theta); - - tmp1 = Row[0][0]; tmp2 = Row[0][1]; - Row[0][0] = (float)( c*tmp1 + s*tmp2); - Row[0][1] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[1][0]; tmp2 = Row[1][1]; - Row[1][0] = (float)( c*tmp1 + s*tmp2); - Row[1][1] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[2][0]; tmp2 = Row[2][1]; - Row[2][0] = (float)( c*tmp1 + s*tmp2); - Row[2][1] = (float)(-s*tmp1 + c*tmp2); -} - - -/*********************************************************************************************** - * M3DC::Rotate_Z -- Post-multiplies the matrix by a rotation about Z * - * * - * INPUT: * - * s - sine of the angle to rotate * - * c - cosine of the angle to rotate * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Rotate_Z(float s,float c) -{ - float tmp1,tmp2; - - tmp1 = Row[0][0]; tmp2 = Row[0][1]; - Row[0][0] = (float)( c*tmp1 + s*tmp2); - Row[0][1] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[1][0]; tmp2 = Row[1][1]; - Row[1][0] = (float)( c*tmp1 + s*tmp2); - Row[1][1] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[2][0]; tmp2 = Row[2][1]; - Row[2][0] = (float)( c*tmp1 + s*tmp2); - Row[2][1] = (float)(-s*tmp1 + c*tmp2); -} - -/*********************************************************************************************** - * M3DC::Pre_Rotate_X -- Pre-multiplies the matrix by a rotation about X * - * * - * INPUT: * - * theta - angle (in radians) to rotate * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/1/1999 NH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Pre_Rotate_X(float theta) -{ - float tmp1,tmp2; - float c,s; - - c = cosf(theta); - s = sinf(theta); - - tmp1 = Row[1][0]; tmp2 = Row[2][0]; - Row[1][0] = (float)(c*tmp1 - s*tmp2); - Row[2][0] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[1][1]; tmp2 = Row[2][1]; - Row[1][1] = (float)(c*tmp1 - s*tmp2); - Row[2][1] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[1][2]; tmp2 = Row[2][2]; - Row[1][2] = (float)(c*tmp1 - s*tmp2); - Row[2][2] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[1][3]; tmp2 = Row[2][3]; - Row[1][3] = (float)(c*tmp1 - s*tmp2); - Row[2][3] = (float)(s*tmp1 + c*tmp2); -} - -/*********************************************************************************************** - * M3DC::Pre_Rotate_Y -- Pre-multiplies the matrix by a rotation about Y * - * * - * INPUT: * - * theta - angle (in radians) to rotate * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/1/1999 NH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Pre_Rotate_Y(float theta) -{ - float tmp1,tmp2; - float c,s; - - c = cosf(theta); - s = sinf(theta); - - tmp1 = Row[0][0]; tmp2 = Row[2][0]; - Row[0][0] = (float)( c*tmp1 + s*tmp2); - Row[2][0] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[0][1]; tmp2 = Row[2][1]; - Row[0][1] = (float)( c*tmp1 + s*tmp2); - Row[2][1] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[0][2]; tmp2 = Row[2][2]; - Row[0][2] = (float)( c*tmp1 + s*tmp2); - Row[2][2] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[0][3]; tmp2 = Row[2][3]; - Row[0][3] = (float)( c*tmp1 + s*tmp2); - Row[2][3] = (float)(-s*tmp1 + c*tmp2); -} - -/*********************************************************************************************** - * M3DC::Pre_Rotate_Z -- Pre-multiplies the matrix by a rotation about Z * - * * - * INPUT: * - * theta - angle (in radians) to rotate * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/1/1999 NH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Pre_Rotate_Z(float theta) -{ - float tmp1,tmp2; - float c,s; - - c = cosf(theta); - s = sinf(theta); - - tmp1 = Row[0][0]; tmp2 = Row[1][0]; - Row[0][0] = (float)(c*tmp1 - s*tmp2); - Row[1][0] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[0][1]; tmp2 = Row[1][1]; - Row[0][1] = (float)(c*tmp1 - s*tmp2); - Row[1][1] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[0][2]; tmp2 = Row[1][2]; - Row[0][2] = (float)(c*tmp1 - s*tmp2); - Row[1][2] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[0][3]; tmp2 = Row[1][3]; - Row[0][3] = (float)(c*tmp1 - s*tmp2); - Row[1][3] = (float)(s*tmp1 + c*tmp2); -} - -/*********************************************************************************************** - * M3DC::Pre_Rotate_X -- Pre-multiplies the matrix by a rotation about X * - * * - * INPUT: * - * s - sine of the angle to rotate * - * c - cosine of the angle to rotate * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/1/1999 NH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Pre_Rotate_X(float s,float c) -{ - float tmp1,tmp2; - - tmp1 = Row[1][0]; tmp2 = Row[2][0]; - Row[1][0] = (float)(c*tmp1 - s*tmp2); - Row[2][0] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[1][1]; tmp2 = Row[2][1]; - Row[1][1] = (float)(c*tmp1 - s*tmp2); - Row[2][1] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[1][2]; tmp2 = Row[2][2]; - Row[1][2] = (float)(c*tmp1 - s*tmp2); - Row[2][2] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[1][3]; tmp2 = Row[2][3]; - Row[1][3] = (float)(c*tmp1 - s*tmp2); - Row[2][3] = (float)(s*tmp1 + c*tmp2); -} - -/*********************************************************************************************** - * M3DC::Pre_Rotate_Y -- Pre-multiplies the matrix by a rotation about Y * - * * - * INPUT: * - * s - sine of the angle to rotate * - * c - cosine of the angle to rotate * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/1/1999 NH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Pre_Rotate_Y(float s,float c) -{ - float tmp1,tmp2; - - tmp1 = Row[0][0]; tmp2 = Row[2][0]; - Row[0][0] = (float)( c*tmp1 + s*tmp2); - Row[2][0] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[0][1]; tmp2 = Row[2][1]; - Row[0][1] = (float)( c*tmp1 + s*tmp2); - Row[2][1] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[0][2]; tmp2 = Row[2][2]; - Row[0][2] = (float)( c*tmp1 + s*tmp2); - Row[2][2] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[0][3]; tmp2 = Row[2][3]; - Row[0][3] = (float)( c*tmp1 + s*tmp2); - Row[2][3] = (float)(-s*tmp1 + c*tmp2); -} - -/*********************************************************************************************** - * M3DC::Pre_Rotate_Z -- Pre-multiplies the matrix by a rotation about Z * - * * - * INPUT: * - * s - sine of the angle to rotate * - * c - cosine of the angle to rotate * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/1/1999 NH : Created. * - *=============================================================================================*/ -inline void Matrix3D::Pre_Rotate_Z(float s,float c) -{ - float tmp1,tmp2; - - tmp1 = Row[0][0]; tmp2 = Row[1][0]; - Row[0][0] = (float)(c*tmp1 - s*tmp2); - Row[1][0] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[0][1]; tmp2 = Row[1][1]; - Row[0][1] = (float)(c*tmp1 - s*tmp2); - Row[1][1] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[0][2]; tmp2 = Row[1][2]; - Row[0][2] = (float)(c*tmp1 - s*tmp2); - Row[1][2] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[0][3]; tmp2 = Row[1][3]; - Row[0][3] = (float)(c*tmp1 - s*tmp2); - Row[1][3] = (float)(s*tmp1 + c*tmp2); -} - -/*********************************************************************************************** - * M3DC::In_Place_Pre_Rotate_X -- Pre-multiplies rotation part of matrix by a rotation about X * - * * - * INPUT: * - * theta - angle (in radians) to rotate * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/1/1999 NH : Created. * - *=============================================================================================*/ -inline void Matrix3D::In_Place_Pre_Rotate_X(float theta) -{ - float tmp1,tmp2; - float c,s; - - c = cosf(theta); - s = sinf(theta); - - tmp1 = Row[1][0]; tmp2 = Row[2][0]; - Row[1][0] = (float)(c*tmp1 - s*tmp2); - Row[2][0] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[1][1]; tmp2 = Row[2][1]; - Row[1][1] = (float)(c*tmp1 - s*tmp2); - Row[2][1] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[1][2]; tmp2 = Row[2][2]; - Row[1][2] = (float)(c*tmp1 - s*tmp2); - Row[2][2] = (float)(s*tmp1 + c*tmp2); -} - -/*********************************************************************************************** - * M3DC::In_Place_Pre_Rotate_Y -- Pre-multiplies rotation part of matrix by a rotation about Y * - * * - * INPUT: * - * theta - angle (in radians) to rotate * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/1/1999 NH : Created. * - *=============================================================================================*/ -inline void Matrix3D::In_Place_Pre_Rotate_Y(float theta) -{ - float tmp1,tmp2; - float c,s; - - c = cosf(theta); - s = sinf(theta); - - tmp1 = Row[0][0]; tmp2 = Row[2][0]; - Row[0][0] = (float)( c*tmp1 + s*tmp2); - Row[2][0] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[0][1]; tmp2 = Row[2][1]; - Row[0][1] = (float)( c*tmp1 + s*tmp2); - Row[2][1] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[0][2]; tmp2 = Row[2][2]; - Row[0][2] = (float)( c*tmp1 + s*tmp2); - Row[2][2] = (float)(-s*tmp1 + c*tmp2); -} - -/*********************************************************************************************** - * M3DC::In_Place_Pre_Rotate_Z -- Pre-multiplies rotation part of matrix by a rotation about Z * - * * - * INPUT: * - * theta - angle (in radians) to rotate * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/1/1999 NH : Created. * - *=============================================================================================*/ -inline void Matrix3D::In_Place_Pre_Rotate_Z(float theta) -{ - float tmp1,tmp2; - float c,s; - - c = cosf(theta); - s = sinf(theta); - - tmp1 = Row[0][0]; tmp2 = Row[1][0]; - Row[0][0] = (float)(c*tmp1 - s*tmp2); - Row[1][0] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[0][1]; tmp2 = Row[1][1]; - Row[0][1] = (float)(c*tmp1 - s*tmp2); - Row[1][1] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[0][2]; tmp2 = Row[1][2]; - Row[0][2] = (float)(c*tmp1 - s*tmp2); - Row[1][2] = (float)(s*tmp1 + c*tmp2); -} - -/*********************************************************************************************** - * M3DC::In_Place_Pre_Rotate_X -- Pre-multiplies rotation part of matrix by a rotation about X * - * * - * INPUT: * - * s - sine of the angle to rotate * - * c - cosine of the angle to rotate * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/1/1999 NH : Created. * - *=============================================================================================*/ -inline void Matrix3D::In_Place_Pre_Rotate_X(float s,float c) -{ - float tmp1,tmp2; - - tmp1 = Row[1][0]; tmp2 = Row[2][0]; - Row[1][0] = (float)(c*tmp1 - s*tmp2); - Row[2][0] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[1][1]; tmp2 = Row[2][1]; - Row[1][1] = (float)(c*tmp1 - s*tmp2); - Row[2][1] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[1][2]; tmp2 = Row[2][2]; - Row[1][2] = (float)(c*tmp1 - s*tmp2); - Row[2][2] = (float)(s*tmp1 + c*tmp2); -} - -/*********************************************************************************************** - * M3DC::In_Place_Pre_Rotate_Y -- Pre-multiplies rotation part of matrix by a rotation about Y * - * * - * INPUT: * - * s - sine of the angle to rotate * - * c - cosine of the angle to rotate * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/1/1999 NH : Created. * - *=============================================================================================*/ -inline void Matrix3D::In_Place_Pre_Rotate_Y(float s,float c) -{ - float tmp1,tmp2; - - tmp1 = Row[0][0]; tmp2 = Row[2][0]; - Row[0][0] = (float)( c*tmp1 + s*tmp2); - Row[2][0] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[0][1]; tmp2 = Row[2][1]; - Row[0][1] = (float)( c*tmp1 + s*tmp2); - Row[2][1] = (float)(-s*tmp1 + c*tmp2); - - tmp1 = Row[0][2]; tmp2 = Row[2][2]; - Row[0][2] = (float)( c*tmp1 + s*tmp2); - Row[2][2] = (float)(-s*tmp1 + c*tmp2); -} - -/*********************************************************************************************** - * M3DC::In_Place_Pre_Rotate_Z -- Pre-multiplies rotation part of matrix by a rotation about Z * - * * - * INPUT: * - * s - sine of the angle to rotate * - * c - cosine of the angle to rotate * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/1/1999 NH : Created. * - *=============================================================================================*/ -inline void Matrix3D::In_Place_Pre_Rotate_Z(float s,float c) -{ - float tmp1,tmp2; - - tmp1 = Row[0][0]; tmp2 = Row[1][0]; - Row[0][0] = (float)(c*tmp1 - s*tmp2); - Row[1][0] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[0][1]; tmp2 = Row[1][1]; - Row[0][1] = (float)(c*tmp1 - s*tmp2); - Row[1][1] = (float)(s*tmp1 + c*tmp2); - - tmp1 = Row[0][2]; tmp2 = Row[1][2]; - Row[0][2] = (float)(c*tmp1 - s*tmp2); - Row[1][2] = (float)(s*tmp1 + c*tmp2); -} - -/*********************************************************************************************** - * operator * -- Matrix multiplication * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix3D operator * (const Matrix3D &A,const Matrix3D &B) -{ - Matrix3D C; - float tmp1,tmp2,tmp3; - - tmp1 = B[0][0]; - tmp2 = B[1][0]; - tmp3 = B[2][0]; - - C[0][0] = (float)(A[0][0]*tmp1 + A[0][1]*tmp2 + A[0][2]*tmp3); - C[1][0] = (float)(A[1][0]*tmp1 + A[1][1]*tmp2 + A[1][2]*tmp3); - C[2][0] = (float)(A[2][0]*tmp1 + A[2][1]*tmp2 + A[2][2]*tmp3); - - tmp1 = B[0][1]; - tmp2 = B[1][1]; - tmp3 = B[2][1]; - - C[0][1] = (float)(A[0][0]*tmp1 + A[0][1]*tmp2 + A[0][2]*tmp3); - C[1][1] = (float)(A[1][0]*tmp1 + A[1][1]*tmp2 + A[1][2]*tmp3); - C[2][1] = (float)(A[2][0]*tmp1 + A[2][1]*tmp2 + A[2][2]*tmp3); - - tmp1 = B[0][2]; - tmp2 = B[1][2]; - tmp3 = B[2][2]; - - C[0][2] = (float)(A[0][0]*tmp1 + A[0][1]*tmp2 + A[0][2]*tmp3); - C[1][2] = (float)(A[1][0]*tmp1 + A[1][1]*tmp2 + A[1][2]*tmp3); - C[2][2] = (float)(A[2][0]*tmp1 + A[2][1]*tmp2 + A[2][2]*tmp3); - - tmp1 = B[0][3]; - tmp2 = B[1][3]; - tmp3 = B[2][3]; - - C[0][3] = (float)(A[0][0]*tmp1 + A[0][1]*tmp2 + A[0][2]*tmp3 + A[0][3]); - C[1][3] = (float)(A[1][0]*tmp1 + A[1][1]*tmp2 + A[1][2]*tmp3 + A[1][3]); - C[2][3] = (float)(A[2][0]*tmp1 + A[2][1]*tmp2 + A[2][2]*tmp3 + A[2][3]); - - return C; -} - -/*********************************************************************************************** - * operator * -- Matrix - vector multiplication * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *=============================================================================================*/ -inline Vector3 operator * (const Matrix3D &A,const Vector3 &a) -{ -#if 0 - return Vector3 - ( - (A[0][0]*a[0] + A[0][1]*a[1] + A[0][2]*a[2] + A[0][3]), - (A[1][0]*a[0] + A[1][1]*a[1] + A[1][2]*a[2] + A[1][3]), - (A[2][0]*a[0] + A[2][1]*a[1] + A[2][2]*a[2] + A[2][3]) - ); -#else - return Vector3 - ( - (A.Row[0].X*a.X + A.Row[0].Y*a.Y + A.Row[0].Z*a.Z + A.Row[0].W), - (A.Row[1].X*a.X + A.Row[1].Y*a.Y + A.Row[1].Z*a.Z + A.Row[1].W), - (A.Row[2].X*a.X + A.Row[2].Y*a.Y + A.Row[2].Z*a.Z + A.Row[2].W) - ); -#endif -} - - -/*********************************************************************************************** - * operator == -- Matrix equality operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 04/29/1998 NH : Created. * - *=============================================================================================*/ -inline bool operator == (const Matrix3D &A, const Matrix3D &B) -{ - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 4; j++) { - if (A[i][j] != B[i][j]) return false; - } - } - return true; -} - - -/*********************************************************************************************** - * operator != -- Matrix inequality operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 04/29/1998 NH : Created. * - *=============================================================================================*/ -inline bool operator != (const Matrix3D &A, const Matrix3D &B) -{ - return !(A == B); -} - - -inline void Matrix3D::Transform_Vector(const Matrix3D & A,const Vector3 & in,Vector3 * out) -{ - Vector3 tmp; - Vector3 * v; - - // check for aliased parameters - if (out == &in) { - tmp = in; - v = &tmp; - } else { - v = (Vector3 *)∈ // whats the right way to do this... - } - - out->X = (A[0][0] * v->X + A[0][1] * v->Y + A[0][2] * v->Z + A[0][3]); - out->Y = (A[1][0] * v->X + A[1][1] * v->Y + A[1][2] * v->Z + A[1][3]); - out->Z = (A[2][0] * v->X + A[2][1] * v->Y + A[2][2] * v->Z + A[2][3]); -} - -inline void Matrix3D::Rotate_Vector(const Matrix3D & A,const Vector3 & in,Vector3 * out) -{ - Vector3 tmp; - Vector3 * v; - - // check for aliased parameters - if (out == &in) { - tmp = in; - v = &tmp; - } else { - v = (Vector3 *)∈ - } - - out->X = (A[0][0] * v->X + A[0][1] * v->Y + A[0][2] * v->Z); - out->Y = (A[1][0] * v->X + A[1][1] * v->Y + A[1][2] * v->Z); - out->Z = (A[2][0] * v->X + A[2][1] * v->Y + A[2][2] * v->Z); -} - -inline void Matrix3D::Inverse_Transform_Vector(const Matrix3D & A,const Vector3 & in,Vector3 * out) -{ - Vector3 tmp; - Vector3 * v; - - // check for aliased parameters - if (out == &in) { - tmp = in; - v = &tmp; - } else { - v = (Vector3 *)∈ // whats the right way to do this... - } - - Vector3 diff(v->X - A[0][3], v->Y - A[1][3], v->Z - A[2][3]); - Matrix3D::Inverse_Rotate_Vector(A, diff, out); -} - -inline void Matrix3D::Inverse_Rotate_Vector(const Matrix3D & A,const Vector3 & in,Vector3 * out) -{ - Vector3 tmp; - Vector3 * v; - - // check for aliased parameters - if (out == &in) { - tmp = in; - v = &tmp; - } else { - v = (Vector3 *)∈ - } - out->X = (A[0][0] * v->X + A[1][0] * v->Y + A[2][0] * v->Z); - out->Y = (A[0][1] * v->X + A[1][1] * v->Y + A[2][1] * v->Z); - out->Z = (A[0][2] * v->X + A[1][2] * v->Y + A[2][2] * v->Z); -} - -#endif /* MATRIX3D_H */ diff --git a/Generals/Code/Tools/WW3D/pluglib/matrix4.cpp b/Generals/Code/Tools/WW3D/pluglib/matrix4.cpp deleted file mode 100644 index 580d8a14168..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/matrix4.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WWMath * - * * - * $Archive:: /Commando/Code/wwmath/matrix4.cpp $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 11/13/99 10:50a $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Matrix4::Multiply -- Multiply two Matrix4's together * - * Matrix4::Multiply -- Multiply a Matrix3D * Matrix4 * - * Matrix4::Multiply -- Multiply a Matrix4 * Matrix3D * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "matrix4.h" -#include - -/*********************************************************************************************** - * Matrix4::Multiply -- Multiply two Matrix4's together * - * * - * INPUT: * - * a - first operand * - * b - second operand * - * res - pointer to matrix to store the result in (must not point to a or b) * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/13/99 gth : Created. * - *=============================================================================================*/ -void Matrix4::Multiply(const Matrix4 &a,const Matrix4 &b,Matrix4 * res) -{ - assert(res != &a); - assert(res != &b); - - #define ROWCOL(i,j) a[i][0]*b[0][j] + a[i][1]*b[1][j] + a[i][2]*b[2][j] + a[i][3]*b[3][j] - - (*res)[0][0] = ROWCOL(0,0); - (*res)[0][1] = ROWCOL(0,1); - (*res)[0][2] = ROWCOL(0,2); - (*res)[0][3] = ROWCOL(0,3); - - (*res)[1][0] = ROWCOL(1,0); - (*res)[1][1] = ROWCOL(1,1); - (*res)[1][2] = ROWCOL(1,2); - (*res)[1][3] = ROWCOL(1,3); - - (*res)[2][0] = ROWCOL(2,0); - (*res)[2][1] = ROWCOL(2,1); - (*res)[2][2] = ROWCOL(2,2); - (*res)[2][3] = ROWCOL(2,3); - - (*res)[3][0] = ROWCOL(3,0); - (*res)[3][1] = ROWCOL(3,1); - (*res)[3][2] = ROWCOL(3,2); - (*res)[3][3] = ROWCOL(3,3); - - #undef ROWCOL -} - - -/*********************************************************************************************** - * Matrix4::Multiply -- Multiply a Matrix3D * Matrix4 * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/13/99 gth : Created. * - *=============================================================================================*/ -void Matrix4::Multiply(const Matrix3D &a,const Matrix4 &b,Matrix4 * res) -{ - assert(res != &b); - - #define ROWCOL(i,j) a[i][0]*b[0][j] + a[i][1]*b[1][j] + a[i][2]*b[2][j] + a[i][3]*b[3][j] - - (*res)[0][0] = ROWCOL(0,0); - (*res)[0][1] = ROWCOL(0,1); - (*res)[0][2] = ROWCOL(0,2); - (*res)[0][3] = ROWCOL(0,3); - - (*res)[1][0] = ROWCOL(1,0); - (*res)[1][1] = ROWCOL(1,1); - (*res)[1][2] = ROWCOL(1,2); - (*res)[1][3] = ROWCOL(1,3); - - (*res)[2][0] = ROWCOL(2,0); - (*res)[2][1] = ROWCOL(2,1); - (*res)[2][2] = ROWCOL(2,2); - (*res)[2][3] = ROWCOL(2,3); - - (*res)[3][0] = b[3][0]; // last row of a is 0,0,0,1 - (*res)[3][1] = b[3][1]; // this leaves the last row of b unchanged - (*res)[3][2] = b[3][2]; - (*res)[3][3] = b[3][3]; - - #undef ROWCOL -} - - -/*********************************************************************************************** - * Matrix4::Multiply -- Multiply a Matrix4 * Matrix3D * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -void Matrix4::Multiply(const Matrix4 & a,const Matrix3D & b,Matrix4 * res) -{ - assert(res != &a); - - // ROWCOL multiplies a row of 'a' by one of the first three columns of 'b' (4th entry in b is zero) - // ROWCOL4 multiplies a row of 'a' by the fourth column of 'b' (4th entry in b is one) - - #define ROWCOL(i,j) a[i][0]*b[0][j] + a[i][1]*b[1][j] + a[i][2]*b[2][j] - #define ROWCOL4(i,j) a[i][0]*b[0][j] + a[i][1]*b[1][j] + a[i][2]*b[2][j] + a[i][3] - - (*res)[0][0] = ROWCOL(0,0); - (*res)[0][1] = ROWCOL(0,1); - (*res)[0][2] = ROWCOL(0,2); - (*res)[0][3] = ROWCOL4(0,3); - - (*res)[1][0] = ROWCOL(1,0); - (*res)[1][1] = ROWCOL(1,1); - (*res)[1][2] = ROWCOL(1,2); - (*res)[1][3] = ROWCOL4(1,3); - - (*res)[2][0] = ROWCOL(2,0); - (*res)[2][1] = ROWCOL(2,1); - (*res)[2][2] = ROWCOL(2,2); - (*res)[2][3] = ROWCOL4(2,3); - - (*res)[3][0] = ROWCOL(3,0); - (*res)[3][1] = ROWCOL(3,1); - (*res)[3][2] = ROWCOL(3,2); - (*res)[3][3] = ROWCOL4(3,3); - - #undef ROWCOL - #undef ROWCOL4 -} diff --git a/Generals/Code/Tools/WW3D/pluglib/matrix4.h b/Generals/Code/Tools/WW3D/pluglib/matrix4.h deleted file mode 100644 index 947af370344..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/matrix4.h +++ /dev/null @@ -1,716 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/matrix4.h 15 2/03/00 4:55p Jason_a $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * File Name : MATRIX4.H * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 06/02/97 * - * * - * Last Update : June 2, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Matrix4::Matrix4 -- Constructor, optionally initialize to Identitiy matrix * - * Matrix4::Matrix4 -- Copy Constructor * - * Matrix4::Matrix4 -- Convert a Matrix3D (fake 4x4) to a Matrix4 * - * Matrix4::Matrix4 -- Constructor * - * Matrix4::Make_Identity -- Initializes the matrix to Identity * - * Matrix4::Init -- Initializes from the contents of the give Matrix3D * - * Matrix4::Init -- Initializes the rows from the given Vector4s * - * Matrix4::Init_Ortho -- Initialize to an orthographic projection matrix * - * Matrix4::Init_Perspective -- Initialize to a perspective projection matrix * - * Matrix4::Init_Perspective -- Initialize to a perspective projection matrix * - * Matrix4::Transpose -- Returns transpose of the matrix * - * Matrix4::Inverse -- returns the inverse of the matrix * - * Matrix4::operator = -- assignment operator * - * Matrix4::operator += -- "plus equals" operator * - * Matrix4::operator-= -- "minus equals" operator * - * Matrix4::operator *= -- "times equals" operator * - * Matrix4::operator /= -- "divide equals" operator * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef MATRIX4_H -#define MATRIX4_H - -#include "always.h" -#include "vector4.h" -#include "matrix3d.h" -#include "WWmatrix3.h" - - -class Matrix4 -{ -public: - - /* - ** Constructors - */ - Matrix4(void) {}; - Matrix4(const Matrix4 & m); - - explicit Matrix4(bool identity); - explicit Matrix4(const Matrix3D & m); - explicit Matrix4(const Matrix3 & m); - explicit Matrix4(const Vector4 & v0, const Vector4 & v1, const Vector4 & v2, const Vector4 & v3); - - void Make_Identity(void); - void Init(const Matrix3D & m); - void Init(const Matrix3 & m); - void Init(const Vector4 & v0, const Vector4 & v1, const Vector4 & v2, const Vector4 & v3); - - void Init_Ortho(float left,float right,float bottom,float top,float znear,float zfar); - void Init_Perspective(float hfov,float vfov,float znear,float zfar); - void Init_Perspective(float left,float right,float bottom,float top,float znear,float zfar); - - /* - ** Access operators - */ - Vector4 & operator [] (int i) { return Row[i]; } - const Vector4 & operator [] (int i) const { return Row[i]; } - - /* - ** Transpose and Inverse - */ - Matrix4 Transpose(void) const; - Matrix4 Inverse(void) const; - - /* - ** Assignment operators - */ - Matrix4 & operator = (const Matrix4 & m); - Matrix4 & operator += (const Matrix4 & m); - Matrix4 & operator -= (const Matrix4 & m); - Matrix4 & operator *= (float d); - Matrix4 & operator /= (float d); - - /* - ** Negation - */ - friend Matrix4 operator - (const Matrix4& a); - - /* - ** Scalar multiplication and division - */ - friend Matrix4 operator * (const Matrix4& a,float d); - friend Matrix4 operator * (float d,const Matrix4& a); - friend Matrix4 operator / (const Matrix4& a,float d); - - /* - ** matrix addition - */ - friend Matrix4 operator + (const Matrix4& a, const Matrix4& b); - friend Matrix4 Add(const Matrix4& a); - - /* - ** matrix subtraction - */ - friend Matrix4 operator - (const Matrix4 & a, const Matrix4 & b); - friend Matrix4 Subtract(const Matrix4 & a, const Matrix4 & b); - - /* - ** matrix multiplication - */ - friend Matrix4 operator * (const Matrix4 & a, const Matrix4 & b); - friend Matrix4 Multiply(const Matrix4 & a, const Matrix4 & b); - - /* - ** Comparison operators - */ - friend int operator == (const Matrix4 & a, const Matrix4 & b); - friend int operator != (const Matrix4 & a, const Matrix4 & b); - - /* - ** Swap two matrices in place - */ - friend void Swap(Matrix4 & a,Matrix4 & b); - - /* - ** Linear Transforms - */ - friend Vector4 operator * (const Matrix4 & a, const Vector4 & v); - friend Vector4 operator * (const Matrix4 & a, const Vector3 & v); - - /* - ** Matrix multiplication without temporaries... - */ - static void Multiply(const Matrix4 &A,const Matrix4 &B,Matrix4 * set_result); - static void Multiply(const Matrix3D &A,const Matrix4 &B,Matrix4 * set_result); - static void Multiply(const Matrix4 &A,const Matrix3D &B,Matrix4 * set_result); - - static void Transform_Vector(const Matrix4 & tm,const Vector3 & in,Vector3 * out); - -protected: - - Vector4 Row[4]; - -}; - - -/*********************************************************************************************** - * Matrix4::Matrix4 -- Constructor, optionally initialize to Identitiy matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix4::Matrix4(bool identity) -{ - if (identity) { - Make_Identity(); - } -} - -/*********************************************************************************************** - * Matrix4::Matrix4 -- Copy Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix4::Matrix4(const Matrix4 & m) -{ - Row[0] = m.Row[0]; Row[1] = m.Row[1]; Row[2] = m.Row[2]; Row[3] = m.Row[3]; -} - -/*********************************************************************************************** - * Matrix4::Matrix4 -- Convert a Matrix3D (fake 4x4) to a Matrix4 * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix4::Matrix4(const Matrix3D & m) -{ - Init(m); -} - -/*********************************************************************************************** - * Matrix4::Matrix4 -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix4::Matrix4(const Vector4 & r0, const Vector4 & r1, const Vector4 & r2, const Vector4 & r3) -{ - Init(r0,r1,r2,r3); -} - - -/*********************************************************************************************** - * Matrix4::Make_Identity -- Initializes the matrix to Identity * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/5/99 gth : Created. * - *=============================================================================================*/ -inline void Matrix4::Make_Identity(void) -{ - Row[0].Set(1.0,0.0,0.0,0.0); - Row[1].Set(0.0,1.0,0.0,0.0); - Row[2].Set(0.0,0.0,1.0,0.0); - Row[3].Set(0.0,0.0,0.0,1.0); -} - - -/*********************************************************************************************** - * Matrix4::Init -- Initializes from the contents of the give Matrix3D * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/5/99 gth : Created. * - *=============================================================================================*/ -inline void Matrix4::Init(const Matrix3D & m) -{ - Row[0] = m[0]; Row[1] = m[1]; Row[2] = m[2]; Row[3] = Vector4(0.0,0.0,0.0,1.0); -} - - -/*********************************************************************************************** - * Matrix4::Init -- Initializes the rows from the given Vector4s * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/5/99 gth : Created. * - *=============================================================================================*/ -inline void Matrix4::Init(const Vector4 & r0, const Vector4 & r1, const Vector4 & r2, const Vector4 & r3) -{ - Row[0] = r0; Row[1] = r1; Row[2] = r2; Row[3] = r3; -} - - -/*********************************************************************************************** - * Matrix4::Init_Ortho -- Initialize to an orthographic projection matrix * - * * - * You can find the formulas for this in the appendix of the OpenGL programming guide. Also * - * this happens to be the same convention used by Surrender. * - * * - * The result of this projection will be that points inside the volume will have all coords * - * between -1 and +1. A point at znear will project to z=-1. A point at zfar will project * - * to z=+1... * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Note that the znear and zfar parameters are positive distances to the clipping planes * - * even though in the camera coordinate system, the clipping planes are at negative z * - * coordinates. This holds for all of the projection initializations and is consistent * - * with OpenGL's convention. * - * * - * HISTORY: * - * 11/5/99 gth : Created. * - *=============================================================================================*/ -inline void Matrix4::Init_Ortho -( - float left, - float right, - float bottom, - float top, - float znear, - float zfar -) -{ - assert(znear >= 0.0f); - assert(zfar > znear); - - Make_Identity(); - Row[0][0] = 2.0f / (right - left); - Row[0][3] = -(right + left) / (right - left); - Row[1][1] = 2.0f / (top - bottom); - Row[1][3] = -(top + bottom) / (top - bottom); - Row[2][2] = -2.0f / (zfar - znear); - Row[2][3] = -(zfar + znear) / (zfar - znear); -} - - -/*********************************************************************************************** - * Matrix4::Init_Perspective -- Initialize to a perspective projection matrix * - * * - * You can find the formulas for this matrix in the appendix of the OpenGL programming guide. * - * Also, this happens to be the same convention used by Surrender. * - * * - * INPUT: * - * hfov - horizontal field of view (in radians) * - * vfov - vertical field of view (in radians) * - * znear - distance to near z clipping plane (positive) * - * zfar - distance to the far z clipping plane (positive) * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Note that the znear and zfar parameters are positive distances to the clipping planes * - * even though in the camera coordinate system, the clipping planes are at negative z * - * coordinates. This holds for all of the projection initializations and is consistent * - * with OpenGL's convention. * - * * - * HISTORY: * - * 11/5/99 gth : Created. * - *=============================================================================================*/ -inline void Matrix4::Init_Perspective(float hfov,float vfov,float znear,float zfar) -{ - assert(znear > 0.0f); - assert(zfar > znear); - - Make_Identity(); - Row[0][0] = (1.0 / tan(hfov*0.5)); - Row[1][1] = (1.0 / tan(vfov*0.5)); - Row[2][2] = -(zfar + znear) / (zfar - znear); - Row[2][3] = -(2.0*zfar*znear) / (zfar - znear); - Row[3][2] = -1.0f; - Row[3][3] = 0.0f; -} - - -/*********************************************************************************************** - * Matrix4::Init_Perspective -- Initialize to a perspective projection matrix * - * * - * You can find the formulas for this matrix in the appendix of the OpenGL programming guide. * - * Also, this happens to be the same convention used by Surrender. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Note that the znear and zfar parameters are positive distances to the clipping planes * - * even though in the camera coordinate system, the clipping planes are at negative z * - * coordinates. This holds for all of the projection initializations and is consistent * - * with OpenGL's convention. * - * * - * HISTORY: * - * 11/5/99 gth : Created. * - *=============================================================================================*/ -inline void Matrix4::Init_Perspective -( - float left, - float right, - float bottom, - float top, - float znear, - float zfar -) -{ - assert(znear > 0.0f); - assert(zfar > 0.0f); - - Make_Identity(); - Row[0][0] = 2.0*znear / (right - left); - Row[0][2] = (right + left) / (right - left); - Row[1][1] = 2.0*znear / (top - bottom); - Row[1][2] = (top + bottom) / (top - bottom); - Row[2][2] = -(zfar + znear) / (zfar - znear); - Row[2][3] = -(2.0*zfar*znear) / (zfar - znear); - Row[3][2] = -1.0f; - Row[3][3] = 0.0f; -} - -/*********************************************************************************************** - * Matrix4::Transpose -- Returns transpose of the matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix4 Matrix4::Transpose() const -{ - return Matrix4( - Vector4(Row[0][0], Row[1][0], Row[2][0], Row[3][0]), - Vector4(Row[0][1], Row[1][1], Row[2][1], Row[3][1]), - Vector4(Row[0][2], Row[1][2], Row[2][2], Row[3][2]), - Vector4(Row[0][3], Row[1][3], Row[2][3], Row[3][3]) - ); -} - -/*********************************************************************************************** - * Matrix4::Inverse -- returns the inverse of the matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix4 Matrix4::Inverse() const // Gauss-Jordan elimination with partial pivoting -{ - Matrix4 a(*this); // As a evolves from original mat into identity - Matrix4 b(true); // b evolves from identity into inverse(a) - int i, j, i1; - - // Loop over cols of a from left to right, eliminating above and below diagonal - for (j=0; j<4; j++) { - - // Find largest pivot in column j among rows j..3 - i1 = j; - for (i=j+1; i<4; i++) { - if (WWMath::Fabs(a[i][j]) > WWMath::Fabs(a[i1][j])) { - i1 = i; - } - } - - // Swap rows i1 and j in a and b to put pivot on diagonal - Swap(a.Row[i1], a.Row[j]); - Swap(b.Row[i1], b.Row[j]); - - // Scale row j to have a unit diagonal - if (a[j][j]==0.) { - //ALGEBRA_ERROR("Matrix4::inverse: singular matrix; can't invert\n"); - } - b.Row[j] /= a.Row[j][j]; - a.Row[j] /= a.Row[j][j]; - - // Eliminate off-diagonal elems in col j of a, doing identical ops to b - for (i=0; i<4; i++) { - if (i != j) { - b.Row[i] -= a[i][j] * b.Row[j]; - a.Row[i] -= a[i][j] * a.Row[j]; - } - } - } - return b; -} - -/*********************************************************************************************** - * Matrix4::operator = -- assignment operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix4 & Matrix4::operator = (const Matrix4 & m) -{ - Row[0] = m.Row[0]; Row[1] = m.Row[1]; Row[2] = m.Row[2]; Row[3] = m.Row[3]; - return *this; -} - -/*********************************************************************************************** - * Matrix4::operator += -- "plus equals" operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix4& Matrix4::operator += (const Matrix4 & m) -{ - Row[0] += m.Row[0]; Row[1] += m.Row[1]; Row[2] += m.Row[2]; Row[3] += m.Row[3]; - return *this; -} - -/*********************************************************************************************** - * Matrix4::operator-= -- "minus equals" operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix4& Matrix4::operator -= (const Matrix4 & m) -{ - Row[0] -= m.Row[0]; Row[1] -= m.Row[1]; Row[2] -= m.Row[2]; Row[3] -= m.Row[3]; - return *this; -} - -/*********************************************************************************************** - * Matrix4::operator *= -- "times equals" operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix4& Matrix4::operator *= (float d) -{ - Row[0] *= d; Row[1] *= d; Row[2] *= d; Row[3] *= d; - return *this; -} - -/*********************************************************************************************** - * Matrix4::operator /= -- "divide equals" operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline Matrix4& Matrix4::operator /= (float d) -{ - float ood = d; - Row[0] *= ood; Row[1] *= ood; Row[2] *= ood; Row[3] *= ood; - return *this; -} - -inline Matrix4 operator - (const Matrix4 & a) -{ - return Matrix4(-a.Row[0], -a.Row[1], -a.Row[2], -a.Row[3]); -} - -inline Matrix4 operator * (const Matrix4 & a, float d) -{ - return Matrix4(a.Row[0] * d, a.Row[1] * d, a.Row[2] * d, a.Row[3] * d); -} - -inline Matrix4 operator * (float d, const Matrix4 & a) -{ - return a*d; -} - -inline Matrix4 operator / (const Matrix4 & a, float d) -{ - float ood = 1.0f / d; - return Matrix4(a.Row[0] * ood, a.Row[1] * ood, a.Row[2] * ood, a.Row[3] * ood); -} - -/* -** matrix addition -*/ -inline Matrix4 operator + (const Matrix4 & a, const Matrix4 & b) -{ - return Matrix4( - a.Row[0] + b.Row[0], - a.Row[1] + b.Row[1], - a.Row[2] + b.Row[2], - a.Row[3] + b.Row[3] - ); -} - -inline Matrix4 Add(const Matrix4 & a, const Matrix4 & b) -{ return a+b; } - -/* -** matrix subtraction -*/ -inline Matrix4 operator - (const Matrix4 & a, const Matrix4 & b) -{ - return Matrix4( - a.Row[0] - b.Row[0], - a.Row[1] - b.Row[1], - a.Row[2] - b.Row[2], - a.Row[3] - b.Row[3] - ); -} - -inline Matrix4 Subtract(const Matrix4 & a, const Matrix4 & b) -{ return a-b; } - -/* -** matrix multiplication -*/ -inline Matrix4 operator * (const Matrix4 & a, const Matrix4 & b) -{ - #define ROWCOL(i, j) a[i][0]*b[0][j] + a[i][1]*b[1][j] + a[i][2]*b[2][j] + a[i][3]*b[3][j] - - return Matrix4( - Vector4(ROWCOL(0,0), ROWCOL(0,1), ROWCOL(0,2), ROWCOL(0,3)), - Vector4(ROWCOL(1,0), ROWCOL(1,1), ROWCOL(1,2), ROWCOL(1,3)), - Vector4(ROWCOL(2,0), ROWCOL(2,1), ROWCOL(2,2), ROWCOL(2,3)), - Vector4(ROWCOL(3,0), ROWCOL(3,1), ROWCOL(3,2), ROWCOL(3,3)) - ); - - #undef ROWCOL -} - -inline Matrix4 Multiply(const Matrix4 & a, const Matrix4 & b) -{ return a*b; } - - - -/* -** Multiply a Matrix4 by a Vector3 (assumes w=1.0!!!). Yeilds a Vector4 result -*/ -inline Vector4 operator * (const Matrix4 & a, const Vector3 & v) { - return Vector4( - a[0][0] * v[0] + a[0][1] * v[1] + a[0][2] * v[2] + a[0][3] * 1.0, - a[1][0] * v[0] + a[1][1] * v[1] + a[1][2] * v[2] + a[1][3] * 1.0, - a[2][0] * v[0] + a[2][1] * v[1] + a[2][2] * v[2] + a[2][3] * 1.0, - a[3][0] * v[0] + a[3][1] * v[1] + a[3][2] * v[2] + a[3][3] * 1.0 - ); -} - -/* -** Multiply a Matrix4 by a Vector4 -*/ -inline Vector4 operator * (const Matrix4 & a, const Vector4 & v) { - return Vector4( - a[0][0] * v[0] + a[0][1] * v[1] + a[0][2] * v[2] + a[0][3] * v[3], - a[1][0] * v[0] + a[1][1] * v[1] + a[1][2] * v[2] + a[1][3] * v[3], - a[2][0] * v[0] + a[2][1] * v[1] + a[2][2] * v[2] + a[2][3] * v[3], - a[3][0] * v[0] + a[3][1] * v[1] + a[3][2] * v[2] + a[3][3] * v[3] - ); -} - -/* -** Multiply a Matrix4 by a Vector4 -*/ -inline void Matrix4::Transform_Vector(const Matrix4 & A,const Vector3 & in,Vector3 * out) -{ - Vector3 tmp; - Vector3 * v; - - // check for aliased parameters - if (out == &in) { - tmp = in; - v = &tmp; - } else { - v = (Vector3 *)∈ // whats the right way to do this... - } - - out->X = (A[0][0] * v->X + A[0][1] * v->Y + A[0][2] * v->Z + A[0][3]); - out->Y = (A[1][0] * v->X + A[1][1] * v->Y + A[1][2] * v->Z + A[1][3]); - out->Z = (A[2][0] * v->X + A[2][1] * v->Y + A[2][2] * v->Z + A[2][3]); -} - -#endif /*MATRIX4_H*/ \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/pluglib/nodefilt.cpp b/Generals/Code/Tools/WW3D/pluglib/nodefilt.cpp deleted file mode 100644 index 388e6bf7916..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/nodefilt.cpp +++ /dev/null @@ -1,286 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/nodefilt.cpp 9 1/16/98 10:34a Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G * - * * - * File Name : NODEFILT.CPP * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 06/09/97 * - * * - * Last Update : June 9, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * VisibleMeshINodeFilter::Accept_Node -- Accepts visible meshes * - * AnimatedINodeFilter::Accept_Node -- Accepts animated INodes * - * RootINodeFilter::Accept_Node -- Accepts root INodes * - * VisibleHelperINodeFilter::Accept_Node -- Accepts visible helper objects * - * VisibleMeshOrHelperINodeFilter::Accept_Node -- Accepts visible helper or mesh objects * - * HelperINodeFilter::Accept_Node -- Accepts all helper inodes (including hidden) * - * MeshINodeFilter::Accept_Node -- Accepts all mesh inodes (including hidden) * - * VisibleSelectedINodeFilter::Accept_Node -- Accepts Visible and selected inodes * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "nodefilt.h" -#include - - -/* -** The default node filter: -*/ -VisibleMeshINodeFilter DefaultINodeFilter; - - -/*********************************************************************************************** - * HelperINodeFilter::Accept_Node -- Accepts all helper inodes (including hidden) * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/10/1997 GH : Created. * - *=============================================================================================*/ -BOOL HelperINodeFilter::Accept_Node(INode * node,TimeValue time) -{ - Object * obj = node->EvalWorldState(time).obj; - - if (obj && obj->SuperClassID() == HELPER_CLASS_ID) { - - return TRUE; - - } - - return FALSE; -} - - -/*********************************************************************************************** - * MeshINodeFilter::Accept_Node -- Accepts all mesh inodes (including hidden) * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/10/1997 GH : Created. * - *=============================================================================================*/ -BOOL MeshINodeFilter::Accept_Node(INode * node,TimeValue time) -{ - Object * obj = node->EvalWorldState(time).obj; - - if (obj && - obj->CanConvertToType(triObjectClassID) && - obj->SuperClassID() == GEOMOBJECT_CLASS_ID) - { - - return TRUE; - - } else { - - return FALSE; - - } -} - - -/*********************************************************************************************** - * VisibleMeshINodeFilter::Accept_Node -- Accepts visible meshes * - * * - * Accepts nodes which: * - * - can be converted to tri-meshes * - * - are not hidden * - * - whose visibility > 0.0 * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -BOOL VisibleMeshINodeFilter::Accept_Node(INode * node, TimeValue time) -{ - Object * obj = node->EvalWorldState(time).obj; - - if - ( - obj - && !node->IsHidden () - && obj->CanConvertToType(triObjectClassID) - && obj->SuperClassID() == GEOMOBJECT_CLASS_ID -// && node->GetVisibility (time) > 0.0f - ) - { - - return TRUE; - - } else { - - return FALSE; - - } -} - -/*********************************************************************************************** - * VisibleHelperINodeFilter::Accept_Node -- Accepts visible helper objects * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/03/1997 GH : Created. * - *=============================================================================================*/ -BOOL VisibleHelperINodeFilter::Accept_Node(INode * node, TimeValue time) -{ - Object * obj = node->EvalWorldState(time).obj; - - if ((!obj) || (node->IsHidden()) /*|| (node->GetVisibility(time) <= 0.0f)*/) { - - return FALSE; - - } - - if (obj->SuperClassID() == HELPER_CLASS_ID) { - - return TRUE; - - } - - return FALSE; -} - - -/*********************************************************************************************** - * VisibleMeshOrHelperINodeFilter::Accept_Node -- Accepts visible helper or mesh objects * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/03/1997 GH : Created. * - *=============================================================================================*/ -BOOL VisibleMeshOrHelperINodeFilter::Accept_Node(INode * node, TimeValue time) -{ - Object * obj = node->EvalWorldState(time).obj; - - if ((!obj) || (node->IsHidden()) /*|| (node->GetVisibility(time) <= 0.0f)*/) { - - return FALSE; - - } - - if (obj->CanConvertToType(triObjectClassID) && obj->SuperClassID() == GEOMOBJECT_CLASS_ID) { - - return TRUE; - - } - - if (obj->SuperClassID() == HELPER_CLASS_ID) { - - return TRUE; - - } - - return FALSE; -} - -/*********************************************************************************************** - * AnimatedINodeFilter::Accept_Node -- Accepts animated INodes * - * * - * Accepts nodes which: * - * - can be converted to tri-meshes * - * - are not hidden * - * - whose visibility > 0.0 * - * - have animation keys! * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -BOOL AnimatedINodeFilter::Accept_Node(INode * node, TimeValue time) -{ - Object * obj = node->EvalWorldState(time).obj; - Control * poscon = node->GetTMController()->GetPositionController(); - Control * rotcon = node->GetTMController()->GetRotationController(); - - int numkeys = 0; - if (poscon != NULL) { - IKeyControl * poskeys = GetKeyControlInterface(poscon); - if (poskeys != NULL) numkeys += poskeys->GetNumKeys(); - } - - if (rotcon != NULL) { - IKeyControl * rotkeys = GetKeyControlInterface(rotcon); - if (rotkeys != NULL) numkeys += rotkeys->GetNumKeys(); - } - - if (obj && !node->IsHidden() && numkeys > 0) { - return TRUE; - } - - return FALSE; -} - - -/*********************************************************************************************** - * VisibleSelectedINodeFilter::Accept_Node -- Accepts Visible and selected inodes * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/13/98 GTH : Created. * - *=============================================================================================*/ -BOOL VisibleSelectedINodeFilter::Accept_Node(INode * node, TimeValue time) -{ - if (!node->IsHidden() && node->Selected()) { - return TRUE; - } else { - return FALSE; - } -} - diff --git a/Generals/Code/Tools/WW3D/pluglib/nodefilt.h b/Generals/Code/Tools/WW3D/pluglib/nodefilt.h deleted file mode 100644 index 928cf955814..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/nodefilt.h +++ /dev/null @@ -1,178 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/nodefilt.h 6 1/14/98 10:23a Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G * - * * - * File Name : NODEFILT.H * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 06/09/97 * - * * - * Last Update : June 9, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef NODEFILT_H -#define NODEFILT_H - -#include "always.h" -#include - -/*************************************************************** -* -* INodeFilterClass -* -* This is simply an object used to accept or reject INodes -* based on whatever criteria you desire. There are some -* default node filters defined in this module or you can -* create your own by inheriting the Abstract Base Class -* INodeFilterClass and implementing the Accept_Node method. -* -***************************************************************/ -class INodeFilterClass -{ -public: - virtual BOOL Accept_Node(INode * node, TimeValue time) = 0; -}; - - -/*************************************************************** -* -* AnyINodeFilter -* -* Accepts all INodes... -* -***************************************************************/ -class AnyINodeFilter : public INodeFilterClass -{ -public: - virtual BOOL Accept_Node(INode * node, TimeValue time) { return TRUE; } -}; - - -/*************************************************************** -* -* HelperINodeFilter -* -* Accepts INodes which are Helper objects -* -***************************************************************/ -class HelperINodeFilter : public INodeFilterClass -{ -public: - virtual BOOL Accept_Node(INode * node, TimeValue time); -}; - - -/*************************************************************** -* -* MeshINodeFilter -* -* Only accepts INodes which are Triangle meshes -* -***************************************************************/ -class MeshINodeFilter : public INodeFilterClass -{ -public: - virtual BOOL Accept_Node(INode * node, TimeValue time); -}; - -/*************************************************************** -* -* VisibleMeshINodeFilter -* -* Only accepts INodes which are Triangle meshes and are -* currently visible -* -***************************************************************/ -class VisibleMeshINodeFilter : public INodeFilterClass -{ -public: - virtual BOOL Accept_Node(INode * node, TimeValue time); -}; - -/*************************************************************** -* -* VisibleHelperINodeFilter -* -* Only accepts INodes which are Helper objects and are -* currently visible -* -***************************************************************/ -class VisibleHelperINodeFilter : public INodeFilterClass -{ -public: - virtual BOOL Accept_Node(INode * node, TimeValue time); -}; - - -/*************************************************************** -* -* VisibleMeshOrHelperINodeFilter -* -* Only accepts INodes which are Triangle meshes or helper -* objects and are currently visible -* -***************************************************************/ -class VisibleMeshOrHelperINodeFilter : public INodeFilterClass -{ -public: - virtual BOOL Accept_Node(INode * node, TimeValue time); -}; - - -/*************************************************************** -* -* AnimatedINodeFilter -* -* Only accepts INodes which contain at least on animation -* key. -* -***************************************************************/ -class AnimatedINodeFilter : public INodeFilterClass -{ -public: - virtual BOOL Accept_Node(INode * node, TimeValue time); -}; - - -/*************************************************************** -* -* VisibleSelectedINodeFilter -* -* Only accepts INodes which are Visible and Selected -* -***************************************************************/ -class VisibleSelectedINodeFilter : public INodeFilterClass -{ -public: - virtual BOOL Accept_Node(INode * node, TimeValue time); -}; - - - -#endif /*NODEFILT_H*/ \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/pluglib/nodelist.cpp b/Generals/Code/Tools/WW3D/pluglib/nodelist.cpp deleted file mode 100644 index 5eecc4499ca..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/nodelist.cpp +++ /dev/null @@ -1,373 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/pluglib/nodelist.cpp 8 1/02/01 6:31p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G * - * * - * File Name : NODELIST.CPP * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 06/09/97 * - * * - * Last Update : June 9, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * INodeListClass::INodeListClass -- Create an INodeList * - * INodeListClass::~INodeListClass -- Delete the INode List * - * INode * INodeListClass::operator[] -- Array-like access to the list members * - * INodeListClass::callback -- callback function for MAX * - * INodeListClass::INodeListClass -- A "copy" contstructor with filtering... * - * INodeListClass::INodeListClass -- constructor * - * INodeListClass::INodeListClass -- Constructor * - * INodeListClass::Insert -- insert a list of nodes into this list * - * INodeListClass::Insert -- Inserts an INode into the list * - * INodeListClass::Add_Tree -- Add a tree of INodes to the list * - * INodeListClass::Remove -- Remove the i'th element of the list * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "nodelist.h" - - -static AnyINodeFilter _AnyFilter; - - -/******************************************************************************* -* ListEntryClass -* -* Used to implement a linked list of INodes. -* -*******************************************************************************/ -class INodeListEntryClass -{ -public: - - INodeListEntryClass(INode * n,TimeValue /*time*/) { Node = n; } - ~INodeListEntryClass(void) {} - - INode * Node; - INodeListEntryClass * Next; -}; - -/*********************************************************************************************** - * INodeListClass::INodeListClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/02/1997 GH : Created. * - *=============================================================================================*/ -INodeListClass::INodeListClass(TimeValue time,INodeFilterClass * inodefilter) : - NumNodes(0), - Time(time), - ListHead(NULL), - INodeFilter(inodefilter) -{ - if (INodeFilter == NULL) { - INodeFilter = &_AnyFilter; - } -} - -/*********************************************************************************************** - * INodeListClass::INodeListClass -- Create an INodeList * - * * - * INPUT: * - * scene - 3dsMAX scene to enumerate * - * time - time at which to create the list of INodes * - * inodefilter - object which will accept or reject each INode in the scene * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -INodeListClass::INodeListClass(IScene * scene,TimeValue time,INodeFilterClass * inodefilter) : - NumNodes(0), - Time(time), - ListHead(NULL), - INodeFilter(inodefilter) -{ - if (INodeFilter == NULL) { - INodeFilter = &_AnyFilter; - } - scene->EnumTree(this); -} - - -/*********************************************************************************************** - * INodeListClass::INodeListClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/13/98 GTH : Created. * - *=============================================================================================*/ -INodeListClass::INodeListClass(INode * root,TimeValue time,INodeFilterClass * nodefilter) : - NumNodes(0), - Time(time), - ListHead(NULL), - INodeFilter(nodefilter) -{ - if (INodeFilter == NULL) { - INodeFilter = &_AnyFilter; - } - Add_Tree(root); -} - - -/*********************************************************************************************** - * INodeListClass::INodeListClass -- A "copy" contstructor with filtering... * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/02/1997 GH : Created. * - *=============================================================================================*/ -INodeListClass::INodeListClass(INodeListClass & copyfrom,TimeValue time,INodeFilterClass * inodefilter) : - NumNodes(0), - Time(time), - ListHead(NULL), - INodeFilter(inodefilter) -{ - if (INodeFilter == NULL) { - INodeFilter = &_AnyFilter; - } - for (unsigned i=0; iNext; - delete ListHead; - ListHead = next; - } - - NumNodes = 0; - ListHead = NULL; -} - - -/*********************************************************************************************** - * INode * INodeListClass::operator[] -- Array-like access to the list members * - * * - * INPUT: * - * index - index of the list entry * - * * - * OUTPUT: * - * pointer to an INode * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -INode * INodeListClass::operator[] ( int index ) const -{ - INodeListEntryClass * entry = ListHead; - while (index > 0 && entry != NULL ) - { - entry = entry->Next; - index--; - } - return entry->Node; -} - - -/*********************************************************************************************** - * INodeListClass::Insert -- insert a list of nodes into this list * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/14/98 GTH : Created. * - *=============================================================================================*/ -void INodeListClass::Insert(INodeListClass & insertlist) -{ - for (unsigned int i=0; iAccept_Node(node,Time)) - { - INodeListEntryClass * newentry = new INodeListEntryClass(node, Time); - newentry->Next = ListHead; - ListHead = newentry; - NumNodes++; - } -} - - -/*********************************************************************************************** - * INodeListClass::Remove -- Remove the i'th element of the list * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/27/2000 gth : Created. * - *=============================================================================================*/ -void INodeListClass::Remove(int i) -{ - if ((i < 0) || (i > Num_Nodes())) { - return; - } - - INodeListEntryClass * prev = ListHead; - while (i > 1) { - prev = prev->Next; - } - - INodeListEntryClass * deleteme = prev->Next; - if (deleteme != NULL) { - prev->Next = prev->Next->Next; - delete deleteme; - } -} - - -/*********************************************************************************************** - * INodeListClass::Add_Tree -- Add a tree of INodes to the list * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/13/98 GTH : Created. * - *=============================================================================================*/ -void INodeListClass::Add_Tree(INode * root) -{ - if (root == NULL) return; - - Insert(root); - for (int i=0; iNumberOfChildren(); i++) { - Add_Tree(root->GetChildNode(i)); - } -} - - -/*********************************************************************************************** - * INodeListClass::callback -- callback function for MAX * - * * - * 3dsMAX calls this function with a pointer to each INode in the scene. We keep a pointer * - * to the ones we like. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/09/1997 GH : Created. * - *=============================================================================================*/ -int INodeListClass::callback(INode * node) -{ - Insert(node); - - return TREE_CONTINUE; // Keep on enumerating.... -} - - -void INodeListClass::Sort(const INodeCompareClass & node_compare) -{ - for (unsigned int i=0; iNode,nj->Node) > 0) { - INode * tmp = ni->Node; - ni->Node = nj->Node; - nj->Node = tmp; - } - } - } -} - -INodeListEntryClass * INodeListClass::get_nth_item(int index) -{ - INodeListEntryClass * entry = ListHead; - while (index > 0 && entry != NULL ) - { - entry = entry->Next; - index--; - } - return entry; -} - diff --git a/Generals/Code/Tools/WW3D/pluglib/nodelist.h b/Generals/Code/Tools/WW3D/pluglib/nodelist.h deleted file mode 100644 index 426f59d7135..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/nodelist.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/pluglib/nodelist.h 7 1/02/01 6:31p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G * - * * - * File Name : NODELIST.H * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 06/09/97 * - * * - * Last Update : June 9, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef NODELIST_H -#define NODELIST_H - -#include "always.h" -#include - -#ifndef NODEFILT_H -#include "nodefilt.h" -#endif - - -class INodeListEntryClass; -class INodeCompareClass; - - -/******************************************************************************* -* INodeListClass -* -* This is a class that can enumerate a 3dsMax scene and build a list of -* all of the INodes that meet your desired criteria. -* -*******************************************************************************/ -class INodeListClass : public ITreeEnumProc -{ -public: - - INodeListClass(TimeValue time,INodeFilterClass * nodefilter = NULL); - INodeListClass(IScene * scene,TimeValue time,INodeFilterClass * nodefilter = NULL); - INodeListClass(INode * root,TimeValue time,INodeFilterClass * nodefilter = NULL); - INodeListClass(INodeListClass & copyfrom,TimeValue time,INodeFilterClass * inodefilter = NULL); - ~INodeListClass(); - - void Set_Filter(INodeFilterClass * inodefilter) { INodeFilter = inodefilter; } - void Insert(INodeListClass & insertlist); - void Insert(INode * node); - void Remove(int i); - unsigned Num_Nodes(void) const { return NumNodes; } - INode * operator[] (int index) const; - void Sort(const INodeCompareClass & node_compare); - void Add_Tree(INode * root); - -private: - - unsigned NumNodes; - TimeValue Time; - INodeListEntryClass * ListHead; - INodeFilterClass * INodeFilter; - - INodeListEntryClass * get_nth_item(int index); - int callback(INode * node); -}; - - -class INodeCompareClass -{ -public: - // returns <0 if nodea < node b. - // returns =0 if nodea = node b. - // returns >0 if nodea > node b. - virtual int operator() (INode * nodea,INode * nodeb) const = 0; -}; - - -#endif /*NODELIST_H*/ \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/pluglib/noinit.h b/Generals/Code/Tools/WW3D/pluglib/noinit.h deleted file mode 100644 index f3972382582..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/noinit.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/noinit.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 3/23/99 5:20p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef NOINIT_H -#define NOINIT_H - -/********************************************************************** -** This class is solely used as a parameter to a constructor that does -** absolutely no initialization to the object being constructed. By using -** this method, it is possible to load and save data directly from a -** class that has virtual functions. The construction process automatically -** takes care of initializing the virtual function table pointer and the -** rest of the constructor doesn't initialize any data members. After loading -** into a class object, simply perform an in-place new operation. -*/ -#ifndef NoInitClass -class NoInitClass { - public: - void operator () (void) const {}; -}; -#endif - - -#endif diff --git a/Generals/Code/Tools/WW3D/pluglib/palette.cpp b/Generals/Code/Tools/WW3D/pluglib/palette.cpp deleted file mode 100644 index 75bbace1c14..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/palette.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/PALETTE.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * PaletteClass::Adjust -- Adjusts the palette toward another palette. * - * PaletteClass::Adjust -- Adjusts this palette toward black. * - * PaletteClass::Closest_Color -- Finds closest match to color specified. * - * PaletteClass::PaletteClass -- Constructor that fills palette with color specified. * - * PaletteClass::operator = -- Assignment operator for palette objects. * - * PaletteClass::operator == -- Equality operator for palette objects. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "always.h" -#include "palette.h" -#include - - -/*********************************************************************************************** - * PaletteClass::PaletteClass -- Constructor that fills palette with color specified. * - * * - * This constructor will fill the palette with the color specified. * - * * - * INPUT: rgb -- Reference to the color to fill the entire palette with. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -PaletteClass::PaletteClass(RGBClass const & rgb) -{ - for (int index = 0; index < COLOR_COUNT; index++) { - Palette[index] = rgb; - } -} - -PaletteClass::PaletteClass(unsigned char *binary_palette) -{ - memcpy(&Palette[0], binary_palette, sizeof(Palette)); -} - -/*********************************************************************************************** - * PaletteClass::operator == -- Equality operator for palette objects. * - * * - * This is the comparison for equality operator. It will compare palette objects to * - * determine if they are identical. * - * * - * INPUT: palette -- Reference to the palette to compare to this palette. * - * * - * OUTPUT: Are the two palettes identical? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -int PaletteClass::operator == (PaletteClass const & palette) const -{ - if (this == &palette) return(true); - return(memcmp(&Palette[0], &palette.Palette[0], sizeof(Palette)) == 0); -} - - -/*********************************************************************************************** - * PaletteClass::operator = -- Assignment operator for palette objects. * - * * - * This is the assignment operator for palette objects. Although the default C++ generated * - * assignment operator would function correctly, it would not check for self-assignment * - * and thus this routine can be faster. * - * * - * INPUT: palette -- Reference to that palette that will be copied into this palette. * - * * - * OUTPUT: Returns with a reference to the newly copied to palette. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -PaletteClass & PaletteClass::operator = (PaletteClass const & palette) -{ - if (this == &palette) return(*this); - - memcpy(&Palette[0], &palette.Palette[0], sizeof(Palette)); - return(*this); -} - - -/*********************************************************************************************** - * PaletteClass::Adjust -- Adjusts this palette toward black. * - * * - * This routine is used to adjust this palette toward black. Typical use of this routine * - * is when fading the palette to black. * - * * - * INPUT: ratio -- The ratio to fade this palette to black. 0 means no fading at all. 255 * - * means 100% faded to black. * - * * - * OUTPUT: none * - * * - * WARNINGS: This routine doesn't actually set the palette to the video card. Use the Set() * - * function to achieve that purpose. * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -void PaletteClass::Adjust(int ratio) -{ - for (int index = 0; index < COLOR_COUNT; index++) { - Palette[index].Adjust(ratio, BlackColor); - } -} - - -/*********************************************************************************************** - * PaletteClass::Adjust -- Adjusts the palette toward another palette. * - * * - * This routine is used to adjust a palette toward a destination palette by the ratio * - * specified. This is primarily used by the palette fading routines. * - * * - * INPUT: palette -- Reference to the destination palette. * - * * - * ratio -- The ratio to adjust this palette toward the destination palette. A * - * value of 0 means no adjustment at all. A value of 255 means 100% * - * adjustment. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -void PaletteClass::Adjust(int ratio, PaletteClass const & palette) -{ - for (int index = 0; index < COLOR_COUNT; index++) { - Palette[index].Adjust(ratio, palette[index]); - } -} - - -/*********************************************************************************************** - * PaletteClass::Partial_Adjust -- Adjusts the specified parts of this palette toward black. * - * * - * This routine is used to adjust this palette toward black. Typical use of this routine * - * is when fading the palette to black. The input lookup table is used to determine * - * which entries should fade and which should stay the same * - * * - * INPUT: ratio -- The ratio to fade this palette to black. 0 means no fading at all. 255 * - * means 100% faded to black. * - * * - * lookup -- ptr to lookup table * - * * - * OUTPUT: none * - * * - * WARNINGS: This routine doesn't actually set the palette to the video card. Use the Set() * - * function to achieve that purpose. * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -void PaletteClass::Partial_Adjust(int ratio, char *lut) -{ - for (int index = 0; index < COLOR_COUNT; index++) { - if (lut[index]) { - Palette[index].Adjust(ratio, BlackColor); - } - } -} - - -/*********************************************************************************************** - * PaletteClass::Partial_Adjust -- Adjusts the palette toward another palette. * - * * - * This routine is used to adjust a palette toward a destination palette by the ratio * - * specified. This is primarily used by the palette fading routines. The input lookup * - * table is used to determine which entries should fade and which should stay the same * - * * - * * - * INPUT: palette -- Reference to the destination palette. * - * * - * ratio -- The ratio to adjust this palette toward the destination palette. A * - * value of 0 means no adjustment at all. A value of 255 means 100% * - * adjustment. * - * * - * lookup -- ptr to lookup table * - * * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -void PaletteClass::Partial_Adjust(int ratio, PaletteClass const & palette, char *lut) -{ - for (int index = 0; index < COLOR_COUNT; index++) { - if (lut[index]) { - Palette[index].Adjust(ratio, palette[index]); - } - } -} - - -/*********************************************************************************************** - * PaletteClass::Closest_Color -- Finds closest match to color specified. * - * * - * This routine will examine the palette and return with the color index number for the * - * color that most closely matches the color specified. Remap operations rely heavily on * - * this routine to allow working with a constant palette. * - * * - * INPUT: rgb -- Reference to a color to search for in the current palette. * - * * - * OUTPUT: Returns with a color index value to most closely matches the specified color. * - * * - * WARNINGS: This routine will quite likely not find an exact match. * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -int PaletteClass::Closest_Color(RGBClass const & rgb) const -{ - int closest = 0; - int value = -1; - - RGBClass const * ptr = &Palette[0]; - for (int index = 0; index < COLOR_COUNT; index++) { - int difference = rgb.Difference(*ptr++); - if (value == -1 || difference < value) { - value = difference; - closest = index; - } - } - return(closest); -} diff --git a/Generals/Code/Tools/WW3D/pluglib/palette.h b/Generals/Code/Tools/WW3D/pluglib/palette.h deleted file mode 100644 index cfea843f97a..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/palette.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/PALETTE.H $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 12:00p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef PALETTE_H -#define PALETTE_H - -#include "rgb.h" - -/* -** The palette class is used to manipulate a palette as a whole. All 256 colors are -** represented by the palette class object. -*/ -class PaletteClass -{ - public: - enum { - COLOR_COUNT=256 // Number of color indices on the palette. - }; - - PaletteClass(void) {}; - PaletteClass(RGBClass const & rgb); - PaletteClass(unsigned char *binary_palette); - - RGBClass & operator[] (int index) {return(Palette[index % COLOR_COUNT]);}; - RGBClass const & operator[] (int index) const {return(Palette[index % COLOR_COUNT]);}; - RGBClass & Get_Color(int index) {return(Palette[index % COLOR_COUNT]);}; - RGBClass const & Get_Color(int index) const {return(Palette[index % COLOR_COUNT]);}; - int operator == (PaletteClass const & palette) const; - int operator != (PaletteClass const & palette) const {return(!(operator ==(palette)));}; - PaletteClass & operator = (PaletteClass const & palette); - operator const unsigned char * (void) const {return((const unsigned char *)&Palette[0]);}; - operator unsigned char * (void) {return((unsigned char *)&Palette[0]);}; - - void Adjust(int ratio); - void Adjust(int ratio, PaletteClass const & palette); - void Partial_Adjust(int ratio, char *lut); - void Partial_Adjust(int ratio, PaletteClass const & palette, char *lut); - int Closest_Color(RGBClass const & rgb) const; - - protected: - RGBClass Palette[COLOR_COUNT]; -}; - - -#endif diff --git a/Generals/Code/Tools/WW3D/pluglib/plane.h b/Generals/Code/Tools/WW3D/pluglib/plane.h deleted file mode 100644 index 4ea15f8a28a..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/plane.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/pluglib/plane.h 8 4/22/98 6:36p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Voxel Technology * - * * - * File Name : PLANE.H * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 03/17/97 * - * * - * Last Update : March 17, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef PLANE_H -#define PLANE_H - -#ifndef VECTOR3_H -#include "vector3.h" -#endif - -/* -** PlaneClass -** -** 3D-planes. This class needs to be fleshed out but it does what I need for now. -*/ - -class PlaneClass -{ -public: - - Vector3 N; - float D; - - PlaneClass(void) : N(0.0f,0.0f,1.0f), D(0.0f) { } - PlaneClass(float a,float b,float c,float d) : N(a,b,c),D(d) { } - PlaneClass(const Vector3 & normal,float dist) : N(normal), D(dist) { } - - // Create a plane given the normal and a point on the plane - PlaneClass(const Vector3 & normal,const Vector3 & point); - - // Create a plane out of three points, ordered according to a right-hand convention. - PlaneClass(const Vector3 & point1, const Vector3 & point2, const Vector3 & point3); - - void Set(float a,float b,float c,float d) { N[0] = a; N[1] = b; N[2] = c; D = d; } -}; - -inline PlaneClass::PlaneClass(const Vector3 & normal,const Vector3 & point) -{ - N = normal; - D = Vector3::Dot_Product(normal , point); -} - -inline PlaneClass::PlaneClass(const Vector3 & point1, const Vector3 & point2, const Vector3 & point3) -{ - N = Vector3::Cross_Product((point2 - point1), (point3 - point1)); - if (N != Vector3(0.0f, 0.0f, 0.0f)) { - // Points are not colinear. Normalize N and calculate D. - N.Normalize(); - D = N * point1; - } else { - // They are colinear - return default plane (constructors can't fail). - N = Vector3(0.0f, 0.0f, 1.0f); - D = 0.0f; - } -} - -inline bool In_Front(const Vector3 & point,const PlaneClass & plane) -{ - double dist = point * plane.N; - return (dist > plane.D); -} - - - -#endif /*PLANE_H*/ \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/pluglib/rawfile.cpp b/Generals/Code/Tools/WW3D/pluglib/rawfile.cpp deleted file mode 100644 index 3b43850314c..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/rawfile.cpp +++ /dev/null @@ -1,1262 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /VSS_Sync/wwlib/rawfile.cpp $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 8/29/01 10:24p $* - * * - * $Revision:: 12 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * RawFileClass::Bias -- Bias a file with a specific starting position and length. * - * RawFileClass::Close -- Perform a closure of the file. * - * RawFileClass::Create -- Creates an empty file. * - * RawFileClass::Delete -- Deletes the file object from the disk. * - * RawFileClass::Error -- Handles displaying a file error message. * - * RawFileClass::Get_Date_Time -- Gets the date and time the file was last modified. * - * RawFileClass::Is_Available -- Checks to see if the specified file is available to open. * - * RawFileClass::Open -- Assigns name and opens file in one operation. * - * RawFileClass::Open -- Opens the file object with the rights specified. * - * RawFileClass::RawFileClass -- Simple constructor for a file object. * - * RawFileClass::Raw_Seek -- Performs a seek on the unbiased file * - * RawFileClass::Read -- Reads the specified number of bytes into a memory buffer. * - * RawFileClass::Seek -- Reposition the file pointer as indicated. * - * RawFileClass::Set_Date_Time -- Sets the date and time the file was last modified. * - * RawFileClass::Set_Name -- Manually sets the name for a file object. * - * RawFileClass::Size -- Determines size of file (in bytes). * - * RawFileClass::Write -- Writes the specified data to the buffer specified. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "always.h" -#include "rawfile.h" -#include -//#include -#include -#include -#include -#include -#include "win.h" -#include -#include -#ifdef _UNIX -#include -#include -#endif - - -#if 0 //#ifdef NEVER (gth) the MAX sdk must #define NEVER! yikes :-) - /* - ** This is a duplicate of the error numbers. The error handler for the RawFileClass handles - ** these errors. If the error routine is overridden and additional errors are defined, then - ** use numbers starting with 100. Note that these errors here are listed in numerical order. - ** These errors are defined in the standard header file "ERRNO.H". - */ - EZERO, // Non-error. - EINVFNC, // Invalid function number. - ENOFILE, // File not found. - ENOENT=ENOFILE, // No such file or directory. - ENOPATH, // Path not found. - EMFILE, // Too many open files. - EACCES, // Permission denied. - EBADF, // Bad file number. - ECONTR, // Memory blocks destroyed. - ENOMEM, // Not enough core memory. - EINVMEM, // Invalid memory block address. - EINVENV, // Invalid environment. - EINVFMT, // Invalid format. - EINVACC, // Invalid access code. - EINVDAT, // Invalid data. - EFAULT, // Unknown error. - EINVDRV, // Invalid drive specified. - ENODEV=EINVDRV, // No such device. - ECURDIR, // Attempt to remove CurDir. - ENOTSAM, // Not same device. - ENMFILE, // No more files. - EINVAL, // Invalid argument. - E2BIG, // Argument list too long. - ENOEXEC, // exec format error. - EXDEV, // Cross-device link. - ENFILE, // Too many open files. - ECHILD, // No child process. - ENOTTY, // not used - ETXTBSY, // not used - EFBIG, // not used - ENOSPC, // No space left on device. - ESPIPE, // Illegal seek. - EROFS, // Read-only file system. - EMLINK, // not used - EPIPE, // Broken pipe. - EDOM, // Math argument. - ERANGE, // Result too large. - EEXIST, // File already exists. - EDEADLOCK, // Locking violation. - EPERM, // Operation not permitted. - ESRCH, // not used - EINTR, // Interrupted function call. - EIO, // Input/output error. - ENXIO, // No such device or address. - EAGAIN, // Resource temporarily unavailable. - ENOTBLK, // not used - EBUSY, // Resource busy. - ENOTDIR, // not used - EISDIR, // not used - EUCLEAN, // not used -#endif - - -/*********************************************************************************************** - * RawFileClass::RawFileClass -- Default constructor for a file object. * - * * - * This constructs a null file object. A null file object has no file handle or filename * - * associated with it. In order to use a file object created in this fashion it must be * - * assigned a name and then opened. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/18/1994 JLB : Created. * - *=============================================================================================*/ -RawFileClass::RawFileClass(void) : - Rights(READ), - BiasStart(0), - BiasLength(-1), - Handle(NULL_HANDLE), - Filename(0), - Date(0), - Time(0), - Allocated(false) -{ -} - - - -/*********************************************************************************************** - * RawFileClass::Is_Open -- Checks to see if the file is open or not. * - * * - * Use this routine to determine if the file is open. It returns true if it is. * - * * - * INPUT: none * - * * - * OUTPUT: bool; Is the file open? * - * * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/18/1994 JLB : Created. * - *=============================================================================================*/ -bool RawFileClass::Is_Open(void) const -{ - return(Handle != NULL_HANDLE); -} - -/*********************************************************************************************** - * RawFileClass::Error -- Handles displaying a file error message. * - * * - * Display an error message as indicated. If it is allowed to retry, then pressing a key * - * will return from this function. Otherwise, it will exit the program with "exit()". * - * * - * INPUT: error -- The error number (same as the DOSERR.H error numbers). * - * * - * canretry -- Can this routine exit normally so that retrying can occur? If this is * - * false, then the program WILL exit in this routine. * - * * - * filename -- Optional filename to report with this error. If no filename is * - * supplied, then no filename is listed in the error message. * - * * - * OUTPUT: none, but this routine might not return at all if the "canretry" parameter is * - * false or the player pressed ESC. * - * * - * WARNINGS: This routine may not return at all. It handles being in text mode as well as * - * if in a graphic mode. * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - *=============================================================================================*/ -void RawFileClass::Error(int, int, char const * ) -{ -} - -/*********************************************************************************************** - * RawFileClass::Transfer_Block_Size * - * * - * This function returns the largest size a low level DOS read or write may * - * perform. Larger file transfers are performed in chunks of this size or less. * - * * - * INPUT: none * - * * - * OUTPUT: * - * * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/18/1994 JLB : Created. * - *=============================================================================================*/ -int RawFileClass::Transfer_Block_Size(void) -{ - return (int)((unsigned)UINT_MAX)-16L; -} - -/*********************************************************************************************** - * RawFileClass::RawFileClass -- Simple constructor for a file object. * - * * - * This constructor is called when a file object is created with a supplied filename, but * - * not opened at the same time. In this case, an assumption is made that the supplied * - * filename is a constant string. A duplicate of the filename string is not created since * - * it would be wasteful in that case. * - * * - * INPUT: filename -- The filename to assign to this file object. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - *=============================================================================================*/ -RawFileClass::RawFileClass(char const * filename) : - Rights(0), - BiasStart(0), - BiasLength(-1), - Handle(NULL_HANDLE), - Filename(filename), - Date(0), - Time(0), - Allocated(false) -{ -} - -/*********************************************************************************************** - * RawFileClass::~RawFileClass -- Default deconstructor for a file object. * - * * - * This constructs a null file object. A null file object has no file handle or filename * - * associated with it. In order to use a file object created in this fashion it must be * - * assigned a name and then opened. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/18/1994 JLB : Created. * - *=============================================================================================*/ -RawFileClass::~RawFileClass(void) -{ - Reset (); -} - -/*********************************************************************************************** - * RawFileClass::Reset -- Closes the file handle and resets the object's state. - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 06/10/1999 PDS : Created. * - *=============================================================================================*/ -void RawFileClass::Reset(void) -{ - Close(); - if (Allocated && Filename) { - free((char *)Filename); - Filename = NULL; - Allocated = false; - } -} - -/*********************************************************************************************** - * RawFileClass::Set_Name -- Manually sets the name for a file object. * - * * - * This routine will set the name for the file object to the name specified. This name is * - * duplicated in free store. This allows the supplied name to be a temporarily constructed * - * text string. Setting the name in this fashion doesn't affect the closed or opened state * - * of the file. * - * * - * INPUT: filename -- The filename to assign to this file object. * - * * - * OUTPUT: Returns with a pointer to the allocated copy of this filename. This pointer is * - * guaranteed to remain valid for the duration of this file object or until the name * - * is changed -- whichever is sooner. * - * * - * WARNINGS: Because of the allocation this routine must perform, memory could become * - * fragmented. * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - *=============================================================================================*/ -char const * RawFileClass::Set_Name(char const * filename) -{ - if (Filename != NULL && Allocated) { - free((char *)Filename); - Filename = NULL; - Allocated = false; - } - - if (filename == NULL) return(NULL); - - Bias(0); - - char *nameptr = strdup(filename); - if (nameptr == NULL) { - Error(ENOMEM, false, filename); - } - - /* - ** If this is a UNIX build, fix the filename from the DOS-like name passed in - */ - #ifdef _UNIX - for (int i=0; i 0) { - bytesread = 0; - - int readok=TRUE; - - #ifdef _UNIX - readok=TRUE; - bytesread=fread(buffer,1,size,Handle); - if ((bytesread == 0)&&( ! feof(Handle))) - readok=ferror(Handle); - #else - readok=ReadFile(Handle, buffer, size, &(unsigned long&)bytesread, NULL); - #endif - - - if (! readok) { - size -= bytesread; - total += bytesread; - Error(GetLastError(), true, Filename); - continue; - } - size -= bytesread; - total += bytesread; - if (bytesread == 0) break; - } - bytesread = total; - - /* - ** Close the file if it was opened by this routine and return - ** the actual number of bytes read into the buffer. - */ - if (opened) Close(); - return(bytesread); -} - - -/*********************************************************************************************** - * RawFileClass::Write -- Writes the specified data to the buffer specified. * - * * - * This routine will write the data specified to the file. * - * * - * INPUT: buffer -- The buffer that holds the data to write. * - * * - * size -- The number of bytes to write to the file. * - * * - * OUTPUT: Returns with the number of bytes written to the file. This routine catches the * - * case of a disk full condition, so this routine will always return with the number * - * matching the size request. * - * * - * WARNINGS: A fatal file condition could cause this routine to never return. * - * * - * HISTORY: * - * 10/18/1994 JLB : Created. * - *=============================================================================================*/ -int RawFileClass::Write(void const * buffer, int size) -{ - long byteswritten = 0; - int opened = false; // Was the file manually opened? - - /* - ** Check to open status of the file. If the file is open, then merely write to - ** it. Otherwise, open the file for writing and then close the file when the - ** output is finished. - */ - if (!Is_Open()) { - if (!Open(WRITE)) { - return(0); - } - opened = true; - } - - int writeok=TRUE; - #ifdef _UNIX - byteswritten = fwrite(buffer, 1, size, Handle); - if (byteswritten != size) - writeok = FALSE; - #else - writeok=WriteFile(Handle, buffer, size, &(unsigned long&)byteswritten, NULL); - #endif - - if (! writeok) { - Error(GetLastError(), false, Filename); - } - - /* - ** Fixup the bias length if necessary. - */ - if (BiasLength != -1) { - if (Raw_Seek(0) > BiasStart+BiasLength) { - BiasLength = Raw_Seek(0) - BiasStart; - } - } - - /* - ** If this routine had to open the file, then close it before returning. - */ - if (opened) { - Close(); - } - - /* - ** Return with the number of bytes written. This will always be the number of bytes - ** requested, since the case of the disk being full is caught by this routine. - */ - return(byteswritten); -} - - -/*********************************************************************************************** - * RawFileClass::Seek -- Reposition the file pointer as indicated. * - * * - * Use this routine to move the filepointer to the position indicated. It can move either * - * relative to current position or absolute from the beginning or ending of the file. This * - * routine will only return if it successfully performed the seek. * - * * - * INPUT: pos -- The position to seek to. This is interpreted as relative to the position * - * indicated by the "dir" parameter. * - * * - * dir -- The relative position to relate the seek to. This can be either SEEK_SET * - * for the beginning of the file, SEEK_CUR for the current position, or * - * SEEK_END for the end of the file. * - * * - * OUTPUT: This routine returns the position that the seek ended up at. * - * * - * WARNINGS: If there was a file error, then this routine might never return. * - * * - * HISTORY: * - * 10/18/1994 JLB : Created. * - *=============================================================================================*/ -int RawFileClass::Seek(int pos, int dir) -{ - - /* - ** A file that is biased will have a seek operation modified so that the file appears to - ** exist only within the bias range. All bytes outside of this range appear to be - ** non-existant. - */ - if (BiasLength != -1) { - switch (dir) { - case SEEK_SET: - if (pos > BiasLength) { - pos = BiasLength; - } - pos += BiasStart; - break; - - case SEEK_CUR: - break; - - case SEEK_END: - dir = SEEK_SET; - pos += BiasStart + BiasLength; -// pos = (pos <= BiasStart+BiasLength) ? pos : BiasStart+BiasLength; -// pos = (pos >= BiasStart) ? pos : BiasStart; - break; - } - - /* - ** Perform the modified raw seek into the file. - */ - long newpos = Raw_Seek(pos, dir) - BiasStart; - - /* - ** Perform a final double check to make sure the file position fits with the bias range. - */ - if (newpos < 0) { - newpos = Raw_Seek(BiasStart, SEEK_SET) - BiasStart; - } - if (newpos > BiasLength) { - newpos = Raw_Seek(BiasStart+BiasLength, SEEK_SET) - BiasStart; - } - return(newpos); - } - - /* - ** If the file is not biased in any fashion, then the normal seek logic will - ** work just fine. - */ - return(Raw_Seek(pos, dir)); -} - - -/*********************************************************************************************** - * RawFileClass::Size -- Determines size of file (in bytes). * - * * - * Use this routine to determine the size of the file. The file must exist or this is an * - * error condition. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the number of bytes in the file. * - * * - * WARNINGS: This routine handles error conditions and will not return unless the file * - * exists and can successfully be queried for file length. * - * * - * HISTORY: * - * 10/18/1994 JLB : Created. * - *=============================================================================================*/ -int RawFileClass::Size(void) -{ - int size = 0; - - /* - ** A biased file already has its length determined. - */ - if (BiasLength != -1) { - return(BiasLength); - } - - /* - ** If the file is open, then proceed normally. - */ - if (Is_Open()) { - - #ifdef _UNIX - fpos_t curpos,startpos,endpos; - fgetpos(Handle,&curpos); - - fseek(Handle,0,SEEK_SET); - fgetpos(Handle,&startpos); - - fseek(Handle,0,SEEK_END); - fgetpos(Handle,&endpos); - - size=endpos-startpos; - fsetpos(Handle,&curpos); - #else - size = GetFileSize(Handle, NULL); - #endif - - /* - ** If there was in internal error, then call the error function. - */ - if (size == 0xFFFFFFFF) { - Error(GetLastError(), false, Filename); - } - - } else { - - /* - ** If the file wasn't open, then open the file and call this routine again. Count on - ** the fact that the open function must succeed. - */ - if (Open()) { - size = Size(); - - /* - ** Since we needed to open the file we must remember to close the file when the - ** size has been determined. - */ - Close(); - } - } - - BiasLength = size-BiasStart; - return(BiasLength); -} - - -/*********************************************************************************************** - * RawFileClass::Create -- Creates an empty file. * - * * - * This routine will create an empty file from the file object. The file object's filename * - * must already have been assigned before this routine will function. * - * * - * INPUT: none * - * * - * OUTPUT: bool; Was the file successfully created? This routine will always return true. * - * * - * WARNINGS: A fatal error condition could occur with this routine. Especially if the disk * - * is full or a read-only media was selected. * - * * - * HISTORY: * - * 10/18/1994 JLB : Created. * - *=============================================================================================*/ -int RawFileClass::Create(void) -{ - Close(); - if (Open(WRITE)) { - - /* - ** A biased file must be at least as long as the bias offset. Seeking to the - ** appropriate start offset has the effect of lengthening the file to the - ** correct length. - */ - if (BiasLength != -1) { - Seek(0, SEEK_SET); - } - - Close(); - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * RawFileClass::Delete -- Deletes the file object from the disk. * - * * - * This routine will delete the file object from the disk. If the file object doesn't * - * exist, then this routine will return as if it had succeeded (since the effect is the * - * same). * - * * - * INPUT: none * - * * - * OUTPUT: bool; Was the file deleted? If the file was already missing, the this value will * - * be false. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/18/1994 JLB : Created. * - *=============================================================================================*/ -int RawFileClass::Delete(void) -{ - /* - ** If the file was open, then it must be closed first. - */ - Close(); - - /* - ** If there is no filename associated with this object, then this indicates a fatal error - ** condition. Report this and abort. - */ - if (!Filename) { - Error(ENOENT, false); - } - - /* - ** Repetitively try to delete the file if possible. Either return with success, or - ** abort the program with an error. - */ - for (;;) { - - /* - ** If the file is already missing, then return with this fact. No action is necessary. - ** This can occur as this section loops if the file exists on a floppy and the floppy - ** was removed, the file deleted on another machine, and then the floppy was - ** reinserted. Admittedly, this is a rare case, but is handled here. - */ - if (!Is_Available()) { - return(false); - } - - int deleteok; - #ifdef _UNIX - deleteok=(unlink(Filename)==0)?TRUE:FALSE; - #else - deleteok=DeleteFile(Filename); - #endif - - if (! deleteok) { - Error(GetLastError(), false, Filename); - return(false); - } - break; - } - - /* - ** DOS reports that the file was successfully deleted. Return with this fact. - */ - return(true); -} - - -/*********************************************************************************************** - * RawFileClass::Get_Date_Time -- Gets the date and time the file was last modified. * - * * - * Use this routine to get the date and time of the file. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the file date and time as a long. * - * Use the YEAR(long), MONTH(),.... * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 11/14/1995 DRD : Created. * - * 07/13/1996 JLB : Handles win32 method. * - *=============================================================================================*/ -unsigned long RawFileClass::Get_Date_Time(void) -{ -#ifdef _UNIX - struct stat statbuf; - lstat(Filename, &statbuf); - return(statbuf.st_mtime); -#else - BY_HANDLE_FILE_INFORMATION info; - - if (GetFileInformationByHandle(Handle, &info)) { - WORD dosdate; - WORD dostime; - FileTimeToDosDateTime(&info.ftLastWriteTime, &dosdate, &dostime); - return((dosdate << 16) | dostime); - } - return(0); -#endif -} - - -/*********************************************************************************************** - * RawFileClass::Set_Date_Time -- Sets the date and time the file was last modified. * - * * - * Use this routine to set the date and time of the file. * - * * - * INPUT: the file date and time as a long * - * * - * OUTPUT: successful or not if the file date and time was changed. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 11/14/1995 DRD : Created. * - * 07/13/1996 JLB : Handles win 32 method * - *=============================================================================================*/ -bool RawFileClass::Set_Date_Time(unsigned long datetime) -{ -#ifdef _UNIX - assert(0); - return(false); -#else - if (RawFileClass::Is_Open()) { - BY_HANDLE_FILE_INFORMATION info; - - if (GetFileInformationByHandle(Handle, &info)) { - FILETIME filetime; - if (DosDateTimeToFileTime((WORD)(datetime >> 16), (WORD)(datetime & 0x0FFFF), &filetime)) { - return(SetFileTime(Handle, &info.ftCreationTime, &filetime, &filetime) != 0); - } - } - } - return(false); -#endif -} - - -/*********************************************************************************************** - * RawFileClass::Bias -- Bias a file with a specific starting position and length. * - * * - * This will bias a file by giving it an artificial starting position and length. By * - * using this routine, it is possible to 'fool' the file into ignoring a header and * - * trailing extra data. An example of this would be a file inside of a mixfile. * - * * - * INPUT: start -- The starting offset that will now be considered the start of the * - * file. * - * * - * length -- The forced length of the file. For files that are opened for write, * - * this serves as the artificial constraint on the file's length. For * - * files opened for read, this limits the usable file size. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 06/02/1996 JLB : Created. * - *=============================================================================================*/ -void RawFileClass::Bias(int start, int length) -{ - if (start == 0) { - BiasStart = 0; - BiasLength = -1; - return; - } - - BiasLength = RawFileClass::Size(); - BiasStart += start; - if (length != -1) { - BiasLength = BiasLength < length ? BiasLength : length; - } - BiasLength = BiasLength > 0 ? BiasLength : 0; - - /* - ** Move the current file offset to a legal position if necessary and the - ** file was open. - */ - if (Is_Open()) { - RawFileClass::Seek(0, SEEK_SET); - } -} - - -/*********************************************************************************************** - * RawFileClass::Raw_Seek -- Performs a seek on the unbiased file * - * * - * This will perform a seek on the file as if it were unbiased. This is in spite of any * - * bias setting the file may have. The ability to perform a raw seek in this fasion is * - * necessary to maintain the bias ability. * - * * - * INPUT: pos -- The position to seek the file relative to the "dir" parameter. * - * * - * dir -- The origin of the seek operation. * - * * - * OUTPUT: Returns with the new position of the seek operation. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 08/04/1996 JLB : Created. * - *=============================================================================================*/ -int RawFileClass::Raw_Seek(int pos, int dir) -{ - /* - ** If the file isn't opened, then this is a fatal error condition. - */ - if (!Is_Open()) { - Error(EBADF, false, Filename); - } - - #ifdef _UNIX - pos=fseek(Handle, pos, dir); - #else - switch (dir) { - case SEEK_SET: - dir = FILE_BEGIN; - break; - - case SEEK_CUR: - dir = FILE_CURRENT; - break; - - case SEEK_END: - dir = FILE_END; - break; - } - pos = SetFilePointer(Handle, pos, NULL, dir); - #endif - - /* - ** If there was an error in the seek, then bail with an error condition. - */ - if (pos == 0xFFFFFFFF) { - Error(GetLastError(), false, Filename); - } - - /* - ** Return with the new position of the file. This will range between zero and the number of - ** bytes the file contains. - */ - return(pos); -} - -/*********************************************************************************************** - * RawFileClass::Attach -- Provides a file handle for the class to use. - * * - * INPUT: handle -- the Win32 file handle. - * * - * OUTPUT: - * * - * WARNINGS: none * - * * - * HISTORY: * - * 06/10/1999 PDS : Created. * - *=============================================================================================*/ -void RawFileClass::Attach (void *handle, int rights) -{ - Reset (); - - Rights = rights; - BiasStart = 0; - BiasLength = -1; - Date = 0; - Time = 0; - Allocated = false; - - #ifdef _UNIX - Handle = (FILE *)handle; - #else - Handle = handle; - #endif -} - -/*********************************************************************************************** - * RawFileClass::Detach -- Removes the file handle from the object without closing the handle. - * * - * INPUT - * * - * OUTPUT: - * * - * WARNINGS: none * - * * - * HISTORY: * - * 06/10/1999 PDS : Created. * - *=============================================================================================*/ -void RawFileClass::Detach (void) -{ - Rights = 0; - BiasStart = 0; - BiasLength = -1; - Date = 0; - Time = 0; - Allocated = false; - Handle = NULL_HANDLE; -} - diff --git a/Generals/Code/Tools/WW3D/pluglib/rawfile.h b/Generals/Code/Tools/WW3D/pluglib/rawfile.h deleted file mode 100644 index 0cbfa37ae53..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/rawfile.h +++ /dev/null @@ -1,205 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/rawfile.h $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 10/04/99 10:25a $* - * * - * $Revision:: 8 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * RawFileClass::File_Name -- Returns with the filename associate with the file object. * - * RawFileClass::RawFileClass -- Default constructor for a file object. * - * RawFileClass::~RawFileClass -- Default deconstructor for a file object. * - * RawFileClass::Is_Open -- Checks to see if the file is open or not. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef RAWFILE_Hx -#define RAWFILE_Hx - -//#include - -// #include "win.h" - -#ifdef _UNIX -#include -#include "osdep.h" - #define NULL_HANDLE NULL - #define HANDLE_TYPE FILE* -#else - #define NULL_HANDLE INVALID_HANDLE_VALUE - #define HANDLE_TYPE HANDLE -#endif - -#include "wwfile.h" - - -#ifndef WWERROR -#define WWERROR -1 -#endif - -/* -** This is the definition of the raw file class. It is derived from the abstract base FileClass -** and handles the interface to the low level DOS routines. This is the first class in the -** chain of derived file classes that actually performs a useful function. With this class, -** I/O is possible. More sophisticated features, such as packed files, CD-ROM support, -** file caching, and XMS/EMS memory support, are handled by derived classes. -** -** Of particular importance is the need to override the error routine if more sophisticated -** error handling is required. This is more than likely if greater functionality is derived -** from this base class. -*/ -class RawFileClass : public FileClass -{ - typedef FileClass BASECLASS; - - public: - - /* - ** This is a record of the access rights used to open the file. These rights are - ** used if the file object is duplicated. - */ - int Rights; - - RawFileClass(char const *filename); - RawFileClass(void); - RawFileClass (RawFileClass const & f); - RawFileClass & operator = (RawFileClass const & f); - virtual ~RawFileClass(void); - - virtual char const * File_Name(void) const; - virtual char const * Set_Name(char const *filename); - virtual int Create(void); - virtual int Delete(void); - virtual bool Is_Available(int forced=false); - virtual bool Is_Open(void) const; - virtual int Open(char const *filename, int rights=READ); - virtual int Open(int rights=READ); - virtual int Read(void *buffer, int size); - virtual int Seek(int pos, int dir=SEEK_CUR); - virtual int Size(void); - virtual int Write(void const *buffer, int size); - virtual void Close(void); - virtual unsigned long Get_Date_Time(void); - virtual bool Set_Date_Time(unsigned long datetime); - virtual void Error(int error, int canretry = false, char const * filename=NULL); - - void Bias(int start, int length=-1); - - virtual void * Get_File_Handle(void) { return Handle; } - - virtual void Attach (void *handle, int rights=READ); - virtual void Detach (void); - - /* - ** These bias values enable a sub-portion of a file to appear as if it - ** were the whole file. This comes in very handy for multi-part files such as - ** mixfiles. - */ - int BiasStart; - int BiasLength; - - protected: - - /* - ** This function returns the largest size a low level DOS read or write may - ** perform. Larger file transfers are performed in chunks of this size or less. - */ - int Transfer_Block_Size(void); - - int Raw_Seek(int pos, int dir=SEEK_CUR); - void Reset(void); - - private: - - /* - ** This is the low level DOS handle. A -1 indicates an empty condition. - */ - #ifdef _UNIX - FILE* Handle; - #else - void * Handle; - #endif - - /* - ** This points to the filename as a NULL terminated string. It may point to either a - ** constant or an allocated string as indicated by the "Allocated" flag. - */ - char const * Filename; - - // - // file date and time are in the following formats: - // - // date bits 0-4 day (0-31) - // bits 5-8 month (1-12) - // bits 9-15 year (0-119 representing 1980-2099) - // - // time bits 0-4 second/2 (0-29) - // bits 5-10 minutes (0-59) - // bits 11-15 hours (0-23) - // - unsigned short Date; - unsigned short Time; - - /* - ** Filenames that were assigned as part of the construction process - ** are not allocated. It is assumed that the filename string is a - ** constant in that case and thus making duplication unnecessary. - ** This value will be non-zero if the filename has be allocated - ** (using strdup()). - */ - bool Allocated; -}; - - -/*********************************************************************************************** - * RawFileClass::File_Name -- Returns with the filename associate with the file object. * - * * - * Use this routine to determine what filename is associated with this file object. If no * - * filename has yet been assigned, then this routing will return NULL. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with a pointer to the file name associated with this file object or NULL * - * if one doesn't exist. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/18/1994 JLB : Created. * - *=============================================================================================*/ -inline char const * RawFileClass::File_Name(void) const -{ - return(Filename); -} - - - -#endif diff --git a/Generals/Code/Tools/WW3D/pluglib/realcrc.cpp b/Generals/Code/Tools/WW3D/pluglib/realcrc.cpp deleted file mode 100644 index 9da812b1645..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/realcrc.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Westwood Library * - * * - * $Archive:: /Commando/Code/wwlib/realcrc.cpp $* - * * - * Author:: Byon Garrabrant * - * * - * $Modtime:: 7/09/99 1:44p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * CRC_Memory -- calculates a CRC for a block of memory * - * CRC_String -- Calculates a CRC for a NULL-terminated string * - * CRC_Stringi -- Calculates a CRC for a string, case-insensitive * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "realcrc.h" -#include - -// CRC for poly 0x04C11DB7 -unsigned long CRC32_Table[ 256 ] = -{ - 0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL, - 0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L, - 0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L, - 0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L, - 0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL, - 0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L, - 0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL, - 0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L, - 0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L, - 0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL, - 0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L, - 0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L, - 0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L, - 0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL, - 0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L, - 0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL, - 0x76DC4190L, 0x01DB7106L, 0x98D220BCL, 0xEFD5102AL, - 0x71B18589L, 0x06B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L, - 0x7807C9A2L, 0x0F00F934L, 0x9609A88EL, 0xE10E9818L, - 0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L, - 0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL, - 0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L, - 0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL, - 0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L, - 0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L, - 0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL, - 0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L, - 0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L, - 0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L, - 0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL, - 0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L, - 0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL, - 0xEDB88320L, 0x9ABFB3B6L, 0x03B6E20CL, 0x74B1D29AL, - 0xEAD54739L, 0x9DD277AFL, 0x04DB2615L, 0x73DC1683L, - 0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L, - 0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L, - 0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL, - 0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L, - 0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL, - 0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L, - 0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L, - 0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL, - 0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L, - 0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L, - 0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L, - 0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL, - 0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L, - 0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL, - 0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x026D930AL, - 0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L, - 0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L, - 0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L, - 0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL, - 0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L, - 0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL, - 0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L, - 0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L, - 0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL, - 0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L, - 0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L, - 0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L, - 0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL, - 0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L, - 0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL -}; - -#define CRC32(c,crc) (CRC32_Table[((unsigned long)(crc) ^ (c)) & 0xFFL] ^ (((crc) >> 8) & 0x00FFFFFFL)) - - -/*********************************************************************************************** - * CRC_Memory -- calculates a CRC for a block of memory * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -unsigned long CRC_Memory( const unsigned char *data, unsigned long length, unsigned long crc ) -{ - crc ^= 0xFFFFFFFF; // invert previous CRC - while ( length-- ) { - crc = CRC32( *data++, crc ); // calc crc for each byte - } - return (crc ^ 0xFFFFFFFF); // invert new CRC and return it -} - - -/*********************************************************************************************** - * CRC_String -- Calculates a CRC for a NULL-terminated string * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -unsigned long CRC_String( const char *string, unsigned long crc ) -{ - crc ^= 0xFFFFFFFF; // invert previous CRC - while ( *string ) { - crc = CRC32( *string++, crc ); // calc crc for each byte - } - return (crc ^ 0xFFFFFFFF); // invert new CRC and return it -} - - -/*********************************************************************************************** - * CRC_Stringi -- Calculates a CRC for a string, case-insensitive * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -unsigned long CRC_Stringi( const char *string, unsigned long crc ) -{ - crc ^= 0xFFFFFFFF; // invert previous CRC - while ( *string ) { - char c = (char)toupper(*string++); - crc = CRC32( c, crc ); // calc crc for each byte - } - return (crc ^ 0xFFFFFFFF); // invert new CRC and return it -} diff --git a/Generals/Code/Tools/WW3D/pluglib/realcrc.h b/Generals/Code/Tools/WW3D/pluglib/realcrc.h deleted file mode 100644 index 793692934f2..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/realcrc.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Westwood Library * - * * - * $Archive:: /G/wwlib/realcrc.h $* - * * - * Author:: Byon Garrabrant * - * * - * $Modtime:: 4/02/99 12:00p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef REALCRC_H -#define REALCRC_H - - -unsigned long CRC_Memory( const unsigned char *data, unsigned long length, unsigned long crc = 0 ); -unsigned long CRC_String( const char *string, unsigned long crc = 0 ); -unsigned long CRC_Stringi( const char *string, unsigned long crc = 0 ); - - -#endif diff --git a/Generals/Code/Tools/WW3D/pluglib/rgb.cpp b/Generals/Code/Tools/WW3D/pluglib/rgb.cpp deleted file mode 100644 index 3249f90e71d..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/rgb.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/RGB.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * RGBClass::Adjust -- Adjust one RGB value toward another. * - * RGBClass::Difference -- Determines the "distance" between two colors. * - * RGBClass::operator HSVClass -- Conversion operator for RGB to HSV object. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "hsv.h" -#include "palette.h" -#include "rgb.h" - -RGBClass const BlackColor(0, 0, 0); - - -/*********************************************************************************************** - * RGBClass::Adjust -- Adjust one RGB value toward another. * - * * - * This routine is used to modify an RGB value to proportionately match another RGB value * - * according to the ratio parameter specified. Typical use of this routine is in palette * - * fading from one palette to another or to black. * - * * - * INPUT: ratio -- The ration of transformation. This value is in the form of 0 to 255, * - * with 0 being no change, and 255 being 100% transformed into the * - * destination color. * - * * - * rgb -- Reference to the destination RGB color to transform this color into. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -void RGBClass::Adjust(int ratio, RGBClass const & rgb) -{ - /* - ** Ratio conversion is limited to 0 through 100%. This is - ** the range of 0 to 255. - */ - ratio &= 0x00FF; - - - /* - ** Adjust the color guns by the ratio specified toward the - ** destination color. - */ - int value = (int)rgb.Red - (int)Red; - Red = (unsigned char)((int)Red + (value * ratio) / 256); - - value = (int)rgb.Green - (int)Green; - Green = (unsigned char)((int)Green + (value * ratio) / 256); - - value = (int)rgb.Blue - (int)Blue; - Blue = (unsigned char)((int)Blue + (value * ratio) / 256); -} - - -/*********************************************************************************************** - * RGBClass::Difference -- Determines the "distance" between two colors. * - * * - * This routine is used to calculate a relative distance between two colors. The value is * - * relative only to itself and thus is useful only for determining the magnitude of * - * color difference rather than the nature of the color difference. Palette remapping * - * code uses this routine to find closest matches for colors. * - * * - * INPUT: rgb -- Reference to the color to be compared to this color. * - * * - * OUTPUT: Returns the difference between the two colors. The value returned is zero if the * - * colors exactly match. The greater the positive value the greater the difference * - * between the colors. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -int RGBClass::Difference(RGBClass const & rgb) const -{ - int r = (int)Red - (int)rgb.Red; - if (r < 0) r = -r; - - int g = (int)Green - (int)rgb.Green; - if (g < 0) g = -g; - - int b = (int)Blue - (int)rgb.Blue; - if (b < 0) b = -b; - - /* - ** At first crack, the difference algorithm might be coded as the sum of the color differences - ** (or sum of the square of the color distances). However, this would not take advantage of the - ** fact that the human eye is most sensative to green, followed by the color blue. With this - ** thought in mind, the following difference algorithm is used. - */ - return(4*g + 3*b + 2*r); -} - - -/*********************************************************************************************** - * RGBClass::operator HSVClass -- Conversion operator for RGB to HSV object. * - * * - * This conversion operator will convert an RGBClass object into an HSVClass object. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with a reference (implicit) to the HSVClass object that most closely * - * represents the RGBClass object. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/20/1996 JLB : Created. * - *=============================================================================================*/ -RGBClass::operator HSVClass (void) const -{ - int hue; - int saturation; - int value; - - /* - ** Fetch working component values for the color guns. - */ - int red = Get_Red(); - int green = Get_Green(); - int blue = Get_Blue(); - - /* - ** The hue defaults to none. Only if there is a saturation value will the - ** hue be calculated. - */ - hue = 0; - - /* - ** Set the value (brightness) to match the brightest color gun. - */ - value = (red > green) ? red : green; - if (blue > value) value = blue; - - /* - ** Determine the amount of true white present in the color. This is the - ** minimum color gun value. The white component is used to determine - ** color saturation. - */ - int white = (red < green) ? red : green; - if (blue < white) white = blue; - - /* - ** Determine the saturation (intensity) of the color by comparing the - ** ratio of true white as a component of the overall color. The more - ** white component, the less saturation. - */ - saturation = 0; - if (value) { - saturation = ((value - white) * 255) / value; - } - - /* - ** If there is any saturation at all, then the hue must be calculated. The - ** hue is based on a six sided color wheel. - */ - if (saturation != 0) { - unsigned int tmp = value - white; - unsigned int r1 = ((value - red) * 255) / tmp; - unsigned int g1 = ((value - green) * 255) / tmp; - unsigned int b1 = ((value - blue) * 255) / tmp; - - // Find effect of second most predominant color. - // In which section of the hexagon of colors does the color lie? - if (value == red) { - if (white == green) { - tmp = 5 * 256 + b1; - } else { - tmp = 1 * 256 - g1; - } - } else { - if (value == green) { - if (white == blue) { - tmp = 1 * 256 + r1; - } else { - tmp = 3 * 256 - b1; - } - } else { - if (white == red) { - tmp = 3 * 256 + g1; - } else { - tmp = 5 * 256 - r1; - } - } - } - - // Divide by six and round. - hue = tmp / 6; - } - - HSVClass hsv((unsigned char)hue, (unsigned char)saturation, (unsigned char)value); - return(hsv); -} - diff --git a/Generals/Code/Tools/WW3D/pluglib/rgb.h b/Generals/Code/Tools/WW3D/pluglib/rgb.h deleted file mode 100644 index 3b001a8298c..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/rgb.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/RGB.H $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 12:00p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef RGB_H -#define RGB_H - -class PaletteClass; -class HSVClass; - - -/* -** Each color entry is represented by this class. It holds the values for the color -** guns. The gun values are recorded in device dependant format, but the interface -** uses gun values from 0 to 255. -*/ -class RGBClass -{ - public: - RGBClass(void) : Red(0), Green(0), Blue(0) {} - RGBClass(unsigned char red, unsigned char green, unsigned char blue) : Red(red), Green(green), Blue(blue) {} - operator HSVClass (void) const; - RGBClass & operator = (RGBClass const & rgb) { - if (this == &rgb) return(*this); - - Red = rgb.Red; - Green = rgb.Green; - Blue = rgb.Blue; - return(*this); - } - - enum { - MAX_VALUE=255 - }; - - void Adjust(int ratio, RGBClass const & rgb); - int Difference(RGBClass const & rgb) const; - int Get_Red(void) const {return (Red);} - int Get_Green(void) const {return(Green);} - int Get_Blue(void) const {return(Blue);} - void Set_Red(unsigned char value) {Red = value;} - void Set_Green(unsigned char value) {Green = value;} - void Set_Blue(unsigned char value) {Blue = value;} - - private: - - friend class PaletteClass; - - /* - ** These hold the actual color gun values in machine independant scale. This - ** means the values range from 0 to 255. - */ - unsigned char Red; - unsigned char Green; - unsigned char Blue; -}; - -extern RGBClass const BlackColor; - -#endif diff --git a/Generals/Code/Tools/WW3D/pluglib/uarray.h b/Generals/Code/Tools/WW3D/pluglib/uarray.h deleted file mode 100644 index cc2918599d2..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/uarray.h +++ /dev/null @@ -1,228 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Library * - * * - * $Archive:: /G/wwlib/uarray.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 9/24/99 1:56p $* - * * - * $Revision:: 7 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * UniqueArrayClass::UniqueArrayClass -- constructor * - * UniqueArrayClass::~UniqueArrayClass -- destructor * - * UniqueArrayClass::Add -- Add an item to the array * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef UARRAY_H -#define UARRAY_H - -#ifndef HASHCALC_H -#include "hashcalc.h" -#endif - -#ifndef VECTOR_H -#include "Vector.H" -#endif - - -/* -** UniqueArrayClass -** This template class can be used to generate an array of unique objects -** amongst a huge list of objects which may or may not be unique. However, -** in order to use the UniqueArrayClass, you will need to implement a -** HashCalculatorClass for the type you are using. -** -** Note that the UniqueArrayClass does *copies* of the objects you are -** giving it. It is meant to be used with relatively lightweight objects. -*/ -template class UniqueArrayClass -{ - -public: - - UniqueArrayClass(int initialsize,int growthrate,HashCalculatorClass * hasher); - ~UniqueArrayClass(void); - - int Add(const T & new_item); - - int Count(void) const { return Get_Unique_Count(); } - int Get_Unique_Count(void) const { return UniqueItems.Count(); } - const T & Get(int index) const { return UniqueItems[index].Item; } - const T & operator [] (int index) const { return Get(index); } - -private: - - enum { NO_ITEM = 0xFFFFFFFF }; - - class HashItem - { - public: - T Item; - int NextHashIndex; - - bool operator == (const HashItem & that) { return ((Item == that.Item) && (NextHashIndex == that.NextHashIndex)); } - bool operator != (const HashItem & that) { return !(*this == that); } - }; - - // Dynamic Vector of the unique items: - DynamicVectorClass UniqueItems; - - // Hash table: - int HashTableSize; - int * HashTable; - - // object which does the hashing for the type - HashCalculatorClass * HashCalculator; - - friend class VectorClass; - friend class DynamicVectorClass; -}; - - - -/*********************************************************************************************** - * UniqueArrayClass::UniqueArrayClass -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/29/98 GTH : Created. * - *=============================================================================================*/ -template -UniqueArrayClass::UniqueArrayClass(int initial_size,int growth_rate,HashCalculatorClass * hasher) : - UniqueItems(initial_size), - HashCalculator(hasher) -{ - // set the growth rate. - UniqueItems.Set_Growth_Step(growth_rate); - - // sizing and allocating the actual hash table - int bits = HashCalculator->Num_Hash_Bits(); - assert(bits > 0); - assert(bits < 24); - HashTableSize = 1<::~UniqueArrayClass -- destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/29/98 GTH : Created. * - *=============================================================================================*/ -template -UniqueArrayClass::~UniqueArrayClass(void) -{ - if (HashTable != NULL) { - delete[] HashTable; - HashTable = NULL; - } -} - - -/*********************************************************************************************** - * UniqueArrayClass::Add -- Add an item to the array * - * * - * Only adds the item to the end of the array if another duplicate item is not found. Returns * - * the array index of where the item is stored. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/29/98 GTH : Created. * - *=============================================================================================*/ -template -inline int UniqueArrayClass::Add(const T & new_item) -{ - /* - ** Use the hash table to quickly (hopefully :-) detect - ** whether this item is already in the array - */ - int num_hash_vals; - HashCalculator->Compute_Hash(new_item); - num_hash_vals = HashCalculator->Num_Hash_Values(); - - unsigned int lasthash = 0xFFFFFFFF; - unsigned int hash; - - for (int hidx = 0; hidx < num_hash_vals; hidx++) { - hash = HashCalculator->Get_Hash_Value(hidx); - if (hash != lasthash) { - - int test_item_index = HashTable[hash]; - - while (test_item_index != 0xFFFFFFFF) { - if (HashCalculator->Items_Match(UniqueItems[test_item_index].Item,new_item)) { - return test_item_index; - } - test_item_index = UniqueItems[test_item_index].NextHashIndex; - } - } - lasthash = hash; - } - - /* - ** Ok, this is a new item so add it (copy it!) into the array - */ - int index = UniqueItems.Count(); - int hash_index = HashCalculator->Get_Hash_Value(0); - - HashItem entry; - entry.Item = new_item; - entry.NextHashIndex = HashTable[hash_index]; - HashTable[hash_index] = index; - - UniqueItems.Add(entry); - - return index; -} - - -#endif // UARRAY_H - diff --git a/Generals/Code/Tools/WW3D/pluglib/vector2.h b/Generals/Code/Tools/WW3D/pluglib/vector2.h deleted file mode 100644 index 1c9b96ceca1..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/vector2.h +++ /dev/null @@ -1,640 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/wwmath/vector2.h 19 9/01/00 5:30p Ian_l $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Westwood 3D * - * * - * File Name : VECTOR2.H * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 02/24/97 * - * * - * Last Update : February 24, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Scalar Division Operator -- Divide a vector by a scalar * - * Scalar Multiply Operator -- Multiply a vector by a scalar * - * Vector Addition Operator -- Add two vectors * - * Vector Subtraction Operator -- Subract two vectors * - * Vector Inner Product Operator -- Compute the inner or dot product * - * Vector Equality Operator -- Detemine if two vectors are identical * - * Equal_Within_Epsilon -- Determine if two vectors are identical within * - * Vector Inequality Operator -- Detemine if two vectors are identical * - * Swap -- swap two Vector2's * - * Vector2::Is_Valid -- Verifies that all components are valid floats * - * Vector2::Update_Min -- sets each component of the vector to the min of this and a. * - * Vector2::Update_Max -- sets each component of the vector to the max of this and a. * - * Vector2::Scale -- multiply components of a vector by independant scaling factors. * - * Vector2::Lerp -- linearly interpolates two Vector2's * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef VECTOR2_H -#define VECTOR2_H - -#include "always.h" -#include "wwmath.h" -#include - - -/* -** 2-Dimensional Vectors -*/ - -class Vector2 -{ - -public: - - union { - float X; - float U; - }; - - union { - float Y; - float V; - }; - - // Constructors - Vector2(void) {}; - Vector2(const Vector2 & v) { X = v.X; Y = v.Y; } - Vector2(float x, float y) { X = x; Y = y; } - Vector2(const float vector[2]) { X = vector[0]; Y = vector[1]; } - - - // Assignment - Vector2 & operator = (const Vector2 & v) { X = v[0]; Y = v[1]; return *this; } - void Set(float x, float y) { X = x; Y = y; } - void Set(const Vector2 & v) { X = v.X; Y = v.Y; } - - // Array access - float & operator [](int i) { return (&X)[i]; } - const float & operator [](int i) const { return (&X)[i]; } - - // normalize, compute length - void Normalize(void); - float Length(void) const; - float Length2(void) const; - - // unary operators - Vector2 operator-() const { return Vector2(-X,-Y); } - Vector2 operator+() const { return *this; } - - Vector2 & operator += (const Vector2 & v) { X += v.X; Y += v.Y; return *this; } - Vector2 & operator -= (const Vector2 & v) { X -= v.X; Y -= v.Y; return *this; } - Vector2 & operator *= (float k) { X = (float)(X*k); Y=(float)(Y*k); return *this; } - Vector2 & operator /= (float k) { k=1.0f/k; X*=k; Y*=k; return *this; } - - // scalar multiplication, division - friend Vector2 operator * (const Vector2 &a,float k); - friend Vector2 operator * (float k,const Vector2 &a); - friend Vector2 operator / (const Vector2 &a,float k); - - // vector addition,subtraction - friend Vector2 operator + (const Vector2 &a,const Vector2 &b); - friend Vector2 operator - (const Vector2 &a,const Vector2 &b); - - // dot product / inner product - friend float operator * (const Vector2 &a,const Vector2 &b); - static float Dot_Product(const Vector2 &a,const Vector2 &b); - - // dot product between a and perpendicular vector to b - static float Perp_Dot_Product(const Vector2 &a,const Vector2 &b); - - // Equality operators - friend bool operator == (const Vector2 &a,const Vector2 &b); - friend bool operator != (const Vector2 &a,const Vector2 &b); - friend bool Equal_Within_Epsilon(const Vector2 &a,const Vector2 &b,float epsilon); - - // Rotation - void Rotate(float theta); - void Rotate(float s, float c); - bool Rotate_Towards_Vector(Vector2 &target, float max_theta, bool & positive_turn); - bool Rotate_Towards_Vector(Vector2 &target, float max_s, float max_c, bool & positive_turn); - - // verify that none of the members of this vector are invalid floats - bool Is_Valid(void) const; - - // make this vector the min or max of itself and the passed vector - void Update_Min (const Vector2 & a); - void Update_Max (const Vector2 & a); - void Scale (float a, float b); - - static float Distance(const Vector2 &p1, const Vector2 &p2); - static float Quick_Distance(const Vector2 &p1, const Vector2 &p2); - - // interpolate between two Vector2's - static void Lerp(const Vector2 & a,const Vector2 & b,float t,Vector2 * set_result); -}; - - -/************************************************************************** - * Scalar Multiply Operator -- Multiply a vector by a scalar * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *========================================================================*/ -inline Vector2 operator * (const Vector2 &a,float k) -{ - return Vector2((a[0] * k),(a[1] * k)); -} - -inline Vector2 operator * (float k, const Vector2 &a) -{ - return Vector2((a[0] * k),(a[1] * k)); -} - -/************************************************************************** - * Scalar Division Operator -- Divide a vector by a scalar * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline Vector2 operator / (const Vector2 &a,float k) -{ - float ook=1.0f/k; - return Vector2((a[0] * ook),(a[1] * ook)); -} - -/************************************************************************** - * Vector Addition Operator -- Add two vectors * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *========================================================================*/ -inline Vector2 operator + (const Vector2 &a,const Vector2 &b) -{ - return Vector2( - a.X + b.X, - a.Y + b.Y - ); -} - -/************************************************************************** - * Vector Subtraction Operator -- Subract two vectors * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *========================================================================*/ -inline Vector2 operator - (const Vector2 &a,const Vector2 &b) -{ - return Vector2( - a.X - b.X, - a.Y - b.Y - ); -} - -/************************************************************************** - * Vector Inner Product -- Compute the inner or dot product of two vector * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline float operator * (const Vector2 &a,const Vector2 &b) -{ - return a.X*b.X + a.Y*b.Y; -} - -inline float Vector2::Dot_Product(const Vector2 &a,const Vector2 &b) -{ - return a*b; -} - -inline float Vector2::Perp_Dot_Product(const Vector2 &a,const Vector2 &b) -{ - return a.X * -b.Y + a.Y * b.X; -} - -/************************************************************************** - * Vector Equality Operator -- Detemine if two vectors are identical * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline bool operator == (const Vector2 &a,const Vector2 &b) -{ - return ( (a[0] == b[0]) && (a[1] == b[1])); -} - -/************************************************************************** - * Vector Inequality Operator -- Detemine if two vectors are identical * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline bool operator != (const Vector2 &a,const Vector2 &b) -{ - return ( (a[0] != b[0]) || (a[1] != b[1])); -} - -/************************************************************************** - * Equal_Within_Epsilon -- Determine if two vectors are identical within e* - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline bool Equal_Within_Epsilon(const Vector2 &a,const Vector2 &b,float epsilon) -{ - return( (WWMath::Fabs(a.X - b.X) < epsilon) && (WWMath::Fabs(a.Y - b.Y) < epsilon) ); -} - -/************************************************************************** - * Vector2::Normalize -- Normalizes the vector. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline void Vector2::Normalize() -{ - float len2 = Length2(); - if (len2 != 0.0f) { - float oolen = WWMath::Inv_Sqrt(len2); - X *= oolen; - Y *= oolen; - } -} - -inline Vector2 Normalize(const Vector2 & vec) -{ - float len2 = vec.Length2(); - if (len2 != 0.0f) { - float oolen = WWMath::Inv_Sqrt(len2); - return vec / oolen; - } -} - -/************************************************************************** - * Vector2::Length -- Returns the length of the vector * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline float Vector2::Length() const -{ - return (float)WWMath::Sqrt(Length2()); -} - -/************************************************************************** - * Vector2::Length -- Returns the square of the length of the vector * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline float Vector2::Length2() const -{ - return (X*X + Y*Y); -} - -/************************************************************************** - * Vector2::Rotate -- Rotate vector * - * * - * INPUT: * - * float theta - angle to rotate * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline void Vector2::Rotate(float theta) -{ - Rotate(sin(theta), cos(theta)); -} - -/************************************************************************** - * Vector2::Rotate -- Rotate vector * - * * - * INPUT: * - * s - sine of the angle * - * c - cosine of the angle * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline void Vector2::Rotate(float s, float c) -{ - float new_x = X * c + Y * -s; - float new_y = X * s + Y * c; - X = new_x; - Y = new_y; -} - -/************************************************************************** - * Vector2::Rotate -- Rotate towards given vector (stop on reaching it) * - * * - * INPUT: * - * float theta - angle to rotate * - * * - * OUTPUT: * - * bool - true if we have reached the desired vector * - * * - * WARNINGS: * - * This function assumes both vectors are normalized! * - * * - * HISTORY: * - *========================================================================*/ -inline bool Vector2::Rotate_Towards_Vector(Vector2 &target, float max_theta, bool & positive_turn) -{ - return Rotate_Towards_Vector(target, sin(max_theta), cos(max_theta), positive_turn); -} - -/************************************************************************** - * Vector2::Rotate -- Rotate towards given vector (stop on reaching it) * - * * - * INPUT: * - * s - sine of the angle * - * c - cosine of the angle * - * * - * OUTPUT: * - * bool - true if we have reached the desired vector * - * * - * WARNINGS: * - * This function assumes both vectors are normalized! * - * * - * HISTORY: * - *========================================================================*/ -inline bool Vector2::Rotate_Towards_Vector(Vector2 &target, float max_s, float max_c, bool & positive_turn) -{ - bool return_value = false; - - positive_turn = Vector2::Perp_Dot_Product(target, *this) > 0.0f; - - if (Vector2::Dot_Product(*this, target) >= max_c) { - Set(target); - return_value = true; - } else { - // Determine turn direction and rotate accordingly. - if (positive_turn) { - Rotate(max_s, max_c); - } else { - Rotate(-max_s, max_c); - } - } - - return return_value; -} - -/*********************************************************************************************** - * Swap -- swap two Vector2's * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -inline void Swap(Vector2 & a,Vector2 & b) -{ - Vector2 tmp(a); - a = b; - b = tmp; -} - - -/*********************************************************************************************** - * Vector2::Is_Valid -- Verifies that all components are valid floats * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/99 gth : Created. * - *=============================================================================================*/ -inline bool Vector2::Is_Valid(void) const -{ - return (WWMath::Is_Valid_Float(X) && WWMath::Is_Valid_Float(Y)); -} - - -/*********************************************************************************************** - * Vector2::Update_Min -- Set each component of the vector to the min of this and a. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/12/00 IML : Created. * - *=============================================================================================*/ -inline void Vector2::Update_Min (const Vector2 & a) -{ - if (a.X < X) X = a.X; - if (a.Y < Y) Y = a.Y; -} - - -/*********************************************************************************************** - * Vector2::Update_Max -- Set each component of the vector to the max of this and a. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/12/00 IML : Created. * - *=============================================================================================*/ -inline void Vector2::Update_Max (const Vector2 & a) -{ - if (a.X > X) X = a.X; - if (a.Y > Y) Y = a.Y; -} - - -/*********************************************************************************************** - * Vector2::Scale -- multiply components of a vector by independant scaling factors. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/19/2000 IML : Created. * - *=============================================================================================*/ -inline void Vector2::Scale (float a, float b) -{ - X *= a; - Y *= b; -} - - -/*********************************************************************************************** - * Quick_Distance -- Fast but inaccurate 2D distance calculation. * - * * - * * - * * - * * - * HISTORY: * - * 11/29/1999MLL: Created. * - *=============================================================================================*/ -inline float Quick_Distance(float x1, float y1, float x2, float y2) -{ - // From Graphic Gems I. - float x_diff = x1 - x2; - float y_diff = y1 - y2; - - WWMath::Fabs(x_diff); - WWMath::Fabs(y_diff); - - if (x_diff > y_diff) - { - return ((y_diff / 2) + x_diff); - } - else - { - return ((x_diff / 2) + y_diff); - } -} - -inline float Vector2::Quick_Distance(const Vector2 &a, const Vector2 &b) -{ - return ::Quick_Distance(a.X, a.Y, b.X, b.Y); -} - - -/*********************************************************************************************** - * Distance -- Accurate distance 2D calculation. * - * * - * * - * * - * * - * HISTORY: * - * 11/29/1999MLL: Created. * - *=============================================================================================*/ -inline float Vector2::Distance(const Vector2 &a, const Vector2 &b) -{ - Vector2 temp; - temp = a - b; - - return (temp.Length()); -} - -inline float Distance(float x1, float y1, float x2, float y2) -{ - float x_diff = x1 - x2; - float y_diff = y1 - y2; - - return (WWMath::Sqrt((x_diff * x_diff) + (y_diff * y_diff))); -} - - -/*********************************************************************************************** - * Vector2::Lerp -- linearly interpolates two Vector2's * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/14/2000 gth : Created. * - *=============================================================================================*/ -inline void Vector2::Lerp(const Vector2 & a,const Vector2 & b,float t,Vector2 * set_result) -{ - assert(set_result != NULL); - set_result->X = (a.X + (b.X - a.X)*t); - set_result->Y = (a.Y + (b.Y - a.Y)*t); -} - - -#endif /* VECTOR2_H */ - diff --git a/Generals/Code/Tools/WW3D/pluglib/vector3.h b/Generals/Code/Tools/WW3D/pluglib/vector3.h deleted file mode 100644 index fb3e0076209..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/vector3.h +++ /dev/null @@ -1,930 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/wwmath/vector3.h 40 5/11/01 7:11p Jani_p $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Westwood 3D * - * * - * File Name : VECTOR3.H * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 02/24/97 * - * * - * Last Update : February 24, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Scalar Division Operator -- Divide a vector by a scalar * - * Scalar Multiply Operator -- Multiply a vector by a scalar * - * Vector Addition Operator -- Add two vectors * - * Vector Subtraction Operator -- Subract two vectors * - * Vector Inner Product Operator -- Compute the inner or dot product * - * Vector Equality Operator -- Determine if two vectors are identical * - * Vector Inequality Operator -- Determine if two vectors are identical * - * Equal_Within_Epsilon -- Determine if two vectors are identical within * - * Cross_Product -- compute the cross product of two vectors * - * Vector3::Normalize -- Normalizes the vector. * - * Vector3::Length -- Returns the length of the vector * - * Vector3::Length2 -- Returns the square of the length of the vector * - * Vector3::Quick_Length -- returns a quick approximation of the length * - * Swap -- swap two Vector3's * - * Lerp -- linearly interpolate two Vector3's by an interpolation factor. * - * Lerp -- linearly interpolate two Vector3's without return-by-value * - * Vector3::Add -- Add two vector3's without return-by-value * - * Vector3::Subtract -- Subtract two vector3's without return-by-value * - * Vector3::Update_Min -- sets each component of the vector to the min of this and a * - * Vector3::Update_Max -- Sets each component of the vector to the max of this and a * - * Vector3::Scale -- scale this vector by 3 independent scale factors * - * Vector3::Rotate_X -- rotates this vector around the X axis * - * Vector3::Rotate_X -- Rotates this vector around the x axis * - * Vector3::Rotate_Y -- Rotates this vector around the y axis * - * Vector3::Rotate_Y -- Rotates this vector around the Y axis * - * Vector3::Rotate_Z -- Rotates this vector around the Z axis * - * Vector3::Rotate_Z -- Rotates this vector around the Z axis * - * Vector3::Is_Valid -- Verifies that each component of this vector is a valid float * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef VECTOR3_H -#define VECTOR3_H - -#include "always.h" -#include "wwmath.h" -#include -#ifdef _UNIX -#include "osdep.h" -#endif - - -/* -** Vector3 - 3-Dimensional Vectors -*/ -class Vector3 -{ - -public: - - - float X; - float Y; - float Z; - - - // Constructors - WWINLINE Vector3(void) {}; - WWINLINE Vector3(const Vector3 & v) { X = v.X; Y = v.Y; Z = v.Z; } - WWINLINE Vector3(float x, float y, float z) { X = x; Y = y; Z = z; } - WWINLINE Vector3(const float vector[3]) { X = vector[0]; Y = vector[1]; Z = vector[2]; } - - // Assignment - WWINLINE Vector3 & operator = (const Vector3 & v) { X = v.X; Y = v.Y; Z = v.Z; return *this; } - WWINLINE void Set(float x, float y, float z) { X = x; Y = y; Z = z; } - WWINLINE void Set(const Vector3 & that) { X = that.X; Y = that.Y; Z = that.Z; } - - // Array access - WWINLINE float & operator [](int i) { return (&X)[i]; } - WWINLINE const float & operator [](int i) const { return (&X)[i]; } - - // normalize, compute length - void Normalize(void); - WWINLINE float Length(void) const; - WWINLINE float Length2(void) const; - float Quick_Length(void) const; - void Scale(const Vector3 & scale); - - // rotation, (warning, modifies this vector!) - WWINLINE void Rotate_X(float angle); - WWINLINE void Rotate_X(float s_angle,float c_angle); - WWINLINE void Rotate_Y(float angle); - WWINLINE void Rotate_Y(float s_angle,float c_angle); - WWINLINE void Rotate_Z(float angle); - WWINLINE void Rotate_Z(float s_angle,float c_angle); - - // unary operators - WWINLINE Vector3 operator-() const { return(Vector3(-X,-Y,-Z)); } - WWINLINE Vector3 operator+() const { return *this; } - - WWINLINE Vector3 & operator += (const Vector3 & v) { X += v.X; Y += v.Y; Z += v.Z; return *this; } - WWINLINE Vector3 & operator -= (const Vector3 & v) { X -= v.X; Y -= v.Y; Z -= v.Z; return *this; } - WWINLINE Vector3 & operator *= (float k) { X = X*k; Y=Y*k; Z=Z*k; return *this; } - WWINLINE Vector3 & operator /= (float k) { float ook=1.0f/k; X=X*ook; Y=Y*ook; Z=Z*ook; return *this; } - - // scalar multiplication, division - WWINLINE friend Vector3 operator * (const Vector3 &a,float k); - WWINLINE friend Vector3 operator * (float k,const Vector3 &a); - WWINLINE friend Vector3 operator / (const Vector3 &a,float k); - - // vector addition,subtraction - WWINLINE friend Vector3 operator + (const Vector3 &a,const Vector3 &b); - WWINLINE friend Vector3 operator - (const Vector3 &a,const Vector3 &b); - - // Equality operators - friend bool operator == (const Vector3 &a,const Vector3 &b); - friend bool operator != (const Vector3 &a,const Vector3 &b); - WWINLINE friend bool Equal_Within_Epsilon(const Vector3 &a,const Vector3 &b,float epsilon); - - // dot product / inner product - WWINLINE friend float operator * (const Vector3 &a,const Vector3 &b); - static WWINLINE float Dot_Product(const Vector3 &a,const Vector3 &b); - - // cross product / outer product - static WWINLINE Vector3 Cross_Product(const Vector3 &a,const Vector3 &b); - static WWINLINE void Cross_Product(const Vector3 &a,const Vector3 &b,Vector3 * result); - static WWINLINE float Cross_Product_X(const Vector3 &a,const Vector3 &b); - static WWINLINE float Cross_Product_Y(const Vector3 &a,const Vector3 &b); - static WWINLINE float Cross_Product_Z(const Vector3 &a,const Vector3 &b); - - // add and subtract without return by value - static WWINLINE void Add(const Vector3 & a,const Vector3 & b,Vector3 * c); - static WWINLINE void Subtract(const Vector3 & a,const Vector3 & b,Vector3 * c); - - // Line intersection functions. - static WWINLINE float Find_X_At_Y(float y, const Vector3 &p1, const Vector3 &p2); - static WWINLINE float Find_X_At_Z(float z, const Vector3 &p1, const Vector3 &p2); - static WWINLINE float Find_Y_At_X(float x, const Vector3 &p1, const Vector3 &p2); - static WWINLINE float Find_Y_At_Z(float z, const Vector3 &p1, const Vector3 &p2); - static WWINLINE float Find_Z_At_X(float x, const Vector3 &p1, const Vector3 &p2); - static WWINLINE float Find_Z_At_Y(float z, const Vector3 &p1, const Vector3 &p2); - - // make this vector the min or max of itself and the passed vector - WWINLINE void Update_Min(const Vector3 & a); - WWINLINE void Update_Max(const Vector3 & a); - WWINLINE void Cap_Absolute_To(const Vector3 & a); - - // verify that none of the members of this vector are invalid floats - WWINLINE bool Is_Valid(void) const; - - static WWINLINE float Quick_Distance(const Vector3 &p1, const Vector3 &p2); - static WWINLINE float Distance(const Vector3 &p1, const Vector3 &p2); - - // Linearly interpolate two Vector3's - static void Lerp(const Vector3 & a, const Vector3 & b, float alpha,Vector3 * set_result); - - // Color Conversion - WWINLINE unsigned long Convert_To_ABGR( void ) const; - WWINLINE unsigned long Convert_To_ARGB( void ) const; -}; - - -/************************************************************************** - * Scalar Multiply Operator -- Multiply a vector by a scalar * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *========================================================================*/ -WWINLINE Vector3 operator * (const Vector3 &a,float k) -{ - return Vector3((a.X * k),(a.Y * k),(a.Z * k)); -} - -WWINLINE Vector3 operator * (float k, const Vector3 &a) -{ - return Vector3((a.X * k),(a.Y * k),(a.Z * k)); -} - -/************************************************************************** - * Scalar Division Operator -- Divide a vector by a scalar * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -WWINLINE Vector3 operator / (const Vector3 &a,float k) -{ - float ook = 1.0f/k; - return Vector3((a.X * ook),(a.Y * ook),(a.Z * ook)); -} - -/************************************************************************** - * Vector Addition Operator -- Add two vectors * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *========================================================================*/ -WWINLINE Vector3 operator + (const Vector3 &a,const Vector3 &b) -{ - return Vector3( - a.X+b.X, - a.Y+b.Y, - a.Z+b.Z - ); -} - -/************************************************************************** - * Vector Subtraction Operator -- Subract two vectors * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *========================================================================*/ -WWINLINE Vector3 operator - (const Vector3 &a,const Vector3 &b) -{ - return Vector3( - a.X-b.X, - a.Y-b.Y, - a.Z-b.Z - ); -} - -/************************************************************************** - * Vector Inner Product -- Compute the inner or dot product of two vector * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -WWINLINE float operator * (const Vector3 &a,const Vector3 &b) -{ - return a.X*b.X + - a.Y*b.Y + - a.Z*b.Z; -} - -WWINLINE float Vector3::Dot_Product(const Vector3 &a,const Vector3 &b) -{ - return a*b; -} - - -/************************************************************************** - * Vector Equality Operator -- Determine if two vectors are identical * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -WWINLINE bool operator == (const Vector3 &a,const Vector3 &b) -{ - return ( (a.X == b.X) && (a.Y == b.Y) && (a.Z == b.Z)); -} - -/************************************************************************** - * Vector Inequality Operator -- Determine if two vectors are identical * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -WWINLINE bool operator != (const Vector3 &a,const Vector3 &b) -{ - return ( (a.X != b.X) || (a.Y != b.Y) || (a.Z != b.Z)); -} - -/************************************************************************** - * Equal_Within_Epsilon -- Determine if two vectors are identical within e* - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -WWINLINE bool Equal_Within_Epsilon(const Vector3 &a,const Vector3 &b,float epsilon) -{ - return( (WWMath::Fabs(a.X - b.X) < epsilon) && - (WWMath::Fabs(a.Y - b.Y) < epsilon) && - (WWMath::Fabs(a.Z - b.Z) < epsilon) ); -} - - -/************************************************************************** - * Cross_Product -- compute the cross product of two vectors * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -WWINLINE Vector3 Vector3::Cross_Product(const Vector3 &a,const Vector3 &b) -{ - return Vector3( - (a.Y * b.Z - a.Z * b.Y), - (a.Z * b.X - a.X * b.Z), - (a.X * b.Y - a.Y * b.X) - ); -} - -WWINLINE void Vector3::Cross_Product(const Vector3 &a,const Vector3 &b,Vector3 * set_result) -{ - assert(set_result != &a); - set_result->X = (a.Y * b.Z - a.Z * b.Y); - set_result->Y = (a.Z * b.X - a.X * b.Z); - set_result->Z = (a.X * b.Y - a.Y * b.X); -} - -WWINLINE float Vector3::Cross_Product_X(const Vector3 &a,const Vector3 &b) -{ - return a.Y * b.Z - a.Z * b.Y; -} - -WWINLINE float Vector3::Cross_Product_Y(const Vector3 &a,const Vector3 &b) -{ - return a.Z * b.X - a.X * b.Z; -} - -WWINLINE float Vector3::Cross_Product_Z(const Vector3 &a,const Vector3 &b) -{ - return a.X * b.Y - a.Y * b.X; -} - -/************************************************************************** - * Vector3::Normalize -- Normalizes the vector. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -WWINLINE void Vector3::Normalize() -{ - float len2 = Length2(); - if (len2 != 0.0f) - { - float oolen = WWMath::Inv_Sqrt(len2); - X *= oolen; - Y *= oolen; - Z *= oolen; - } -} - -#ifdef ALLOW_TEMPORARIES -WWINLINE Vector3 Normalize(const Vector3 & vec) -{ - float len2 = vec.Length2(); - if (len2 != 0.0f) - { - float oolen = WWMath::Inv_Sqrt(len2); - return vec * oolen; - } - return vec; -} -#endif - -/************************************************************************** - * Vector3::Length -- Returns the length of the vector * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -WWINLINE float Vector3::Length() const -{ - return WWMath::Sqrt(Length2()); -} - -/************************************************************************** - * Vector3::Length2 -- Returns the square of the length of the vector * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -WWINLINE float Vector3::Length2() const -{ - return X*X + Y*Y + Z*Z; -} - - -/*********************************************************************************************** - * Vector3::Quick_Length -- returns a quick approximation of the length * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 7/15/98 GTH : Created. * - *=============================================================================================*/ -WWINLINE float Vector3::Quick_Length(void) const -{ - // this method of approximating the length comes from Graphics Gems 1 and - // supposedly gives an error of +/- 8% - float max = WWMath::Fabs(X); - float mid = WWMath::Fabs(Y); - float min = WWMath::Fabs(Z); - float tmp; - - if (max < mid) { tmp = max; max = mid; mid = tmp; } - if (max < min) { tmp = max; max = min; min = tmp; } - if (mid < min) { tmp = mid; mid = min; min = mid; } - - return max + (11.0f / 32.0f)*mid + (1.0f / 4.0f)*min; -} - - -/*********************************************************************************************** - * Swap -- swap two Vector3's * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -WWINLINE void Swap(Vector3 & a,Vector3 & b) -{ - Vector3 tmp(a); - a = b; - b = tmp; -} - -/*********************************************************************************************** - * Lerp -- linearly interpolate two Vector3's by an interpolation factor. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: No checking is done to ensure that alpha is between 0 and 1. * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -WWINLINE Vector3 Lerp(const Vector3 & a, const Vector3 & b, float alpha) -{ - return Vector3( - (a.X + (b.X - a.X)*alpha), - (a.Y + (b.Y - a.Y)*alpha), - (a.Z + (b.Z - a.Z)*alpha) - ); -} - - -/*********************************************************************************************** - * Lerp -- linearly interpolate two Vector3's without return-by-value * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/99 gth : Created. * - *=============================================================================================*/ -WWINLINE void Lerp(const Vector3 & a, const Vector3 & b, float alpha,Vector3 * set_result) -{ - assert(set_result != NULL); - set_result->X = (a.X + (b.X - a.X)*alpha); - set_result->Y = (a.Y + (b.Y - a.Y)*alpha); - set_result->Z = (a.Z + (b.Z - a.Z)*alpha); -} - -WWINLINE void Vector3::Lerp(const Vector3 & a, const Vector3 & b, float alpha,Vector3 * set_result) -{ - assert(set_result != NULL); - set_result->X = (a.X + (b.X - a.X)*alpha); - set_result->Y = (a.Y + (b.Y - a.Y)*alpha); - set_result->Z = (a.Z + (b.Z - a.Z)*alpha); -} - -/*********************************************************************************************** - * Vector3::Add -- Add two vector3's without return-by-value * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/99 gth : Created. * - *=============================================================================================*/ -WWINLINE void Vector3::Add(const Vector3 &a,const Vector3 &b,Vector3 * set_result) -{ - assert(set_result != NULL); - set_result->X = a.X + b.X; - set_result->Y = a.Y + b.Y; - set_result->Z = a.Z + b.Z; -} - - -/*********************************************************************************************** - * Vector3::Subtract -- Subtract two vector3's without return-by-value * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/99 gth : Created. * - *=============================================================================================*/ -WWINLINE void Vector3::Subtract(const Vector3 &a,const Vector3 &b,Vector3 * set_result) -{ - assert(set_result != NULL); - set_result->X = a.X - b.X; - set_result->Y = a.Y - b.Y; - set_result->Z = a.Z - b.Z; -} - - -/*********************************************************************************************** - * Vector3::Update_Min -- sets each component of the vector to the min of this and a * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/99 gth : Created. * - *=============================================================================================*/ -WWINLINE void Vector3::Update_Min(const Vector3 & a) -{ - if (a.X < X) X = a.X; - if (a.Y < Y) Y = a.Y; - if (a.Z < Z) Z = a.Z; -} - - -/*********************************************************************************************** - * Vector3::Update_Max -- Sets each component of the vector to the max of this and a * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/99 gth : Created. * - *=============================================================================================*/ -WWINLINE void Vector3::Update_Max(const Vector3 & a) -{ - if (a.X > X) X = a.X; - if (a.Y > Y) Y = a.Y; - if (a.Z > Z) Z = a.Z; -} - -/*********************************************************************************************** - * Vector3::Cap_To_Absolute_Of -- Sets each component of the vector to no larger than the -ve or +ve of* - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/29/99 wst : Created. * - *=============================================================================================*/ -WWINLINE void Vector3::Cap_Absolute_To(const Vector3 & a) -{ - if (X > 0) - { - if (a.X < X) X = a.X; - } - else - { - if (-a.X > X) X = -a.X; - } - - if (Y > 0) - { - if (a.Y < Y) Y = a.Y; - } - else - { - if (-a.Y > Y) Y = -a.Y; - } - - if (Z > 0) - { - if (a.Z < Z) Z = a.Z; - } - else - { - if (-a.Z > Z) Z = -a.Z; - } - -} - -/*********************************************************************************************** - * Vector3::Scale -- scale this vector by 3 independent scale factors * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/99 gth : Created. * - *=============================================================================================*/ -WWINLINE void Vector3::Scale(const Vector3 & scale) -{ - X *= scale.X; - Y *= scale.Y; - Z *= scale.Z; -} - - -/*********************************************************************************************** - * Vector3::Rotate_X -- rotates this vector around the X axis * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/99 gth : Created. * - *=============================================================================================*/ -WWINLINE void Vector3::Rotate_X(float angle) -{ - Rotate_X(sinf(angle),cosf(angle)); -} - - -/*********************************************************************************************** - * Vector3::Rotate_X -- Rotates this vector around the x axis * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/99 gth : Created. * - *=============================================================================================*/ -WWINLINE void Vector3::Rotate_X(float s_angle,float c_angle) -{ - float tmp_y = Y; - float tmp_z = Z; - - Y = c_angle * tmp_y - s_angle * tmp_z; - Z = s_angle * tmp_y + c_angle * tmp_z; -} - - -/*********************************************************************************************** - * Vector3::Rotate_Y -- Rotates this vector around the y axis * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/99 gth : Created. * - *=============================================================================================*/ -WWINLINE void Vector3::Rotate_Y(float angle) -{ - Rotate_Y(sinf(angle),cosf(angle)); -} - - -/*********************************************************************************************** - * Vector3::Rotate_Y -- Rotates this vector around the Y axis * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/99 gth : Created. * - *=============================================================================================*/ -WWINLINE void Vector3::Rotate_Y(float s_angle,float c_angle) -{ - float tmp_x = X; - float tmp_z = Z; - - X = c_angle * tmp_x + s_angle * tmp_z; - Z = -s_angle * tmp_x + c_angle * tmp_z; -} - - -/*********************************************************************************************** - * Vector3::Rotate_Z -- Rotates this vector around the Z axis * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/99 gth : Created. * - *=============================================================================================*/ -WWINLINE void Vector3::Rotate_Z(float angle) -{ - Rotate_Z(sinf(angle),cosf(angle)); -} - - -/*********************************************************************************************** - * Vector3::Rotate_Z -- Rotates this vector around the Z axis * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/99 gth : Created. * - *=============================================================================================*/ -WWINLINE void Vector3::Rotate_Z(float s_angle,float c_angle) -{ - float tmp_x = X; - float tmp_y = Y; - - X = c_angle * tmp_x - s_angle * tmp_y; - Y = s_angle * tmp_x + c_angle * tmp_y; -} - - -/*********************************************************************************************** - * Vector3::Is_Valid -- Verifies that each component of this vector is a valid float * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/99 gth : Created. * - *=============================================================================================*/ -WWINLINE bool Vector3::Is_Valid(void) const -{ - return (WWMath::Is_Valid_Float(X) && WWMath::Is_Valid_Float(Y) && WWMath::Is_Valid_Float(Z)); -} - -WWINLINE float Vector3::Find_X_At_Y(float y, const Vector3 &p1, const Vector3 &p2) -{ - return(p1.X + ((y - p1.Y) * ((p2.X - p1.X) / (p2.Y - p1.Y)))); -} -WWINLINE float Vector3::Find_X_At_Z(float z, const Vector3 &p1, const Vector3 &p2) -{ - return(p1.X + ((z - p1.Z) * ((p2.X - p1.X) / (p2.Z - p1.Z)))); -} -WWINLINE float Vector3::Find_Y_At_X(float x, const Vector3 &p1, const Vector3 &p2) -{ - return(p1.Y + ((x - p1.X) * ((p2.Y - p1.Y) / (p2.X - p1.X)))); -} -WWINLINE float Vector3::Find_Y_At_Z(float z, const Vector3 &p1, const Vector3 &p2) -{ - return(p1.Y + ((z - p1.Z) * ((p2.Y - p1.Y) / (p2.Z - p1.Z)))); -} -WWINLINE float Vector3::Find_Z_At_X(float x, const Vector3 &p1, const Vector3 &p2) -{ - return(p1.Z + ((x - p1.X) * ((p2.Z - p1.Z) / (p2.X - p1.X)))); -} -WWINLINE float Vector3::Find_Z_At_Y(float y, const Vector3 &p1, const Vector3 &p2) -{ - return(p1.Z + ((y - p1.Y) * ((p2.Z - p1.Z) / (p2.Y - p1.Y)))); -} - -/*********************************************************************************************** - * Vector3::Distance -- Accurate distance calculation. * - * * - * * - * * - * * - * HISTORY: * - * 11/29/1999MLL: Created. * - *=============================================================================================*/ -WWINLINE float Vector3::Distance(const Vector3 &p1, const Vector3 &p2) -{ - Vector3 temp; - temp = p1 - p2; - return (temp.Length()); -} - -/*********************************************************************************************** - * Vector3::Quick_Distance -- Fast but inaccurate distance calculation. * - * * - * * - * * - * * - * HISTORY: * - * 11/29/1999MLL: Created. * - *=============================================================================================*/ -WWINLINE float Vector3::Quick_Distance(const Vector3 &p1, const Vector3 &p2) -{ - Vector3 temp; - temp = p1 - p2; - return (temp.Quick_Length()); -} - -/*********************************************************************************************** - * Vector3::Convert_To_ABGR -- Converts to SR packed color . * - * * - * * - * * - * * - * HISTORY: * - * 11/29/1999MLL: Created. * - *=============================================================================================*/ -WWINLINE unsigned long Vector3::Convert_To_ABGR( void ) const -{ - return (unsigned(255)<<24) | - (unsigned(Z*255.0f)<<16) | - (unsigned(Y*255.0f)<<8) | - (unsigned(X*255.0f)); -} - -/*********************************************************************************************** - * Vector3::Convert_To_ARGB -- Converts to packed color . * - * * - * * - * * - * * - * HISTORY: * - * 11/29/1999MLL: Created. * - *=============================================================================================*/ -WWINLINE unsigned long Vector3::Convert_To_ARGB( void ) const -{ - return (unsigned(255)<<24) | - (unsigned(X*255.0f)<<16) | - (unsigned(Y*255.0f)<<8) | - (unsigned(Z*255.0f)); -} - -#endif /* Vector3_H */ - diff --git a/Generals/Code/Tools/WW3D/pluglib/vector3i.h b/Generals/Code/Tools/WW3D/pluglib/vector3i.h deleted file mode 100644 index ad43313d691..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/vector3i.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WWMath * - * * - * $Archive:: /Commando/Code/wwmath/vector3i.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 5/10/01 11:37p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef VECTOR3I_H -#define VECTOR3I_H - -#include "always.h" - -class Vector3i -{ -public: - - int I; - int J; - int K; - - WWINLINE Vector3i(void); - WWINLINE Vector3i(int i,int j,int k); - - WWINLINE bool operator== (const Vector3i & v) const; - WWINLINE bool operator!= (const Vector3i& v) const; - WWINLINE const int& operator[] (int n) const; - WWINLINE int& operator[] (int n); -}; - - -WWINLINE Vector3i::Vector3i(void) -{ -} - -WWINLINE Vector3i::Vector3i(int i,int j,int k) -{ - I = i; J = j; K = k; -} - -WWINLINE bool Vector3i::operator == (const Vector3i & v) const -{ - return (I == v.I && J == v.J && K == v.K); -} - -WWINLINE bool Vector3i::operator != (const Vector3i& v) const -{ - return !(I == v.I && J == v.J && K == v.K); -} - -WWINLINE const int& Vector3i::operator[] (int n) const -{ - return ((int*)this)[n]; -} - -WWINLINE int& Vector3i::operator[] (int n) -{ - return ((int*)this)[n]; -} - -#endif \ No newline at end of file diff --git a/Generals/Code/Tools/WW3D/pluglib/vector4.h b/Generals/Code/Tools/WW3D/pluglib/vector4.h deleted file mode 100644 index 87fb6a460db..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/vector4.h +++ /dev/null @@ -1,390 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/wwmath/vector4.h 12 12/14/99 11:08a Greg_h $ */ -/*************************************************************************** - *** Confidential - Westwood Studios *** - *************************************************************************** - * * - * Project Name : Westwood 3D * - * * - * File Name : VECTOR4.H * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 02/24/97 * - * * - * Last Update : June 2, 1997 [GH] * - * * - *-------------------------------------------------------------------------* - * Functions: * - * Scalar Division Operator -- Divide a vector by a scalar * - * Scalar Multiply Operator -- Multiply a vector by a scalar * - * Vector Addition Operator -- Add two vectors * - * Vector Subtraction Operator -- Subract two vectors * - * Vector Inner Product Operator -- Compute the inner or dot product * - * Vector Equality Operator -- Detemine if two vectors are identical * - * Vector Inequality Operator -- Detemine if two vectors are identical * - * Swap -- swap two Vector4's * - * Vector4::Is_Valid -- Vector4::Is_Valid * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef VECTOR4_H -#define VECTOR4_H - -#include "always.h" -#include "wwmath.h" -#include - -/* -** Vector4 - 4 dimensional vectors -*/ -class Vector4 -{ - -public: - - float X; - float Y; - float Z; - float W; - - - // Constructors - Vector4(void) {}; - Vector4(const Vector4 & v) { X = v.X; Y = v.Y; Z = v.Z; W = v.W; } - Vector4(float x, float y, float z, float w) { X = x; Y = y; Z = z; W = w; } - Vector4(const float vector[4]) { X = vector[0]; Y = vector[1]; Z = vector[2]; W = vector[3]; } - - // Assignment - Vector4 & operator = (const Vector4 & v) { X = v.X; Y = v.Y; Z = v.Z; W = v.W; return *this; } - void Set(float x, float y, float z, float w) { X = x; Y = y; Z = z; W = w; } - - // Array access - float & operator [](int i) { return (&X)[i]; } - const float & operator [](int i) const { return (&X)[i]; } - - // normalize, compute length - void Normalize(void); - float Length(void) const; - float Length2(void) const; - - // unary operators - Vector4 operator-() const { return(Vector4(-X,-Y,-Z,-W)); } - Vector4 operator+() const { return *this; } - - Vector4 & operator += (const Vector4 & v) { X += v.X; Y += v.Y; Z += v.Z; W += v.W; return *this; } - Vector4 & operator -= (const Vector4 & v) { X -= v.X; Y -= v.Y; Z -= v.Z; W += v.W; return *this; } - Vector4 & operator *= (float k) { X = X*k; Y=Y*k; Z=Z*k; W=W*k; return *this; } - Vector4 & operator /= (float k) { k=1.0f/k; X = X*k; Y=Y*k; Z=Z*k; W=W*k; return *this; } - - // scalar multiplication, division - friend Vector4 operator * (const Vector4 &a,float k); - friend Vector4 operator * (float k,const Vector4 &a); - friend Vector4 operator / (const Vector4 &a,float k); - - // vector addition,subtraction - friend Vector4 operator + (const Vector4 &a,const Vector4 &b); - friend Vector4 operator - (const Vector4 &a,const Vector4 &b); - - // dot product / inner product - friend float operator * (const Vector4 &a,const Vector4 &b); - static float Dot_Product(const Vector4 &a,const Vector4 &b); - - // Equality operators - friend bool operator == (const Vector4 &a,const Vector4 &b); - friend bool operator != (const Vector4 &a,const Vector4 &b); - - // verify that none of the members of this vector are invalid floats - bool Is_Valid(void) const; -}; - -/************************************************************************** - * Scalar Multiply Operator -- Multiply a vector by a scalar * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *========================================================================*/ -inline Vector4 operator * (const Vector4 &a,float k) -{ - return Vector4((a.X * k),(a.Y * k),(a.Z * k),(a.W * k)); -} - -inline Vector4 operator * (float k, const Vector4 &a) -{ - return a*k; -} - -/************************************************************************** - * Scalar Division Operator -- Divide a vector by a scalar * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline Vector4 operator / (const Vector4 &a,float k) -{ - float ook=1.0f/k; - return Vector4((a[0] * ook),(a[1] * ook),(a[2] * ook),(a[3] * ook)); -} - -/************************************************************************** - * Vector Addition Operator -- Add two vectors * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *========================================================================*/ -inline Vector4 operator + (const Vector4 &a,const Vector4 &b) -{ - return Vector4( - a[0]+b[0], - a[1]+b[1], - a[2]+b[2], - a[3]+b[3] - ); -} - -/************************************************************************** - * Vector Subtraction Operator -- Subract two vectors * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *========================================================================*/ -inline Vector4 operator - (const Vector4 &a,const Vector4 &b) -{ - return Vector4( - a[0]-b[0], - a[1]-b[1], - a[2]-b[2], - a[3]-b[3] - ); -} - -/************************************************************************** - * Vector Inner Product -- Compute the inner or dot product of two vector * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline float operator * (const Vector4 &a,const Vector4 &b) -{ - return a[0]*b[0] + - a[1]*b[1] + - a[2]*b[2] + - a[3]*b[3]; -} - -inline float Vector4::Dot_Product(const Vector4 &a,const Vector4 &b) -{ - return a*b; -} - - -/************************************************************************** - * Vector Equality Operator -- Detemine if two vectors are identical * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline bool operator == (const Vector4 &a,const Vector4 &b) -{ - return ( (a[0] == b[0]) && (a[1] == b[1]) && (a[2] == b[2]) && (a[3] == b[3])); -} - -/************************************************************************** - * Vector Inequality Operator -- Detemine if two vectors are identical * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline bool operator != (const Vector4 &a,const Vector4 &b) -{ - return ( (a[0] != b[0]) || (a[1] != b[1]) || (a[2] != b[2]) || (a[3] != b[3])); -} - -/************************************************************************** - * Vector4::Normalize -- Normalizes the vector. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline void Vector4::Normalize() -{ - float len2 = Length2(); - if (len2 != 0.0f) { - float oolen = WWMath::Inv_Sqrt(len2); - X *= oolen; - Y *= oolen; - Z *= oolen; - W *= oolen; - } -} - -inline Vector4 Normalize(const Vector4 & vec) -{ - float len2 = vec.Length2(); - if (len2 != 0.0f) { - float oolen = WWMath::Inv_Sqrt(len2); - return vec * oolen; - } -} - -/************************************************************************** - * Vector4::Length -- Returns the length of the vector * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline float Vector4::Length() const -{ - return WWMath::Sqrt(Length2()); -} - -/************************************************************************** - * Vector4::Length -- Returns the square of the length of the vector * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *========================================================================*/ -inline float Vector4::Length2() const -{ - return X*X + Y*Y + Z*Z + W*W; -} - - -/*********************************************************************************************** - * Swap -- swap two Vector4's * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1997 GH : Created. * - *=============================================================================================*/ -inline void Swap(Vector4 & a,Vector4 & b) -{ - Vector4 tmp(a); - a = b; - b = tmp; -} - -/*********************************************************************************************** - * Lerp -- linearly interpolate two Vector4's by an interpolation factor. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: No checking is done to ensure that alpha is between 0 and 1. * - * * - * HISTORY: * - * 01/14/1999 NH : Created. * - *=============================================================================================*/ -inline Vector4 Lerp(const Vector4 & a, const Vector4 & b, float alpha) -{ - return Vector4( - (a.X + (b.X - a.X)*alpha), - (a.Y + (b.Y - a.Y)*alpha), - (a.Z + (b.Z - a.Z)*alpha), - (a.W + (b.W - a.W)*alpha) - ); -} - - -/*********************************************************************************************** - * Vector4::Is_Valid -- Vector4::Is_Valid * - * * - * verifies that all members of this vector are valid floats * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/18/99 gth : Created. * - *=============================================================================================*/ -inline bool Vector4::Is_Valid(void) const -{ - return (WWMath::Is_Valid_Float(X) && WWMath::Is_Valid_Float(Y) && WWMath::Is_Valid_Float(Z) && WWMath::Is_Valid_Float(W)); -} - - -#endif /* VECTOR4_H */ - diff --git a/Generals/Code/Tools/WW3D/pluglib/visualc.h b/Generals/Code/Tools/WW3D/pluglib/visualc.h deleted file mode 100644 index aec680e3f2d..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/visualc.h +++ /dev/null @@ -1,125 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/visualc.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 5/16/01 4:11p $* - * * - * $Revision:: 9 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#if defined(_MSC_VER) - -/********************************************************************** -** The "bool" integral type was defined by the C++ comittee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#include "bool.h" - - -/* -** Make the inline depth 255 -*/ -#pragma inline_depth(255) - - -/* -** Turn off some unneeded warnings. -*/ - -// "unreferenced inline function has been removed" Yea, so what? -#pragma warning(disable : 4514) - -// "conversion from 'double' to 'float', possible loss of data" Yea, so what? -#pragma warning(disable : 4244) - -// "overflow in floating-point constant arithmetic" This warning occurs even if the -// loss of precision is insignificant. -#pragma warning(disable : 4056) - -// "function not inlined" This warning is typically useless. The inline keyword -// only serves as a suggestion to the compiler and it may or may not inline a -// function on a case by case basis. No need to be told of this. -#pragma warning(disable : 4710) - -// "'this' used in base member initializer list" Using "this" in a base member -// initializer is valid -- no need for this warning. -#pragma warning(disable : 4355) - -// "typedef-name used as a synonym for class-name". This is by design and should -// not be a warning. -#pragma warning(disable : 4097) - -// Unreferenced local function removed. -#pragma warning(disable : 4505) - -// 'function selected for automatic inlining' -#pragma warning(disable : 4711) - -// 'copy constructor could not be generated' -#pragma warning(disable : 4511) - -// 'assignment operator could not be generated' -#pragma warning(disable : 4512) - -// 'unreferenced formal parameter' -#pragma warning(disable : 4100) - -// HIDE WARNING 4786 "identifier was truncated to '255' characters in the browser information" -// Tempates create LLLOOONNNGGG identifiers! -#pragma warning(disable : 4786) - -// 'function selected for automatic inline expansion'. Cool, but since we're treating -// warnings as errors, don't warn me about this! -#pragma warning(disable : 4711) - - - -#define M_E 2.71828182845904523536 -#define M_LOG2E 1.44269504088896340736 -#define M_LOG10E 0.434294481903251827651 -#define M_LN2 0.693147180559945309417 -#define M_LN10 2.30258509299404568402 -#define M_PI 3.14159265358979323846 -#define M_PI_2 1.57079632679489661923 -#define M_PI_4 0.785398163397448309616 -#define M_1_PI 0.318309886183790671538 -#define M_2_PI 0.636619772367581343076 -#define M_1_SQRTPI 0.564189583547756286948 -#define M_2_SQRTPI 1.12837916709551257390 -#define M_SQRT2 1.41421356237309504880 -#define M_SQRT_2 0.707106781186547524401 - - -#endif - diff --git a/Generals/Code/Tools/WW3D/pluglib/w3d_file.h b/Generals/Code/Tools/WW3D/pluglib/w3d_file.h deleted file mode 100644 index 29f63966c8f..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/w3d_file.h +++ /dev/null @@ -1,889 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/ww3d/w3d_file.h 56 8/12/98 11:16a Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Library * - * * - * $Archive:: /Commando/Code/ww3d/w3d_file.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 8/11/98 4:15p $* - * * - * $Revision:: 56 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef W3D_FILE_H -#define W3D_FILE_H - -#include "always.h" - -#ifndef BITTYPE_H -#include "BITTYPE.H" -#endif - - -/******************************************************************************** - -VERSION NUMBERS: - - Each Major chunk type will contain a "header" as its first - sub-chunk. The first member of this header will be a Version - number formatted so that its major revision number is the - high two bytes and its minor revision number is the lower two - bytes. - -Version 1.0: - - MESHES - contained the following chunks: - W3D_CHUNK_MESH_HEADER, // header for a mesh - W3D_CHUNK_VERTICES, // array of vertices - W3D_CHUNK_VERTEX_NORMALS, // array of normals - W3D_CHUNK_SURRENDER_NORMALS, // array of surrender normals (one per vertex as req. by surrender) - W3D_CHUNK_TEXCOORDS, // array of texture coordinates - W3D_CHUNK_MATERIALS, // array of materials - W3D_CHUNK_TRIANGLES, // array of triangles - W3D_CHUNK_SURRENDER_TRIANGLES,// array of surrender format tris - W3D_CHUNK_MESH_USER_TEXT, // Name of owning hierarchy, text from the MAX comment field - - HIERARCHY TREES - contained the following chunks: - W3D_CHUNK_HIERARCHY_HEADER, - W3D_CHUNK_PIVOTS, - W3D_CHUNK_PIVOT_FIXUPS, - - HIERARCHY ANIMATIONS - contained the following chunks: - W3D_CHUNK_ANIMATION_HEADER, - W3D_CHUNK_ANIMATION_CHANNEL, - - MESH CONNECTIONS - (blueprint for a hierarchical model) contained these chunks: - - -Version 2.0: - - MESHES: - - - Mesh header now contains the hierarchy model name. The mesh name will be built - as . instead of the old convention: . - - - The material chunk is replaced with a new material structure which contains - some information for animating materials. - - - Vertex Influences link vertices of a mesh to bones in a hierarchy, this is - the information needed for skinning. - - - Damage chunks added. A damage chunk contains a new set of materials, a set - of vertex offsets, and a set of vertex colors. - - Added the following chunks: - - W3D_CHUNK_VERTEX_COLORS, - W3D_CHUNK_VERTEX_INFLUENCES, - W3D_CHUNK_DAMAGE, - W3D_CHUNK_DAMAGE_HEADER, - W3D_CHUNK_DAMAGE_MATERIALS, - W3D_CHUNK_DAMAGE_VERTICES, - W3D_CHUNK_DAMAGE_COLORS, - W3D_CHUNK_MATERIALS2, - - MESH CONNECTIONS: Hierarchy models can now contain skins and collision meshes - in addition to the normal meshes. - - W3D_CHUNK_COLLISION_CONNECTION, // collision meshes connected to the hierarchy - W3D_CHUNK_SKIN_CONNECTION, // skins connected to the hierarchy - W3D_CHUNK_CONNECTION_AUX_DATA // extension of the connection header - - -Dec 12, 1997 - - Changed MESH_CONNECTIONS chunks into HMODEL chunks because the name - mesh connections was becoming more and more inappropriate... This was only - a data structure naming change so no-one other than the coders are affected - - Added W3D_CHUNK_LODMODEL. An LOD Model contains a set of names for - render objects, each with a specified distance range. - - -Feb 6, 1998 - - Added W3D_CHUNK_SECTMESH and its sub-chunks. This will be the file - format for the terrain geometry exported from POV's Atlas tool. - -March 29, 1998 : Version 3.0 - - - New material chunk which supports the new features of the 3D engine - - Modified HTrees to always have a root transform to remove all of the - special case -1 bone indexes. - - Added new mesh types, A mesh can now be categorized as: normal, - aligned, skin, collision, or shadow. - -June 22, 1998 - - Removed the "SECTMESH" chunks which were never implemented or used. - - Adding a new type of object: The 'Tilemap'. This simple-sounding object - is a binary partition tree of tiles where tiles are rectangular regions of - space. In each leaf to the tree, a mesh is referenced. The tile map is - made of several chunks: - - - W3D_CHUNK_TILEMAP - - W3D_CHUNK_TILEMAP_HEADER - - W3D_CHUNK_TILES - - W3D_CHUNK_MESH - - W3D_CHUNK_MESH - ... - - - W3D_CHUNK_PARTITION_TREE - - W3D_CHUNK_PARTITION_TREE_HEADER - - W3D_CHUNK_PARTITION_TREE_NODES - - - W3D_CHUNK_TILE_INSTANCES - - W3D_CHUNK_TILE_INSTANCE - - - -********************************************************************************/ - - -#define W3D_MAKE_VERSION(major,minor) (((major) << 16) | (minor)) -#define W3D_GET_MAJOR_VERSION(ver) ((ver)>>16) -#define W3D_GET_MINOR_VERSION(ver) ((ver) & 0xFFFF) - -#define W3D_CURRENT_VERSION W3D_MAKE_VERSION(3,0) - - - -/******************************************************************************** - - CHUNK TYPES FOR ALL 3D DATA - - All 3d data is stored in chunks similar to an IFF file. Each - chunk will be headed by an ID and size field. - - All structures defined in this header file are prefixed with - W3d to prevent naming conflicts with in-game structures which - may be slightly different than the on-disk structures. - -********************************************************************************/ - -enum { - - W3D_CHUNK_MESH = 0, // Mesh definition (.WTM file) - W3D_CHUNK_MESH_HEADER, // header for a mesh - W3D_CHUNK_VERTICES, // array of vertices - W3D_CHUNK_VERTEX_NORMALS, // array of normals - W3D_CHUNK_SURRENDER_NORMALS, // array of surrender normals (one per vertex as req. by surrender) - W3D_CHUNK_TEXCOORDS, // array of texture coordinates - W3D_CHUNK_MATERIALS, // array of materials - O_W3D_CHUNK_TRIANGLES, // array of triangles (obsolete) - O_W3D_CHUNK_QUADRANGLES, // array of quads (obsolete) - W3D_CHUNK_SURRENDER_TRIANGLES,// array of surrender format tris - O_W3D_CHUNK_POV_TRIANGLES, // POV format triangles (obsolete) - O_W3D_CHUNK_POV_QUADRANGLES, // POV format quads (obsolete) - W3D_CHUNK_MESH_USER_TEXT, // Name of owning hierarchy, text from the MAX comment field - W3D_CHUNK_VERTEX_COLORS, // Pre-set vertex coloring - W3D_CHUNK_VERTEX_INFLUENCES, // Mesh Deformation vertex connections - W3D_CHUNK_DAMAGE, // Mesh damage, new set of materials, vertex positions, vertex colors - W3D_CHUNK_DAMAGE_HEADER, // Header for the damage data, tells what is coming - W3D_CHUNK_DAMAGE_VERTICES, // Array of modified vertices (W3dMeshDamageVertexStruct's) - W3D_CHUNK_DAMAGE_COLORS, // Array of modified vert colors (W3dMeshDamageColorStruct's) - O_W3D_CHUNK_DAMAGE_MATERIALS, // (OBSOLETE) Damage materials simply wrapped with MATERIALS3 or higher - - W3D_CHUNK_MATERIALS2, // array of version 2 materials (with animation frame counts) - - W3D_CHUNK_MATERIALS3, // array of version 3 materials (all new surrender features supported) - W3D_CHUNK_MATERIAL3, // Each version 3 material wrapped with this chunk ID - W3D_CHUNK_MATERIAL3_NAME, // Name of the material (array of chars, null terminated) - W3D_CHUNK_MATERIAL3_INFO, // contains a W3dMaterial3Struct, general material info - W3D_CHUNK_MATERIAL3_DC_MAP, // wraps the following two chunks, diffuse color texture - W3D_CHUNK_MAP3_FILENAME, // filename of the texture - W3D_CHUNK_MAP3_INFO, // a W3dMap3Struct - W3D_CHUNK_MATERIAL3_DI_MAP, // diffuse illimination map, same format as other maps - W3D_CHUNK_MATERIAL3_SC_MAP, // specular color map, same format as other maps - W3D_CHUNK_MATERIAL3_SI_MAP, // specular illumination map, same format as other maps - - W3D_CHUNK_MESH_HEADER3, // New improved mesh header - W3D_CHUNK_TRIANGLES, // New improved triangles chunk - W3D_CHUNK_PER_TRI_MATERIALS, // Multi-Mtl meshes - An array of uint16 material id's - - W3D_CHUNK_HIERARCHY = 0x100, // hierarchy tree definition (.WHT file) - W3D_CHUNK_HIERARCHY_HEADER, - W3D_CHUNK_PIVOTS, - W3D_CHUNK_PIVOT_FIXUPS, // only needed by the exporter... - - W3D_CHUNK_ANIMATION = 0x200, // hierarchy animation data (.WHA file) - W3D_CHUNK_ANIMATION_HEADER, - W3D_CHUNK_ANIMATION_CHANNEL, - W3D_CHUNK_BIT_CHANNEL, // channel of boolean values (e.g. visibility) - - W3D_CHUNK_HMODEL = 0x300, // blueprint for a hierarchy model - W3D_CHUNK_HMODEL_HEADER, // usually found at end of a .WTM file - W3D_CHUNK_NODE, // render objects connected to the hierarchy - W3D_CHUNK_COLLISION_NODE, // collision meshes connected to the hierarchy - W3D_CHUNK_SKIN_NODE, // skins connected to the hierarchy - W3D_CHUNK_HMODEL_AUX_DATA, // extension of the connection header - W3D_CHUNK_SHADOW_NODE, // shadow object connected to the hierarchy - - W3D_CHUNK_LODMODEL = 0x400, // blueprint for an LOD model. This is simply a - W3D_CHUNK_LODMODEL_HEADER, // collection of 'n' render objects, ordered in terms - W3D_CHUNK_LOD, // of their expected rendering costs. - - W3D_CHUNK_TILEMAP = 0x600, // Tile Map definition. - W3D_CHUNK_TILEMAP_NAME, - W3D_CHUNK_TILEMAP_HEADER, - W3D_CHUNK_TILEMAP_TILE_INSTANCES, - W3D_CHUNK_TILEMAP_PARTITION_TREE, - W3D_CHUNK_TILEMAP_PARTITION_NODE, - -}; - - -struct W3dChunkHeader -{ - uint32 ChunkType; // Type of chunk (see above enumeration) - uint32 ChunkSize; // Size of the chunk, (not including the chunk header) -}; - - -/******************************************************************************** - - WTM ( Westwood Triangle Mesh ) - - Each mesh will be contained within a WTM_CHUNK_MESH within - this chunk will be the following chunks: - - The header will be the first chunk and it tells general - information about the mesh such as how many triangles there - are, how many vertices, the bounding box, center - of mass, inertia matrix, etc. - - The vertex array is an array of Vectors giving the object - space location of each vertex - - The normal array is an array of all of the unique vertex - normal vectors needed by the mesh. This allows for vertices - with multiple normals so that we can duplicate the effect - of the smoothing groups in 3dsMax. - - The surrender normal array is an array of vertex normals which - correspond 1to1 with the vertices. This is because the current - version of surrender can only handle one vertex normal per vertex. - In this case, the application should skip the normal array chunk - and read the surrender normal chunk into its SR_VERTs - - The texture coord array is all of the unique texture coordinates - for the mesh. This allows triangles to share vertices but not - necessarily share texture coordinates. - - The material array is a list of the names and rgb colors of - all of the unique materials used by the mesh. All triangles will - have a material index into this list. - - The triangle array is all of the triangles which make up the - mesh. Each triangle has 3 indices to its vertices, vertex normals, - and texture coordinates. Each also has a material id and the - coefficients for its plane equation. - - The Surrender Triangle array is all of the triangles in a slightly - different format. Surrender triangles contain their u-v coordinates - so there is no indirection and no possibility for sharing. To - make the importer faster, the triangles will also be stored in this - format. The application can read whichever chunk it wants to. - - The mesh user text chunk is a NULL-terminated text buffer. - -********************************************************************************/ - -#define W3D_NAME_LEN 16 - -///////////////////////////////////////////////////////////////////////////////////////////// -// vector -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dVectorStruct -{ - float32 X; // X,Y,Z coordinates - float32 Y; - float32 Z; -}; - -///////////////////////////////////////////////////////////////////////////////////////////// -// quaternion -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dQuaternionStruct -{ - float32 Q[4]; -}; - -///////////////////////////////////////////////////////////////////////////////////////////// -// texture coordinate -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dTexCoordStruct -{ - float32 U; // U,V coordinates - float32 V; -}; - -///////////////////////////////////////////////////////////////////////////////////////////// -// rgb color, one byte per channel, padded to an even 4 bytes -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dRGBStruct -{ - uint8 R; - uint8 G; - uint8 B; - uint8 pad; -}; - -///////////////////////////////////////////////////////////////////////////////////////////// -// Version 1.0 Material, array of these are found inside the W3D_CHUNK_MATERIALS chunk. -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dMaterialStruct -{ - char MaterialName[W3D_NAME_LEN]; // name of the material (NULL terminated) - char PrimaryName[W3D_NAME_LEN]; // primary texture name (NULL terminated) - char SecondaryName[W3D_NAME_LEN]; // secondary texture name (NULL terminated) - uint32 RenderFlags; // Rendering flags - uint8 Red; // Rgb colors - uint8 Green; - uint8 Blue; -}; - -///////////////////////////////////////////////////////////////////////////////////////////// -// Version 2.0 Material, array of these are found inside the W3D_CHUNK_MATERIALS2 chunk. -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dMaterial2Struct -{ - char MaterialName[W3D_NAME_LEN]; // name of the material (NULL terminated) - char PrimaryName[W3D_NAME_LEN]; // primary texture name (NULL terminated) - char SecondaryName[W3D_NAME_LEN]; // secondary texture name (NULL terminated) - uint32 RenderFlags; // Rendering flags - uint8 Red; // Rgb colors - uint8 Green; - uint8 Blue; - uint8 Alpha; - - uint16 PrimaryNumFrames; // number of animated frames (if 1, not animated) - uint16 SecondaryNumFrames; // number of animated frames (if 1, not animated) - - char Pad[12]; // expansion room -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// -// MATERIAL ATTRIBUTES (version 3.0 onward) -///////////////////////////////////////////////////////////////////////////////////////////// -// Use alpha enables alpha channels, etc, Use sorting causes display lists using -// this material to be sorted (even with z-buf, translucent materials need to be sorted) -#define W3DMATERIAL_USE_ALPHA 0x00000001 -#define W3DMATERIAL_USE_SORTING 0x00000002 - -// Hints for render devices that cannot support all features -#define W3DMATERIAL_HINT_DIT_OVER_DCT 0x00000010 -#define W3DMATERIAL_HINT_SIT_OVER_SCT 0x00000020 -#define W3DMATERIAL_HINT_DIT_OVER_DIG 0x00000040 -#define W3DMATERIAL_HINT_SIT_OVER_SIG 0x00000080 -#define W3DMATERIAL_HINT_FAST_SPECULAR_AFTER_ALPHA 0x00000100 - -// Last byte is for PSX: Translucency type and a lighting disable flag. -#define W3DMATERIAL_PSX_MASK 0xFF000000 -#define W3DMATERIAL_PSX_TRANS_MASK 0x07000000 -#define W3DMATERIAL_PSX_TRANS_NONE 0x00000000 -#define W3DMATERIAL_PSX_TRANS_100 0x01000000 -#define W3DMATERIAL_PSX_TRANS_50 0x02000000 -#define W3DMATERIAL_PSX_TRANS_25 0x03000000 -#define W3DMATERIAL_PSX_TRANS_MINUS_100 0x04000000 -#define W3DMATERIAL_PSX_NO_RT_LIGHTING 0x08000000 - -///////////////////////////////////////////////////////////////////////////////////////////// -// MAPPING TYPES (version 3.0 onward) -///////////////////////////////////////////////////////////////////////////////////////////// -#define W3DMAPPING_UV 0 -#define W3DMAPPING_ENVIRONMENT 1 - -///////////////////////////////////////////////////////////////////////////////////////////// -// Version 3.0 Material, A W3D_CHUNK_MATERIALS3 chunk will wrap a bunch of -// W3D_CHUNK_MATERIAL3 chunks. Inside each chunk will be a name chunk, an 'info' chunk which -// contains the following struct, and one or more map chunks. a mesh with 2 materials might -// look like: -// -// W3D_CHUNK_MATERIALS3 <-- simply a wrapper around the array of mtls -// W3D_CHUNK_MATERIAL3 <-- a wrapper around each material -// W3D_CHUNK_STRING <-- name of the material -// W3D_CHUNK_MATERIAL3_INFO <-- standard material properties, a W3dMaterial3Struct -// W3D_CHUNK_MATERIAL3_DC_MAP <-- a map, W3dMap3Struct -// W3D_CHUNK_STRING <-- filename of the map -// W3D_CHUNK_MAP_INFO <-- map parameters -// W3D_CHUNK_MATERIAL3_SC_MAP -// W3D_CHUNK_STRING <-- filename of the map -// W3D_CHUNK_MAP_INFO -// W3D_CHUNK_MATERIAL3 -// W3D_CHUNK_MATERIAL3_NAME -// W3D_CHUNK_MATERIAL3_INFO -// W3D_CHUNK_MATERIAL3_SI_MAP -// -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dMaterial3Struct -{ - uint32 Attributes; // flags,hints,etc. - - W3dRGBStruct DiffuseColor; // diffuse color - W3dRGBStruct SpecularColor; // specular color - - W3dRGBStruct EmissiveCoefficients; // emmissive coefficients, default to 0,0,0 - W3dRGBStruct AmbientCoefficients; // ambient coefficients, default to 1,1,1 - W3dRGBStruct DiffuseCoefficients; // diffuse coeficients, default to 1,1,1 - W3dRGBStruct SpecularCoefficients; // specular coefficients, default to 0,0,0 - - float32 Shininess; // how tight the specular highlight will be, 1 - 1000 (default = 1) - float32 Opacity; // how opaque the material is, 0.0 = invisible, 1.0 = fully opaque (default = 1) - float32 Translucency; // how much light passes through the material. (default = 0) - float32 FogCoeff; // effect of fog (0.0=not fogged, 1.0=fogged) (default = 1) -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// -// A map, only occurs as part of a material, will be preceeded by its name. -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dMap3Struct -{ - uint16 MappingType; // Mapping type, will be one of the above #defines (e.g. W3DMAPPING_UV) - uint16 FrameCount; // Number of frames (1 if not animated) - float32 FrameRate; // Frame rate, frames per second in floating point -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// -// A triangle, occurs inside the W3D_CHUNK_SURRENDER_TRIANGLES chunk -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dSurrenderTriStruct -{ - uint32 Vindex[3]; // vertex, vert normal, and texture coord indexes (all use same index) - W3dTexCoordStruct TexCoord[3]; // texture coordinates (OBSOLETE!!!) - uint32 MaterialIdx; // material index - W3dVectorStruct Normal; // Face normal - uint32 Attributes; // collision flags, sort method, etc - W3dRGBStruct Gouraud[3]; // Pre-set shading values (OBSOLETE!!!) -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// -// A triangle, occurs inside the W3D_CHUNK_TRIANGLES chunk -// This is NEW for Version 3. -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dTriStruct -{ - uint32 Vindex[3]; // vertex,vnormal,texcoord,color indices - uint32 Attributes; // attributes bits - W3dVectorStruct Normal; // plane normal - float32 Dist; // plane distance -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// -// Flags for the Mesh Attributes member -///////////////////////////////////////////////////////////////////////////////////////////// -#define W3D_MESH_FLAG_NONE 0x00000000 // plain ole normal mesh -#define W3D_MESH_FLAG_COLLISION_BOX 0x00000001 // mesh is a collision box (should be 8 verts, should be hidden, etc) -#define W3D_MESH_FLAG_SKIN 0x00000002 // skin mesh -#define W3D_MESH_FLAG_SHADOW 0x00000004 // intended to be projected as a shadow -#define W3D_MESH_FLAG_ALIGNED 0x00000008 // always aligns with camera - -#define W3D_MESH_FLAG_COLLISION_TYPE_MASK 0x00000FF0 // mask for the collision type bits -#define W3D_MESH_FLAG_COLLISION_TYPE_SHIFT 4 // shifting to get to the collision type bits -#define W3D_MESH_FLAG_COLLISION_TYPE_PHYSICAL 0x00000010 // physical collisions -#define W3D_MESH_FLAG_COLLISION_TYPE_PROJECTILE 0x00000020 // projectiles (rays) collide with this - -#define W3D_MESH_FLAG_HIDDEN 0x00001000 // this mesh is hidden by default - - -///////////////////////////////////////////////////////////////////////////////////////////// -// Original (Obsolete) Mesh Header -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dMeshHeaderStruct -{ - uint32 Version; // Currently version 0x100 - char MeshName[W3D_NAME_LEN]; // name of the mesh (Null terminated) - uint32 Attributes; - - // - // Counts, these can be regarded as an inventory of what is to come in the file. - // - uint32 NumTris; // number of triangles (OBSOLETE!) - uint32 NumQuads; // number of quads; (OBSOLETE!) - uint32 NumSrTris; // number of triangles - - uint32 NumPovTris; // (NOT USED) - uint32 NumPovQuads; // (NOT USED) - - uint32 NumVertices; // number of unique vertices - uint32 NumNormals; // number of unique normals (OBSOLETE!) - uint32 NumSrNormals; // number of surrender normals (MUST EQUAL NumVertices or 0) - - uint32 NumTexCoords; // number of unique texture coords (MUST EQUAL NumVertices or 0) - uint32 NumMaterials; // number of unique materials needed - - uint32 NumVertColors; // number of vertex colors (MUST EQUAL NumVertices or 0) - uint32 NumVertInfluences;// vertex influences(MUST EQUAL NumVertices or 0) - uint32 NumDamageStages; // number of damage offset chunks - uint32 FutureCounts[5]; // reserve space for future counts (set to zero). - - // - // LOD controls - // - float32 LODMin; // min LOD distance - float32 LODMax; // max LOD distance - - // - // Collision / rendering quick-rejection - // - W3dVectorStruct Min; // Min corner of the bounding box - W3dVectorStruct Max; // Max corner of the bounding box - W3dVectorStruct SphCenter; // Center of bounding sphere - float32 SphRadius; // Bounding sphere radius - - // - // Default transformation - // - W3dVectorStruct Translation; - float32 Rotation[9]; - - // - // Physics Properties - // - W3dVectorStruct MassCenter; // Center of mass in object space - float32 Inertia[9]; // Inertia tensor (relative to MassCenter) - float32 Volume; // volume of the object - - // - // Name of possible hierarchy this mesh should be attached to - // - char HierarchyTreeName[W3D_NAME_LEN]; - char HierarchyModelName[W3D_NAME_LEN]; - uint32 FutureUse[24]; // Reserved for future use -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// -// Version 3 Mesh Header, trimmed out some of the junk that was in the -// previous versions. -///////////////////////////////////////////////////////////////////////////////////////////// -#define W3D_VERTEX_CHANNEL_LOCATION 0x00000001 // object-space location of the vertex -#define W3D_VERTEX_CHANNEL_NORMAL 0x00000002 // object-space normal for the vertex -#define W3D_VERTEX_CHANNEL_TEXCOORD 0x00000004 // texture coordinate -#define W3D_VERTEX_CHANNEL_COLOR 0x00000008 // vertex color -#define W3D_VERTEX_CHANNEL_BONEID 0x00000010 // per-vertex bone id for skins - -#define W3D_FACE_CHANNEL_FACE 0x00000001 // basic face info, W3dTriStruct... - -struct W3dMeshHeader3Struct -{ - uint32 Version; - uint32 Attributes; - - char MeshName[W3D_NAME_LEN]; - char HierarchyModelName[W3D_NAME_LEN]; - - // - // Counts, these can be regarded as an inventory of what is to come in the file. - // - uint32 NumTris; // number of triangles - uint32 NumVertices; // number of unique vertices - uint32 NumMaterials; // number of unique materials - uint32 NumDamageStages; // number of damage offset chunks - uint32 FutureCounts[3]; // future counts - - uint32 VertexChannels; // bits for presence of types of per-vertex info - uint32 FaceChannels; // bits for presence of types of per-face info - - // - // Bounding volumes - // - W3dVectorStruct Min; // Min corner of the bounding box - W3dVectorStruct Max; // Max corner of the bounding box - W3dVectorStruct SphCenter; // Center of bounding sphere - float32 SphRadius; // Bounding sphere radius - -}; - -// -// Vertex Influences. For "skins" each vertex can be associated with a -// different bone. -// -struct W3dVertInfStruct -{ - uint16 BoneIdx; - uint8 Pad[6]; -}; - -// -// Mesh Damage. This can include a new set of materials for the mesh, -// new positions for certain vertices in the mesh, and new vertex -// colors for certain vertices. -// -struct W3dMeshDamageStruct -{ - uint32 NumDamageMaterials; // number of materials to replace - uint32 NumDamageVerts; // number of vertices to replace - uint32 NumDamageColors; // number of vertex colors to replace - uint32 DamageIndex; // what index is this damage chunk assigned to - uint32 FutureUse[4]; -}; - -struct W3dMeshDamageVertexStruct -{ - uint32 VertexIndex; - W3dVectorStruct NewVertex; -}; - -struct W3dMeshDamageColorStruct -{ - uint32 VertexIndex; - W3dRGBStruct NewColor; -}; - - -/******************************************************************************** - - WHT ( Westwood Hierarchy Tree ) - - A hierarchy tree defines a set of coordinate systems which are connected - hierarchically. The header defines the name, number of pivots, etc. - The pivots chunk will contain a W3dPivotStructs for each node in the - tree. - - The W3dPivotFixupStruct contains a transform for each MAX coordinate - system and our version of that same coordinate system (bone). It is - needed when the user exports the base pose using "Translation Only". - These are the matrices which go from the MAX rotated coordinate systems - to a system which is unrotated in the base pose. These transformations - are needed when exporting a hierarchy animation with the given hierarchy - tree file. - - Another explanation of these kludgy "fixup" matrices: - - What are the "fixup" matrices? These are the transforms which - were applied to the base pose when the user wanted to force the - base pose to use only matrices with certain properties. For - example, if we wanted the base pose to use translations only, - the fixup transform for each node is a transform which when - multiplied by the real node's world transform, yeilds a pure - translation matrix. Fixup matrices are used in the mesh - exporter since all vertices must be transformed by their inverses - in order to make things work. They also show up in the animation - exporter because they are needed to make the animation work with - the new base pose. - -********************************************************************************/ - -struct W3dHierarchyStruct -{ - uint32 Version; - char Name[W3D_NAME_LEN]; // Name of the hierarchy - uint32 NumPivots; - W3dVectorStruct Center; -}; - -struct W3dPivotStruct -{ - char Name[W3D_NAME_LEN]; // Name of the node (UR_ARM, LR_LEG, TORSO, etc) - uint32 ParentIdx; // 0xffffffff = root pivot; no parent - W3dVectorStruct Translation; // translation to pivot point - W3dVectorStruct EulerAngles; // orientation of the pivot point - W3dQuaternionStruct Rotation; // orientation of the pivot point -}; - -struct W3dPivotFixupStruct -{ - float32 TM[4][3]; // this is a direct dump of a MAX 3x4 matrix -}; - - -/******************************************************************************** - - WHA (Westwood Hierarchy Animation) - - A Hierarchy Animation is a set of data defining deltas from the base - position of a hierarchy tree. Translation and Rotation channels can be - attached to any node of the hierarchy tree which the animation is - associated with. - -********************************************************************************/ - -struct W3dAnimHeaderStruct -{ - uint32 Version; - char Name[W3D_NAME_LEN]; - char HierarchyName[W3D_NAME_LEN]; - uint32 NumFrames; - uint32 FrameRate; -}; - -enum -{ - ANIM_CHANNEL_X = 0, - ANIM_CHANNEL_Y, - ANIM_CHANNEL_Z, - ANIM_CHANNEL_XR, - ANIM_CHANNEL_YR, - ANIM_CHANNEL_ZR, - ANIM_CHANNEL_Q -}; - -struct W3dAnimChannelStruct -{ - uint16 FirstFrame; - uint16 LastFrame; - uint16 VectorLen; // length of each vector in this channel - uint16 Flags; // channel type. - uint16 Pivot; // pivot affected by this channel - uint16 pad; - float32 Data[1]; // will be (LastFrame - FirstFrame + 1) * VectorLen long -}; - -enum -{ - BIT_CHANNEL_VIS = 0, // turn meshes on and off depending on anim frame. -}; - -struct W3dBitChannelStruct -{ - uint16 FirstFrame; // all frames outside "First" and "Last" are assumed = DefaultVal - uint16 LastFrame; - uint16 Flags; // channel type. - uint16 Pivot; // pivot affected by this channel - uint8 DefaultVal; // default state when outside valid range. - uint8 Data[1]; // will be (LastFrame - FirstFrame + 1) / 8 long -}; - -/******************************************************************************** - - (HModel - Hiearchy Model) - - A Hierarchy Model is a set of render objects which should be attached to - bones in a hierarchy tree. There can be multiple objects per node - in the tree. Or there may be no objects attached to a particular bone. - -********************************************************************************/ - -struct W3dHModelHeaderStruct -{ - uint32 Version; - char Name[W3D_NAME_LEN]; // Name of this connection set (NULL terminated) - char HierarchyName[W3D_NAME_LEN]; // Name of hierarchy associated with these connections (NULL terminated) - uint16 NumConnections; -}; - -struct W3dHModelAuxDataStruct -{ - uint32 Attributes; - uint32 MeshCount; - uint32 CollisionCount; - uint32 SkinCount; - uint32 ShadowCount; - uint32 FutureCounts[7]; - - float32 LODMin; - float32 LODMax; - uint32 FutureUse[32]; -}; - -struct W3dHModelNodeStruct -{ - // Note: the full name of the Render object is expected to be: . - char RenderObjName[W3D_NAME_LEN]; - uint16 PivotIdx; -}; - - -/******************************************************************************** - - (LODModel - Level-Of-Detail Model) - - An LOD Model is a set of render objects which are interchangeable and - designed to be different resolution versions of the same object. - -********************************************************************************/ - -struct W3dLODModelHeaderStruct -{ - uint32 Version; - char Name[W3D_NAME_LEN]; // Name of this LOD Model - uint16 NumLODs; -}; - -struct W3dLODStruct -{ - char RenderObjName[2*W3D_NAME_LEN]; - float32 LODMin; // "artist" inspired switching distances - float32 LODMax; -}; - - -/******************************************************************************** - - TileMap - - - -********************************************************************************/ - -struct W3dTileMapHeaderStruct -{ - uint32 Version; - uint32 TileInstanceCount; -}; - -#define W3D_TILE_ROTATION_0 0x00 -#define W3D_TILE_ROTATION_90 0x01 -#define W3D_TILE_ROTATION_180 0x02 -#define W3D_TILE_ROTATION_270 0x03 - -struct W3dTileInstanceStruct -{ - char RenderObjName[2*W3D_NAME_LEN]; - uint32 Rotation; - W3dVectorStruct Position; -}; - -#define W3D_TILEMAP_PARTITION_FLAGS_PARTITION 0x0001 -#define W3D_TILEMAP_PARTITION_FLAGS_LEAF 0x0002 -#define W3D_TILEMAP_PARTITION_FLAGS_XNORMAL 0x0004 -#define W3D_TILEMAP_PARTITION_FLAGS_YNORMAL 0x0008 -#define W3D_TILEMAP_PARTITION_FLAGS_ZNORMAL 0x0010 -#define W3D_TILEMAP_PARTITION_FLAGS_FRONT_CHILD 0x0020 -#define W3D_TILEMAP_PARTITION_FLAGS_BACK_CHILD 0x0040 - -struct W3dTileMapPartitionStruct -{ - uint16 Flags; // type of node, type of plane, flags for presence of children. - uint16 InstanceIndex; // if Type==LEAF, this field will store the tile instance index. - float32 Dist; // distance along plane axis. - W3dVectorStruct Min; // min corner of the bounding box - W3dVectorStruct Max; // max corner of the bounding box -}; - - - -#endif diff --git a/Generals/Code/Tools/WW3D/pluglib/w3dquat.cpp b/Generals/Code/Tools/WW3D/pluglib/w3dquat.cpp deleted file mode 100644 index 921e77d377f..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/w3dquat.cpp +++ /dev/null @@ -1,709 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/w3dquat.cpp 29 2/03/00 4:55p Jason_a $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Voxel Technology * - * * - * File Name : QUAT.CPP * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 02/24/97 * - * * - * Last Update : February 28, 1997 [GH] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Quaternion::Quaternion -- constructor * - * Quaternion::Set -- Set the quaternion * - * Quaternion::operator= -- Assignment operator * - * Quaternion::Make_Closest -- Use nearest representation to the given quaternion. * - * Trackball -- Computes a "trackball" quaternion given 2D mouse coordinates * - * Axis_To_Quat -- Creates a quaternion given an axis and angle of rotation * - * Slerp -- Spherical Linear interpolation! * - * Build_Quaternion -- Creates a quaternion from a Matrix * - * Build_Matrix -- Creates a Matrix from a Quaternion * - * Normalize -- normalizes a quaternion * - * Quaternion::Quaternion -- constructor * - * Slerp_Setup -- Get ready to call "Cached_Slerp" * - * Cached_Slerp -- Quaternion slerping, optimized with cached values * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "w3dquat.h" -#include "matrix3d.h" -#include "matrix4.h" -#include "wwmath.h" - -#include -//#include -#include -#include -#include - -#define SLERP_EPSILON 0.001 - -static int _nxt[3] = { 1 , 2 , 0 }; - - -// ------------------------------------------------------------ -// local functions -// ------------------------------------------------------------ -static float project_to_sphere(float,float,float); - - -/*********************************************************************************************** - * Quaternion::Quaternion -- constructor * - * * - * constructs a quaternion from the given axis and angle of rotation (in RADIANS of course) * - * * - * INPUT: * - * axis - axis of the rotation * - * angle - rotation angle * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/10/97 GTH : Created. * - *=============================================================================================*/ -Quaternion::Quaternion(const Vector3 & axis,float angle) -{ - float s = sinf(angle/2); - float c = cosf(angle/2); - X = s * axis.X; - Y = s * axis.Y; - Z = s * axis.Z; - W = c; -} - - -/*********************************************************************************************** - * Quaternion::Normalize -- Normalize to a unit quaternion * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *=============================================================================================*/ -void Quaternion::Normalize() -{ - float mag = WWMath::Sqrt(X * X + Y * Y + Z * Z + W * W); - - if (0.0f == mag) { - return; - } else { - X /= mag; - Y /= mag; - Z /= mag; - W /= mag; - } -} - -/*********************************************************************************************** - * Quaternion::operator= -- Assignment operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/24/1997 GH : Created. * - *=============================================================================================*/ -Quaternion & Quaternion::operator = (const Quaternion & source) -{ - X = source[0]; - Y = source[1]; - Z = source[2]; - W = source[3]; - - return *this; -} - -/*********************************************************************************************** - * Q::Make_Closest -- Use nearest representation to the given quaternion. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/28/1997 GH : Created. * - *=============================================================================================*/ -Quaternion & Quaternion::Make_Closest(const Quaternion & qto) -{ - float cos_t = qto.X * X + qto.Y * Y + qto.Z * Z + qto.W * W; - - // if we are on opposite hemisphere from qto, negate ourselves - if (cos_t < 0.0) { - X = -X; - Y = -Y; - Z = -Z; - W = -W; - } - - return *this; -} - -/*********************************************************************************************** - * Trackball -- Computes a "trackball" quaternion given 2D mouse coordinates * - * * - * INPUT: * - * x0,y0 - x1,y1 - "normalized" mouse coordinates for the mouse movement * - * sphsize - size of the trackball sphere * - * * - * OUTPUT: * - * a quaternion representing the rotation of a trackball * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/28/1997 GH : Created. * - *=============================================================================================*/ -Quaternion Trackball(float x0, float y0, float x1, float y1, float sphsize) -{ - Vector3 a; - Vector3 p1; - Vector3 p2; - Vector3 d; - - float phi,t; - - if ((x0 == x1) && (y0 == y1)) { - return Quaternion(0.0f, 0.0f, 0.0f, 1.0f); // Zero rotation - } - - - // Compute z coordinates for projection of p1 and p2 to - // deformed sphere - p1[0] = x0; - p1[1] = y0; - p1[2] = project_to_sphere(sphsize, x0, y0); - - p2[0] = x1; - p2[1] = y1; - p2[2] = project_to_sphere(sphsize, x1, y1); - - - // Find their cross product - Vector3::Cross_Product(p2,p1,&a); - - // Compute how much to rotate - d = p1 - p2; - t = d.Length() / (2.0f * sphsize); - - // Avoid problems with out of control values - if (t > 1.0f) t = 1.0f; - if (t < -1.0f) t = -1.0f; - phi = 2.0f * asin(t); - - return Axis_To_Quat(a, phi); -} - - -/*********************************************************************************************** - * Axis_To_Quat -- Creates a quaternion given an axis and angle of rotation * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/28/1997 GH : Created. * - *=============================================================================================*/ -Quaternion Axis_To_Quat(const Vector3 &a, float phi) -{ - Quaternion q; - Vector3 tmp = a; - - tmp.Normalize(); - q[0] = tmp[0]; - q[1] = tmp[1]; - q[2] = tmp[2]; - - q.Scale(sinf(phi / 2.0f)); - q[3] = cosf(phi / 2.0f); - - return q; -} - -/*********************************************************************************************** - * Slerp -- Spherical Linear interpolation! * - * * - * INPUT: * - * p - start quaternion * - * q - end quaternion * - * alpha - interpolating parameter * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/28/1997 GH : Created. * - *=============================================================================================*/ -Quaternion Slerp(const Quaternion & p,const Quaternion & q,float alpha) -{ - float beta; // complementary interploation parameter - float theta; // angle between p and q - float sin_t,cos_t; // sine, cosine of theta - float oo_sin_t; - int qflip; // use flip of q? - - // cos theta = dot product of p and q - cos_t = p.X * q.X + p.Y * q.Y + p.Z * q.Z + p.W * q.W; - - // if q is on opposite hemisphere from A, use -B instead - if (cos_t < 0.0) { - cos_t = -cos_t; - qflip = true; - } else { - qflip = false; - } - - if (1.0 - cos_t < SLERP_EPSILON) { - - // if q is very close to p, just linearly interpolate - // between the two. - beta = 1.0 - alpha; - - } else { - - // normal slerp! - theta = acos(cos_t); - sin_t = sinf(theta); - oo_sin_t = 1.0 / sin_t; - beta = sinf(theta - alpha*theta) * oo_sin_t; - alpha = sinf(alpha*theta) * oo_sin_t; - } - - if (qflip) { - alpha = -alpha; - } - - Quaternion res; - res.X = beta*p.X + alpha*q.X; - res.Y = beta*p.Y + alpha*q.Y; - res.Z = beta*p.Z + alpha*q.Z; - res.W = beta*p.W + alpha*q.W; - - return res; -} - - -/*********************************************************************************************** - * Slerp_Setup -- Get ready to call "Cached_Slerp" * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/27/98 GTH : Created. * - *=============================================================================================*/ -void Slerp_Setup(const Quaternion & p,const Quaternion & q,SlerpInfoStruct * slerpinfo) -{ - float cos_t; - - assert(slerpinfo != NULL); - - // cos theta = dot product of p and q - cos_t = p.X * q.X + p.Y * q.Y + p.Z * q.Z + p.W * q.W; - - // if q is on opposite hemisphere from A, use -B instead - if (cos_t < 0.0) { - cos_t = -cos_t; - slerpinfo->Flip = true; - } else { - slerpinfo->Flip = false; - } - - if (1.0 - cos_t < SLERP_EPSILON) { - - slerpinfo->Linear = true; - slerpinfo->Theta = 0.0f; - slerpinfo->SinT = 0.0f; - - } else { - - slerpinfo->Linear = false; - slerpinfo->Theta = acos(cos_t); - slerpinfo->SinT = sinf(slerpinfo->Theta); - - } -} - -/*********************************************************************************************** - * Cached_Slerp -- Quaternion slerping, optimized with cached values * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/27/98 GTH : Created. * - *=============================================================================================*/ -Quaternion Cached_Slerp(const Quaternion & p,const Quaternion & q,float alpha,SlerpInfoStruct * slerpinfo) -{ - float beta; // complementary interploation parameter - float oo_sin_t; - - if (slerpinfo->Linear) { - - // if q is very close to p, just linearly interpolate - // between the two. - beta = 1.0 - alpha; - - } else { - - // normal slerp! - oo_sin_t = 1.0 / slerpinfo->Theta; - beta = sin(slerpinfo->Theta - alpha*slerpinfo->Theta) * oo_sin_t; - alpha = sin(alpha*slerpinfo->Theta) * oo_sin_t; - } - - if (slerpinfo->Flip) { - alpha = -alpha; - } - - Quaternion res; - res.X = beta*p.X + alpha*q.X; - res.Y = beta*p.Y + alpha*q.Y; - res.Z = beta*p.Z + alpha*q.Z; - res.W = beta*p.W + alpha*q.W; - - return res; -} - -void Cached_Slerp(const Quaternion & p,const Quaternion & q,float alpha,SlerpInfoStruct * slerpinfo,Quaternion * set_q) -{ - float beta; // complementary interploation parameter - float oo_sin_t; - - if (slerpinfo->Linear) { - - // if q is very close to p, just linearly interpolate - // between the two. - beta = 1.0 - alpha; - - } else { - - // normal slerp! - oo_sin_t = 1.0 / slerpinfo->Theta; - beta = sin(slerpinfo->Theta - alpha*slerpinfo->Theta) * oo_sin_t; - alpha = sin(alpha*slerpinfo->Theta) * oo_sin_t; - } - - if (slerpinfo->Flip) { - alpha = -alpha; - } - - set_q->X = beta*p.X + alpha*q.X; - set_q->Y = beta*p.Y + alpha*q.Y; - set_q->Z = beta*p.Z + alpha*q.Z; - set_q->W = beta*p.W + alpha*q.W; -} - -/*********************************************************************************************** - * Build_Quaternion -- Creates a quaternion from a Matrix * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Matrix MUST NOT have scaling! * - * * - * HISTORY: * - * 02/28/1997 GH : Created. * - *=============================================================================================*/ -Quaternion Build_Quaternion(const Matrix3D & mat) -{ - float tr,s; - int i,j,k; - Quaternion q; - - // sum the diagonal of the rotation matrix - tr = mat[0][0] + mat[1][1] + mat[2][2]; - - if (tr > 0.0f) { - - s = sqrt(tr + 1.0); - q[3] = s * 0.5; - s = 0.5 / s; - - q[0] = (mat[2][1] - mat[1][2]) * s; - q[1] = (mat[0][2] - mat[2][0]) * s; - q[2] = (mat[1][0] - mat[0][1]) * s; - - } else { - - i=0; - if (mat[1][1] > mat[0][0]) i = 1; - if (mat[2][2] > mat[i][i]) i = 2; - j = _nxt[i]; - k = _nxt[j]; - - s = sqrt((mat[i][i] - (mat[j][j] + mat[k][k])) + 1.0); - - q[i] = s * 0.5; - if (s != 0.0) { - s = 0.5 / s; - } - - q[3] = ( mat[k][j] - mat[j][k] ) * s; - q[j] = ( mat[j][i] + mat[i][j] ) * s; - q[k] = ( mat[k][i] + mat[i][k] ) * s; - - } - - return q; -} - -Quaternion Build_Quaternion(const Matrix3 & mat) -{ - float tr,s; - int i,j,k; - Quaternion q; - - // sum the diagonal of the rotation matrix - tr = mat[0][0] + mat[1][1] + mat[2][2]; - - if (tr > 0.0) { - - s = sqrt(tr + 1.0); - q[3] = s * 0.5; - s = 0.5 / s; - - q[0] = (mat[2][1] - mat[1][2]) * s; - q[1] = (mat[0][2] - mat[2][0]) * s; - q[2] = (mat[1][0] - mat[0][1]) * s; - - } else { - - i = 0; - if (mat[1][1] > mat[0][0]) i = 1; - if (mat[2][2] > mat[i][i]) i = 2; - - j = _nxt[i]; - k = _nxt[j]; - - s = sqrt( (mat[i][i] - (mat[j][j]+mat[k][k])) + 1.0); - - q[i] = s * 0.5; - - if (s != 0.0) { - s = 0.5/s; - } - - q[3] = ( mat[k][j] - mat[j][k] ) * s; - q[j] = ( mat[j][i] + mat[i][j] ) * s; - q[k] = ( mat[k][i] + mat[i][k] ) * s; - } - - return q; -} - -Quaternion Build_Quaternion(const Matrix4 & mat) -{ - float tr,s; - int i,j,k; - Quaternion q; - - // sum the diagonal of the rotation matrix - tr = mat[0][0] + mat[1][1] + mat[2][2]; - - if (tr > 0.0) { - - s = sqrt(tr + 1.0); - q[3] = s * 0.5; - s = 0.5 / s; - - q[0] = (mat[2][1] - mat[1][2]) * s; - q[1] = (mat[0][2] - mat[2][0]) * s; - q[2] = (mat[1][0] - mat[0][1]) * s; - - } else { - - i = 0; - if (mat[1][1] > mat[0][0]) i = 1; - if (mat[2][2] > mat[i][i]) i = 2; - - j = _nxt[i]; - k = _nxt[j]; - - s = sqrt( (mat[i][i] - (mat[j][j]+mat[k][k])) + 1.0); - - q[i] = s * 0.5; - if (s != 0.0) { - s = 0.5/s; - } - q[3] = ( mat[k][j] - mat[j][k] ) * s; - q[j] = ( mat[j][i] + mat[i][j] ) * s; - q[k] = ( mat[k][i] + mat[i][k] ) * s; - } - - return q; -} - - -/*********************************************************************************************** - * Build_Matrix -- Creates a Matrix from a Quaternion * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/28/1997 GH : Created. * - *=============================================================================================*/ -Matrix3 Build_Matrix3(const Quaternion & q) -{ - Matrix3 m; - - m[0][0] = (float)(1.0 - 2.0 * (q[1] * q[1] + q[2] * q[2])); - m[0][1] = (float)(2.0 * (q[0] * q[1] - q[2] * q[3])); - m[0][2] = (float)(2.0 * (q[2] * q[0] + q[1] * q[3])); - - m[1][0] = (float)(2.0 * (q[0] * q[1] + q[2] * q[3])); - m[1][1] = (float)(1.0 - 2.0f * (q[2] * q[2] + q[0] * q[0])); - m[1][2] = (float)(2.0 * (q[1] * q[2] - q[0] * q[3])); - - m[2][0] = (float)(2.0 * (q[2] * q[0] - q[1] * q[3])); - m[2][1] = (float)(2.0 * (q[1] * q[2] + q[0] * q[3])); - m[2][2] =(float)(1.0 - 2.0 * (q[1] * q[1] + q[0] * q[0])); - - return m; -} - -Matrix3D Build_Matrix3D(const Quaternion & q) -{ - Matrix3D m; - - // initialize the rotation sub-matrix - m[0][0] = (float)(1.0 - 2.0 * (q[1] * q[1] + q[2] * q[2])); - m[0][1] = (float)(2.0 * (q[0] * q[1] - q[2] * q[3])); - m[0][2] = (float)(2.0 * (q[2] * q[0] + q[1] * q[3])); - - m[1][0] = (float)(2.0 * (q[0] * q[1] + q[2] * q[3])); - m[1][1] = (float)(1.0 - 2.0f * (q[2] * q[2] + q[0] * q[0])); - m[1][2] = (float)(2.0 * (q[1] * q[2] - q[0] * q[3])); - - m[2][0] = (float)(2.0 * (q[2] * q[0] - q[1] * q[3])); - m[2][1] = (float)(2.0 * (q[1] * q[2] + q[0] * q[3])); - m[2][2] =(float)(1.0 - 2.0 * (q[1] * q[1] + q[0] * q[0])); - - // no translation - m[0][3] = m[1][3] = m[2][3] = 0.0f; - - return m; -} - -Matrix4 Build_Matrix4(const Quaternion & q) -{ - Matrix4 m; - - // initialize the rotation sub-matrix - m[0][0] = (float)(1.0 - 2.0 * (q[1] * q[1] + q[2] * q[2])); - m[0][1] = (float)(2.0 * (q[0] * q[1] - q[2] * q[3])); - m[0][2] = (float)(2.0 * (q[2] * q[0] + q[1] * q[3])); - - m[1][0] = (float)(2.0 * (q[0] * q[1] + q[2] * q[3])); - m[1][1] = (float)(1.0 - 2.0f * (q[2] * q[2] + q[0] * q[0])); - m[1][2] = (float)(2.0 * (q[1] * q[2] - q[0] * q[3])); - - m[2][0] = (float)(2.0 * (q[2] * q[0] - q[1] * q[3])); - m[2][1] = (float)(2.0 * (q[1] * q[2] + q[0] * q[3])); - m[2][2] = (float)(1.0 - 2.0 * (q[1] * q[1] + q[0] * q[0])); - - // no translation - m[0][3] = m[1][3] = m[2][3] = 0.0f; - - // last row - m[3][0] = m[3][1] = m[3][2] = 0.0f; - m[3][3] = 1.0f; - return m; -} - -void Quaternion::Rotate_X(float theta) -{ - // TODO: optimize this - *this = (*this) * Quaternion(Vector3(1,0,0),theta); -} - -void Quaternion::Rotate_Y(float theta) -{ - // TODO: optimize this - *this = (*this) * Quaternion(Vector3(0,1,0),theta); -} - -void Quaternion::Rotate_Z(float theta) -{ - // TODO: optimize this - *this = (*this) * Quaternion(Vector3(0,0,1),theta); -} - -float project_to_sphere(float r, float x, float y) -{ - const float SQRT2 = 1.41421356f; - float t, z; - float d = WWMath::Sqrt(x * x + y * y); - - if (d < r * (SQRT2/(2.0f))) // inside sphere - z = WWMath::Sqrt(r * r - d * d); - else { // on hyperbola - t = r / SQRT2; - z = t * t / d; - } - - return z; -} - - -void Quaternion::Randomize(void) -{ - X = ((float) (rand() & 0xFFFF)) / 65536.0f; - Y = ((float) (rand() & 0xFFFF)) / 65536.0f; - Z = ((float) (rand() & 0xFFFF)) / 65536.0f; - W = ((float) (rand() & 0xFFFF)) / 65536.0f; - - Normalize(); -} - - diff --git a/Generals/Code/Tools/WW3D/pluglib/w3dquat.h b/Generals/Code/Tools/WW3D/pluglib/w3dquat.h deleted file mode 100644 index 09e7567a15f..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/w3dquat.h +++ /dev/null @@ -1,262 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Tools/max2w3d/w3dquat.h 27 2/03/00 4:55p Jason_a $ */ -/*************************************************************************** - *** Confidential - Westwood Studios *** - *************************************************************************** - * * - * Project Name : Voxel Technology * - * * - * File Name : QUAT.H * - * * - * Programmer : Greg Hjelstrom * - * * - * Start Date : 02/24/97 * - * * - * Last Update : February 24, 1997 [GH] * - * * - *-------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef QUAT_H -#define QUAT_H - -#include "always.h" -#include "wwmath.h" -#include "WWmatrix3.h" -#include "vector3.h" - - -class Quaternion -{ -private: - -public: - - // X,Y,Z are the imaginary parts of the quaterion - // W is the real part - float X; - float Y; - float Z; - float W; - -public: - - Quaternion(void) {}; - explicit Quaternion(bool init) { if (init) { X = 0.0f; Y = 0.0f; Z = 0.0f; W = 1.0f; } } - explicit Quaternion(float a, float b, float c, float d) { X=a; Y=b; Z=c; W=d; } - explicit Quaternion(const Vector3 & axis,float angle); - Quaternion & operator=(const Quaternion & source); - - void Set(float a = 0.0, float b = 0.0, float c = 0.0, float d = 1.0) { X = a; Y = b; Z = c; W = d; } - void Make_Identity(void) { Set(); }; - void Scale(float s) { X = (float)(s*X); Y = (float)(s*Y); Z = (float)(s*Z); W = (float)(s*W); } - - // Array access - float & operator [](int i) { return (&X)[i]; } - const float & operator [](int i) const { return (&X)[i]; } - - // Unary operators. - // Remember that q and -q represent the same 3D rotation. - Quaternion operator-() const { return(Quaternion(-X,-Y,-Z,-W)); } - Quaternion operator+() const { return *this; } - - // Every 3D rotation can be expressed by two different quaternions, This - // function makes the current quaternion convert itself to the representation - // which is closer on the 4D unit-hypersphere to the given quaternion. - Quaternion & Make_Closest(const Quaternion & qto); - - // Square of the magnitude of the quaternion - float Length2(void) const { return (X*X + Y*Y + Z*Z + W*W); } - - // Magnitude of the quaternion - float Length(void) const { return WWMath::Sqrt(Length2()); } - - // Make the quaternion unit length - void Normalize(void); - - // post-concatenate rotations about the coordinate axes - void Rotate_X(float theta); - void Rotate_Y(float theta); - void Rotate_Z(float theta); - - // initialize this quaternion randomly (creates a random *unit* quaternion) - void Randomize(void); - - // transform (rotate) a vector with this quaternion - Vector3 Rotate_Vector(const Vector3 & v) const; - void Rotate_Vector(const Vector3 & v,Vector3 * set_result) const; - - // verify that none of the members of this quaternion are invalid floats - bool Is_Valid(void) const; -}; - -// Inverse of the quaternion (1/q) -inline Quaternion Inverse(const Quaternion & a) -{ - return Quaternion(-a[0],-a[1],-a[2],a[3]); -} - -// Conjugate of the quaternion -inline Quaternion Conjugate(const Quaternion & a) -{ - return Quaternion(-a[0],-a[1],-a[2],a[3]); -} - -// Add two quaternions -inline Quaternion operator + (const Quaternion & a,const Quaternion & b) -{ - return Quaternion(a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3]); -} - -// Subract two quaternions -inline Quaternion operator - (const Quaternion & a,const Quaternion & b) -{ - return Quaternion(a[0] - b[0], a[1] - b[1], a[2] - b[2], a[3] - b[3]); -} - -// Multiply a quaternion by a scalar: -inline Quaternion operator * (float scl, const Quaternion & a) -{ - return Quaternion(scl*a[0], scl*a[1], scl*a[2], scl*a[3]); -} - -// Multiply a quaternion by a scalar -inline Quaternion operator * (const Quaternion & a, float scl) -{ - return scl*a; -} - -// Multiply two quaternions -inline Quaternion operator * (const Quaternion & a,const Quaternion & b) -{ - return Quaternion - ( - a.W*b.X + b.W*a.X + (a.Y*b.Z - b.Y*a.Z), - a.W*b.Y + b.W*a.Y - (a.X*b.Z - b.X*a.Z), - a.W*b.Z + b.W*a.Z + (a.X*b.Y - b.X*a.Y), - a.W * b.W - (a.X * b.X + a.Y * b.Y + a.Z * b.Z) - ); -} - -// Divide two quaternions -inline Quaternion operator / (const Quaternion & a,const Quaternion & b) -{ - return a * Inverse(b); -} - -// Normalized version of the quaternion -inline Quaternion Normalize(const Quaternion & a) -{ - float mag = a.Length(); - if (0.0f == mag) { - return a; - } else { - float oomag = 1.0f / mag; - return Quaternion(a[0] * oomag, a[1] * oomag, a[2] * oomag, a[3] * oomag); - } -} - -// This function computes a quaternion based on an axis -// (defined by the given Vector a) and an angle about -// which to rotate. The angle is expressed in radians. -Quaternion Axis_To_Quat(const Vector3 &a, float angle); - -// Pass the x and y coordinates of the last and current position -// of the mouse, scaled so they are from -1.0 to 1.0 -// The quaternion is the computed as the rotation of a trackball -// between the two points projected onto a sphere. This can -// be used to implement an intuitive viewing control system. -Quaternion Trackball(float x0, float y0, float x1, float y1, float sphsize); - -// Spherical Linear interpolation of quaternions -Quaternion Slerp(const Quaternion & a,const Quaternion & b,float t); - -// Convert a rotation matrix into a quaternion -Quaternion Build_Quaternion(const Matrix3 & matrix); -Quaternion Build_Quaternion(const Matrix3D & matrix); -Quaternion Build_Quaternion(const Matrix4 & matrix); - -// Convert a quaternion into a rotation matrix -Matrix3 Build_Matrix3(const Quaternion & quat); -Matrix3D Build_Matrix3D(const Quaternion & quat); -Matrix4 Build_Matrix4(const Quaternion & quat); - - -// Some values can be cached if you are performing multiple slerps -// between the same two quaternions... -struct SlerpInfoStruct -{ - float SinT; - float Theta; - bool Flip; - bool Linear; -}; - -// Cached slerp implementation -void Slerp_Setup(const Quaternion & p,const Quaternion & q,SlerpInfoStruct * slerpinfo); -void Cached_Slerp(const Quaternion & p,const Quaternion & q,float alpha,SlerpInfoStruct * slerpinfo,Quaternion * set_q); -Quaternion Cached_Slerp(const Quaternion & p,const Quaternion & q,float alpha,SlerpInfoStruct * slerpinfo); - -inline Vector3 Quaternion::Rotate_Vector(const Vector3 & v) const -{ - float x = W*v.X + (Y*v.Z - v.Y*Z); - float y = W*v.Y - (X*v.Z - v.X*Z); - float z = W*v.Z + (X*v.Y - v.X*Y); - float w = -(X*v.X + Y*v.Y + Z*v.Z); - - return Vector3 - ( - w*(-X) + W*x + (y*(-Z) - (-Y)*z), - w*(-Y) + W*y - (x*(-Z) - (-X)*z), - w*(-Z) + W*z + (x*(-Y) - (-X)*y) - ); -} - -inline void Quaternion::Rotate_Vector(const Vector3 & v,Vector3 * result) const -{ - assert(result != NULL); - - float x = W*v.X + (Y*v.Z - v.Y*Z); - float y = W*v.Y - (X*v.Z - v.X*Z); - float z = W*v.Z + (X*v.Y - v.X*Y); - float w = -(X*v.X + Y*v.Y + Z*v.Z); - - result->X = w*(-X) + W*x + (y*(-Z) - (-Y)*z); - result->Y = w*(-Y) + W*y - (x*(-Z) - (-X)*z); - result->Z = w*(-Z) + W*z + (x*(-Y) - (-X)*y); -} - -inline bool Quaternion::Is_Valid(void) const -{ - return ( WWMath::Is_Valid_Float(X) && - WWMath::Is_Valid_Float(Y) && - WWMath::Is_Valid_Float(Z) && - WWMath::Is_Valid_Float(W) ); -} - -#endif /* QUAT_H */ - - - diff --git a/Generals/Code/Tools/WW3D/pluglib/watcom.h b/Generals/Code/Tools/WW3D/pluglib/watcom.h deleted file mode 100644 index 58e8cd07ff3..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/watcom.h +++ /dev/null @@ -1,118 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/WATCOM.H $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 11:56a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#if !defined(WATCOM_H) && defined(__WATCOMC__) -#define WATCOM_H - - -/********************************************************************** -** The "bool" integral type was defined by the C++ comittee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#include "bool.h" - -// Turn all warnings into errors. -#pragma warning * 0 - -// Disables warning when "sizeof" is used on an object with virtual functions. -#pragma warning 549 9 - -// Disable the "Integral value may be truncated during assignment or initialization". -#pragma warning 389 9 - -// Allow constructing a temporary to be used as a parameter. -#pragma warning 604 9 - -// Disable the construct resolved as an expression warning. -#pragma warning 595 9 - -// Disable the strange "construct resolved as a declaration/type" warning. -#pragma warning 594 9 - -// Disable the "pre-compiled header file cannot be used" warning. -#pragma warning 698 9 - -// Disable the "temporary object used to initialize a non-constant reference" warning. -#pragma warning 665 9 - -// Disable the "pointer or reference truncated by cast. Cast is supposed to REMOVE warnings, not create them. -#pragma warning 579 9 - -// Disable the warning that suggests a null destructor be placed in class definition. -#pragma warning 656 9 - -// Disable the warning about moving empty constructors/destructors to the class declaration. -#pragma warning 657 9 - -// No virtual destructor is not an error in C&C. -#pragma warning 004 9 - -// Integral constant will be truncated warning is usually ok when dealing with bitfields. -#pragma warning 388 9 - -// Turns off unreferenced function parameter warning. -//#pragma off(unreferenced) - -/* -** The "bool" integral type was defined by the C++ comittee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#include "bool.h" - -#if !defined(__BORLANDC__) -#define M_E 2.71828182845904523536 -#define M_LOG2E 1.44269504088896340736 -#define M_LOG10E 0.434294481903251827651 -#define M_LN2 0.693147180559945309417 -#define M_LN10 2.30258509299404568402 -#define M_PI 3.14159265358979323846 -#define M_PI_2 1.57079632679489661923 -#define M_PI_4 0.785398163397448309616 -#define M_1_PI 0.318309886183790671538 -#define M_2_PI 0.636619772367581343076 -#define M_1_SQRTPI 0.564189583547756286948 -#define M_2_SQRTPI 1.12837916709551257390 -#define M_SQRT2 1.41421356237309504880 -#define M_SQRT_2 0.707106781186547524401 -#endif - - -#endif diff --git a/Generals/Code/Tools/WW3D/pluglib/win.h b/Generals/Code/Tools/WW3D/pluglib/win.h deleted file mode 100644 index b8bf81f40e4..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/win.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/win.h $* - * * - * $Author:: Denzil_l $* - * * - * $Modtime:: 6/26/01 1:59p $* - * * - * $Revision:: 10 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef WIN_H -#define WIN_H - -/* -** This header file includes the Windows headers. If there are any special pragmas that need -** to occur around this process, they are performed here. Typically, certain warnings will need -** to be disabled since the Windows headers are repleat with illegal and dangerous constructs. -** -** Within the windows headers themselves, Microsoft has disabled the warnings 4290, 4514, -** 4069, 4200, 4237, 4103, 4001, 4035, 4164. Makes you wonder, eh? -*/ - -// When including windows, lets just bump the warning level back to 3... -#if (_MSC_VER >= 1200) -#pragma warning(push, 3) -#endif - -// this define should also be in the DSP just in case someone includes windows stuff directly -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif - -#include -//#include -//#include -//#include -//#include - -#if (_MSC_VER >= 1200) -#pragma warning(pop) -#endif - -#ifdef _WINDOWS -extern HINSTANCE ProgramInstance; -extern HWND MainWindow; -extern bool GameInFocus; - -#ifdef _DEBUG - -void __cdecl Print_Win32Error(unsigned long win32Error); - -#else // _DEBUG - -#define Print_Win32Error - -#endif // _DEBUG - -#else // _WINDOWS -#include -#endif // _WINDOWS - -#endif // WIN_H diff --git a/Generals/Code/Tools/WW3D/pluglib/wwfile.h b/Generals/Code/Tools/WW3D/pluglib/wwfile.h deleted file mode 100644 index 8356f4315dc..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/wwfile.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/wwfile.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 5/04/01 7:43p $* - * * - * $Revision:: 8 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef WWFILE_Hx -#define WWFILE_Hx - -#ifdef _UNIX -#include "osdep.h" -#endif - -#define YEAR(dt) (((dt & 0xFE000000) >> (9 + 16)) + 1980) -#define MONTH(dt) ((dt & 0x01E00000) >> (5 + 16)) -#define DAY(dt) ((dt & 0x001F0000) >> (0 + 16)) -#define HOUR(dt) ((dt & 0x0000F800) >> 11) -#define MINUTE(dt) ((dt & 0x000007E0) >> 5) -#define SECOND(dt) ((dt & 0x0000001F) << 1) - -#ifndef SEEK_SET -#define SEEK_SET 0 // Seek from start of file. -#define SEEK_CUR 1 // Seek relative from current location. -#define SEEK_END 2 // Seek from end of file. -#endif - -#ifndef NULL - #define NULL 0 -#endif - - -class FileClass -{ - public: - - enum - { - READ = 1, - WRITE = 2, - PRINTF_BUFFER_SIZE = 1024 - }; - - virtual ~FileClass(void) {}; - virtual char const * File_Name(void) const = 0; - virtual char const * Set_Name(char const *filename) = 0; - virtual int Create(void) = 0; - virtual int Delete(void) = 0; - virtual bool Is_Available(int forced=false) = 0; - virtual bool Is_Open(void) const = 0; - virtual int Open(char const *filename, int rights=READ) = 0; - virtual int Open(int rights=READ) = 0; - virtual int Read(void *buffer, int size) = 0; - virtual int Seek(int pos, int dir=SEEK_CUR) = 0; - virtual int Tell(void) { return Seek(0); } - virtual int Size(void) = 0; - virtual int Write(void const *buffer, int size) = 0; - virtual void Close(void) = 0; - virtual unsigned long Get_Date_Time(void) {return(0);} - virtual bool Set_Date_Time(unsigned long ) {return(false);} - virtual void Error(int error, int canretry = false, char const * filename=NULL) = 0; - virtual void * Get_File_Handle(void) { return reinterpret_cast(-1); } - - operator char const * () - { - return File_Name(); - } - - // this form uses a stack buffer of PRINTF_BUFFER_SIZE - int Printf(char *str, ...); - - // this form uses the supplied buffer if PRINTF_BUFFER_SIZE is expected to be too small. - int Printf(char *buffer, int bufferSize, char *str, ...); - - // this form uses the stack buffer but will prepend any output with the indicated number of tab characters '\t' - int Printf_Indented(unsigned depth, char *str, ...); - -}; - -#endif diff --git a/Generals/Code/Tools/WW3D/pluglib/wwmath.cpp b/Generals/Code/Tools/WW3D/pluglib/wwmath.cpp deleted file mode 100644 index 4b7cc68826b..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/wwmath.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WWMath * - * * - * $Archive:: /Commando/Code/wwmath/wwmath.cpp $* - * * - * Author:: Eric_c * - * * - * $Modtime:: 3/18/99 10:39a $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "wwmath.h" -#include - -/* -** -*/ -float WWMath::Random_Float(void) -{ - return ((float)(rand() & 0xFFF)) / (float)(0xFFF); -} diff --git a/Generals/Code/Tools/WW3D/pluglib/wwmath.h b/Generals/Code/Tools/WW3D/pluglib/wwmath.h deleted file mode 100644 index 0966d29a7e9..00000000000 --- a/Generals/Code/Tools/WW3D/pluglib/wwmath.h +++ /dev/null @@ -1,257 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WWMath * - * * - * $Archive:: /Commando/Code/wwmath/wwmath.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 3/16/00 8:28p $* - * * - * $Revision:: 40 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef WWMATH_H -#define WWMATH_H - -#include "always.h" -#include -#include - -/* -** Some global constants. -*/ -#define WWMATH_EPSILON 0.0001f -#define WWMATH_EPSILON2 WWMATH_EPSILON * WWMATH_EPSILON -#define WWMATH_PI 3.141592654f -#define WWMATH_FLOAT_MAX (FLT_MAX) -#define WWMATH_SQRT2 1.414213562f -#define WWMATH_SQRT3 1.732050808f -#define WWMATH_OOSQRT2 0.707106781f -#define WWMATH_OOSQRT3 0.577350269f - - -/* -** Macros to convert between degrees and radians -*/ -#ifndef RAD_TO_DEG -#define RAD_TO_DEG(x) (((double)x)*180.0/WWMATH_PI) -#endif - -#ifndef DEG_TO_RAD -#define DEG_TO_RAD(x) (((double)x)*WWMATH_PI/180.0) -#endif - -#ifndef RAD_TO_DEGF -#define RAD_TO_DEGF(x) (((float)x)*180.0f/WWMATH_PI) -#endif - -#ifndef DEG_TO_RADF -#define DEG_TO_RADF(x) (((float)x)*WWMATH_PI/180.0f) -#endif - - - -/* -** Some simple math functions which work on the built-in types. -** Include the various other header files in the WWMATH library -** in order to get matrices, quaternions, etc. -*/ -class WWMath -{ -public: - -static float Fabs(float val) { return (float)fabs(val); } -static float Sqrt(float val) { return (float)sqrt(val); } -static float Inv_Sqrt(float val) { return 1.0f / (float)sqrt(val); } -static float Sign(float val); -static float Floor(float val) { return (float)floor(val); } -static bool Fast_Is_Float_Positive(const float & val); - -static float Random_Float(void); -static float Random_Float(float min,float max); -static float Clamp(float val, float min = 0.0f, float max = 1.0f); -static double Clamp(double val, double min = 0.0f, double max = 1.0f); -static float Wrap(float val, float min = 0.0f, float max = 1.0f); -static double Wrap(double val, double min = 0.0f, double max = 1.0f); -static float Min(float a, float b); -static float Max(float a, float b); - -static float Lerp(float a, float b, float lerp ); -static double Lerp(double a, double b, float lerp ); - -static long Float_To_Long(float f); -static long Float_To_Long(double f); - -static unsigned char Unit_Float_To_Byte(float f) { return (unsigned char)(f*255.0f); } -static float Byte_To_Unit_Float(unsigned char byte) { return ((float)byte) / 255.0f; } - -static bool Is_Valid_Float(float x); -static bool Is_Valid_Double(double x); - -}; - -inline float WWMath::Sign(float val) -{ - if (val > 0.0f) { - return +1.0f; - } - if (val < 0.0f) { - return -1.0f; - } - return 0.0f; -} - -inline bool WWMath::Fast_Is_Float_Positive(const float & val) -{ - return !((*(int *)(&val)) & 0x80000000); -} - -inline float WWMath::Random_Float(float min,float max) -{ - return Random_Float() * (max-min) + min; -} - -inline float WWMath::Clamp(float val, float min /*= 0.0f*/, float max /*= 1.0f*/) -{ - if(val < min) return min; - if(val > max) return max; - return val; -} - -inline double WWMath::Clamp(double val, double min /*= 0.0f*/, double max /*= 1.0f*/) -{ - if(val < min) return min; - if(val > max) return max; - return val; -} - -inline float WWMath::Wrap(float val, float min /*= 0.0f*/, float max /*= 1.0f*/) -{ - // Implemented as an if rather than a while, to long loops - if ( val >= max ) val -= (max-min); - if ( val < min ) val += (max-min); - - if ( val < min ) { - val = min; - } - if ( val > max ) { - val = max; - } - return val; -} - -inline double WWMath::Wrap(double val, double min /*= 0.0f*/, double max /*= 1.0f*/) -{ - // Implemented as an if rather than a while, to long loops - if ( val >= max ) val -= (max-min); - if ( val < min ) val += (max-min); - if ( val < min ) { - val = min; - } - if ( val > max ) { - val = max; - } - return val; -} - -inline float WWMath::Min(float a, float b) -{ - if (ab) return a; - return b; -} - -inline float WWMath::Lerp(float a, float b, float lerp ) -{ - return (a + (b - a)*lerp); -} - -inline double WWMath::Lerp(double a, double b, float lerp ) -{ - return (a + (b - a)*lerp); -} - - -inline long WWMath::Float_To_Long (float f) -{ -#if defined(_MSC_VER) && defined(_M_IX86) - long retval; - __asm fld dword ptr [f] - __asm fistp dword ptr [retval] - return retval; -#else - return (long) f; -#endif -} - -inline long WWMath::Float_To_Long (double f) -{ -#if defined(_MSC_VER) && defined(_M_IX86) - long retval; - __asm fld qword ptr [f] - __asm fistp dword ptr [retval] - return retval; -#else - return (long) f; -#endif -} - -inline bool WWMath::Is_Valid_Float(float x) -{ - unsigned long * plong = (unsigned long *)(&x); - unsigned long exponent = ((*plong) & 0x7F800000) >> (32-9); - - // if exponent is 0xFF, this is a NAN - if (exponent == 0xFF) { - return false; - } - return true; -} - -inline bool WWMath::Is_Valid_Double(double x) -{ - unsigned long * plong = (unsigned long *)(&x) + 1; - unsigned long exponent = ((*plong) & 0x7FF00000) >> (32-12); - - // if exponent is 0x7FF, this is a NAN - if (exponent == 0x7FF) { - return false; - } - return true; -} - -#endif diff --git a/GeneralsMD/Code/Tools/CMakeLists.txt b/GeneralsMD/Code/Tools/CMakeLists.txt index 2b47c6323d0..24d60d1dd37 100644 --- a/GeneralsMD/Code/Tools/CMakeLists.txt +++ b/GeneralsMD/Code/Tools/CMakeLists.txt @@ -27,5 +27,4 @@ if(RTS_BUILD_ZEROHOUR_EXTRAS) add_subdirectory(timingTest) add_subdirectory(versionUpdate) add_subdirectory(wolSetup) - add_subdirectory(WW3D) endif() diff --git a/GeneralsMD/Code/Tools/WW3D/CMakeLists.txt b/GeneralsMD/Code/Tools/WW3D/CMakeLists.txt deleted file mode 100644 index 1e5b20b0a72..00000000000 --- a/GeneralsMD/Code/Tools/WW3D/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -if (TARGET maxsdk) - add_subdirectory(pluglib) - add_subdirectory(max2w3d) -endif() diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/DISK12.ICO b/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/DISK12.ICO deleted file mode 100644 index 8b21b368431..00000000000 Binary files a/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/DISK12.ICO and /dev/null differ diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/one.bmp b/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/one.bmp deleted file mode 100644 index 12f46639063..00000000000 Binary files a/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/one.bmp and /dev/null differ diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/orig.ico b/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/orig.ico deleted file mode 100644 index 7c1adf6f27d..00000000000 Binary files a/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/orig.ico and /dev/null differ diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/orig1.ico b/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/orig1.ico deleted file mode 100644 index c724f995927..00000000000 Binary files a/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/orig1.ico and /dev/null differ diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/two.bmp b/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/two.bmp deleted file mode 100644 index 45f8fd40328..00000000000 Binary files a/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/two.bmp and /dev/null differ diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/ww3d.bmp b/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/ww3d.bmp deleted file mode 100644 index d63e18ff6f4..00000000000 Binary files a/GeneralsMD/Code/Tools/WW3D/max2w3d/Res/ww3d.bmp and /dev/null differ diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/changes.txt b/GeneralsMD/Code/Tools/WW3D/max2w3d/changes.txt deleted file mode 100644 index c148797992b..00000000000 --- a/GeneralsMD/Code/Tools/WW3D/max2w3d/changes.txt +++ /dev/null @@ -1,412 +0,0 @@ -Version 1.0.4.70: August 22, 2001 -Greg: - Added BumpEnv mapper - - Added NPatch enable flag for meshes (in the w3dtools command panel) -Ian: - Added BumpEnv setting to the shader (in primary gradient) - -Version 1.0.4.69: January 4, 2001 -Greg: - Modified the "bone picker" that the WWSkin space warp uses to allow Max bones to - be used. - -Version 1.0.4.68: December 7, 2000 -Andre: - Added a Static Sort Level parameter to the Surface Properties rollup page of the - material editor. This parameter must be the same across all materials assigned to - one mesh, and is enforced on export. The value is written out as part of the mesh - header to which the material is assigned. - -Version 1.0.4.67: December 6, 2000 -Greg: - Added 'Vehicle' collision bit. This will allow us to create meshes which constrain vehicles - to certain parts of a level without constraining characters or projectiles. - -Version 1.0.4.66: November 7, 2000 -Greg: - Disabled the "optimize meshes" feature because recent developments in the run-time code - seem to have made it un-necessary (and possibly even undesireable due to the extra mesh overhead) - The main reason for disabling the feature is that the automatic nature of it makes some of - our processes harder to debug. Mesh names are lost so the artist has no way of figuring out - which mesh is causing problems when one of the other tools complains about something. - - modified the mesh export code to reject meshes that are using multi-pass transparent materials. - - fixed error message boxes so they pop on top of all windows (they were appearing behind the log window) - -Version 1.0.4.65: October 31, 2000 -Greg: - Finished code re-organization. - - Pat provided new UI for the main export dialog - - Fixed the "smooth across meshes" feature - - Added the export log window. - -Version 1.0.4.64: October 20, 2000 -Greg: - Fixed a bug in the name editing dialog in the W3D utility panel - - Modified the VAlpha behavior so that only the *last* pass with alpha blending - gets the vertex alpha (instead of all passes with alpha blending) - - Added the Aggregate geometry type. This lets you request external - W3D objects to be attached to bones in your model. - - Added preliminary mesh optimization features. During the export, meshes can be split - into single-material meshes and then meshes which use the same materials - can be combined into larger meshes. - -Version 1.0.4.63: October 19, 2000 -Greg: Re-organized the entire DoExport function. - - First I unified all of the code to go through the "DoOriginBasedExport" - code by using the scene root as the origin when there were no user-defined - origins. - - Re-organized the Export_Geometry function to use a new abstract - class: GeometryExporTaskClass which encapsulates a lot of code that was - cut-and-pasted many times through the w3dexp.cpp module. - - Broke several classes and functions out of w3dexp.cpp into their own - modules. - - Modified/Cleaned HierarchySaveClass and MeshConnections class. - -Version 1.0.4.62: October 11, 2000 -Greg: Re-organised the W3DUtility plugin. Moved several dialog boxes - used by it into their own modules and created a modeless dialog - containing the w3d settings that can be left up when the user - is not in Max's utility panel. - -Version 1.0.4.61: September 26, 2000 -Greg: Added copying of the dazzle app data structure to the MaxScript - extensions. - -Version 1.0.4.60: September 22, 2000 -Greg: Added dazzle exporting to the plugin. Modified MeshConnnections - class and the w3d file format so that HModels are exported in a - slightly simpler manner and so that they can support dazzles. The - "auxiliary" header for hmodels is now obsolete. - -Version 1.0.4.59: September 18, 2000 -Greg: Modified the code so that collections are exported even when no - meshes or other render objects are present. This is used to create - collections of proxy objects for the renegade level editor. Also - modified the "origin" export code to support exporting collections - with origins. - -Version 1.0.4.58: August 25, 2000 -Greg: Fixed a crash bug that happens if you create a PS2 material. The - bug was caused by the modifications to the texture pane to replace - the NoMipMap and Resize buttons with a single NoLOD button. For some - reason, the PS2 material uses a separate dialog template for its - texture pane which is the same as the dialog template for the - normal material. Since the PS2 version of the template was not updated, - the code would crash when initializing the NoLOD button. - -Version 1.0.4.57: August 18, 2000 -Andre: Fixed the loading of version 4 ParameterBlocks so that the value - for Stage1MappingType is correct. - -Version 1.0.4.56: August 16,2000 -Greg: Removed the texture flags and buttons for No-Mipmapping and enable - resizing. These are all lumped into the setting for No-LOD now. - The GameMtl still has the entries in its parameter block for - No-Mipmapping and Resize and I use the No-Mipmap setting to set - the initial state of the No-LOD flag... This also required a flag - in GameMtl indicating that the conversion had been done. Ug... :-) - -Version 1.0.4.55: August 6, 2000 -Greg: Added new colliison type: camera. In renegade we have some physically - collideable meshes which the camera should not collide with so I had - to make a separate flag for camera collision. When the appdata chunk - is first converted to the new version, the camera collision flag is - set to the same setting as the current state of physical collision. - - Added light-glare geometry type. This currently only exports the - position of the pivot point of the max object. It will be used to - indicate where there should be fancy light glare effects in the level - - Added NoLOD option to textures in the W3D material. This setting will - be used on textures which should not scale down even when texture - reduction is being used. - - Fixed serious bug in the parameter block description for the W3D - material plugin (GameMtl.cpp) - -Version 1.0.4.54: July 13, 2000 -Greg: Fixed a bug related to user-defined origins not working when they - are rotate or moved from 0,0,0. - -Version 1.0.4.53: July 12, 2000 -Andre: Added support for a different mappers on stage 0/1 of the Vertex - Material. Added support for the new silhouette mapper type. - These changes can be found in the VertexMaterial panel in the - W3d material editor. - -Version 1.0.4.52: May 30, 2000 -Greg: Added support for Max's multiple mapping channels. This can be - found in the VertexMaterial panel in the W3d material editor. - -Version 1.0.4.51: May 22, 2000 -Greg: Added AABTree exporting so that we don't have to generate AABTrees - at run-time. This is controlled by the "Optimize Collision Detection" - checkbox on the exporter options dialog box. - Added prefix and suffix features to the naming tool. - Added detatch vertices feature to the skin modifier. - -Version 1.0.4.50: May 8, 2000 -Andre: Added a new MAX Script extension: wwInputBox - This is a generic way of getting user input in a Windows-like - manner (as opposed to typing it in the Listener window as - MAX wants to force you to do). - -Version 1.0.4.49: May 2, 2000 -Greg: Fixed a bug in vchannel.cpp. Was writing out garbage animation - channels which would crash wdump. - -Version 1.0.4.48: May 1, 2000 -Greg: Changed the way skins are exported so that their vertices are - sorted with respect to the bone they are attached to. Also - made it so vertices are secondarily sorted by vertex material - (this means that non-skinned meshes will sort by vertex - material only.) - -Version 1.0.4.47: April 19 2000 -Greg: Added a new geometry option for "shatterable" objects. Wrote - a new W3DAppData2Struct which replaces the old AppData1Struct. - Whenever the old format app data is encountered, a new one - is created to replace it. This new app data chunk has more - space in it for future expansion. - Also fixed a crash bug in the skin modifier related to deleting - bones from the space warp. - -Version 1.0.4.46: March 28, 2000 -Greg: Added "Transform Nodes" to the collection export. We already had - "Placeholder" objects which were signified by a '~' after the - name. Now we have "Transform Nodes" which are signified by a '*' - after the name. Transform Nodes instruct one of the Renegade tools - to merge another W3D collection into the file at a given transform. - The purpose was to allow us to lightmap certain building interiors - only once and then merge them into many levels... - -Version 1.0.4.45: March 8, 2000 -Andre: Changed the Is_Origin() test to check for hidden nodes. If a - node is hidden, it will not be accepted as an origin. This - means that hiding an LOD prevents it from being exported (as - you would expect). - -Version unchanged: early March -Andre: Fixed a couple of crash bugs related to animation exporting. - -Version 1.0.4.43: February 29, 2000 -Greg: Fixed a bug which caused all meshes marked to cast shadows to - not get texture coordinates. - Fixed meshsave.cpp to detect and properly handle mirrored meshes. - -Version 1.0.4.42: January 24, 2000 -Lytle: Added Playstation 2 material support, including converting W3D - materials to PS2 materials. Added support for vertex colors and - vertex alpha to exist concurrently. - -Version 1.0.4.41: January 13, 2000 -Andre: Fixed a nasty memory overwriting bug in MeshConnectionsClass - that only reared its head under very unique circumstances. - It was a copy/paste bug that would lead to writing a W3D - file with incorrect data. It would manifest itself by crashing - the viewer (and potentially the game engines) when trying to - load the file. - -Version 1.0.4.40: December 16, 1999 -Ian: Added 'Export Utilites' group to W3D Utility panel and added a - 'Export with Std Mtls' button to this group. This button will - first convert all W3D materials in the scene to standard - materials, then call the export feature, then, after export, - convert materials back to W3D materials. The purpose of this - utility is to make it possible to export W3D material attributes - to third party file formats (eg. Lightscape Preparation files). - -Version 1.0.4.39: November 15, 1999 -Andre: Changed the mesh LOD naming convention so that we use numbers - that correspond to the LOD number (highest-to-lowest) instead - of letters that went from lowest-to-highest. - -Version 1.0.4.38: November 12, 1999 -Greg: Updated MeshConnections class and the hmodel chunk definitions - in w3d_file class to not treat shadow meshes as a different type - of mesh. - -Version 1.0.4.37: November 11, 1999 -Greg: Removed the GEOMETRY_TYPE_SHADOW settings and UI. Added a - EXPORT_CAST_SHADOW flag. This basically means that rather than - shadow casting being a completely different "type" of mesh it - is now an option on any mesh. This required some tweaking - of the AppData structure we're saving and to the w3dutil code. - -Version 1.0.4.35: November 3, 1999 -Andre: Exposed another script extension, called "wwDuplicateSkinWSM". - This extension allows the SceneSetup script to copy bone - information from the base object's skin WSM to the LODs. - Meshes are still unaffected, since the artist will be munging - the meshes to reduce their poly counts. - -Version 1.0.4.34: November 2, 1999 -Andre: Exposed two new script extensions, named "wwCopySkinInfo" and - "wwFindSkinNode". These extensions allow the SceneSetup script - to copy the skin/vertex/bone binding information from the base - model to the LOD and Damage models. - -Version 1.0.4.33: October 18, 1999 -Andre: Merged WWScript.dlx into the exporter, so now WWScript is - unnessesary and should be deleted. The code in that DLX was - ported from MFC to Win32 code during the merge. GetW3DAppData0 - and GetW3DAppData1 are no longer exported from the DLE. - -Version 1.0.4.32: October 11, 1999 -Andre: Correct NULL object handling was implemented when exporting HLODs. - NULL object chunks are only written when using the old-style LOD - setup (one per file), otherwise the name "NULL" is put in the HLOD - and no NULL object chunk is written. - -Version 1.0.4.31: October 5, 1999 -Andre: Fixed a bug in MeshBuilder where a division by zero occurred if the - extents of a triangle was zero in one dimension. - -Version 1.0.4.30: October 1, 1999 -Andre: - Added support for the "suppressPrompts" flag during export. If - Max passes in a TRUE value, we will go with the previous export - settings instead of showing the export options dialog. This makes - non-interactive batch exporting possible. - - Moved W3dExportOptionsStruct from w3ddlg.h to w3dutil.h so that - WWScript can access it easily. - -Version 1.0.4.29: September 27, 1999 -Andre: - Fixed a skin bug that occurred in LOD exporting when a vertex in a - skin was not bound to a bone (it would be exported in unmodified - coordinates, creating a "pop"). - - Strip off any trailing ".%d" or "." from a name in Set_W3D_Name - (as opposed to just ".%d"). - - If the artist sets up damage animations, then the animation on - the base model is no longer exported. (non-damage animations should - still be created in separate files) - - Exporting 2 more symbols from the DLL (GetW3DAppData0 and - GetW3DAppData1). These functions are used by the MAXScript extension - DLL (WWScript.dlx) to copy AppData from one node to another. - -Version 1.0.4.28: September 23, 1999 -Andre: Fixed a bug in LOD exporting when the base object wasn't centered - at the origin. Added support for placing damage models in the scene. - Renamed "Generate LOD extensions" to "Generate extensions" since - the same extensions are used for damage. Added a "Damage Region" - spinner to the W3D Tools panel. With this spinner you can mark - bones as being part of a given damage region (0 to 15, -1 means - not part of a damage region). - -Version 1.0.4.27: September 17, 1999 -Greg: Added degenerate triangle removal to MeshBuilderClass. - -Version 1.0.4.26: September 17, 1999 -Andre: Modified the exporting code to allow artists to define all LODs of - an object in one MAX file. The old way of creating LODs is still - supported so that old art assets are still usable. Added a - "Generate LOD extensions" button to the W3D Tools panel to make - the Origin naming convention less painful. - -Version 1.0.4.25: August 21, 1999 -Greg: Fixed a bug in Export_Geometry. While exporting skins, one line of - code was referring to the list of normal meshes rather than the list - of skins. When you do an export with only a skin and no meshes, this - causes an access violation. - -Version 1.0.4.24: July 27, 1999 -Greg: Changed the Hide/Unhide by W3D type buttons into "Select by W3D Type" - buttons. This should be more useable. Also, added select alpha meshes, - select physical, projectile and vis collision meshes. - Added a material naming tool. - -Version 1.0.4.23: July 9, 1999 -Pat: Changed the default behavior of the collection naming tool to - be 'affect selected' rather than 'affect all' - -Version 1.0.4.22: July 7, 1999 -Pat: The export code doesn't export the DCG array if all vertex colors - are white (1, 1, 1), however this was a problem when using the - new Mesh Deformer, so I added a check during export to see if - the Deformer was modifying vertex colors. Also modified the - hierarchy export code so it will resize its internal array if - the number of nodes is greater than 512. - -Version 1.0.4.21: July 1, 1999 -Pat: Added code to optimze the between-mesh smoothing and added a new - button to the export dialog that allows the user to turn this - smoothing feature on/off. Also added displacement maps to the - W3D material, however due to a bug in the NURBS Mesher modifier, - we decided not to expose the functionality in UI at this time. - -Version 1.0.4.20: June 24, 1999 -Pat: Added code to apply smoothing groups over mesh boundaries. More - work was done on the obj-space mesh deform modifier including save/load, - export, undo, and vertex-alpha support. We fixed a bug where the ErrorClass - object that was used during exception handling was using and freeing a - previously freed pointer. Added a new panel to the material types for - Commando surface types. - -Version 1.0.4.19: June 14, 1999 -Greg: Added the VAlpha checkbox to the W3D utility panel. Checking this - causes the exporter to convert vertex colors into alpha values and put - them in all passes that are using alpha blending. This might be a temporary - solution; I'm thinking we need to extend the Utility panel (and the AppData - structure that we are saving) to allow for more flexible control over vertex - alpha, vertex color, etc. - -Version 1.0.4.18: May 27, 1999 -Greg: Fixed a bug in the code which handles loading a hierarchy tree from another - W3D file. Made the W3D utility panel support multiple selection. -Pat: Added the initial mesh deform object space modifier. Currently doesn't - export the data. - -Version 1.0.4.17: April 9, 1999 -Greg: Fixed a bug related to exporting a mesh with zero vertices. Exporter will - throw an exception which pops up a message box indicating the name of the - mesh. Made the collision boxes behave the same way as meshes when one is - exported with geometry only - it takes on the name of the file. Whew this - part of the exporter code is getting uuuuuugly... - -Version 1.0.4.16: April 6, 1999 -Greg: Fixed a bug related to the storing of the default export options. If the - user exported a model which uses the hierarchy from another model and then - moves the Max file, the next export would crash Max when the exporter couldn't - find the w3d file which contains the hierarchy. - -Version 1.0.4.15: Mar 18, 1999 -Greg: Fixed a bug in the AABox export. Was using the wrong coordinate system for - the box. AABoxes actually seem to be of very limited use. Possibly only - useful as an approximation of a cylinder centered at 0,0,0 in object space - (but moved anywhere on the z-axis) and only for objects that *only* rotate - about the z-axis. (characters) Ug. - -Version 1.0.4.14: Mar 16, 1999 -Greg: Made meshes that are marked as AABox or OBBox export a W3D_CHUNK_BOX instead - of a mesh. The runtime engine can test collision with a box in about the same - amount of time it takes to check a single triangle... so one box is much faster - than a 12 triangle mesh :) These boxes are only for collision detection so - they only export a color, no other rendering information. - -Version 1.0.4.13: Mar 11, 1999 -Greg: Fixed a bug in the collection exporter. Needed to put the entire name - of the render object into the sub object chunk. - -Version 1.0.4.12: Mar 10, 1999 -Naty: Fixed minor bug with start/end animation frames in export dialog. - -Version 1.0.4.11: Mar 4, 1999 -Naty: Added "Camera Oriented" mesh type (and changed the camera aligned button - to read "Camera Parallel"). Export options are now saved in the MAX file - (hierarchy file paths are saved in a relative form). - -Version 1,0,4,10: Mar 3, 1999 -Greg: Modified so that collections are not exported when there is only a single - mesh and forced that mesh to use the name of the file. - Changed w3d_file.h so that meshes have a "container name" instead of - a "hierarchy model name" and set the container name when a collection is exported - -Version 1,0,4,9: Mar 3, 1999 -Naty: New Shader (took out colormaks, fogfunc, new dialog and preset system) - Added alphatest support, added Linear offset mapper and mapper argument - string support - -Version 1,0,4,8: Feb 9, 1999 -Greg: Added the ZNormals option for forcing the normals of a mesh to be 0,0,1 - -Version 1,0,4,7: Feb 8, 1999 -Greg: Fixed 2 bugs in the skin code. Added code to scan the materials used - by a mesh and discard un-used ones. -Naty: Added 'Alpha-Bitmap' button to the texture dialog, added new shader presets - -Version 1,0,4,8: Feb 15, 1999 -Greg: Improved the strip generation algorithm. Now actually turns a cube into 6 - strips instead of 12 individual triangles. Still needs work though... - - diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/max2w3d.def b/GeneralsMD/Code/Tools/WW3D/max2w3d/max2w3d.def deleted file mode 100644 index 3a9fe017757..00000000000 --- a/GeneralsMD/Code/Tools/WW3D/max2w3d/max2w3d.def +++ /dev/null @@ -1,10 +0,0 @@ -LIBRARY max2w3d -EXPORTS - LibDescription @1 - LibNumberClasses @2 - LibClassDesc @3 - LibVersion @4 - GetW3DAppData0 @5 - GetW3DAppData1 @6 -SECTIONS - .data READ WRITE diff --git a/GeneralsMD/Code/Tools/WW3D/max2w3d/max2w3d.rc b/GeneralsMD/Code/Tools/WW3D/max2w3d/max2w3d.rc deleted file mode 100644 index ed224c713b8..00000000000 --- a/GeneralsMD/Code/Tools/WW3D/max2w3d/max2w3d.rc +++ /dev/null @@ -1,1994 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_VOXEL_DEBUG_DIALOG DIALOG DISCARDABLE 0, 0, 171, 114 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Voxelization Debugging" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,114,7,50,14 - CTEXT "Voxel Viewport",IDC_VOXEL_VIEWPORT,7,7,100,100, - SS_CENTERIMAGE - CONTROL "",IDC_LAYER_EDIT,"CustEdit",WS_TABSTOP,120,50,28,10 - CONTROL "",IDC_LAYER_SPIN,"SpinnerControl",0x0,148,50,10,10 - LTEXT "Current Layer",IDC_STATIC,115,36,43,8 -END - -IDD_W3D_EXPORT_OPTIONS DIALOG DISCARDABLE 0, 0, 259, 282 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "W3D Export Options" -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "Hierarchy",IDC_STATIC,7,7,245,64 - GROUPBOX "Animation",IDC_STATIC,7,78,245,107 - GROUPBOX "Geometry",IDC_STATIC,7,188,245,67 - CONTROL "Export",IDC_WHT_EXPORT_RADIO,"Button", - BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,17,22,36,10 - CONTROL "Load from file:",IDC_WHT_LOAD_RADIO,"Button", - BS_AUTORADIOBUTTON,17,37,60,10 - CONTROL "Don't Export",IDC_WHT_NO_EXPORT_RADIO,"Button", - BS_AUTORADIOBUTTON,17,53,55,10 - CONTROL "Use Translation Only",IDC_TRANSLATION_ONLY_CHECK,"Button", - BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,83,54,81,10 - PUSHBUTTON "Browse",IDC_WHT_BROWSE_BUTTON,79,37,165,12,WS_GROUP - CONTROL "Export",IDC_WHA_EXPORT_RADIO,"Button", - BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,17,93,36,10 - CONTROL "Don't Export",IDC_WHA_NO_EXPORT_RADIO,"Button", - BS_AUTORADIOBUTTON,17,108,55,10 - LTEXT "Frames:",IDC_STATIC,84,94,26,10,NOT WS_GROUP - CONTROL "",IDC_RANGE_LOW_EDIT,"CustEdit",WS_GROUP | WS_TABSTOP, - 128,93,28,10 - CONTROL "",IDC_RANGE_LOW_SPIN,"SpinnerControl",0x0,156,93,10,10 - LTEXT "To",IDC_STATIC,168,93,10,10 - CONTROL "",IDC_RANGE_HIGH_EDIT,"CustEdit",WS_TABSTOP,182,93,28, - 10 - CONTROL "",IDC_RANGE_HIGH_SPIN,"SpinnerControl",0x0,210,93,10,10 - CONTROL "Export",IDC_WTM_EXPORT_RADIO,"Button", - BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,15,202,36,10 - CONTROL "Don't Export",IDC_WTM_NO_EXPORT_RADIO,"Button", - BS_AUTORADIOBUTTON,15,220,55,10 - CONTROL "&Smooth Vertex Normals Across Meshes", - IDC_EXPORT_MESH_SMOOTH_CHECK,"Button",BS_AUTOCHECKBOX | - WS_GROUP | WS_TABSTOP,87,203,139,10 - DEFPUSHBUTTON "OK",IDOK,66,261,50,14 - PUSHBUTTON "Cancel",IDCANCEL,144,261,50,14 - CONTROL "&Compress",IDC_COMPRESS_ANIMATION_CHECK,"Button", - BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,17,131,47,10 - LTEXT "Max Translation Error:(unit)",IDC_STATIC,16,150,85,8 - GROUPBOX "Compression Settings",IDC_STATIC,13,120,233,61 - LTEXT "Max Rotational Error:(deg)",IDC_STATIC,16,166,83,8 - CONTROL "Force Key Reduction",IDC_REDUCE_ANIMATION_CHECK,"Button", - BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,156,148,83,10 - COMBOBOX IDC_REDUCE_ANIMATION_COMBO,213,163,29,81, - CBS_DROPDOWNLIST | WS_VSCROLL | WS_GROUP | WS_TABSTOP - LTEXT "Key Reduction %:",IDC_STATIC,153,165,57,8 - LTEXT "Current FPS: %d",IDC_ANIMATION_FPS_STATIC,79,108,80,8 - COMBOBOX IDC_COMPRESS_ANIMATION_FLAVOR_COMBO,65,129,96,49, - CBS_DROPDOWNLIST | WS_VSCROLL | WS_GROUP | WS_TABSTOP - EDITTEXT IDC_MAX_TRANS_ERROR_EDIT,103,147,40,14,ES_AUTOHSCROLL | - WS_GROUP - EDITTEXT IDC_MAX_ROT_ERROR_EDIT,103,163,40,14,ES_AUTOHSCROLL | - WS_GROUP - CONTROL "Review Log",IDC_VIEWLOG_CHECK,"Button",BS_AUTOCHECKBOX | - WS_GROUP | WS_TABSTOP,188,108,54,10 - CONTROL "Optimize Collision Detection",IDC_EXPORT_MESH_AABTREES, - "Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,87,220, - 103,10 - CONTROL "Optimize Mesh Data (mesh names will be lost)", - IDC_EXPORT_MESH_OPTIMIZE,"Button",BS_AUTOCHECKBOX | - BS_MULTILINE | WS_GROUP | WS_TABSTOP,87,237,162,10 - CONTROL "Terrain Mode (all meshes exported in world space)", - IDC_TERRAIN_MODE_CHECK,"Button",BS_AUTOCHECKBOX | - WS_GROUP | WS_TABSTOP,79,22,173,10 -END - -IDD_BONE_INFLUENCE_PARAMS DIALOG DISCARDABLE 0, 0, 108, 78 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "Link to Bone by Name",IDC_LINK_BY_NAME_BUTTON, - "CustButton",WS_TABSTOP,7,7,94,13 - CONTROL "Auto-Link",IDC_AUTO_LINK_BUTTON,"CustButton",WS_TABSTOP, - 7,41,94,13 - CONTROL "Link to Bone",IDC_LINK_BUTTON,"CustButton",WS_TABSTOP,7, - 24,94,13 - CONTROL "Unlink",IDC_UNLINK_BUTTON,"CustButton",WS_TABSTOP,7,58, - 94,13 -END - -IDD_SKELETON_PARAMETERS DIALOG DISCARDABLE 0, 0, 108, 137 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "",IDC_BASE_POSE_EDIT,"CustEdit",WS_TABSTOP,55,7,37,10 - CONTROL "",IDC_BASE_POSE_SPIN,"SpinnerControl",0x0,93,7,7,10 - LTEXT "Base Pose:",IDC_STATIC,7,7,37,10 - CONTROL "Add Bones",IDC_ADD_BONES_BUTTON,"CustButton",WS_TABSTOP, - 7,22,94,13 - CONTROL "Remove Bones",IDC_REMOVE_BONES_BUTTON,"CustButton", - WS_TABSTOP,7,39,94,13 - GROUPBOX "Bones",IDC_STATIC,7,63,94,67 - LISTBOX IDC_BONE_LIST,13,75,81,49,LBS_SORT | - LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP -END - -IDD_SKIN_SOT DIALOG DISCARDABLE 0, 0, 108, 22 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "- All Geometric Objects",IDC_STATIC,7,7,94,8 -END - -IDD_GAMEMTL_PANEL DIALOG DISCARDABLE 0, 0, 217, 286 -STYLE DS_3DLOOK | WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "User1",IDC_DIFFUSE_COLOR,"ColorSwatch",0x0,65,9,34,12 - LTEXT "Diffuse Color:",IDC_STATIC,13,13,43,8 - GROUPBOX "Maps",IDC_STATIC,7,73,203,154 - GROUPBOX "Lighting Coefficients",IDC_STATIC,7,231,203,47 - CONTROL "Diffuse Color:",IDC_MAPON_DCT,"Button",BS_AUTOCHECKBOX, - 11,87,64,10 - PUSHBUTTON "None",IDC_DCT_BUTTON,75,86,132,11 - CONTROL "",IDC_DCT_FRAMES_EDIT,"CustEdit",WS_TABSTOP,37,103,19, - 10 - CONTROL "",IDC_DCT_FRAMES_SPIN,"SpinnerControl",0x0,57,103,7,10 - LTEXT "Frames:",IDC_STATIC,11,104,26,8 - CONTROL "Specular Color:",IDC_MAPON_SCT,"Button",BS_AUTOCHECKBOX, - 11,159,64,10 - PUSHBUTTON "None",IDC_SCT_BUTTON,75,158,132,11 - CONTROL "Diffuse Light:",IDC_MAPON_DIT,"Button",BS_AUTOCHECKBOX, - 11,123,64,10 - PUSHBUTTON "None",IDC_DIT_BUTTON,75,122,132,11 - CONTROL "Specular Light:",IDC_MAPON_SIT,"Button",BS_AUTOCHECKBOX, - 11,193,64,10 - PUSHBUTTON "None",IDC_SIT_BUTTON,75,192,132,11 - CONTROL "User1",IDC_SPECULAR_COLOR,"ColorSwatch",0x0,65,25,34,12 - LTEXT "Specular Color:",IDC_STATIC,14,29,49,8 - LTEXT "Opacity:",IDC_STATIC,110,11,27,8 - LTEXT "Emissive:",IDC_STATIC,87,260,30,8 - CONTROL "",IDC_OPACITY_EDIT,"CustEdit",WS_TABSTOP,160,9,37,10 - CONTROL "",IDC_OPACITY_SPIN,"SpinnerControl",0x0,198,9,7,10 - LTEXT "Shininess:",IDC_STATIC,110,37,33,8 - LTEXT "Translucency:",IDC_STATIC,110,24,46,8 - CONTROL "",IDC_TRANSULCENCY_EDIT,"CustEdit",WS_TABSTOP,160,22,37, - 10 - CONTROL "",IDC_TRANSLUCENCY_SPIN,"SpinnerControl",0x0,198,22,7, - 10 - CONTROL "Ambient Coefficients",IDC_AMBIENT_COEFF,"ColorSwatch", - 0x0,44,244,34,12 - CONTROL "Diffuse Coefficients",IDC_DIFFUSE_COEFF,"ColorSwatch", - 0x0,44,258,34,12 - LTEXT "Ambient:",IDC_STATIC,13,245,28,8 - LTEXT "Diffuse:",IDC_STATIC,16,260,25,8 - CONTROL "Emissive Coefficients",IDC_EMISSIVE_COEFF,"ColorSwatch", - 0x0,119,258,34,12 - CONTROL "Specular Coefficients",IDC_SPECULAR_COEFF,"ColorSwatch", - 0x0,119,243,34,12 - LTEXT "Mapping:",IDC_STATIC,117,104,30,8 - LTEXT "Specular:",IDC_STATIC,86,245,31,8 - COMBOBOX IDC_DCT_MAPPING_COMBO,151,101,56,87,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - CONTROL "Use Alpha",IDC_USE_ALPHA_CHECK,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,14,44,49,10 - CONTROL "Use Sorting",IDC_USE_SORTING_CHECK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,14,58,53,10 - LTEXT "Rate:",IDC_STATIC,68,104,18,8 - CONTROL "",IDC_DCT_RATE_EDIT,"CustEdit",WS_TABSTOP,88,103,19,10 - CONTROL "",IDC_DCT_RATE_SPIN,"SpinnerControl",0x0,108,103,7,10 - CONTROL "",IDC_DIT_FRAMES_EDIT,"CustEdit",WS_TABSTOP,38,139,19, - 10 - CONTROL "",IDC_DIT_FRAMES_SPIN,"SpinnerControl",0x0,58,139,7,10 - LTEXT "Frames:",IDC_STATIC,12,141,26,8 - LTEXT "Mapping:",IDC_STATIC,118,141,30,8 - COMBOBOX IDC_DIT_MAPPING_COMBO,152,138,56,87,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - LTEXT "Rate:",IDC_STATIC,68,141,18,8 - CONTROL "",IDC_DIT_RATE_EDIT,"CustEdit",WS_TABSTOP,88,139,19,10 - CONTROL "",IDC_DIT_RATE_SPIN,"SpinnerControl",0x0,108,139,7,10 - CONTROL "",IDC_SCT_FRAMES_EDIT,"CustEdit",WS_TABSTOP,37,176,19, - 10 - CONTROL "",IDC_SCT_FRAMES_SPIN,"SpinnerControl",0x0,57,176,7,10 - LTEXT "Frames:",IDC_STATIC,11,177,26,8 - LTEXT "Mapping:",IDC_STATIC,117,177,30,8 - COMBOBOX IDC_SCT_MAPPING_COMBO,151,174,56,87,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - LTEXT "Rate:",IDC_STATIC,68,177,18,8 - CONTROL "",IDC_SCT_RATE_EDIT,"CustEdit",WS_TABSTOP,88,176,19,10 - CONTROL "",IDC_SCT_RATE_SPIN,"SpinnerControl",0x0,108,176,7,10 - CONTROL "",IDC_SIT_FRAMES_EDIT,"CustEdit",WS_TABSTOP,38,210,19, - 10 - CONTROL "",IDC_SIT_FRAMES_SPIN,"SpinnerControl",0x0,58,210,7,10 - LTEXT "Frames:",IDC_STATIC,12,211,26,8 - LTEXT "Mapping:",IDC_STATIC,118,211,30,8 - COMBOBOX IDC_SIT_MAPPING_COMBO,152,208,56,87,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - LTEXT "Rate:",IDC_STATIC,69,211,18,8 - CONTROL "",IDC_SIT_RATE_EDIT,"CustEdit",WS_TABSTOP,89,210,19,10 - CONTROL "",IDC_SIT_RATE_SPIN,"SpinnerControl",0x0,109,210,7,10 - CONTROL "",IDC_FOG_EDIT,"CustEdit",WS_TABSTOP,177,245,19,10 - CONTROL "",IDC_FOG_SPIN,"SpinnerControl",0x0,197,245,7,10 - LTEXT "Fog:",IDC_STATIC,160,245,15,8 - CONTROL "",IDC_SHININESS_EDIT,"CustEdit",WS_TABSTOP,160,35,37,10 - CONTROL "",IDC_SHININESS_SPIN,"SpinnerControl",0x0,198,35,7,10 - CONTROL "Display in Viewport",IDC_VIEWPORT_DISPLAY_CHECK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,110,58,75,10 -END - -IDD_GAMEMTL_NOTES_PANEL DIALOG DISCARDABLE 0, 0, 217, 58 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Texture Maps are subject to the following limitations:", - IDC_STATIC,8,19,164,8 - LTEXT "Width and height must be a power of 2",IDC_STATIC,16,30, - 123,8 - LTEXT "Maximum width and height is 256",IDC_STATIC,16,41,105,8 - LTEXT "All maps must be Bitmap Textures which use Targa files", - IDC_STATIC,7,8,175,8 -END - -IDD_GAMEMTL_HINTS_PANEL DIALOG DISCARDABLE 0, 0, 217, 79 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "Favor diffuse light texture over diffuse color texture", - IDC_DIT_OVER_DCT_CHECK,"Button",BS_AUTOCHECKBOX | - BS_CENTER | BS_PUSHLIKE | WS_TABSTOP,8,9,204,10 - CONTROL "Favor specular light texture over specular color texture", - IDC_SIT_OVER_SCT_CHECK,"Button",BS_AUTOCHECKBOX | - BS_CENTER | BS_PUSHLIKE | WS_TABSTOP,8,22,204,10 - CONTROL "Favor diffuse light texture over calculated diffuse lighting", - IDC_DIT_OVER_DIG_CHECK,"Button",BS_AUTOCHECKBOX | - BS_CENTER | BS_PUSHLIKE | WS_TABSTOP,8,35,204,10 - CONTROL "Favor specular light texture over calculated specular lighting", - IDC_SIT_OVER_SIG_CHECK,"Button",BS_AUTOCHECKBOX | - BS_CENTER | BS_PUSHLIKE | WS_TABSTOP,8,48,204,10 - CONTROL "Allow fast specular after alpha", - IDC_FAST_SPECULAR_AFTER_ALPHA_CHECK,"Button", - BS_AUTOCHECKBOX | BS_CENTER | BS_PUSHLIKE | WS_TABSTOP,8, - 61,204,10 -END - -IDD_GAMEMTL_PSX_PANEL DIALOG DISCARDABLE 0, 0, 217, 66 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "None",IDC_NO_TRANS,"Button",BS_AUTORADIOBUTTON,17,32,33, - 10 - GROUPBOX "Translucency",IDC_STATIC,7,21,203,38 - CONTROL "100%",IDC_100_TRANS,"Button",BS_AUTORADIOBUTTON,17,45, - 33,10 - CONTROL "50%",IDC_50_TRANS,"Button",BS_AUTORADIOBUTTON,91,33,29, - 10 - CONTROL "25%",IDC_25_TRANS,"Button",BS_AUTORADIOBUTTON,91,45,29, - 10 - CONTROL "-100%",IDC_MINUS_100_TRANS,"Button",BS_AUTORADIOBUTTON, - 161,33,35,10 - CONTROL "Disable real-time lighting",IDC_NO_RT_LIGHTING,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,17,9,91,10 -END - -IDD_GAMEMTL_PASS DIALOG DISCARDABLE 0, 0, 217, 184 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "Tab1",IDC_GAMEMTL_TAB,"SysTabControl32",0x0,7,7,203,170 -END - -IDD_GAMEMTL_VERTEX_MATERIAL DIALOG DISCARDABLE 0, 0, 198, 151 -STYLE WS_CHILD | WS_CAPTION -CAPTION "Vertex Material" -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "Ambient Color",IDC_AMBIENT_COLOR,"ColorSwatch",0x0,46,4, - 34,12 - CONTROL "Diffuse Color",IDC_DIFFUSE_COLOR,"ColorSwatch",0x0,46, - 19,34,12 - CONTROL "Specular Color",IDC_SPECULAR_COLOR,"ColorSwatch",0x0,46, - 34,34,12 - CONTROL "Emissive Color",IDC_EMISSIVE_COLOR,"ColorSwatch",0x0,46, - 49,34,12 - CONTROL "",IDC_OPACITY_EDIT,"CustEdit",WS_TABSTOP,138,3,37,10 - CONTROL "",IDC_OPACITY_SPIN,"SpinnerControl",0x0,176,3,7,10 - CONTROL "",IDC_TRANSULCENCY_EDIT,"CustEdit",WS_TABSTOP,138,14,37, - 10 - CONTROL "",IDC_TRANSLUCENCY_SPIN,"SpinnerControl",0x0,176,14,7, - 10 - CONTROL "",IDC_SHININESS_EDIT,"CustEdit",WS_TABSTOP,138,25,37,10 - CONTROL "",IDC_SHININESS_SPIN,"SpinnerControl",0x0,176,25,7,10 - CONTROL "Specular To Diffuse",IDC_COPY_SPECULAR_DIFFUSE,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,92,41,79,10 - COMBOBOX IDC_MAPPING0_COMBO,27,79,65,87,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_MAPPING0_ARGS_EDIT,27,93,65,37,ES_MULTILINE | - ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | - WS_VSCROLL - CONTROL "",IDC_STAGE0UVCHAN_EDIT,"CustEdit",WS_GROUP | - WS_TABSTOP,59,134,18,10 - CONTROL "",IDC_STAGE0UVCHAN_SPIN,"SpinnerControl",0x0,77,134,10, - 10 - COMBOBOX IDC_MAPPING1_COMBO,124,79,65,87,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_MAPPING1_ARGS_EDIT,124,93,65,37,ES_MULTILINE | - ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | - WS_VSCROLL - CONTROL "",IDC_STAGE1UVCHAN_EDIT,"CustEdit",WS_GROUP | - WS_TABSTOP,152,134,18,10 - CONTROL "",IDC_STAGE1UVCHAN_SPIN,"SpinnerControl",0x0,170,134,10, - 10 - LTEXT "Ambient:",IDC_STATIC,9,6,28,8 - LTEXT "Diffuse:",IDC_STATIC,9,21,25,8 - LTEXT "Specular:",IDC_STATIC,9,36,31,8 - LTEXT "Emissive:",IDC_STATIC,9,51,30,8 - LTEXT "Opacity:",IDC_STATIC,88,3,27,8 - LTEXT "Translucency:",IDC_STATIC,88,13,46,8 - LTEXT "Shininess:",IDC_STATIC,88,23,33,8 - GROUPBOX "Stage 0 Mapping",IDC_STATIC,3,67,94,81 - LTEXT "Type:",IDC_STATIC,8,79,19,8 - LTEXT "Args:",IDC_STATIC,8,92,17,8 - LTEXT "UV Channel:",IDC_STATIC,9,134,41,8 - LTEXT "UV Channel:",IDC_STATIC,104,134,41,8 - GROUPBOX "Stage 1 Mapping",IDC_STATIC,99,67,96,81 - LTEXT "Type:",IDC_STATIC,104,79,19,8 - LTEXT "Args:",IDC_STATIC,104,92,17,8 -END - -IDD_GAMEMTL_SHADER DIALOG DISCARDABLE 0, 0, 198, 134 -STYLE WS_CHILD | WS_CAPTION -CAPTION "Shader" -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "Blend",IDC_STATIC,7,0,184,73 - LTEXT "Blend Mode:",IDC_STATIC,30,15,41,8 - COMBOBOX IDC_PRESET_COMBO,73,13,94,131,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - GROUPBOX "Custom",IDC_STATIC,13,30,172,40 - LTEXT "Src:",IDC_STATIC,16,41,15,11 - COMBOBOX IDC_SRCBLEND_COMBO,34,40,62,157,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - LTEXT "Dest:",IDC_STATIC,99,41,16,11 - COMBOBOX IDC_DESTBLEND_COMBO,119,40,62,157,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - CONTROL "Write ZBuffer",IDC_DEPTHMASK_CHECK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,25,56,58,10 - CONTROL "Alpha Test",IDC_ALPHATEST_CHECK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,110,56,50,10 - GROUPBOX "Advanced",IDC_STATIC,7,74,184,57 - PUSHBUTTON "Defaults",IDC_SHADER_DEFAULTS_BUTTON,18,87,34,12 - LTEXT "Pri Gradient:",IDC_STATIC,71,80,40,8 - COMBOBOX IDC_PRIGRADIENT_COMBO,71,90,57,157,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - LTEXT "Sec Gradient:",IDC_STATIC,131,80,44,8 - COMBOBOX IDC_SECGRADIENT_COMBO,131,90,57,157,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - LTEXT "Depth Cmp:",IDC_STATIC,11,104,38,8 - COMBOBOX IDC_DEPTHCOMPARE_COMBO,11,114,57,157,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - LTEXT "Detail Color:",IDC_STATIC,71,104,39,8 - COMBOBOX IDC_DETAILCOLOR_COMBO,71,114,57,157,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - LTEXT "Detail Alpha:",IDC_STATIC,131,104,41,8 - COMBOBOX IDC_DETAILALPHA_COMBO,131,114,57,157,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP -END - -IDD_GAMEMTL_TEXTURES DIALOG DISCARDABLE 0, 0, 198, 135 -STYLE WS_CHILD | WS_CAPTION -CAPTION "Textures" -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "",IDC_STATIC,7,0,184,65 - PUSHBUTTON "None",IDC_STAGE0_BUTTON,14,11,104,11 - CONTROL "Publish",IDC_STAGE0_PUBLISH_BUTTON,"CustButton", - WS_TABSTOP,121,11,29,11 - CONTROL "Display",IDC_STAGE0_DISPLAY_BUTTON,"CustButton", - WS_TABSTOP,154,11,29,11 - CONTROL "Clamp U",IDC_STAGE0_CLAMP_U_BUTTON,"CustButton", - WS_TABSTOP,14,24,34,11 - CONTROL "Clamp V",IDC_STAGE0_CLAMP_V_BUTTON,"CustButton", - WS_TABSTOP,51,24,34,11 - LTEXT "Frames:",IDC_STATIC,15,37,26,8 - CONTROL "",IDC_STAGE0_FRAMES_EDIT,"CustEdit",WS_TABSTOP,41,37,19, - 10 - CONTROL "",IDC_STAGE0_FRAMES_SPIN,"SpinnerControl",0x0,61,37,7, - 10 - LTEXT "Rate:",IDC_STATIC,79,37,18,8 - CONTROL "",IDC_STAGE0_RATE_EDIT,"CustEdit",WS_TABSTOP,98,37,19, - 10 - CONTROL "",IDC_STAGE0_RATE_SPIN,"SpinnerControl",0x0,118,37,7,10 - COMBOBOX IDC_STAGE0_ANIM_COMBO,135,37,48,63,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - LTEXT "Pass Hint:",IDC_STATIC,15,49,33,8 - COMBOBOX IDC_STAGE0_HINT_COMBO,50,48,75,157,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - CONTROL "Alpha Button",IDC_STAGE0_ALPHA_BITMAP_BUTTON,"CustButton", - WS_TABSTOP,135,51,47,11 - GROUPBOX "",IDC_STATIC,7,65,184,66 - CONTROL "Stage 1 Texture (Detail Texture)",IDC_STAGE1_ENABLE, - "Button",BS_AUTOCHECKBOX,13,65,117,10 - PUSHBUTTON "None",IDC_STAGE1_BUTTON,14,76,104,11 - CONTROL "Stage 0 Texture ",IDC_STAGE0_ENABLE,"Button", - BS_AUTOCHECKBOX,13,0,68,10 - CONTROL "Publish",IDC_STAGE1_PUBLISH_BUTTON,"CustButton", - WS_TABSTOP,121,76,29,11 - CONTROL "Display",IDC_STAGE1_DISPLAY_BUTTON,"CustButton", - WS_TABSTOP,154,76,29,11 - CONTROL "Clamp U",IDC_STAGE1_CLAMP_U_BUTTON,"CustButton", - WS_TABSTOP,14,89,34,11 - CONTROL "Clamp V",IDC_STAGE1_CLAMP_V_BUTTON,"CustButton", - WS_TABSTOP,51,89,34,11 - LTEXT "Frames:",IDC_STATIC,15,102,26,8 - CONTROL "",IDC_STAGE1_FRAMES_EDIT,"CustEdit",WS_TABSTOP,41,102, - 19,10 - CONTROL "",IDC_STAGE1_FRAMES_SPIN,"SpinnerControl",0x0,61,102,7, - 10 - LTEXT "Rate:",IDC_STATIC,79,102,18,8 - CONTROL "",IDC_STAGE1_RATE_EDIT,"CustEdit",WS_TABSTOP,100,102,19, - 10 - CONTROL "",IDC_STAGE1_RATE_SPIN,"SpinnerControl",0x0,120,102,7, - 10 - COMBOBOX IDC_STAGE1_ANIM_COMBO,135,102,48,63,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - LTEXT "Pass Hint:",IDC_STATIC,15,113,33,8 - COMBOBOX IDC_STAGE1_HINT_COMBO,50,113,75,157,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - CONTROL "Alpha Button",IDC_STAGE1_ALPHA_BITMAP_BUTTON,"CustButton", - WS_TABSTOP,135,117,47,11 - CONTROL "NoLOD",IDC_STAGE0_NOLOD_BUTTON,"CustButton",WS_TABSTOP, - 87,24,34,11 - CONTROL "NoLOD",IDC_STAGE1_NOLOD_BUTTON,"CustButton",WS_TABSTOP, - 87,89,34,11 -END - -IDD_GAMEMTL_PASS_COUNT DIALOGEX 0, 0, 217, 27 -STYLE WS_CHILD | WS_VISIBLE -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - PUSHBUTTON "Change",IDC_SETPASSCOUNT,146,8,41,11 - CTEXT "1",IDC_GAMEMTL_PASSCOUNT_STATIC,96,8,20,11,0, - WS_EX_CLIENTEDGE - LTEXT "Current Pass Count:",IDC_STATIC,26,9,64,8 -END - -IDD_GAMEMTL_PASS_COUNT_DIALOG DIALOG DISCARDABLE 0, 0, 190, 45 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Set pass count" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,133,7,50,14 - PUSHBUTTON "Cancel",IDCANCEL,133,23,50,14 - CONTROL "woohoo!",IDC_PASSCOUNT_SPIN,"SpinnerControl",WS_TABSTOP, - 113,16,10,12 - CONTROL "Custom1",IDC_PASSCOUNT_EDIT,"CustEdit",WS_TABSTOP,90,16, - 22,12 - LTEXT "Set number of passes",IDC_STATIC,15,17,70,11 -END - -IDD_GENERATE_NAMES_DIALOG DIALOG DISCARDABLE 0, 0, 201, 199 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Generate Node Names" -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "",IDC_STATIC,7,7,130,50 - CONTROL "Assign Names",IDC_ASSIGN_NAMES_CHECK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,15,7,61,10 - GROUPBOX "",IDC_STATIC,7,131,130,42 - CONTROL "Assign Collision Bits",IDC_ASSIGN_COLLISION_BITS_CHECK, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,131,77,10 - DEFPUSHBUTTON "OK",IDOK,141,7,50,14 - PUSHBUTTON "Cancel",IDCANCEL,141,24,50,14 - LTEXT "Root Name:",IDC_STATIC,15,20,39,8 - EDITTEXT IDC_BASE_NAME_EDIT,62,17,63,14,ES_AUTOHSCROLL - LTEXT "Starting Name Index:",IDC_STATIC,15,40,67,8 - CONTROL "",IDC_NAME_INDEX_EDIT,"CustEdit",WS_GROUP | WS_TABSTOP, - 87,39,28,10 - CONTROL "",IDC_NAME_INDEX_SPIN,"SpinnerControl",0x0,115,39,10,10 - CONTROL "Affect All",IDC_AFFECT_ALL_RADIO,"Button", - BS_AUTORADIOBUTTON,15,179,44,10 - CONTROL "Affect Selected",IDC_AFFECT_SELECTED_RADIO,"Button", - BS_AUTORADIOBUTTON,67,179,65,10 - CONTROL "Physical",IDC_COLLISION_PHYSICAL,"Button", - BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,15,146,42,10 - CONTROL "Vis",IDC_COLLISION_VIS,"Button",BS_AUTOCHECKBOX,63,146, - 25,10 - CONTROL "Projectile",IDC_COLLISION_PROJECTILE,"Button", - BS_AUTOCHECKBOX,15,158,45,10 - GROUPBOX "",IDC_STATIC,7,60,130,31 - CONTROL "Assign Prefix",IDC_ASSIGN_PREFIX_CHECK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,15,59,56,10 - LTEXT "Prefix:",IDC_STATIC,15,74,20,8 - EDITTEXT IDC_PREFIX_EDIT,62,71,63,14,ES_AUTOHSCROLL - GROUPBOX "",IDC_STATIC,7,96,130,31 - CONTROL "Assign Suffix",IDC_ASSIGN_SUFFIX_CHECK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,15,95,56,10 - LTEXT "Suffix:",IDC_STATIC,15,109,20,8 - EDITTEXT IDC_SUFFIX_EDIT,61,106,63,14,ES_AUTOHSCROLL - LTEXT "Remember that W3D names must be no longer than 15 characters. Using Prefix or Suffix can exceed this limit.", - IDC_STATIC,142,42,52,75 -END - -IDD_MESH_DEFORM_PANEL DIALOG DISCARDABLE 0, 0, 108, 168 -STYLE WS_CHILD | WS_CLIPSIBLINGS -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Vertex &Color:",IDC_STATIC,7,7,41,8 - CONTROL "Vertex Color",IDC_VERTEX_COLOR,"ColorSwatch",0x0,53,3, - 48,15 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,4,24,98,1 - LTEXT "Deform &Progression",IDC_STATIC,7,21,62,8 - CONTROL "Slider1",IDC_STATE_SLIDER,"msctls_trackbar32", - TBS_AUTOTICKS | WS_TABSTOP,7,33,94,12 - CONTROL 130,IDC_STATIC,"Static",SS_BITMAP,9,50,11,10 - CONTROL 131,IDC_STATIC,"Static",SS_BITMAP,89,50,11,10 - CONTROL "Link Set States",IDC_LOCK_SETS,"CustButton",WS_TABSTOP, - 7,66,70,13 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,4,86,99,1 - LTEXT "&Deform Sets",IDC_STATIC,7,82,40,8 - LTEXT "&Max Sets:",IDC_STATIC,11,95,32,8 - CONTROL "",IDC_MAX_SETS_EDIT,"CustEdit",WS_TABSTOP,55,95,22,10 - CONTROL "",IDC_MAX_SETS_SPIN,"SpinnerControl",WS_TABSTOP,79,95, - 10,10 - LTEXT "Current Set:",IDC_STATIC,11,111,38,8 - LTEXT "Static",IDC_CURRENT_SET_STATIC,55,110,30,11,SS_SUNKEN - CONTROL "Slider1",IDC_CURRENT_SET_SLIDER,"msctls_trackbar32", - TBS_AUTOTICKS | WS_TABSTOP,7,123,94,12 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,4,145,99,1 - LTEXT "&Runtime Options",IDC_STATIC,7,141,53,8 - CONTROL "&Manual Deform",IDC_MANUALAPPLY,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,11,153,64,10 -END - -IDD_GAMEMTL_SURFACE_TYPE DIALOG DISCARDABLE 0, 0, 217, 42 -STYLE WS_CHILD | WS_VISIBLE -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Surface &Type:",IDC_STATIC,26,9,46,8 - COMBOBOX IDC_SURFACE_TYPE_COMBO,77,7,133,77,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - LTEXT "Static Sorting Level:",IDC_STATIC,8,25,64,8 - CONTROL "Enabled",IDC_ENABLE_SORT_LEVEL,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,77,25,42,10 - CONTROL "",IDC_SORT_LEVEL,"CustEdit",WS_TABSTOP,123,25,19,10 - CONTROL "",IDC_SORT_LEVEL_SPIN,"SpinnerControl",0x0,143,25,7,10 -END - -IDD_GAMEMTL_DISPLACEMENT_MAP DIALOG DISCARDABLE 0, 0, 217, 25 -STYLE WS_CHILD | WS_VISIBLE -FONT 8, "MS Sans Serif" -BEGIN - PUSHBUTTON "None",IDC_TEXTURE_BUTTON,106,7,104,11 - RTEXT "Amount:",IDC_STATIC,7,8,55,8 - CONTROL "",IDC_AMOUNT_EDIT,"CustEdit",WS_TABSTOP,67,8,19,10 - CONTROL "",IDC_AMOUNT_SPIN,"SpinnerControl",0x0,87,8,7,10 -END - -IDD_GENERATE_MTL_NAMES_DIALOG DIALOG DISCARDABLE 0, 0, 204, 70 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Generate Material Names" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,147,7,50,14 - PUSHBUTTON "Cancel",IDCANCEL,147,25,50,14 - LTEXT "Root Name:",IDC_STATIC,15,12,39,8 - EDITTEXT IDC_BASE_NAME_EDIT,62,9,63,14,ES_AUTOHSCROLL - LTEXT "Starting Name Index:",IDC_STATIC,15,32,67,8 - CONTROL "",IDC_NAME_INDEX_EDIT,"CustEdit",WS_GROUP | WS_TABSTOP, - 87,31,28,10 - CONTROL "",IDC_NAME_INDEX_SPIN,"SpinnerControl",0x0,115,31,10,10 - CONTROL "Affect All",IDC_AFFECT_ALL_RADIO,"Button", - BS_AUTORADIOBUTTON,15,51,44,10 - CONTROL "Affect Selected",IDC_AFFECT_SELECTED_RADIO,"Button", - BS_AUTORADIOBUTTON,67,51,65,10 -END - -IDD_GENERATE_LOD_EXTENSION_DIALOG DIALOG DISCARDABLE 0, 0, 203, 86 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Generate Extensions" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,146,7,50,14 - PUSHBUTTON "Cancel",IDCANCEL,146,24,50,14 - LTEXT "This will append an extension to the currently selected objects. LOD 0 should be your highest-poly model, with increasing LOD numbers going to your lower-poly models. Damage models should be extension numbers 1 and up.", - IDC_STATIC,7,45,189,34 - LTEXT "Extension number:",IDC_STATIC,21,20,59,8 - CONTROL "",IDC_LOD_INDEX_EDIT,"CustEdit",WS_GROUP | WS_TABSTOP, - 85,19,28,10 - CONTROL "",IDC_LOD_INDEX_SPIN,"SpinnerControl",0x0,113,19,10,10 -END - -IDD_EXPORT_ALL DIALOG DISCARDABLE 0, 0, 203, 74 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Export All Max Scenes" -FONT 8, "MS Sans Serif" -BEGIN - EDITTEXT IDC_DIRECTORY,35,14,107,14,ES_AUTOHSCROLL - PUSHBUTTON "&Browse...",IDC_BROWSE,146,14,50,14 - CONTROL "Traverse &Subfolders",IDC_RECURSIVE,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,35,34,79,10 - DEFPUSHBUTTON "OK",IDOK,87,53,50,14 - PUSHBUTTON "Cancel",IDCANCEL,146,53,50,14 - LTEXT "Folder:",IDC_STATIC,7,17,22,8 -END - -IDD_SCENE_SETUP DIALOG DISCARDABLE 0, 0, 222, 245 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "LOD and Damage Configuration" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,165,7,50,14 - PUSHBUTTON "Cancel",IDCANCEL,165,24,50,14 - GROUPBOX "LOD",IDC_STATIC,7,7,144,114 - LTEXT "Number of LODs to create:",IDC_STATIC,15,20,86,8 - LTEXT "Offset from original (X Axis):",IDC_STATIC,15,36,86,8 - EDITTEXT IDC_LOD_COUNT,112,18,25,14,ES_AUTOHSCROLL | ES_NUMBER - EDITTEXT IDC_LOD_OFFSET,112,34,25,14,ES_AUTOHSCROLL - GROUPBOX "Create as",IDC_STATIC,17,52,84,61 - CONTROL "Copies",IDC_LOD_AS_COPY,"Button",BS_AUTORADIOBUTTON | - WS_TABSTOP,35,66,37,10 - CONTROL "Instances",IDC_LOD_AS_INSTANCE,"Button", - BS_AUTORADIOBUTTON,35,81,47,10 - CONTROL "References",IDC_LOD_AS_REFERENCE,"Button", - BS_AUTORADIOBUTTON,35,96,53,10 - GROUPBOX "Damage",IDC_STATIC,7,124,144,114 - LTEXT "Number of damage models:",IDC_STATIC,15,140,87,8 - LTEXT "Offset from original (Y Axis):",IDC_STATIC,15,154,86,8 - EDITTEXT IDC_DAMAGE_COUNT,112,137,25,14,ES_AUTOHSCROLL | - ES_NUMBER - EDITTEXT IDC_DAMAGE_OFFSET,112,153,25,14,ES_AUTOHSCROLL - GROUPBOX "Create as",IDC_STATIC,15,170,86,64 - CONTROL "Copies",IDC_DAMAGE_AS_COPY,"Button",BS_AUTORADIOBUTTON | - WS_TABSTOP,35,186,37,10 - CONTROL "Instances",IDC_DAMAGE_AS_INSTANCE,"Button", - BS_AUTORADIOBUTTON,35,200,47,10 - CONTROL "References",IDC_DAMAGE_AS_REFERENCE,"Button", - BS_AUTORADIOBUTTON,35,214,53,10 -END - -IDD_GAMEMTL_PS2_SHADER DIALOGEX 0, 0, 198, 134 -STYLE WS_CHILD | WS_CAPTION -CAPTION "Playstation 2 Shader" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - GROUPBOX "Blend",IDC_STATIC,7,0,184,73 - LTEXT "Blend Mode:",IDC_STATIC,31,9,41,8 - COMBOBOX IDC_PS2_PRESET_COMBO,75,7,94,131,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - GROUPBOX "Custom",IDC_STATIC,13,30,172,40 - LTEXT "A:",IDC_STATIC,15,38,15,11 - COMBOBOX IDC_A_COMBO,32,38,62,157,CBS_DROPDOWNLIST | WS_VSCROLL | - WS_TABSTOP - LTEXT "B:",IDC_STATIC,98,38,16,11 - COMBOBOX IDC_B_COMBO,118,38,62,157,CBS_DROPDOWNLIST | WS_VSCROLL | - WS_TABSTOP - CONTROL "ZBuffer",IDC_DEPTHMASK_CHECK,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,132,83,39,10 - CONTROL "Alpha Test",IDC_ALPHATEST_CHECK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,132,95,50,10 - GROUPBOX "Advanced",IDC_STATIC,7,74,184,57 - PUSHBUTTON "Defaults",IDC_SHADER_DEFAULTS_BUTTON,18,87,34,12 - LTEXT "Pri Gradient:",IDC_STATIC,71,80,40,8 - COMBOBOX IDC_PRIGRADIENT_COMBO,71,90,57,157,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - LTEXT "Depth Cmp:",IDC_STATIC,11,104,38,8 - COMBOBOX IDC_DEPTHCOMPARE_COMBO,11,114,57,157,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - LTEXT "Detail Color:",IDC_STATIC,71,104,39,8,WS_DISABLED - COMBOBOX IDC_DETAILCOLOR_COMBO,71,114,57,157,CBS_DROPDOWNLIST | - WS_DISABLED | WS_VSCROLL | WS_TABSTOP - LTEXT "Detail Alpha:",IDC_STATIC,131,104,41,8,WS_DISABLED - COMBOBOX IDC_DETAILALPHA_COMBO,131,114,57,157,CBS_DROPDOWNLIST | - WS_DISABLED | WS_VSCROLL | WS_TABSTOP - LTEXT "(A - B) * C + D",IDC_STATIC,15,20,60,10 - LTEXT "D:",IDC_STATIC,98,52,15,11 - COMBOBOX IDC_D_COMBO,118,52,62,157,CBS_DROPDOWNLIST | WS_VSCROLL | - WS_TABSTOP - LTEXT "C:",IDC_STATIC,15,52,15,11 - COMBOBOX IDC_C_COMBO,32,52,62,157,CBS_DROPDOWNLIST | WS_VSCROLL | - WS_TABSTOP - CONTROL "",IDC_COMPATIBLE,"RICHEDIT",ES_READONLY | ES_NUMBER | - WS_BORDER | WS_TABSTOP,100,20,79,14,WS_EX_DLGMODALFRAME -END - -IDD_GAMEMTL_PS2_TEXTURES DIALOG DISCARDABLE 0, 0, 198, 135 -STYLE WS_CHILD | WS_CAPTION -CAPTION "Textures" -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "",IDC_STATIC,7,0,184,65 - PUSHBUTTON "None",IDC_STAGE0_BUTTON,14,11,104,11 - CONTROL "Publish",IDC_STAGE0_PUBLISH_BUTTON,"CustButton", - WS_TABSTOP,121,11,29,11 - CONTROL "Display",IDC_STAGE0_DISPLAY_BUTTON,"CustButton", - WS_TABSTOP,154,11,29,11 - CONTROL "Clamp U",IDC_STAGE0_CLAMP_U_BUTTON,"CustButton", - WS_TABSTOP,14,24,40,11 - CONTROL "Clamp V",IDC_STAGE0_CLAMP_V_BUTTON,"CustButton", - WS_TABSTOP,60,24,40,11 - LTEXT "Frames:",IDC_STATIC,15,37,26,8,WS_DISABLED - CONTROL "",IDC_STAGE0_FRAMES_EDIT,"CustEdit",WS_DISABLED | - WS_TABSTOP,41,37,19,10 - CONTROL "",IDC_STAGE0_FRAMES_SPIN,"SpinnerControl",WS_DISABLED, - 61,37,7,10 - LTEXT "Rate:",IDC_STATIC,79,37,18,8,WS_DISABLED - CONTROL "",IDC_STAGE0_RATE_EDIT,"CustEdit",WS_DISABLED | - WS_TABSTOP,98,37,19,10 - CONTROL "",IDC_STAGE0_RATE_SPIN,"SpinnerControl",WS_DISABLED,118, - 37,7,10 - COMBOBOX IDC_STAGE0_ANIM_COMBO,135,37,48,63,CBS_DROPDOWNLIST | - WS_DISABLED | WS_VSCROLL | WS_TABSTOP - LTEXT "Pass Hint:",IDC_STATIC,15,49,33,8 - COMBOBOX IDC_STAGE0_HINT_COMBO,50,48,75,157,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - CONTROL "Alpha Button",IDC_STAGE0_ALPHA_BITMAP_BUTTON,"CustButton", - WS_TABSTOP,135,51,47,11 - CONTROL "Stage 1 Texture (Detail Texture)",IDC_STAGE1_ENABLE, - "Button",BS_AUTOCHECKBOX,13,65,117,10 - PUSHBUTTON "None",IDC_STAGE1_BUTTON,14,76,104,11 - CONTROL "hoax",IDC_STAGE1_PUBLISH_BUTTON,"CustButton",WS_TABSTOP, - 121,76,29,11 - CONTROL "hoax",IDC_STAGE1_DISPLAY_BUTTON,"CustButton",WS_TABSTOP, - 154,76,29,11 - CONTROL "Clamp U",IDC_STAGE1_CLAMP_U_BUTTON,"CustButton", - WS_TABSTOP,14,89,40,11 - CONTROL "Clamp V",IDC_STAGE1_CLAMP_V_BUTTON,"CustButton", - WS_TABSTOP,60,89,40,11 - LTEXT "Frames:",IDC_STATIC,15,102,26,8,WS_DISABLED - CONTROL "",IDC_STAGE1_FRAMES_EDIT,"CustEdit",WS_DISABLED | - WS_TABSTOP,41,102,19,10 - CONTROL "",IDC_STAGE1_FRAMES_SPIN,"SpinnerControl",WS_DISABLED, - 61,102,7,10 - LTEXT "Rate:",IDC_STATIC,79,102,18,8,WS_DISABLED - CONTROL "",IDC_STAGE1_RATE_EDIT,"CustEdit",WS_DISABLED | - WS_TABSTOP,100,102,19,10 - CONTROL "",IDC_STAGE1_RATE_SPIN,"SpinnerControl",WS_DISABLED,120, - 102,7,10 - COMBOBOX IDC_STAGE1_ANIM_COMBO,135,102,48,63,CBS_DROPDOWNLIST | - WS_DISABLED | WS_VSCROLL | WS_TABSTOP - LTEXT "Pass Hint:",IDC_STATIC,15,113,33,8 - COMBOBOX IDC_STAGE1_HINT_COMBO,50,113,75,157,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - CONTROL "Alpha Button",IDC_STAGE1_ALPHA_BITMAP_BUTTON,"CustButton", - WS_TABSTOP,135,117,47,11 - CONTROL "Stage 0 Texture ",IDC_STAGE0_ENABLE,"Button", - BS_AUTOCHECKBOX,13,0,68,10 - GROUPBOX "",IDC_STATIC,7,65,184,66 - CONTROL "NoLOD",IDC_STAGE0_NOLOD_BUTTON,"CustButton",WS_TABSTOP, - 105,24,34,11 - CONTROL "NoLOD",IDC_STAGE1_NOLOD_BUTTON,"CustButton",WS_TABSTOP, - 105,89,34,11 -END - -IDD_ALPHA_MODIFIER DIALOG DISCARDABLE 0, 0, 100, 38 -STYLE WS_CHILD | WS_VISIBLE | WS_BORDER -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "",IDC_ALPHA_EDIT,"CustEdit",WS_TABSTOP,11,21,37,10 - CONTROL "",IDC_ALPHA_SPIN,"SpinnerControl",0x0,49,21,7,10 - LTEXT "Vertex Alpha Value:",IDC_STATIC,18,7,63,8, - SS_CENTERIMAGE - CONTROL "Find",IDC_ALPHA_CHECKBOX,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,62,21,29,10 -END - -IDD_W3D_LOG DIALOG DISCARDABLE 0, 0, 334, 319 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Animation Export Log" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,277,298,50,14 - CONTROL "Progress1",IDC_ANIM_COMPRESS_PROGRESS,"msctls_progress32", - PBS_SMOOTH | WS_BORDER,7,296,260,16 - CONTROL "",IDC_ANIM_LOG_RICHEDIT,"RICHEDIT",ES_MULTILINE | - ES_AUTOVSCROLL | ES_READONLY | ES_NUMBER | WS_BORDER | - WS_VSCROLL | WS_TABSTOP,7,7,320,282 -END - -IDD_INPUT_DIALOG DIALOG DISCARDABLE 0, 0, 197, 47 -STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE | - WS_CAPTION | WS_SYSMENU -CAPTION "Dialog Caption" -FONT 8, "MS Sans Serif" -BEGIN - EDITTEXT IDC_VALUE,7,24,129,14,ES_AUTOHSCROLL - DEFPUSHBUTTON "OK",IDOK,140,7,50,14 - PUSHBUTTON "Cancel",IDCANCEL,140,24,50,14 - LTEXT "Label",IDC_LABEL,7,7,129,17 -END - -IDD_W3DUTILITY_FLOATER_DIALOG DIALOG DISCARDABLE 0, 0, 114, 50 -STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "W3D Export Settings" -FONT 8, "MS Sans Serif" -BEGIN -END - -IDD_W3DUTILITY_SETTINGS_DIALOG DIALOG DISCARDABLE 0, 0, 108, 239 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "Object Export Options",-1,4,7,100,65 - CONTROL "Export Transform (Bone)",IDC_HIERARCHY_CHECK,"Button", - BS_3STATE | WS_GROUP | WS_TABSTOP,11,34,90,10 - CONTROL "Export Geometry",IDC_GEOMETRY_CHECK,"Button",BS_3STATE, - 11,46,68,10 - GROUPBOX "Geometry Options",-1,4,72,100,113 - CONTROL "Normal",IDC_GEOMETRY_NORMAL,"Button",BS_AUTORADIOBUTTON | - WS_GROUP,7,81,38,10 - CONTROL "Cam-Parallel",IDC_GEOMETRY_CAMERA_ALIGNED,"Button", - BS_AUTORADIOBUTTON,7,91,55,10 - CONTROL "Cam-Orient",IDC_GEOMETRY_CAMERA_ORIENTED,"Button", - BS_AUTORADIOBUTTON,7,102,51,10 - CONTROL "AABox",IDC_GEOMETRY_AABOX,"Button",BS_AUTORADIOBUTTON,7, - 113,37,10 - CONTROL "OBBox",IDC_GEOMETRY_OBBOX,"Button",BS_AUTORADIOBUTTON,7, - 124,38,10 - CONTROL "2Side",IDC_GEOMETRY_TWO_SIDED,"Button",BS_3STATE | - WS_GROUP | WS_TABSTOP,63,81,34,10 - CONTROL "Hide",IDC_GEOMETRY_HIDE,"Button",BS_3STATE,63,92,31,10 - CONTROL "ZNrm",IDC_GEOMETRY_ZNORMALS,"Button",BS_3STATE,63,103, - 33,10 - GROUPBOX "Collision Options",-1,4,185,100,50 - CONTROL "Physical",IDC_COLLISION_PHYSICAL,"Button",BS_3STATE | - WS_GROUP | WS_TABSTOP,14,198,42,10 - CONTROL "Projectile",IDC_COLLISION_PROJECTILE,"Button",BS_3STATE, - 14,210,45,10 - CONTROL "Vis",IDC_COLLISION_VIS,"Button",BS_3STATE,61,198,25,10 - CONTROL "VAlpha",IDC_GEOMETRY_VERTEX_ALPHA,"Button",BS_3STATE,63, - 114,39,10 - CONTROL "Null (LOD)",IDC_GEOMETRY_NULL,"Button", - BS_AUTORADIOBUTTON,7,135,49,10 - LTEXT "Damage Region:",-1,11,59,54,8 - CONTROL "",IDC_DAMREG_INDEX_EDIT,"CustEdit",WS_GROUP | - WS_TABSTOP,69,58,18,10 - CONTROL "",IDC_DAMREG_INDEX_SPIN,"SpinnerControl",0x0,88,58,10, - 10 - CONTROL "Shadw",IDC_GEOMETRY_CAST_SHADOW,"Button",BS_3STATE,63, - 126,38,10 - CONTROL "Shatter",IDC_GEOMETRY_SHATTERABLE,"Button",BS_3STATE,63, - 138,39,10 - CONTROL "Camera",IDC_COLLISION_CAMERA,"Button",BS_3STATE,61,210, - 40,10 - CONTROL "Dazzle",IDC_GEOMETRY_DAZZLE,"Button",BS_AUTORADIOBUTTON, - 7,156,37,10 - COMBOBOX IDC_DAZZLE_COMBO,8,168,90,86,CBS_DROPDOWN | WS_VSCROLL | - WS_TABSTOP - CONTROL "Object Name",IDC_OBJ_NAME,"CustEdit",WS_TABSTOP,11,18, - 88,12 - CONTROL "Aggregate",IDC_GEOMETRY_AGGREGATE,"Button", - BS_AUTORADIOBUTTON,7,146,49,10 - CONTROL "Vehicle",IDC_COLLISION_VEHICLE,"Button",BS_3STATE,14, - 222,39,10 - CONTROL "NPatch",IDC_GEOMETRY_NPATCH,"Button",BS_3STATE,63,150, - 40,10 -END - -IDD_W3DUTILITY_TOOLS_DIALOG DIALOG DISCARDABLE 0, 0, 108, 212 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "Naming Utilities",-1,4,85,100,67 - PUSHBUTTON "Assign Node Names",IDC_COLLECTION_NAMES_GENERATE,13,98, - 79,14 - GROUPBOX "Select by W3D Type",-1,4,3,100,80 - PUSHBUTTON "Select Bones",IDC_SELECT_HIERARCHY,13,14,79,14 - PUSHBUTTON "Select Geometry",IDC_SELECT_GEOMETRY,13,30,79,14 - PUSHBUTTON "Select Alpha Meshes",IDC_SELECT_ALPHA_MESHES,13,46,79, - 14 - PUSHBUTTON "Phys",IDC_SELECT_PHYSICAL,13,62,25,14 - PUSHBUTTON "Proj",IDC_SELECT_PROJECTILE,40,62,25,14 - PUSHBUTTON "Vis",IDC_SELECT_VIS,67,62,25,14 - PUSHBUTTON "Assign Material Names",IDC_MATERIAL_NAMES_GENERATE,13, - 115,79,14 - PUSHBUTTON "Assign Extensions",IDC_LOD_EXTENSION_GENERATE,13,132,79, - 14 - GROUPBOX "Export Utilities",IDC_EXPORT_UTILITIES_GROUP,4,153,100, - 36 - PUSHBUTTON "Export with Std Mtls",IDC_EXPORT_STANDARD_MATERIALS,13, - 166,79,14 - PUSHBUTTON "Create Settings Floater",IDC_CREATE_SETTINGS_FLOATER,14, - 194,79,14 -END - -IDD_W3D_PRESET_EXPORT_OPTIONS DIALOG DISCARDABLE 0, 0, 234, 330 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "W3D Export Options" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,58,309,50,14 - PUSHBUTTON "Cancel",IDCANCEL,124,309,50,14 - CONTROL 158,IDC_STATIC,"Static",SS_BITMAP | SS_CENTERIMAGE,7,7, - 220,47 - CONTROL "&Hierarchical Model",IDC_HLOD_RADIO,"Button", - BS_AUTORADIOBUTTON,9,61,109,10 - CONTROL "Hierarchical &Animated Model",IDC_ANIM_HLOD_RADIO, - "Button",BS_AUTORADIOBUTTON,9,77,109,10 - CONTROL "&Pure Animation",IDC_ANIM_RADIO,"Button", - BS_AUTORADIOBUTTON,9,93,109,10 - CONTROL "&Renegade Terrain",IDC_TERRAIN_RADIO,"Button", - BS_AUTORADIOBUTTON,134,61,89,10 - CONTROL "&Skeleton",IDC_SKELETON_RADIO,"Button", - BS_AUTORADIOBUTTON,134,77,89,10 - CONTROL "Simple &Mesh",IDC_MESH_RADIO,"Button", - BS_AUTORADIOBUTTON,134,93,89,10 - GROUPBOX "Se&ttings",IDC_GROUP_BOX,7,109,220,180 - CONTROL "Review &Log",IDC_REVIEW_LOG,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,7,295,54,10 -END - -IDD_EXPORT_PANE_HLOD DIALOG DISCARDABLE 0, 0, 201, 164 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "This will export a model without animation data.", - IDC_STATIC,7,7,187,13 - PUSHBUTTON "&Browse...",IDC_WHT_BROWSE_BUTTON,18,99,165,12,WS_GROUP - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,79,186,1 - CONTROL "&Smooth Vertex Normals Across Meshes", - IDC_EXPORT_MESH_SMOOTH_CHECK,"Button",BS_AUTOCHECKBOX | - WS_GROUP | WS_TABSTOP,7,24,139,10 - CONTROL "&Optimize Collision Detection",IDC_EXPORT_MESH_AABTREES, - "Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,39, - 103,10 - CONTROL "Optimize &Mesh Data (mesh names will be lost)", - IDC_EXPORT_MESH_OPTIMIZE,"Button",BS_AUTOCHECKBOX | - BS_MULTILINE | WS_DISABLED | WS_GROUP | WS_TABSTOP,7,54, - 162,10 - CONTROL "Export Using Existing Skeleton:",IDC_USE_SKELETON_CHECK, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,86,114,10 - CONTROL "&Convert Material Diffuse Colors to Texture", - IDC_EXPORT_MESH_MAT_TO_TEXTURE,"Button",BS_AUTOCHECKBOX | - WS_GROUP | WS_TABSTOP,7,67,147,10 -END - -IDD_EXPORT_PANE_ANIMATED_HLOD DIALOG DISCARDABLE 0, 0, 201, 164 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "This will export the model with geometry and animation data.", - IDC_STATIC,7,7,187,17 - PUSHBUTTON "&Browse...",IDC_WHT_BROWSE_BUTTON,18,99,165,12,WS_GROUP - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,79,186,1 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,8,119,186,1 - LTEXT "&Frames:",IDC_STATIC,9,127,26,10,NOT WS_GROUP - CONTROL "",IDC_RANGE_LOW_EDIT,"CustEdit",WS_GROUP | WS_TABSTOP, - 43,125,28,12 - CONTROL "",IDC_RANGE_LOW_SPIN,"SpinnerControl",0x0,71,125,10,12 - LTEXT "To",IDC_STATIC,87,127,10,10 - CONTROL "",IDC_RANGE_HIGH_EDIT,"CustEdit",WS_TABSTOP,104,125,28, - 12 - CONTROL "",IDC_RANGE_HIGH_SPIN,"SpinnerControl",0x0,132,125,10, - 12 - PUSHBUTTON "&Settings...",IDC_COMPRESSION_SETTINGS,59,145,126,12, - WS_GROUP - CONTROL "&Smooth Vertex Normals Across Meshes", - IDC_EXPORT_MESH_SMOOTH_CHECK,"Button",BS_AUTOCHECKBOX | - WS_GROUP | WS_TABSTOP,7,30,139,10 - CONTROL "&Optimize Collision Detection",IDC_EXPORT_MESH_AABTREES, - "Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,45, - 103,10 - CONTROL "Optimize &Mesh Data (mesh names will be lost)", - IDC_EXPORT_MESH_OPTIMIZE,"Button",BS_AUTOCHECKBOX | - BS_MULTILINE | WS_DISABLED | WS_GROUP | WS_TABSTOP,7,60, - 162,10 - CONTROL "Export Using Existing Skeleton:",IDC_USE_SKELETON_CHECK, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,86,114,10 - CONTROL "&Compress",IDC_COMPRESS_ANIMATION_CHECK,"Button", - BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,147,47,10 -END - -IDD_EXPORT_PANE_ANIMATION DIALOG DISCARDABLE 0, 0, 201, 164 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "This will export the animation without any geometry data.", - IDC_STATIC,7,6,187,14 - PUSHBUTTON "&Browse...",IDC_WHT_BROWSE_BUTTON,18,42,165,12,WS_GROUP - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,8,60,186,1 - CONTROL "Export Using Existing Skeleton:",IDC_USE_SKELETON_CHECK, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,30,114,10 - LTEXT "&Frames:",IDC_STATIC,9,70,26,10,NOT WS_GROUP - CONTROL "",IDC_RANGE_LOW_EDIT,"CustEdit",WS_GROUP | WS_TABSTOP, - 43,68,28,12 - CONTROL "",IDC_RANGE_LOW_SPIN,"SpinnerControl",0x0,71,68,10,12 - LTEXT "To",IDC_STATIC,87,70,10,10 - CONTROL "",IDC_RANGE_HIGH_EDIT,"CustEdit",WS_TABSTOP,104,68,28, - 12 - CONTROL "",IDC_RANGE_HIGH_SPIN,"SpinnerControl",0x0,132,68,10,12 - PUSHBUTTON "&Settings...",IDC_COMPRESSION_SETTINGS,59,87,126,12, - WS_GROUP - CONTROL "&Compress",IDC_COMPRESS_ANIMATION_CHECK,"Button", - BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,89,47,10 -END - -IDD_EXPORT_PANE_MESH DIALOG DISCARDABLE 0, 0, 201, 164 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "This will export a single mesh. If there are more then one mesh, only the first one will be exported.", - IDC_STATIC,7,7,187,19 - CONTROL "Optimize Collision Detection",IDC_EXPORT_MESH_AABTREES, - "Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,30, - 103,10 - CONTROL "Convert Material Diffuse Colors to Texture", - IDC_EXPORT_MESH_MAT_TO_TEXTURE,"Button",BS_AUTOCHECKBOX | - WS_GROUP | WS_TABSTOP,7,45,147,10 -END - -IDD_EXPORT_PANE_SKELETON DIALOG DISCARDABLE 0, 0, 201, 164 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "This will export the hierarchy tree without any geometry or animation data.", - IDC_STATIC,7,7,187,24 -END - -IDD_EXPORT_PANE_TERRAIN DIALOG DISCARDABLE 0, 0, 201, 164 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "This will export the geometry in the Renegade terrain format.", - IDC_STATIC,7,7,187,15 - CONTROL "&Smooth Vertex Normals Across Meshes", - IDC_EXPORT_MESH_SMOOTH_CHECK,"Button",BS_AUTOCHECKBOX | - WS_GROUP | WS_TABSTOP,7,30,139,10 - CONTROL "Optimize Mesh Data (mesh names will be lost)", - IDC_EXPORT_MESH_OPTIMIZE,"Button",BS_AUTOCHECKBOX | - BS_MULTILINE | WS_DISABLED | WS_GROUP | WS_TABSTOP,7,45, - 162,10 -END - -IDD_ANIMATION_COMPRESSION DIALOG DISCARDABLE 0, 0, 170, 162 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Animation Compression Settings" -FONT 8, "MS Sans Serif" -BEGIN - ICON IDI_DISK,IDC_STATIC,7,7,20,20 - LTEXT "Specify compression settings for the exported animation.", - IDC_STATIC,42,7,121,15 - LTEXT "Compresion &Type:",IDC_STATIC,7,35,62,8 - COMBOBOX IDC_COMPRESS_ANIMATION_FLAVOR_COMBO,72,33,91,49, - CBS_DROPDOWNLIST | WS_VSCROLL | WS_GROUP | WS_TABSTOP - LTEXT "Max Translation Error:",IDC_STATIC,7,57,70,8 - EDITTEXT IDC_MAX_TRANS_ERROR_EDIT,83,54,40,14,ES_AUTOHSCROLL | - WS_GROUP - LTEXT "units",IDC_STATIC,128,57,16,8 - LTEXT "Max Rotational Error:",IDC_STATIC,7,77,67,8 - EDITTEXT IDC_MAX_ROT_ERROR_EDIT,83,74,40,14,ES_AUTOHSCROLL | - WS_GROUP - LTEXT "degrees",IDC_STATIC,128,77,26,8 - LTEXT "Key Reduction %:",IDC_STATIC,7,100,57,8 - COMBOBOX IDC_REDUCE_ANIMATION_COMBO,67,97,31,81,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_GROUP | WS_TABSTOP - CONTROL "Force Key Reduction",IDC_REDUCE_ANIMATION_CHECK,"Button", - BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,7,118,83,10 - DEFPUSHBUTTON "OK",IDOK,29,141,50,14 - PUSHBUTTON "Cancel",IDCANCEL,91,141,50,14 -END - -IDD_GRIDSNAP_PARAMS DIALOG DISCARDABLE 0, 0, 108, 24 -STYLE WS_CHILD -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "",IDC_GRIDDIM_EDIT,"CustEdit",WS_GROUP | WS_TABSTOP,57, - 7,33,10 - CONTROL "",IDC_GRIDDIM_SPIN,"SpinnerControl",0x0,91,7,10,10 - LTEXT "Grid Dimension",IDC_STATIC,7,8,48,8 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_VOXEL_DEBUG_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 164 - TOPMARGIN, 7 - BOTTOMMARGIN, 107 - END - - IDD_W3D_EXPORT_OPTIONS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 252 - TOPMARGIN, 7 - BOTTOMMARGIN, 275 - END - - IDD_BONE_INFLUENCE_PARAMS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 101 - TOPMARGIN, 7 - BOTTOMMARGIN, 71 - END - - IDD_SKELETON_PARAMETERS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 101 - TOPMARGIN, 7 - BOTTOMMARGIN, 130 - END - - IDD_SKIN_SOT, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 101 - TOPMARGIN, 7 - BOTTOMMARGIN, 15 - END - - IDD_GAMEMTL_PANEL, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 210 - TOPMARGIN, 7 - BOTTOMMARGIN, 279 - END - - IDD_GAMEMTL_NOTES_PANEL, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 210 - TOPMARGIN, 7 - BOTTOMMARGIN, 51 - END - - IDD_GAMEMTL_HINTS_PANEL, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 210 - TOPMARGIN, 7 - BOTTOMMARGIN, 72 - END - - IDD_GAMEMTL_PSX_PANEL, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 210 - TOPMARGIN, 7 - BOTTOMMARGIN, 59 - END - - IDD_GAMEMTL_PASS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 210 - TOPMARGIN, 7 - BOTTOMMARGIN, 177 - END - - IDD_GAMEMTL_VERTEX_MATERIAL, DIALOG - BEGIN - LEFTMARGIN, 3 - RIGHTMARGIN, 195 - TOPMARGIN, 1 - BOTTOMMARGIN, 144 - END - - IDD_GAMEMTL_SHADER, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 191 - TOPMARGIN, 7 - BOTTOMMARGIN, 127 - END - - IDD_GAMEMTL_TEXTURES, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 191 - TOPMARGIN, 7 - BOTTOMMARGIN, 128 - END - - IDD_GAMEMTL_PASS_COUNT, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 210 - TOPMARGIN, 7 - BOTTOMMARGIN, 20 - END - - IDD_GAMEMTL_PASS_COUNT_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 183 - TOPMARGIN, 7 - BOTTOMMARGIN, 38 - END - - IDD_GENERATE_NAMES_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 194 - TOPMARGIN, 7 - BOTTOMMARGIN, 192 - END - - IDD_MESH_DEFORM_PANEL, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 101 - TOPMARGIN, 3 - BOTTOMMARGIN, 165 - END - - IDD_GAMEMTL_SURFACE_TYPE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 210 - TOPMARGIN, 7 - BOTTOMMARGIN, 35 - END - - IDD_GAMEMTL_DISPLACEMENT_MAP, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 210 - TOPMARGIN, 7 - BOTTOMMARGIN, 18 - END - - IDD_GENERATE_MTL_NAMES_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 197 - TOPMARGIN, 7 - BOTTOMMARGIN, 62 - END - - IDD_GENERATE_LOD_EXTENSION_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 196 - TOPMARGIN, 7 - BOTTOMMARGIN, 79 - END - - IDD_EXPORT_ALL, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 196 - TOPMARGIN, 7 - BOTTOMMARGIN, 67 - END - - IDD_SCENE_SETUP, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 215 - TOPMARGIN, 7 - BOTTOMMARGIN, 238 - END - - IDD_GAMEMTL_PS2_SHADER, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 191 - TOPMARGIN, 7 - BOTTOMMARGIN, 127 - END - - IDD_GAMEMTL_PS2_TEXTURES, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 191 - TOPMARGIN, 7 - BOTTOMMARGIN, 128 - END - - IDD_ALPHA_MODIFIER, DIALOG - BEGIN - BOTTOMMARGIN, 36 - END - - IDD_W3D_LOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 327 - TOPMARGIN, 7 - BOTTOMMARGIN, 312 - END - - IDD_INPUT_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 190 - TOPMARGIN, 7 - BOTTOMMARGIN, 40 - END - - IDD_W3DUTILITY_FLOATER_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 107 - TOPMARGIN, 7 - BOTTOMMARGIN, 43 - END - - IDD_W3DUTILITY_SETTINGS_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 4 - RIGHTMARGIN, 104 - TOPMARGIN, 7 - BOTTOMMARGIN, 235 - END - - IDD_W3DUTILITY_TOOLS_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 4 - RIGHTMARGIN, 104 - TOPMARGIN, 7 - BOTTOMMARGIN, 208 - END - - IDD_W3D_PRESET_EXPORT_OPTIONS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 227 - TOPMARGIN, 7 - BOTTOMMARGIN, 323 - END - - IDD_EXPORT_PANE_HLOD, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 194 - TOPMARGIN, 7 - BOTTOMMARGIN, 157 - END - - IDD_EXPORT_PANE_ANIMATED_HLOD, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 194 - TOPMARGIN, 7 - BOTTOMMARGIN, 157 - END - - IDD_EXPORT_PANE_ANIMATION, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 194 - TOPMARGIN, 6 - BOTTOMMARGIN, 157 - END - - IDD_EXPORT_PANE_MESH, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 194 - TOPMARGIN, 7 - BOTTOMMARGIN, 157 - END - - IDD_EXPORT_PANE_SKELETON, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 194 - TOPMARGIN, 7 - BOTTOMMARGIN, 157 - END - - IDD_EXPORT_PANE_TERRAIN, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 194 - TOPMARGIN, 7 - BOTTOMMARGIN, 157 - END - - IDD_ANIMATION_COMPRESSION, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 163 - TOPMARGIN, 7 - BOTTOMMARGIN, 155 - END - - IDD_GRIDSNAP_PARAMS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 101 - TOPMARGIN, 7 - BOTTOMMARGIN, 17 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog Info -// - -IDD_GAMEMTL_PANEL DLGINIT -BEGIN - IDC_DCT_MAPPING_COMBO, 0x403, 3, 0 -0x5655, "\000" - IDC_DCT_MAPPING_COMBO, 0x403, 5, 0 -0x6e45, 0x6f76, "\000" - IDC_DIT_MAPPING_COMBO, 0x403, 3, 0 -0x5655, "\000" - IDC_DIT_MAPPING_COMBO, 0x403, 5, 0 -0x6e45, 0x6f76, "\000" - IDC_SCT_MAPPING_COMBO, 0x403, 3, 0 -0x5655, "\000" - IDC_SCT_MAPPING_COMBO, 0x403, 5, 0 -0x6e45, 0x6f76, "\000" - IDC_SIT_MAPPING_COMBO, 0x403, 3, 0 -0x5655, "\000" - IDC_SIT_MAPPING_COMBO, 0x403, 5, 0 -0x6e45, 0x6f76, "\000" - 0 -END - -IDD_GAMEMTL_SHADER DLGINIT -BEGIN - IDC_SRCBLEND_COMBO, 0x403, 5, 0 -0x655a, 0x6f72, "\000" - IDC_SRCBLEND_COMBO, 0x403, 4, 0 -0x6e4f, 0x0065, - IDC_SRCBLEND_COMBO, 0x403, 10, 0 -0x7253, 0x2063, 0x6c41, 0x6870, 0x0061, - IDC_SRCBLEND_COMBO, 0x403, 12, 0 -0x2d31, 0x7253, 0x2063, 0x6c41, 0x6870, 0x0061, - IDC_DESTBLEND_COMBO, 0x403, 5, 0 -0x655a, 0x6f72, "\000" - IDC_DESTBLEND_COMBO, 0x403, 4, 0 -0x6e4f, 0x0065, - IDC_DESTBLEND_COMBO, 0x403, 10, 0 -0x7253, 0x2063, 0x6f43, 0x6f6c, 0x0072, - IDC_DESTBLEND_COMBO, 0x403, 12, 0 -0x2d31, 0x7253, 0x2063, 0x6f43, 0x6f6c, 0x0072, - IDC_DESTBLEND_COMBO, 0x403, 10, 0 -0x7253, 0x2063, 0x6c41, 0x6870, 0x0061, - IDC_DESTBLEND_COMBO, 0x403, 12, 0 -0x2d31, 0x7253, 0x2063, 0x6c41, 0x6870, 0x0061, - IDC_DESTBLEND_COMBO, 0x403, 17, 0 -0x7253, 0x2063, 0x6f43, 0x6f6c, 0x2072, 0x7250, 0x4665, 0x676f, "\000" - IDC_PRIGRADIENT_COMBO, 0x403, 8, 0 -0x6944, 0x6173, 0x6c62, 0x0065, - IDC_PRIGRADIENT_COMBO, 0x403, 9, 0 -0x6f4d, 0x7564, 0x616c, 0x6574, "\000" - IDC_PRIGRADIENT_COMBO, 0x403, 4, 0 -0x6441, 0x0064, - IDC_PRIGRADIENT_COMBO, 0x403, 17, 0 -0x7542, 0x706d, 0x452d, 0x766e, 0x7269, 0x6e6f, 0x656d, 0x746e, "\000" - IDC_SECGRADIENT_COMBO, 0x403, 8, 0 -0x6944, 0x6173, 0x6c62, 0x0065, - IDC_SECGRADIENT_COMBO, 0x403, 7, 0 -0x6e45, 0x6261, 0x656c, "\000" - IDC_DEPTHCOMPARE_COMBO, 0x403, 11, 0 -0x6150, 0x7373, 0x4e20, 0x7665, 0x7265, "\000" - IDC_DEPTHCOMPARE_COMBO, 0x403, 10, 0 -0x6150, 0x7373, 0x4c20, 0x7365, 0x0073, - IDC_DEPTHCOMPARE_COMBO, 0x403, 11, 0 -0x6150, 0x7373, 0x4520, 0x7571, 0x6c61, "\000" - IDC_DEPTHCOMPARE_COMBO, 0x403, 12, 0 -0x6150, 0x7373, 0x4c20, 0x7145, 0x6175, 0x006c, - IDC_DEPTHCOMPARE_COMBO, 0x403, 13, 0 -0x6150, 0x7373, 0x4720, 0x6572, 0x7461, 0x7265, "\000" - IDC_DEPTHCOMPARE_COMBO, 0x403, 12, 0 -0x6150, 0x7373, 0x4e20, 0x7145, 0x6175, 0x006c, - IDC_DEPTHCOMPARE_COMBO, 0x403, 12, 0 -0x6150, 0x7373, 0x4720, 0x7145, 0x6175, 0x006c, - IDC_DEPTHCOMPARE_COMBO, 0x403, 12, 0 -0x6150, 0x7373, 0x4120, 0x776c, 0x7961, 0x0073, - IDC_DETAILCOLOR_COMBO, 0x403, 8, 0 -0x6944, 0x6173, 0x6c62, 0x0065, - IDC_DETAILCOLOR_COMBO, 0x403, 7, 0 -0x6544, 0x6174, 0x6c69, "\000" - IDC_DETAILCOLOR_COMBO, 0x403, 6, 0 -0x6353, 0x6c61, 0x0065, - IDC_DETAILCOLOR_COMBO, 0x403, 9, 0 -0x6e49, 0x5376, 0x6163, 0x656c, "\000" - IDC_DETAILCOLOR_COMBO, 0x403, 4, 0 -0x6441, 0x0064, - IDC_DETAILCOLOR_COMBO, 0x403, 4, 0 -0x7553, 0x0062, - IDC_DETAILCOLOR_COMBO, 0x403, 5, 0 -0x7553, 0x5262, "\000" - IDC_DETAILCOLOR_COMBO, 0x403, 6, 0 -0x6c42, 0x6e65, 0x0064, - IDC_DETAILCOLOR_COMBO, 0x403, 12, 0 -0x6544, 0x6174, 0x6c69, 0x6c42, 0x6e65, 0x0064, - IDC_DETAILALPHA_COMBO, 0x403, 8, 0 -0x6944, 0x6173, 0x6c62, 0x0065, - IDC_DETAILALPHA_COMBO, 0x403, 7, 0 -0x6544, 0x6174, 0x6c69, "\000" - IDC_DETAILALPHA_COMBO, 0x403, 6, 0 -0x6353, 0x6c61, 0x0065, - IDC_DETAILALPHA_COMBO, 0x403, 9, 0 -0x6e49, 0x5376, 0x6163, 0x656c, "\000" - 0 -END - -IDD_GAMEMTL_VERTEX_MATERIAL DLGINIT -BEGIN - IDC_MAPPING0_COMBO, 0x403, 3, 0 -0x5655, "\000" - IDC_MAPPING0_COMBO, 0x403, 12, 0 -0x6e45, 0x6976, 0x6f72, 0x6d6e, 0x6e65, 0x0074, - IDC_MAPPING0_COMBO, 0x403, 12, 0 -0x6c43, 0x7361, 0x6973, 0x2063, 0x6e45, 0x0076, - IDC_MAPPING0_COMBO, 0x403, 7, 0 -0x6353, 0x6572, 0x6e65, "\000" - IDC_MAPPING0_COMBO, 0x403, 14, 0 -0x694c, 0x656e, 0x7261, 0x4f20, 0x6666, 0x6573, 0x0074, - IDC_MAPPING0_COMBO, 0x403, 22, 0 -0x6953, 0x686c, 0x756f, 0x7465, 0x6574, 0x2820, 0x626f, 0x6f73, 0x656c, -0x6574, 0x0029, - IDC_MAPPING0_COMBO, 0x403, 6, 0 -0x6353, 0x6c61, 0x0065, - IDC_MAPPING0_COMBO, 0x403, 5, 0 -0x7247, 0x6469, "\000" - IDC_MAPPING0_COMBO, 0x403, 7, 0 -0x6f52, 0x6174, 0x6574, "\000" - IDC_MAPPING0_COMBO, 0x403, 5, 0 -0x6953, 0x656e, "\000" - IDC_MAPPING0_COMBO, 0x403, 5, 0 -0x7453, 0x7065, "\000" - IDC_MAPPING0_COMBO, 0x403, 7, 0 -0x695a, 0x7a67, 0x6761, "\000" - IDC_MAPPING0_COMBO, 0x403, 15, 0 -0x5357, 0x6320, 0x616c, 0x7373, 0x6369, 0x6520, 0x766e, "\000" - IDC_MAPPING0_COMBO, 0x403, 15, 0 -0x5357, 0x6520, 0x766e, 0x7269, 0x6e6f, 0x656d, 0x746e, "\000" - IDC_MAPPING0_COMBO, 0x403, 17, 0 -0x7247, 0x6469, 0x6320, 0x616c, 0x7373, 0x6369, 0x6520, 0x766e, "\000" - IDC_MAPPING0_COMBO, 0x403, 17, 0 -0x7247, 0x6469, 0x6520, 0x766e, 0x7269, 0x6e6f, 0x656d, 0x746e, "\000" - IDC_MAPPING0_COMBO, 0x403, 7, 0 -0x6152, 0x646e, 0x6d6f, "\000" - IDC_MAPPING0_COMBO, 0x403, 5, 0 -0x6445, 0x6567, "\000" - IDC_MAPPING0_COMBO, 0x403, 8, 0 -0x7542, 0x706d, 0x6e45, 0x0076, - IDC_MAPPING1_COMBO, 0x403, 3, 0 -0x5655, "\000" - IDC_MAPPING1_COMBO, 0x403, 12, 0 -0x6e45, 0x6976, 0x6f72, 0x6d6e, 0x6e65, 0x0074, - IDC_MAPPING1_COMBO, 0x403, 12, 0 -0x6c43, 0x7361, 0x6973, 0x2063, 0x6e45, 0x0076, - IDC_MAPPING1_COMBO, 0x403, 7, 0 -0x6353, 0x6572, 0x6e65, "\000" - IDC_MAPPING1_COMBO, 0x403, 14, 0 -0x694c, 0x656e, 0x7261, 0x4f20, 0x6666, 0x6573, 0x0074, - IDC_MAPPING1_COMBO, 0x403, 22, 0 -0x6953, 0x686c, 0x756f, 0x7465, 0x6574, 0x2820, 0x626f, 0x6f73, 0x656c, -0x6574, 0x0029, - IDC_MAPPING1_COMBO, 0x403, 6, 0 -0x6353, 0x6c61, 0x0065, - IDC_MAPPING1_COMBO, 0x403, 5, 0 -0x7247, 0x6469, "\000" - IDC_MAPPING1_COMBO, 0x403, 7, 0 -0x6f52, 0x6174, 0x6574, "\000" - IDC_MAPPING1_COMBO, 0x403, 5, 0 -0x6953, 0x656e, "\000" - IDC_MAPPING1_COMBO, 0x403, 5, 0 -0x7453, 0x7065, "\000" - IDC_MAPPING1_COMBO, 0x403, 7, 0 -0x695a, 0x7a67, 0x6761, "\000" - IDC_MAPPING1_COMBO, 0x403, 15, 0 -0x5357, 0x6320, 0x616c, 0x7373, 0x6369, 0x6520, 0x766e, "\000" - IDC_MAPPING1_COMBO, 0x403, 15, 0 -0x5357, 0x6520, 0x766e, 0x7269, 0x6e6f, 0x656d, 0x746e, "\000" - IDC_MAPPING1_COMBO, 0x403, 17, 0 -0x7247, 0x6469, 0x6320, 0x616c, 0x7373, 0x6369, 0x6520, 0x766e, "\000" - IDC_MAPPING1_COMBO, 0x403, 17, 0 -0x7247, 0x6469, 0x6520, 0x766e, 0x7269, 0x6e6f, 0x656d, 0x746e, "\000" - IDC_MAPPING1_COMBO, 0x403, 7, 0 -0x6152, 0x646e, 0x6d6f, "\000" - IDC_MAPPING1_COMBO, 0x403, 5, 0 -0x6445, 0x6567, "\000" - IDC_MAPPING1_COMBO, 0x403, 8, 0 -0x7542, 0x706d, 0x6e45, 0x0076, - 0 -END - -IDD_GAMEMTL_TEXTURES DLGINIT -BEGIN - IDC_STAGE0_ANIM_COMBO, 0x403, 5, 0 -0x6f4c, 0x706f, "\000" - IDC_STAGE0_ANIM_COMBO, 0x403, 10, 0 -0x6950, 0x676e, 0x502d, 0x6e6f, 0x0067, - IDC_STAGE0_ANIM_COMBO, 0x403, 5, 0 -0x6e4f, 0x6563, "\000" - IDC_STAGE0_ANIM_COMBO, 0x403, 7, 0 -0x614d, 0x756e, 0x6c61, "\000" - IDC_STAGE0_HINT_COMBO, 0x403, 13, 0 -0x6142, 0x6573, 0x5420, 0x7865, 0x7574, 0x6572, "\000" - IDC_STAGE0_HINT_COMBO, 0x403, 18, 0 -0x6d45, 0x7369, 0x6973, 0x6576, 0x4c20, 0x6769, 0x7468, 0x616d, 0x0070, - - IDC_STAGE0_HINT_COMBO, 0x403, 16, 0 -0x6e45, 0x6976, 0x6f72, 0x6d6e, 0x6e65, 0x2074, 0x614d, 0x0070, - IDC_STAGE0_HINT_COMBO, 0x403, 15, 0 -0x6853, 0x6e69, 0x6e79, 0x7365, 0x2073, 0x614d, 0x6b73, "\000" - IDC_STAGE1_ANIM_COMBO, 0x403, 5, 0 -0x6f4c, 0x706f, "\000" - IDC_STAGE1_ANIM_COMBO, 0x403, 10, 0 -0x6950, 0x676e, 0x502d, 0x6e6f, 0x0067, - IDC_STAGE1_ANIM_COMBO, 0x403, 5, 0 -0x6e4f, 0x6563, "\000" - IDC_STAGE1_ANIM_COMBO, 0x403, 7, 0 -0x614d, 0x756e, 0x6c61, "\000" - IDC_STAGE1_HINT_COMBO, 0x403, 13, 0 -0x6142, 0x6573, 0x5420, 0x7865, 0x7574, 0x6572, "\000" - IDC_STAGE1_HINT_COMBO, 0x403, 18, 0 -0x6d45, 0x7369, 0x6973, 0x6576, 0x4c20, 0x6769, 0x7468, 0x616d, 0x0070, - - IDC_STAGE1_HINT_COMBO, 0x403, 16, 0 -0x6e45, 0x6976, 0x6f72, 0x6d6e, 0x6e65, 0x2074, 0x614d, 0x0070, - IDC_STAGE1_HINT_COMBO, 0x403, 15, 0 -0x6853, 0x6e69, 0x6e79, 0x7365, 0x2073, 0x614d, 0x6b73, "\000" - 0 -END - -IDD_GAMEMTL_PS2_SHADER DLGINIT -BEGIN - IDC_A_COMBO, 0x403, 7, 0 -0x6f53, 0x7275, 0x6563, "\000" - IDC_A_COMBO, 0x403, 12, 0 -0x6544, 0x7473, 0x6e69, 0x7461, 0x6f69, 0x006e, - IDC_A_COMBO, 0x403, 5, 0 -0x655a, 0x6f72, "\000" - IDC_B_COMBO, 0x403, 7, 0 -0x6f53, 0x7275, 0x6563, "\000" - IDC_B_COMBO, 0x403, 12, 0 -0x6544, 0x7473, 0x6e69, 0x7461, 0x6f69, 0x006e, - IDC_B_COMBO, 0x403, 5, 0 -0x655a, 0x6f72, "\000" - IDC_PRIGRADIENT_COMBO, 0x403, 6, 0 -0x6544, 0x6163, 0x006c, - IDC_PRIGRADIENT_COMBO, 0x403, 9, 0 -0x6f4d, 0x7564, 0x616c, 0x6574, "\000" - IDC_PRIGRADIENT_COMBO, 0x403, 10, 0 -0x6948, 0x6867, 0x696c, 0x6867, 0x0074, - IDC_PRIGRADIENT_COMBO, 0x403, 12, 0 -0x6948, 0x6867, 0x696c, 0x6867, 0x2074, 0x0032, - IDC_DEPTHCOMPARE_COMBO, 0x403, 11, 0 -0x6150, 0x7373, 0x4e20, 0x7665, 0x7265, "\000" - IDC_DEPTHCOMPARE_COMBO, 0x403, 10, 0 -0x6150, 0x7373, 0x4c20, 0x7365, 0x0073, - IDC_DEPTHCOMPARE_COMBO, 0x403, 12, 0 -0x6150, 0x7373, 0x4120, 0x776c, 0x7961, 0x0073, - IDC_DEPTHCOMPARE_COMBO, 0x403, 12, 0 -0x6150, 0x7373, 0x4c20, 0x7145, 0x6175, 0x006c, - IDC_DETAILCOLOR_COMBO, 0x403, 8, 0 -0x6944, 0x6173, 0x6c62, 0x0065, - IDC_DETAILCOLOR_COMBO, 0x403, 7, 0 -0x6544, 0x6174, 0x6c69, "\000" - IDC_DETAILCOLOR_COMBO, 0x403, 6, 0 -0x6353, 0x6c61, 0x0065, - IDC_DETAILCOLOR_COMBO, 0x403, 9, 0 -0x6e49, 0x5376, 0x6163, 0x656c, "\000" - IDC_DETAILCOLOR_COMBO, 0x403, 4, 0 -0x6441, 0x0064, - IDC_DETAILCOLOR_COMBO, 0x403, 4, 0 -0x7553, 0x0062, - IDC_DETAILCOLOR_COMBO, 0x403, 5, 0 -0x7553, 0x5262, "\000" - IDC_DETAILCOLOR_COMBO, 0x403, 6, 0 -0x6c42, 0x6e65, 0x0064, - IDC_DETAILCOLOR_COMBO, 0x403, 12, 0 -0x6544, 0x6174, 0x6c69, 0x6c42, 0x6e65, 0x0064, - IDC_DETAILALPHA_COMBO, 0x403, 8, 0 -0x6944, 0x6173, 0x6c62, 0x0065, - IDC_DETAILALPHA_COMBO, 0x403, 7, 0 -0x6544, 0x6174, 0x6c69, "\000" - IDC_DETAILALPHA_COMBO, 0x403, 6, 0 -0x6353, 0x6c61, 0x0065, - IDC_DETAILALPHA_COMBO, 0x403, 9, 0 -0x6e49, 0x5376, 0x6163, 0x656c, "\000" - IDC_D_COMBO, 0x403, 7, 0 -0x6f53, 0x7275, 0x6563, "\000" - IDC_D_COMBO, 0x403, 12, 0 -0x6544, 0x7473, 0x6e69, 0x7461, 0x6f69, 0x006e, - IDC_D_COMBO, 0x403, 5, 0 -0x655a, 0x6f72, "\000" - IDC_C_COMBO, 0x403, 10, 0 -0x7253, 0x2063, 0x6c41, 0x6870, 0x0061, - IDC_C_COMBO, 0x403, 11, 0 -0x6544, 0x7473, 0x4120, 0x706c, 0x6168, "\000" - IDC_C_COMBO, 0x403, 4, 0 -0x6e4f, 0x0065, - 0 -END - -IDD_GAMEMTL_PS2_TEXTURES DLGINIT -BEGIN - IDC_STAGE0_ANIM_COMBO, 0x403, 5, 0 -0x6f4c, 0x706f, "\000" - IDC_STAGE0_ANIM_COMBO, 0x403, 10, 0 -0x6950, 0x676e, 0x502d, 0x6e6f, 0x0067, - IDC_STAGE0_ANIM_COMBO, 0x403, 5, 0 -0x6e4f, 0x6563, "\000" - IDC_STAGE0_ANIM_COMBO, 0x403, 7, 0 -0x614d, 0x756e, 0x6c61, "\000" - IDC_STAGE0_HINT_COMBO, 0x403, 13, 0 -0x6142, 0x6573, 0x5420, 0x7865, 0x7574, 0x6572, "\000" - IDC_STAGE0_HINT_COMBO, 0x403, 18, 0 -0x6d45, 0x7369, 0x6973, 0x6576, 0x4c20, 0x6769, 0x7468, 0x616d, 0x0070, - - IDC_STAGE0_HINT_COMBO, 0x403, 16, 0 -0x6e45, 0x6976, 0x6f72, 0x6d6e, 0x6e65, 0x2074, 0x614d, 0x0070, - IDC_STAGE0_HINT_COMBO, 0x403, 15, 0 -0x6853, 0x6e69, 0x6e79, 0x7365, 0x2073, 0x614d, 0x6b73, "\000" - IDC_STAGE1_ANIM_COMBO, 0x403, 5, 0 -0x6f4c, 0x706f, "\000" - IDC_STAGE1_ANIM_COMBO, 0x403, 10, 0 -0x6950, 0x676e, 0x502d, 0x6e6f, 0x0067, - IDC_STAGE1_ANIM_COMBO, 0x403, 5, 0 -0x6e4f, 0x6563, "\000" - IDC_STAGE1_ANIM_COMBO, 0x403, 7, 0 -0x614d, 0x756e, 0x6c61, "\000" - IDC_STAGE1_HINT_COMBO, 0x403, 13, 0 -0x6142, 0x6573, 0x5420, 0x7865, 0x7574, 0x6572, "\000" - IDC_STAGE1_HINT_COMBO, 0x403, 18, 0 -0x6d45, 0x7369, 0x6973, 0x6576, 0x4c20, 0x6769, 0x7468, 0x616d, 0x0070, - - IDC_STAGE1_HINT_COMBO, 0x403, 16, 0 -0x6e45, 0x6976, 0x6f72, 0x6d6e, 0x6e65, 0x2074, 0x614d, 0x0070, - IDC_STAGE1_HINT_COMBO, 0x403, 15, 0 -0x6853, 0x6e69, 0x6e79, 0x7365, 0x2073, 0x614d, 0x6b73, "\000" - 0 -END - - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,5,0 - PRODUCTVERSION 1,0,5,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Comments", "Coded by Greg Hjelstrom\0" - VALUE "CompanyName", "Westwood Studios\0" - VALUE "FileDescription", "max2w3d\0" - VALUE "FileVersion", "1, 0, 5, 0\0" - VALUE "InternalName", "max2w3d\0" - VALUE "LegalCopyright", "Copyright � 1998\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "max2w3d.dle\0" - VALUE "PrivateBuild", "\0" - VALUE "ProductName", "Westwood Studios max2w3d\0" - VALUE "ProductVersion", "1, 0, 5, 0\0" - VALUE "SpecialBuild", "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_ORIG ICON DISCARDABLE "Res\\orig.ico" -IDI_DEFORMED ICON DISCARDABLE "res\\orig1.ico" -IDI_DISK ICON DISCARDABLE "Res\\DISK12.ICO" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_NORM BITMAP DISCARDABLE "Res\\one.bmp" -IDB_DEFORM BITMAP DISCARDABLE "Res\\two.bmp" -IDB_WW3D BITMAP DISCARDABLE "Res\\ww3d.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE DISCARDABLE -BEGIN - IDS_COPYRIGHT_NOTICE "Copyright 1997 Westwood Studios" - IDS_AUTHOR_NAME "Greg Hjelstrom" - IDS_GAMEMTL "W3D" - IDS_MAP_TEXTURE "Texture" - IDS_ENVMAP "Env-Map" - IDS_SCENE_EXPORT "Scene Export" - IDS_LIB_DESCRIPTION "Westwood 3D Export Plugins" - IDS_FILE_OPEN_ERROR "Unable to open file" - IDS_DLL_NAME "max2w3d.dle" - IDS_WTM_SHORT_DESCRIPTION "Westwood Textured Mesh" - IDS_WTM_LONG_DESCRIPTION "Westwood Textured Mesh" - IDS_WHT_SHORT_DESCRIPTION "Westwood Hierarchy Tree" - IDS_WHT_LONG_DESCRIPTION "Westwood Hierarchy Tree" - IDS_WHA_SHORT_DESCRIPTION "Westwood Hierarchy Animation" - IDS_WHA_LONG_DESCRIPTION "Westwood Hierarchy Animation" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_WTM_FILE_EXTEN "wtm" - IDS_WHT_FILE_EXTEN "wht" - IDS_WHA_FILE_EXTEN "wha" - IDS_W3D_FILE_EXTEN "w3d" - IDS_W3D_LONG_DESCRIPTION "Westwood 3D Assets" - IDS_W3D_SHORT_DESCRIPTION "Westwood 3D Assets" - IDS_W3D_UTILITY_CLASS_NAME "W3D Tools" - IDS_W3DMENU_CATEGORY "Westwood Tools" - IDS_W3DMENU_TITLE "W3D Tools" - IDS_SOT "Supports Objects of Type" - IDS_DIFFUSE_COLOR "Diffuse Color" - IDS_PARAMETERS "Parameters" - IDS_TEXTURE_MAP "Texture Map" - IDS_ENVIRONMENT_MAP "Environment Map" - IDS_TEXMAPS "Texture Maps" - IDS_AM "Ambient" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_SKIN_CLASS_NAME "Westwood Skin" - IDS_SKIN_OBJECT_NAME "Westwood Skin" - IDS_SKIN "Westwood Skin" - IDS_SKIN_PARAMETERS "Skin Parameters" - IDS_SKIN_INFO "Westwood Skin Info" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_BONE_INFLUENCE_PARAMS "Bone Influence" - IDS_SOT2 "Supports Objects of Type" - IDS_SKELETON_PARAMETERS "Skeleton Parameters" - IDS_PICK_BONE_DIALOG_TITLE "Select bones" - IDS_PICK_BONE_BUTTON_TEXT "Ok" - IDS_MULTIPLE_OBJECTS "Multiple Objects Selected" - IDS_NO_OBJECT "No Object Selected" - IDS_SPECULAR_COLOR "Specular Color" - IDS_AMBIENT_COLOR "Ambient Color" - IDS_EMISSIVE_COLOR "Emissive" - IDS_MATERIAL_HINTS "Material Hints" - IDS_PSX_OPTIONS "Playstation Options" - IDS_UV_MAPPING "UV" - IDS_ENVIRONMENT_MAPPING "Environment" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_DI "Diffuse" - IDS_SP "Specular" - IDS_SH "Shininess" - IDS_SS "Shininess Strength" - IDS_SI "Self-Illumination" - IDS_OP "Opacity" - IDS_FI "Blend" - IDS_BU "Bump" - IDS_RL "Reflection" - IDS_RR "Refraction" - IDS_NONE "None" - IDS_NOTES "Important Info" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_PASS_COUNT "Material Pass Count" - IDS_PASS_SETTINGS "Pass %d Settings" - IDS_PUBLISH "Publish" - IDS_DISPLAY "Display" - IDS_RESIZE "Resize" - IDS_NO_MIPMAP "No Mipmap" - IDS_CLAMP_U "Clamp U" - IDS_CLAMP_V "Clamp V" - IDS_ALPHA_BITMAP "Alpha Bitmap" - IDS_SURFACE_TYPE "Material Surface Type" - IDS_DISPLACEMENT_MAP "Displacement Map" - IDS_ALPHA_MODIFIER_CLASS "Alpha Modifier" - IDS_PS2_GAMEMTL "W3D PS2" - IDS_PC_TO_PS2_MAT_CONVERTER "PC to PS2 Material Converter" - IDS_NO_LOD "No LOD" - IDS_W3DUTILITY_SETTINGS "W3D Export Settings" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_W3DUTILITY_TOOLS "W3D Tools" - IDS_GRIDSNAPMODIFIER "Grid Snap Modifier" - IDS_GRIDSNAP_TITLE "Grid Snap Settings" - IDS_GRID_DIMENSION "Grid Dimension" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/GeneralsMD/Code/Tools/WW3D/pluglib/CMakeLists.txt b/GeneralsMD/Code/Tools/WW3D/pluglib/CMakeLists.txt deleted file mode 100644 index 6c2f8192a43..00000000000 --- a/GeneralsMD/Code/Tools/WW3D/pluglib/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ -set(PLUGLIB_SRC - "aaplane.h" - "always.h" - "BITTYPE.H" - "bool.h" - "borlandc.h" - "chunkio.cpp" - "chunkio.h" - "errclass.h" - "EULER.CPP" - "EULER.H" - "hashcalc.h" - "hsv.cpp" - "hsv.h" - "iostruct.h" - "jshell.cpp" - "matrix3d.cpp" - "matrix3d.h" - "matrix4.cpp" - "matrix4.h" - "nodefilt.cpp" - "nodefilt.h" - "nodelist.cpp" - "nodelist.h" - "noinit.h" - "palette.cpp" - "palette.h" - "plane.h" - "PROGRESS.H" - "rawfile.cpp" - "rawfile.h" - "realcrc.cpp" - "realcrc.h" - "rgb.cpp" - "rgb.h" - "uarray.h" - "Vector.CPP" - "Vector.H" - "vector2.h" - "vector3.h" - "vector3i.h" - "vector4.h" - "visualc.h" - "w3d_file.h" - "w3dquat.cpp" - "w3dquat.h" - "watcom.h" - "win.h" - "wwfile.h" - "wwmath.cpp" - "wwmath.h" - "WWmatrix3.cpp" - "WWmatrix3.h" -) - -add_library(z_pluglib STATIC) -set_target_properties(z_pluglib PROPERTIES OUTPUT_NAME pluglib) - -target_sources(z_pluglib PRIVATE ${PLUGLIB_SRC}) - -target_link_libraries(z_pluglib PRIVATE maxsdk)