diff --git a/GPatch/GPatch.nsi b/GPatch/GPatch.nsi index 5a7dd9a..d074ca8 100644 --- a/GPatch/GPatch.nsi +++ b/GPatch/GPatch.nsi @@ -42,7 +42,7 @@ SetCompressor /SOLID lzma ; MUI end ------ Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" -OutFile "Output\GPatch1_498_222_0.exe" +OutFile "Output\GPatch1_498_224_0.exe" InstallDir "$PROGRAMFILES\Giants\" InstallDirRegKey HKCU "SOFTWARE\PlanetMoon\Giants" "DestDir" ShowInstDetails hide @@ -69,7 +69,8 @@ Section ExecWait "$INSTDIR\Redist\VC_redist.x86.exe /install /passive /norestart" $0 ${If} $0 != 0 - MessageBox MB_OK "Setup failed to install the Visual C++ Runtime. Please visit www.microsoft.com and download the latest version of the Visual C++ redistributable." + ${AndIf} $0 != 1638 ;0x666 - Newer version installed + MessageBox MB_OK "Setup failed to install the Visual C++ Runtime. Please visit www.microsoft.com and download the latest version of the Visual C++ 2019 redistributable." ${EndIf} RMDir /r "$INSTDIR\Redist" ; Delete temporary files @@ -96,8 +97,6 @@ Section Delete $INSTDIR\bin\worldlist5.bin Delete $INSTDIR\bin\mappack1.gzp Delete $INSTDIR\bin\A-GRM1.gzp - Delete $INSTDIR\bin\GData.gbt - Delete $INSTDIR\bin\GData.h SectionEnd diff --git a/Plugins/exp_gts/exp_gts.dle b/Plugins/exp_gts/exp_gts.dle new file mode 100644 index 0000000..10a661d Binary files /dev/null and b/Plugins/exp_gts/exp_gts.dle differ diff --git a/Plugins/gts2gbs/gts2gbs.exe b/Plugins/gts2gbs/gts2gbs.exe new file mode 100644 index 0000000..2b0ac4b Binary files /dev/null and b/Plugins/gts2gbs/gts2gbs.exe differ diff --git a/Plugins/imp_gbs/DLLEntry.cpp b/Plugins/imp_gbs/DLLEntry.cpp new file mode 100644 index 0000000..703aed6 --- /dev/null +++ b/Plugins/imp_gbs/DLLEntry.cpp @@ -0,0 +1,43 @@ +#include "Importer.h" + +HINSTANCE hInstance; +int controlsInit = FALSE; + + +BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) +{ + hInstance = hinstDLL; // Hang on to this DLL's instance handle. + + if (!controlsInit) { + controlsInit = TRUE; + //InitCustomControls(hInstance); // Initialize MAX's custom controls + InitCommonControls(); // Initialize Win95 controls + } + + return (TRUE); +} + +__declspec( dllexport ) const TCHAR* LibDescription() +{ + return _T("LibDescription"); +} + +//TODO: Must change this number when adding a new class +__declspec( dllexport ) int LibNumberClasses() +{ + return 1; +} + +ClassDesc *GetSceneImportDesc(); +__declspec( dllexport ) ClassDesc* LibClassDesc(int i) +{ + switch(i) { + case 0: return GetSceneImportDesc(); + default: return 0; + } +} + +__declspec( dllexport ) ULONG LibVersion() +{ + return VERSION_3DSMAX; +} \ No newline at end of file diff --git a/Plugins/imp_gbs/GbsData.cpp b/Plugins/imp_gbs/GbsData.cpp new file mode 100644 index 0000000..7a9a749 --- /dev/null +++ b/Plugins/imp_gbs/GbsData.cpp @@ -0,0 +1,143 @@ +#include "Importer.h" + +void GbsData::Read(FILE* file) +{ + DWORD versionHeader; + fread(&versionHeader, 4, 1, file); + if (versionHeader != GBS_VERSION) + { + throw std::exception("File does not appear to be a GBS file."); + } + + fread(&optionsflags, 4, 1, file); + fread(&naverts, 4, 1, file); + + averts.resize(naverts); + for (int i = 0; i < naverts; i++) + { + fread(&averts.at(i).x, 4, 1, file); + fread(&averts.at(i).y, 4, 1, file); + fread(&averts.at(i).z, 4, 1, file); + } + if (FlagIsSet(optionsflags, GBSFlagNormals)) + { + fread(&nndefs, 4, 1, file); + fread(&sizendefs, 4, 1, file); + ndefs.resize(sizendefs); + + for (uint i = 0; i < sizendefs; i++) + fread(&ndefs.at(i), 2, 1, file); + } + + fread(&nverts, 4, 1, file); + iverts.resize(nverts); + for (int i = 0; i < nverts; i++) + fread(&iverts.at(i), 2, 1, file); + + if (FlagIsSet(optionsflags, GBSFlagNormals)) + { + inorms.resize(nverts); + for (int i = 0; i < nverts; i++) + fread(&inorms.at(i), 2, 1, file); + } + + if (FlagIsSet(optionsflags, GBSFlagUVs)) + { + vertuv.resize(nverts); + for (int i = 0; i < nverts; i++) + { + fread(&vertuv.at(i).u, 4, 1, file); + fread(&vertuv.at(i).v, 4, 1, file); + vertuv.at(i).v = vertuv.at(i).v + 1.0f; + } + } + + if (FlagIsSet(optionsflags, GBSFlagRGBs)) + { + vertrgb.resize(nverts); + for (int i = 0; i < nverts; i++) + { + fread(&vertrgb.at(i).r, 1, 1, file); + fread(&vertrgb.at(i).g, 1, 1, file); + fread(&vertrgb.at(i).b, 1, 1, file); + } + } + + // Get number of max objects + fread(&nmobjs, 4, 1, file); + MaxObjs.resize(nmobjs); + for (auto& maxObj : MaxObjs) + { + FileMaxObj fileMaxObj; + fread(&fileMaxObj, sizeof(FileMaxObj), 1, file); + + maxObj.vstart = fileMaxObj.vstart; + maxObj.vcount = fileMaxObj.vcount; + maxObj.nstart = fileMaxObj.nstart; + maxObj.ncount = fileMaxObj.ncount; + maxObj.noffset = fileMaxObj.noffset; + maxObj.fstart = 0; + maxObj.fcount = 0; + maxObj.sostart = 0; + maxObj.socount = 0; + } + + VerifyMaxObjs(); + + // Get number of subobjects + fread(&nsobjs, 4, 1, file); + + SubObjs.resize(nsobjs); + for (int ns = 0; ns < nsobjs; ns++) + { + SubObject& object = SubObjs.at(ns); + fread(&object.objname, sizeof(object.objname), 1, file); + fread(&object.maxobjindex, 4, 1, file); + fread(&object.totaltris, 4, 1, file); + fread(&object.ntris, 4, 1, file); + + assert((object.ntris - 1) / 3 == object.totaltris); + + object.tridata.resize(object.ntris + 1); + fread(object.tridata.data(), sizeof(unsigned short) * object.ntris, 1, file); + + fread(&object.vstart, 4, 1, file); + fread(&object.vcount, 4, 1, file); + if (FlagIsSet(optionsflags, GBSFlagUVs)) + { + fread(&object.texname, 1, 32, file); + fread(&object.texname2, 1, 32, file); + } + fread(&object.falloff, 4, 1, file); + + if (FlagIsSet(optionsflags, GBSFlagRGBs)) + fread(&object.blend, 4, 1, file); + + fread(&object.flags, 4, 1, file); + fread(&object.emissive, 1, 4, file); + fread(&object.ambient, 1, 4, file); + fread(&object.diffuse, 1, 4, file); + fread(&object.specular, 1, 4, file); + fread(&object.power, 4, 1, file); + + MaxObj& maxobj = MaxObjs.at(object.maxobjindex); + maxobj.fcount += object.totaltris; + if (!maxobj.socount) + { + maxobj.sostart = ns; + } + maxobj.socount++; + } +} + +bool GbsData::VerifyMaxObjs() +{ + int nmcount = 0; + for (const auto& maxObj : MaxObjs) + { + nmcount += maxObj.vcount; + } + + assert(nmcount == naverts); + return nmcount == naverts; +} \ No newline at end of file diff --git a/Plugins/imp_gbs/GbsData.h b/Plugins/imp_gbs/GbsData.h new file mode 100644 index 0000000..80c2322 --- /dev/null +++ b/Plugins/imp_gbs/GbsData.h @@ -0,0 +1,77 @@ +#pragma once + +#define GBS_VERSION 0xaa0100be +#define GBSFlagNormals 0x0001 +#define GBSFlagUVs 0x0002 +#define GBSFlagRGBs 0x0004 +#define GBSFlagMaxLit (1 << 31) + +struct FileMaxObj +{ + int vstart; + int vcount; + int nstart; + int ncount; + int noffset; +}; + +struct MaxObj : FileMaxObj +{ + int fstart; + int fcount; + int sostart; + int socount; +}; + +struct SubObject +{ + char objname[32]; + DWORD maxobjindex; + int ntris; // count of tridata (including preceding 'count' short) + int totaltris; + std::vector tridata; // indexed tridata, value is pointer to iverts + int vstart; + int vcount; + char texname[32]; + char texname2[32]; + float falloff; + float blend; + DWORD flags; + DWORD emissive; + DWORD ambient; + DWORD diffuse; + DWORD specular; + float power; +}; + +enum TransType +{ + TransNone, + TransAdd, + TransSub, + TransBlend +}; + +struct GbsData +{ +public: + void Read(FILE* file); + + DWORD optionsflags{}; + DWORD nndefs{}; + DWORD sizendefs{}; + std::vector ndefs; + std::vector inorms; + int naverts{}; + std::vector averts; + int nsobjs{}; + int nmobjs{}; + std::vector iverts; + std::vector vertrgb; + int nverts{}; + std::vector vertuv; + std::vector MaxObjs; + std::vector SubObjs; +private: + bool VerifyMaxObjs(); +}; diff --git a/Plugins/imp_gbs/Importer.cpp b/Plugins/imp_gbs/Importer.cpp new file mode 100644 index 0000000..98fb7ea --- /dev/null +++ b/Plugins/imp_gbs/Importer.cpp @@ -0,0 +1,409 @@ +// Importer.cpp : Defines the entry point for the DLL application. +// + +#include "Importer.h" +#include "StdUtil.h" + +class ImpGbsClassDesc : + public ClassDesc2 +{ +public: + int IsPublic() { return TRUE; } + VOID* Create(BOOL Loading) { return new GbsImporter; } + const MCHAR* ClassName() { return _M("ClassName"); } + SClass_ID SuperClassID() { return SCENE_IMPORT_CLASS_ID; } + Class_ID ClassID() { return GIANTSIMP_CLASSID; } + const MCHAR* Category() { return _M(""); } + const MCHAR* InternalName() { return _M("GiantsImp"); } + HINSTANCE HInstance() { return hInstance; } +}; + +static ImpGbsClassDesc g_ImportCD; + +ClassDesc* GetSceneImportDesc() +{ + return &g_ImportCD; +} + +void DisplayMessage(const char* msg) +{ + MessageBoxA(GetActiveWindow(), msg, "GBS Import Error", MB_OK); +} + +int GbsImporter::ExtCount() +{ + return 1; +} + +const MCHAR* GbsImporter::Ext(int n) +{ + switch (n) + { + case 0: + return _M("gbs"); + default: + return (_M("")); + } +} + +const MCHAR* GbsImporter::LongDesc() +{ + return _M("Long Description"); +} + +const MCHAR* GbsImporter::ShortDesc() +{ + return _M("Giants Model"); +} + +const MCHAR* GbsImporter::AuthorName() +{ + return _M("Author"); +} + +const MCHAR* GbsImporter::CopyrightMessage() +{ + return _M("Copyright"); +} + +const MCHAR* GbsImporter::OtherMessage1() +{ + return _M("OtherMessage1"); +} + +const MCHAR* GbsImporter::OtherMessage2() +{ + return _M("OtherMessage2"); +} + +UINT GbsImporter::Version() +{ + return 100; +} + +static BOOL CALLBACK AboutDlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) +{ + return FALSE; +} + +VOID GbsImporter::ShowAbout(HWND hWnd) +{ +} + +bool GbsImporter::EvaluateTriData(unsigned short** pTriData, unsigned short* pTriIdx, unsigned short* acount, int* pV1, int* pV2, int* pV3) +{ + unsigned short* triData = *pTriData; + unsigned short triIdx = *pTriIdx; + unsigned short count = *acount; + + if (!count) + { + if (!(count = *triData)) + { + return false; + } + + triIdx = 0; + } + + *pV1 = triData[triIdx + 1]; + *pV2 = triData[triIdx + 2]; + *pV3 = triData[triIdx + 3]; + triIdx += 3; + + if (!--count) + { + triData += *triData * 3 + 1; + } + + *pTriData = triData; + *pTriIdx = triIdx; + *acount = count; + + return true; +} + +int GbsImporter::DoImport(const MCHAR* Name, ImpInterface* EI, Interface* I, BOOL SupressPrompts) +{ + try + { + m_gbsData = ReadGbsFile(Name); + } + catch (const std::exception& e) + { + DisplayMessage(e.what()); + } + + BuildMeshes(EI); + EI->RedrawViews(); + + return TRUE; +} + +GbsData GbsImporter::ReadGbsFile(const MCHAR* Name) +{ + FILE* file = nullptr; + try + { + errno_t err = _tfopen_s(&file, Name, (_T("rb"))); + if (err != 0) + { + throw std::exception("Could not open input file."); + } + + // Read object into memory + GbsData gbsFile; + gbsFile.Read(file); + + fclose(file); + return gbsFile; + } + catch (const std::exception& e) + { + if (file) + fclose(file); + + throw e; + } +} + +int GbsImporter::GetLocalVertex(Point3* avert, const Mesh& mesh) +{ + for (int i = 0; i < mesh.getNumVerts(); i++) + { + auto& vert = mesh.verts[i]; + + if (vert.x == avert->x && vert.y == avert->y && vert.z == avert->z) + { + return i; + } + } + + assert(false && "Invalid vertex for object"); + return -1; +} + +void GbsImporter::BuildMeshes(ImpInterface* EI) +{ + for (const auto& mobj : m_gbsData.MaxObjs) + { + assert(mobj.fcount > 0); + assert(mobj.vcount > 0); + + Mesh mesh; + mesh.setNumVerts(mobj.vcount); + mesh.setNumTVerts(mobj.vcount); + mesh.setNumVertCol(mobj.vcount); + mesh.setNumFaces(mobj.fcount); + mesh.setNumTVFaces(mobj.fcount); + mesh.setNumVCFaces(mobj.fcount); + + for (int i = 0; i < mobj.vcount; i++) + { + int vstart = mobj.vstart; + int index = i + vstart; + assert(index < m_gbsData.naverts); + + UV* uvptr = (UV*)(m_gbsData.vertuv.data() + (mobj.vstart + i)); + + Point3 point(m_gbsData.averts[index].x, m_gbsData.averts[index].y, m_gbsData.averts[index].z); + + mesh.setVert(i, point); + mesh.setTVert(i, UVVert(uvptr->u, uvptr->v, 0.0f)); + //mesh.setTVert(i, UVVert(uvptr->u, -uvptr->v, 0.0f)); + } + + Mtl* topLevelMaterial = nullptr; + const char* objName = nullptr; + int materialLevel = 0; + + int faceIndex = 0; + for (int subObjIndex = mobj.sostart; subObjIndex < mobj.sostart + mobj.socount; subObjIndex++) + { + SubObject& obj = m_gbsData.SubObjs.at(subObjIndex); + if (mobj.socount > 1) + { + // Max object consists of multiple sub objects + if (materialLevel == 0) + { + // Build parent material (either MixMat or multi-mtl): + topLevelMaterial = BuildParentMaterial(obj, mobj.socount); + objName = obj.objname; + } + + // Add sub-material: + Mtl* subMtl = BuildMaterial(obj, topLevelMaterial); + topLevelMaterial->SetSubMtl(materialLevel, subMtl); + } + else + { + // Just one subobj, build the single material and be done with it: + topLevelMaterial = BuildMaterial(obj, nullptr); + objName = obj.objname; + } + + int v1, v2, v3; + unsigned short tidx = -1; + unsigned short* tptr = obj.tridata.data(); + + unsigned short count = 0; + while (EvaluateTriData(&tptr, &tidx, &count, &v1, &v2, &v3)) + { + assert(faceIndex < mesh.getNumFaces()); + int vstart = mobj.vstart; + Face& face = mesh.faces[faceIndex]; + + // Map from display to animation vertices, then to a "local" index for this sub object, starting from zero: + int remappedV0 = GetLocalVertex(&m_gbsData.averts[m_gbsData.iverts.at(v1)], mesh); + int remappedV1 = GetLocalVertex(&m_gbsData.averts[m_gbsData.iverts.at(v2)], mesh); + int remappedV2 = GetLocalVertex(&m_gbsData.averts[m_gbsData.iverts.at(v3)], mesh); + + VertColor v0Col = VertColor(m_gbsData.vertrgb.at(v1).r / 255.0f, m_gbsData.vertrgb.at(v1).g / 255.0f, m_gbsData.vertrgb.at(v1).b / 255.0f); + VertColor v1Col = VertColor(m_gbsData.vertrgb.at(v2).r / 255.0f, m_gbsData.vertrgb.at(v2).g / 255.0f, m_gbsData.vertrgb.at(v2).b / 255.0f); + VertColor v2Col = VertColor(m_gbsData.vertrgb.at(v3).r / 255.0f, m_gbsData.vertrgb.at(v3).g / 255.0f, m_gbsData.vertrgb.at(v3).b / 255.0f); + + mesh.vertCol[remappedV0] = v0Col; + mesh.vertCol[remappedV1] = v1Col; + mesh.vertCol[remappedV2] = v2Col; + + assert(remappedV0 >= 0 && remappedV1 >= 0 && remappedV2 >= 0); + assert(remappedV0 < mobj.vcount && remappedV1 < mobj.vcount && remappedV2 < mobj.vcount); + assert(remappedV0 < m_gbsData.naverts && remappedV1 < m_gbsData.naverts && remappedV2 < m_gbsData.naverts); + + face.setVerts(remappedV0, remappedV1, remappedV2); + face.setEdgeVisFlags(EDGE_VIS, EDGE_VIS, EDGE_VIS); + face.setMatID(materialLevel); + + TVFace& tvFace = mesh.tvFace[faceIndex]; + tvFace.setTVerts(remappedV0, remappedV1, remappedV2); + + TVFace& vcFace = mesh.vcFace[faceIndex]; + vcFace.setTVerts(remappedV0, remappedV1, remappedV2); + + faceIndex++; + } + + materialLevel++; + } + + mesh.buildNormals(); + mesh.buildBoundingBox(); + mesh.InvalidateEdgeList(); + + TriObject* tri = CreateNewTriObject(); + tri->mesh = mesh; + Matrix3 tm; + tm.IdentityMatrix(); + + ImpNode* Node = EI->CreateNode(); + if (!Node) + { + throw std::exception("Could not create Node"); + } + + Node->Reference(tri); + Node->SetTransform(0, tm); + EI->AddNodeToScene(Node); + INode* iNode = Node->GetINode(); + iNode->SetMtl(topLevelMaterial); + Node->SetName(util::to_wstring(objName).c_str()); + } +} + +Mtl* GbsImporter::BuildParentMaterial(SubObject& obj, int numSubMaterials) +{ + // Check if we need to create a MixMat blend material + // (this check is iffy, not fully certain how to identify MixMat exports but this seems close enough) + if (obj.blend > 0.50 && (obj.flags & 0x10 || obj.flags & 0x20)) + { + //if (bitmapTex) + //{ + // //bitmapTex->GetUVGen()->SetUVWSource(2); + //} + + // Create custom MixMat material (from official 3dsmax plugin) + Mtl* mixMatMaterial = (Mtl*)CreateInstance(SClass_ID(MATERIAL_CLASS_ID), Class_ID(MIXMAT_CLASS_ID, 0)); + mixMatMaterial->SetName(util::to_wstring(obj.objname).c_str()); + + int ns = mixMatMaterial->NumSubMtls(); + + // Set the blend value + IParamBlock2* parameterBlock = mixMatMaterial->GetParamBlock(0); + parameterBlock->SetValue(0, 0, obj.blend); + + return mixMatMaterial; + } + else + { + // Standard multi-material + MultiMtl* multiMtl = NewDefaultMultiMtl(); + multiMtl->SetName(util::to_wstring(obj.objname).c_str()); + multiMtl->SetNumSubMtls(numSubMaterials); + + return multiMtl; + } +} + +Mtl* GbsImporter::BuildMaterial(SubObject& obj, Mtl* parentMaterial) +{ + BitmapTex* bitmapTex = nullptr; + + if (obj.texname && obj.texname[0]) + { + std::wstring mapName = util::to_wstring(obj.texname).c_str(); + mapName += L".tga"; // DDS partially supported but not in use, okay to hardcode for now + + bitmapTex = NewDefaultBitmapTex(); + bitmapTex->SetName(util::to_wstring(obj.texname).c_str()); + bitmapTex->SetMapName(mapName.c_str()); + } + + StdMat2* stdMat = NewDefaultStdMat(); + if (FlagIsSet(obj.flags, GBSFlagMaxLit) || parentMaterial) + { + // This isn't quite right, not all models with blend materials have this flag set. See ripper.gbs. + // Behavior is correct enough for now though. + stdMat->SetWireUnits(TRUE); + } + + stdMat->EnableMap(ID_DI, true); + + if (obj.flags & 0x10) + { + stdMat->SetTransparencyType(TRANSP_ADDITIVE); + } + else if (obj.flags & 0x20) + { + stdMat->SetTransparencyType(TRANSP_SUBTRACTIVE); + } + stdMat->SetShinStr(1.0f, 0); + stdMat->SetOpacFalloff(obj.falloff, 0); + + if (obj.emissive != 0) + { + Color emissive(GetRValue(obj.emissive), GetGValue(obj.emissive), GetBValue(obj.emissive)); + stdMat->SetSelfIllumColor(emissive, 0); + } + + if (bitmapTex) + { + stdMat->SetSubTexmap(ID_DI, bitmapTex); + } + + Color diffuse(GetRValue(obj.diffuse), GetGValue(obj.diffuse), GetBValue(obj.diffuse)); + stdMat->SetDiffuse(diffuse, 0); + Color ambient(GetRValue(obj.ambient), GetGValue(obj.ambient), GetBValue(obj.ambient)); + stdMat->SetAmbient(ambient, 0); + Color specular(GetRValue(obj.specular), GetGValue(obj.specular), GetBValue(obj.specular)); + stdMat->SetSpecular(specular, 0); + stdMat->SetShininess(obj.power / 100.0f, 0); + + stdMat->SetName(util::to_wstring(obj.objname).c_str()); + + return stdMat; +} + +BOOL GbsImporter::SupportsOptions(int Ext, DWORD Options) +{ + return FALSE; +} \ No newline at end of file diff --git a/Plugins/imp_gbs/Importer.h b/Plugins/imp_gbs/Importer.h new file mode 100644 index 0000000..370d768 --- /dev/null +++ b/Plugins/imp_gbs/Importer.h @@ -0,0 +1,39 @@ +#pragma once + +#include "GbsData.h" + +#define GIANTSIMP_CLASSID Class_ID(0x552cac79, 0x46f2d727) + +class GbsImporter : public SceneImport +{ +public: + static HWND hParams; + + int ExtCount(); // Number of extensions supported + const MCHAR* Ext(int n); // Extension #n (i.e. "3DS") + const MCHAR* LongDesc(); // Long ASCII description (i.e. "Autodesk 3D Studio File") + const MCHAR* ShortDesc(); // Short ASCII description (i.e. "3D Studio") + const MCHAR* AuthorName(); // ASCII Author name + const MCHAR* CopyrightMessage(); // ASCII Copyright message + const MCHAR* OtherMessage1(); // Other message #1 + const MCHAR* OtherMessage2(); // Other message #2 + unsigned int Version(); // Version number * 100 (i.e. v3.01 = 301) + void ShowAbout(HWND hWnd); // Show DLL's "About..." box + int DoImport(const MCHAR *name,ImpInterface *i,Interface *gi, BOOL suppressPrompts=FALSE); // Import file + + //Constructor/Destructor + BOOL SupportsOptions(int Ext,DWORD Options); + +private: + GbsData ReadGbsFile(const MCHAR* Name); + Mtl* BuildParentMaterial(SubObject& obj, int numSubMaterials); + Mtl* BuildMaterial(SubObject& obj, Mtl* parentMaterial); + int GetLocalVertex(Point3* avert, const Mesh& mesh); + void BuildMeshes(ImpInterface* EI); + bool EvaluateTriData(unsigned short** pTriData, unsigned short* pTriIdx, unsigned short* acount, int* pV1, int* pV2, int* pV3); + + FILE* m_OpenFile{}; + GbsData m_gbsData; +}; + +extern HINSTANCE hInstance; \ No newline at end of file diff --git a/Plugins/imp_gbs/StdUtil.h b/Plugins/imp_gbs/StdUtil.h new file mode 100644 index 0000000..9e7a0c1 --- /dev/null +++ b/Plugins/imp_gbs/StdUtil.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +namespace util +{ + + inline std::wstring to_wstring(const std::string_view& sourceString) + { + std::wstring_convert> converter; + + return converter.from_bytes(sourceString.data()); + } + + inline std::string to_string(const std::wstring_view& sourceString) + { + using convert_typeX = std::codecvt_utf8; + std::wstring_convert converterX; + + return converterX.to_bytes(sourceString.data()); + } +} \ No newline at end of file diff --git a/Plugins/imp_gbs/imp_gbs.def b/Plugins/imp_gbs/imp_gbs.def new file mode 100644 index 0000000..4d89e8e --- /dev/null +++ b/Plugins/imp_gbs/imp_gbs.def @@ -0,0 +1,8 @@ +LIBRARY imp_gbs +EXPORTS + LibDescription @1 + LibNumberClasses @2 + LibClassDesc @3 + LibVersion @4 +SECTIONS + .data READ WRITE \ No newline at end of file diff --git a/Plugins/imp_gbs/imp_gbs.vcxproj b/Plugins/imp_gbs/imp_gbs.vcxproj new file mode 100644 index 0000000..5f694bd --- /dev/null +++ b/Plugins/imp_gbs/imp_gbs.vcxproj @@ -0,0 +1,191 @@ + + + + + Debug + x64 + + + Hybrid + x64 + + + Release + x64 + + + + {448F061E-AE05-4E06-84A1-C95660FD048C} + GiantsExp + Win32Proj + imp_gbs + + + + DynamicLibrary + v142 + Unicode + + + DynamicLibrary + v142 + Unicode + + + DynamicLibrary + v142 + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>16.0.30427.251 + + + false + + + false + + + + Disabled + Default + $(ADSK_3DSMAX_SDK_2021)\include;$(GIANTS_SDK_PATH)\Include;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;_USRDLL;GIANTSIMP_EXPORTS;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions) + false + EnableFastChecks + MultiThreadedDLL + Use + Level3 + ProgramDatabase + Default + stdcpplatest + stdafx.h + + + 0x0000 + + + + + /def:imp_gbs.def %(AdditionalOptions) + odbc32.lib;odbccp32.lib;comctl32.lib;bmm.lib;core.lib;geom.lib;gfx.lib;mesh.lib;maxutil.lib;maxscrpt.lib;manipsys.lib;paramblk2.lib;vfw32.lib;mnmath.lib;%(AdditionalDependencies) + true + $(ADSK_3DSMAX_SDK_2021)\lib\x64\Release;\..\libs;%(AdditionalLibraryDirectories) + true + NotSet + false + + + $(OutDir)GiantsImp.lib + + + copy "$(TargetPath)" "$(ADSK_3DSMAX_x64_2021)\stdplugs\$(TargetName).dli + + + + + Disabled + Default + $(ADSK_3DSMAX_SDK_2021)\include;$(GIANTS_SDK_PATH)\Include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;GIANTSIMP_EXPORTS;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Use + Level3 + ProgramDatabase + Default + stdcpplatest + stdafx.h + + + 0x0000 + + + + + /def:imp_gbs.def %(AdditionalOptions) + odbc32.lib;odbccp32.lib;comctl32.lib;bmm.lib;core.lib;geom.lib;gfx.lib;mesh.lib;maxutil.lib;maxscrpt.lib;manipsys.lib;paramblk2.lib;vfw32.lib;mnmath.lib;%(AdditionalDependencies) + true + $(ADSK_3DSMAX_SDK_2021)\lib\x64\Release;\..\libs;%(AdditionalLibraryDirectories) + true + NotSet + false + + + + + copy "$(TargetPath)" "$(ADSK_3DSMAX_x64_2021)\stdplugs\$(TargetName).dli + + + + + MinSpace + $(ADSK_3DSMAX_SDK_2021)\include;$(GIANTS_SDK_PATH)\Include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;GIANTSIMP_EXPORTS;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions) + MultiThreadedDLL + Use + Level3 + ProgramDatabase + stdcpplatest + stdafx.h + + + + + + + /def:imp_gbs.def %(AdditionalOptions) + odbc32.lib;odbccp32.lib;comctl32.lib;bmm.lib;core.lib;geom.lib;gfx.lib;mesh.lib;maxutil.lib;maxscrpt.lib;manipsys.lib;paramblk2.lib;vfw32.lib;mnmath.lib;%(AdditionalDependencies) + $(ADSK_3DSMAX_SDK_2021)\lib\x64\Release;\..\libs;%(AdditionalLibraryDirectories) + true + Windows + true + true + false + + + $(OutDir)GiantsImp.lib + + + copy "$(TargetPath)" "$(ADSK_3DSMAX_x64_2021)\stdplugs\$(TargetName).dli + + + + + + + + Create + Create + Create + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Plugins/imp_gbs/imp_gbs.vcxproj.filters b/Plugins/imp_gbs/imp_gbs.vcxproj.filters new file mode 100644 index 0000000..94757cc --- /dev/null +++ b/Plugins/imp_gbs/imp_gbs.vcxproj.filters @@ -0,0 +1,46 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + \ No newline at end of file diff --git a/Plugins/imp_gbs/stdafx.cpp b/Plugins/imp_gbs/stdafx.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Plugins/imp_gbs/stdafx.h b/Plugins/imp_gbs/stdafx.h new file mode 100644 index 0000000..0236b3f --- /dev/null +++ b/Plugins/imp_gbs/stdafx.h @@ -0,0 +1,17 @@ +#pragma once + +// Windows Header Files: +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include + +// 3dsmax headers +#include +#include +#include + +// STL +#include +#include + +// Game SDK includes +#include \ No newline at end of file