# HG changeset patch # User John Tsiombikas # Date 1376878688 -10800 # Node ID fca2ea844875e2d0467712b3ad280045b7c22648 # Parent d96c11a7f809609cd11232e658ab866a729638aa added rudimentary visual studio project diff -r d96c11a7f809 -r fca2ea844875 exporters/maxgoat/maxgoat.vcxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exporters/maxgoat/maxgoat.vcxproj Mon Aug 19 05:18:08 2013 +0300 @@ -0,0 +1,155 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {5BDDFFC1-7900-45D2-92F5-525361057554} + Win32Proj + maxgoat + + + + DynamicLibrary + true + v110 + Unicode + + + DynamicLibrary + true + v110 + Unicode + + + DynamicLibrary + false + v110 + true + Unicode + + + DynamicLibrary + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;MAXGOAT_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;MAXGOAT_EXPORTS;%(PreprocessorDefinitions) + 4996 + + + Windows + true + + + copy /Y "$(TargetPath)" "$(ADSK_3DSMAX_x64_2014)plugins\$(ProjectName).dle" + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;MAXGOAT_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;MAXGOAT_EXPORTS;%(PreprocessorDefinitions) + 4996 + + + Windows + true + true + true + + + copy /Y "$(TargetPath)" "$(ADSK_3DSMAX_x64_2014)plugins\$(ProjectName).dle" + + + + + + + + + \ No newline at end of file diff -r d96c11a7f809 -r fca2ea844875 exporters/maxgoat/maxgoat.vcxproj.filters --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exporters/maxgoat/maxgoat.vcxproj.filters Mon Aug 19 05:18:08 2013 +0300 @@ -0,0 +1,14 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + src + + + \ No newline at end of file diff -r d96c11a7f809 -r fca2ea844875 exporters/maxgoat/src/maxgoat.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exporters/maxgoat/src/maxgoat.cc Mon Aug 19 05:18:08 2013 +0300 @@ -0,0 +1,253 @@ +#include +#include +#include +#include +#include +#include "max.h" +#include "impexp.h" // SceneExport +#include "iparamb2.h" // ClassDesc2 +#include "plugapi.h" +#include "IGame.h" +#include "IGameExport.h" +#include "IConversionmanager.h" + + +#pragma comment (lib, "core.lib") +#pragma comment (lib, "geom.lib") +#pragma comment (lib, "gfx.lib") +#pragma comment (lib, "mesh.lib") +#pragma comment (lib, "maxutil.lib") +#pragma comment (lib, "maxscrpt.lib") +#pragma comment (lib, "paramblk2.lib") +#pragma comment (lib, "msxml2.lib") +#pragma comment (lib, "igame.lib") +#pragma comment (lib, "comctl32.lib") + + +static FILE *logfile; +static HINSTANCE hinst; + +class GoatExporter : public SceneExport { +public: + IGameScene *igame; + + int ExtCount(); + const TCHAR *Ext(int n); + const TCHAR *LongDesc(); + const TCHAR *ShortDesc(); + const TCHAR *AuthorName(); + const TCHAR *CopyrightMessage(); + const TCHAR *OtherMessage1(); + const TCHAR *OtherMessage2(); + unsigned int Version(); + void ShowAbout(HWND win); + + int DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL silent = FALSE, DWORD opt = 0); + + bool export_materials(FILE *fp); +}; + + +int GoatExporter::ExtCount() +{ + return 1; +} + +const TCHAR *GoatExporter::Ext(int n) +{ + return L"txt"; +} + +const TCHAR *GoatExporter::LongDesc() +{ + return L"Goat3D scene file"; +} + +const TCHAR *GoatExporter::ShortDesc() +{ + return L"Goat3D"; +} + +const TCHAR *GoatExporter::AuthorName() +{ + return L"John Tsiombikas"; +} + +const TCHAR *GoatExporter::CopyrightMessage() +{ + return L"Copyright 2013 (C) John Tsiombikas - GNU General Public License v3, see COPYING for details."; +} + +const TCHAR *GoatExporter::OtherMessage1() +{ + return L"other1"; +} + +const TCHAR *GoatExporter::OtherMessage2() +{ + return L"other2"; +} + +unsigned int GoatExporter::Version() +{ + return 10; +} + +void GoatExporter::ShowAbout(HWND win) +{ + MessageBoxA(win, "Goat3D exporter plugin", "About this plugin", 0); +} + +int GoatExporter::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, + BOOL non_interactive, DWORD opt) +{ + char fname[512]; + wcstombs(fname, name, sizeof fname - 1); + + FILE *fp = fopen(fname, "wb"); + if(!fp) { + fprintf(logfile, "failed to open %s for writting: %s", fname, strerror(errno)); + return IMPEXP_FAIL; + } + + if(!(igame = GetIGameInterface())) { + fprintf(logfile, "failed to get the igame interface\n"); + fclose(fp); + return IMPEXP_FAIL; + } + IGameConversionManager *cm = GetConversionManager(); + cm->SetCoordSystem(IGameConversionManager::IGAME_OGL); + igame->InitialiseIGame(); + igame->SetStaticFrame(0); + + export_materials(fp); + + fclose(fp); + + return IMPEXP_SUCCESS; +} + +bool GoatExporter::export_materials(FILE *fp) +{ + IGameProperty *prop; + + int num_mtl = igame->GetRootMaterialCount(); + fprintf(fp, "number of materials: %d\n", num_mtl); + + for(int i=0; iGetRootMaterial(i); + if(mtl) { + Point3 diffuse(1, 1, 1); + Point3 specular(0, 0, 0); + float shin = 1.0, sstr = 1.0; + char name[512] = "unnamed"; + + const MCHAR *wname = mtl->GetMaterialName(); + if(wname) { + wcstombs(name, wname, sizeof name - 1); + } + + if((prop = mtl->GetDiffuseData())) { + prop->GetPropertyValue(diffuse); + } + if((prop = mtl->GetSpecularData())) { + prop->GetPropertyValue(specular); + } + if((prop = mtl->GetSpecularLevelData())) { + prop->GetPropertyValue(sstr); + } + if((prop = mtl->GetGlossinessData())) { + prop->GetPropertyValue(shin); + } + + fprintf(fp, "Material %d (%s):\n", i, name); + fprintf(fp, " diffuse: %f %f %f\n", diffuse[0], diffuse[1], diffuse[2]); + fprintf(fp, " specular: %f %f %f\n", specular[0] * sstr, specular[1] * sstr, specular[2] * sstr); + fprintf(fp, " shininess: %f\n", shin * 100.0); + + for(int j=0; jGetNumberOfTextureMaps(); j++) { + IGameTextureMap *tex = mtl->GetIGameTextureMap(j); + const MCHAR *wfname = tex->GetBitmapFileName(); + if(wfname) { + char fname[512]; + wcstombs(fname, wfname, sizeof fname - 1); + fprintf(fp, " texture%d: %s\n", j, fname); + } + } + } + } + + return true; +} + +// ------------------------------------------ + +class GoatClassDesc : public ClassDesc2 { +public: + int IsPublic() { return TRUE; } + void *Create(BOOL loading = FALSE) { return new GoatExporter; } + const TCHAR *ClassName() { return L"GoatExporter"; } + SClass_ID SuperClassID() { return SCENE_EXPORT_CLASS_ID; } + Class_ID ClassID() { return Class_ID(0x77050f0d, 0x7d4c5ab5); } + const TCHAR *Category() { return L"Mutant Stargoat"; } + + const TCHAR *InternalName() { return L"GoatExporter"; } + HINSTANCE HInstance() { return hinst; } +}; + +static GoatClassDesc class_desc; + +BOOL WINAPI DllMain(HINSTANCE inst_handle, ULONG reason, void *reserved) +{ + if(reason == DLL_PROCESS_ATTACH) { + hinst = inst_handle; + DisableThreadLibraryCalls(hinst); + } + return TRUE; +} + +extern "C" { + +__declspec(dllexport) const TCHAR *LibDescription() +{ + return L"test exporter"; +} + +__declspec(dllexport) int LibNumberClasses() +{ + return 1; +} + +__declspec(dllexport) ClassDesc *LibClassDesc(int i) +{ + return i == 0 ? &class_desc : 0; +} + +__declspec(dllexport) ULONG LibVersion() +{ + return Get3DSMAXVersion(); +} + +__declspec(dllexport) int LibInitialize() +{ + static char path[1024]; + + SHGetFolderPathA(0, CSIDL_PERSONAL, 0, 0, path); + strcat(path, "/testexp.log"); + + if((logfile = fopen(path, "w"))) { + setvbuf(logfile, 0, _IONBF, 0); + } + return TRUE; +} + +__declspec(dllexport) int LibShutdown() +{ + if(logfile) { + fclose(logfile); + logfile = 0; + } + return TRUE; +} + +} // extern "C" \ No newline at end of file diff -r d96c11a7f809 -r fca2ea844875 goat3d.sln --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/goat3d.sln Mon Aug 19 05:18:08 2013 +0300 @@ -0,0 +1,36 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "goat3d", "goat3d.vcxproj", "{86BF319B-9222-4805-918D-DC1B9F77BCEF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "maxgoat", "exporters\maxgoat\maxgoat.vcxproj", "{5BDDFFC1-7900-45D2-92F5-525361057554}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {86BF319B-9222-4805-918D-DC1B9F77BCEF}.Debug|Win32.ActiveCfg = Debug|Win32 + {86BF319B-9222-4805-918D-DC1B9F77BCEF}.Debug|Win32.Build.0 = Debug|Win32 + {86BF319B-9222-4805-918D-DC1B9F77BCEF}.Debug|x64.ActiveCfg = Debug|x64 + {86BF319B-9222-4805-918D-DC1B9F77BCEF}.Debug|x64.Build.0 = Debug|x64 + {86BF319B-9222-4805-918D-DC1B9F77BCEF}.Release|Win32.ActiveCfg = Release|Win32 + {86BF319B-9222-4805-918D-DC1B9F77BCEF}.Release|Win32.Build.0 = Release|Win32 + {86BF319B-9222-4805-918D-DC1B9F77BCEF}.Release|x64.ActiveCfg = Release|x64 + {86BF319B-9222-4805-918D-DC1B9F77BCEF}.Release|x64.Build.0 = Release|x64 + {5BDDFFC1-7900-45D2-92F5-525361057554}.Debug|Win32.ActiveCfg = Debug|Win32 + {5BDDFFC1-7900-45D2-92F5-525361057554}.Debug|Win32.Build.0 = Debug|Win32 + {5BDDFFC1-7900-45D2-92F5-525361057554}.Debug|x64.ActiveCfg = Debug|x64 + {5BDDFFC1-7900-45D2-92F5-525361057554}.Debug|x64.Build.0 = Debug|x64 + {5BDDFFC1-7900-45D2-92F5-525361057554}.Release|Win32.ActiveCfg = Release|Win32 + {5BDDFFC1-7900-45D2-92F5-525361057554}.Release|Win32.Build.0 = Release|Win32 + {5BDDFFC1-7900-45D2-92F5-525361057554}.Release|x64.ActiveCfg = Release|x64 + {5BDDFFC1-7900-45D2-92F5-525361057554}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff -r d96c11a7f809 -r fca2ea844875 goat3d.vcxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/goat3d.vcxproj Mon Aug 19 05:18:08 2013 +0300 @@ -0,0 +1,156 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + {86BF319B-9222-4805-918D-DC1B9F77BCEF} + Win32Proj + goat3d + + + + StaticLibrary + true + v110 + Unicode + + + StaticLibrary + true + v110 + Unicode + + + StaticLibrary + false + v110 + true + Unicode + + + StaticLibrary + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + 4244 + + + Windows + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + 4244 + + + Windows + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + 4244 + + + Windows + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + 4244 + + + Windows + true + true + true + + + + + + \ No newline at end of file diff -r d96c11a7f809 -r fca2ea844875 goat3d.vcxproj.filters --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/goat3d.vcxproj.filters Mon Aug 19 05:18:08 2013 +0300 @@ -0,0 +1,58 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + + + src + + + src + + + src + + + src + + + src + + + \ No newline at end of file