goat3d
changeset 60:0c3576325480
moving the exporter along slowly
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 30 Mar 2014 08:53:33 +0300 |
parents | b0bf3786bd5b |
children | fdece14403ff |
files | exporters/maxgoat/maxgoat.vcxproj exporters/maxgoat/maxgoat.vcxproj.filters exporters/maxgoat/src/maxgoat.cc exporters/maxgoat/src/minwin.cc exporters/maxgoat/src/minwin.h exporters/maxgoat_stub/src/stub.cc |
diffstat | 6 files changed, 189 insertions(+), 69 deletions(-) [+] |
line diff
1.1 --- a/exporters/maxgoat/maxgoat.vcxproj Tue Mar 25 04:37:41 2014 +0200 1.2 +++ b/exporters/maxgoat/maxgoat.vcxproj Sun Mar 30 08:53:33 2014 +0300 1.3 @@ -156,6 +156,10 @@ 1.4 </ItemDefinitionGroup> 1.5 <ItemGroup> 1.6 <ClCompile Include="src\maxgoat.cc" /> 1.7 + <ClCompile Include="src\minwin.cc" /> 1.8 + </ItemGroup> 1.9 + <ItemGroup> 1.10 + <ClInclude Include="src\minwin.h" /> 1.11 </ItemGroup> 1.12 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> 1.13 <ImportGroup Label="ExtensionTargets">
2.1 --- a/exporters/maxgoat/maxgoat.vcxproj.filters Tue Mar 25 04:37:41 2014 +0200 2.2 +++ b/exporters/maxgoat/maxgoat.vcxproj.filters Sun Mar 30 08:53:33 2014 +0300 2.3 @@ -3,12 +3,20 @@ 2.4 <ItemGroup> 2.5 <Filter Include="src"> 2.6 <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> 2.7 - <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> 2.8 + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;h</Extensions> 2.9 </Filter> 2.10 </ItemGroup> 2.11 <ItemGroup> 2.12 <ClCompile Include="src\maxgoat.cc"> 2.13 <Filter>src</Filter> 2.14 </ClCompile> 2.15 + <ClCompile Include="src\minwin.cc"> 2.16 + <Filter>src</Filter> 2.17 + </ClCompile> 2.18 + </ItemGroup> 2.19 + <ItemGroup> 2.20 + <ClInclude Include="src\minwin.h"> 2.21 + <Filter>src</Filter> 2.22 + </ClInclude> 2.23 </ItemGroup> 2.24 </Project> 2.25 \ No newline at end of file
3.1 --- a/exporters/maxgoat/src/maxgoat.cc Tue Mar 25 04:37:41 2014 +0200 3.2 +++ b/exporters/maxgoat/src/maxgoat.cc Sun Mar 30 08:53:33 2014 +0300 3.3 @@ -13,6 +13,7 @@ 3.4 #include "IGameExport.h" 3.5 #include "IConversionmanager.h" 3.6 #include "goat3d.h" 3.7 +#include "minwin.h" 3.8 #include "config.h" 3.9 3.10 3.11 @@ -118,6 +119,8 @@ 3.12 int GoatExporter::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, 3.13 BOOL non_interactive, DWORD opt) 3.14 { 3.15 + mw_test(); 3.16 + 3.17 mtlmap.clear(); 3.18 nodemap.clear(); 3.19
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/exporters/maxgoat/src/minwin.cc Sun Mar 30 08:53:33 2014 +0300 4.3 @@ -0,0 +1,93 @@ 4.4 +#include <string.h> 4.5 +#include <windows.h> 4.6 +#include "minwin.h" 4.7 + 4.8 +#define GOATSCE_WCLASS "goatsce-window" 4.9 + 4.10 +struct MinWidget { 4.11 + HWND win; 4.12 + 4.13 + MWCallback cbfunc; 4.14 + void *cbcls; 4.15 + 4.16 + MinWidget() { win = 0; cbfunc = 0; cbcls = 0; } 4.17 +}; 4.18 + 4.19 +static void init(); 4.20 +static LRESULT CALLBACK handle_msg(HWND win, unsigned int msg, WPARAM wparam, LPARAM lparam); 4.21 + 4.22 +void mw_set_callback(MinWidget *w, MWCallback func, void *cls) 4.23 +{ 4.24 + w->cbfunc = func; 4.25 + w->cbcls = cls; 4.26 +} 4.27 + 4.28 +MinWidget *mw_create_window(MinWidget *parent, const char *name) 4.29 +{ 4.30 + MinWidget *w = new MinWidget; 4.31 + HINSTANCE inst = GetModuleHandle(0); 4.32 + 4.33 + w->win = CreateWindowA(GOATSCE_WCLASS, "Goat3D Scene export options ...", WS_OVERLAPPED, 4.34 + CW_USEDEFAULT, CW_USEDEFAULT, 512, 400, parent ? parent->win : 0, 0, inst, 0); 4.35 + ShowWindow(w->win, 1); 4.36 + 4.37 + return w; 4.38 +} 4.39 + 4.40 +MinWidget *mw_create_button(MinWidget *parent, const char *text, int x, int y, int xsz, int ysz) 4.41 +{ 4.42 + MinWidget *bn = new MinWidget; 4.43 + HINSTANCE inst = GetModuleHandle(0); 4.44 + 4.45 + bn->win = CreateWindowA("BUTTON", text, BS_PUSHBUTTON | BS_TEXT, 4.46 + x, y, xsz, ysz, parent ? parent->win : 0, 0, inst, 0); 4.47 + ShowWindow(bn->win, 1); 4.48 + 4.49 + return bn; 4.50 +} 4.51 + 4.52 +MinWidget *mw_create_checkbox(MinWidget *parent, const char *text, int x, int y, int w, int h, bool checked) 4.53 +{ 4.54 + return 0; 4.55 +} 4.56 + 4.57 + 4.58 +void mw_test() 4.59 +{ 4.60 + MinWidget *win = mw_create_window(0, "test window!"); 4.61 + MinWidget *bn = mw_create_button(win, "button!", 100, 100, 300, 80); 4.62 +} 4.63 + 4.64 +static void init() 4.65 +{ 4.66 + static bool done_init; 4.67 + if(done_init) { 4.68 + return; 4.69 + } 4.70 + done_init = true; 4.71 + 4.72 + HINSTANCE hinst = GetModuleHandle(0); 4.73 + 4.74 + WNDCLASSA wc; 4.75 + memset(&wc, 0, sizeof wc); 4.76 + wc.lpszClassName = GOATSCE_WCLASS; 4.77 + wc.hInstance = hinst; 4.78 + wc.lpfnWndProc = handle_msg; 4.79 + wc.style = CS_HREDRAW | CS_VREDRAW; 4.80 + 4.81 + RegisterClassA(&wc); 4.82 +} 4.83 + 4.84 +static LRESULT CALLBACK handle_msg(HWND win, unsigned int msg, WPARAM wparam, LPARAM lparam) 4.85 +{ 4.86 + switch(msg) { 4.87 + case WM_CLOSE: 4.88 + DestroyWindow(win); 4.89 + break; 4.90 + 4.91 + default: 4.92 + return DefWindowProc(win, msg, wparam, lparam); 4.93 + } 4.94 + 4.95 + return 0; 4.96 +} 4.97 \ No newline at end of file
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/exporters/maxgoat/src/minwin.h Sun Mar 30 08:53:33 2014 +0300 5.3 @@ -0,0 +1,15 @@ 5.4 +#ifndef MINWIN_H_ 5.5 +#define MINWIN_H_ 5.6 + 5.7 +struct MinWidget; 5.8 +typedef void (*MWCallback)(MinWidget*, void*); 5.9 + 5.10 +void mw_set_callback(MinWidget *w, MWCallback func, void *cls); 5.11 + 5.12 +MinWidget *mw_create_window(MinWidget *parent, const char *name); 5.13 +MinWidget *mw_create_button(MinWidget *parent, const char *text, int x, int y, int w, int h); 5.14 +MinWidget *mw_create_checkbox(MinWidget *parent, const char *text, int x, int y, int w, int h, bool checked); 5.15 + 5.16 +void mw_test(); 5.17 + 5.18 +#endif // MINWIN_H_ 5.19 \ No newline at end of file
6.1 --- a/exporters/maxgoat_stub/src/stub.cc Tue Mar 25 04:37:41 2014 +0200 6.2 +++ b/exporters/maxgoat_stub/src/stub.cc Sun Mar 30 08:53:33 2014 +0300 6.3 @@ -37,77 +37,43 @@ 6.4 6.5 static FILE *logfile; 6.6 static HINSTANCE hinst; 6.7 +static const wchar_t *copyright_str = L"Copyright 2013 (C) John Tsiombikas - GNU General Public License v3, see COPYING for details."; 6.8 6.9 class GoatExporterStub : public SceneExport { 6.10 -private: 6.11 - 6.12 public: 6.13 IGameScene *igame; 6.14 6.15 - int ExtCount(); 6.16 - const TCHAR *Ext(int n); 6.17 - const TCHAR *LongDesc(); 6.18 - const TCHAR *ShortDesc(); 6.19 - const TCHAR *AuthorName(); 6.20 - const TCHAR *CopyrightMessage(); 6.21 - const TCHAR *OtherMessage1(); 6.22 - const TCHAR *OtherMessage2(); 6.23 - unsigned int Version(); 6.24 - void ShowAbout(HWND win); 6.25 + int ExtCount() { return 1; } 6.26 + const TCHAR *Ext(int n) { return L"goatsce"; } 6.27 + const TCHAR *LongDesc() { return L"Goat3D Scene file"; } 6.28 + const TCHAR *ShortDesc() { return L"Goat3D Scene"; } 6.29 + const TCHAR *AuthorName() { return L"John Tsiombikas"; } 6.30 + const TCHAR *CopyrightMessage() { return copyright_str; } 6.31 + const TCHAR *OtherMessage1() { return L"foo1"; } 6.32 + const TCHAR *OtherMessage2() { return L"foo2"; } 6.33 + unsigned int Version() { return VERSION(VER_MAJOR, VER_MINOR); } 6.34 + void ShowAbout(HWND win) { MessageBoxA(win, "Goat3D exporter", "About this plugin", 0); } 6.35 6.36 int DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL silent = FALSE, DWORD opt = 0); 6.37 }; 6.38 6.39 +class GoatAnimExporterStub : public SceneExport { 6.40 +public: 6.41 + IGameScene *igame; 6.42 6.43 -int GoatExporterStub::ExtCount() 6.44 -{ 6.45 - return 1; 6.46 -} 6.47 + int ExtCount() { return 1; } 6.48 + const TCHAR *Ext(int n) { return L"goatanm"; } 6.49 + const TCHAR *LongDesc() { return L"Goat3D Animation file"; } 6.50 + const TCHAR *ShortDesc() { return L"Goat3D Animation"; } 6.51 + const TCHAR *AuthorName() { return L"John Tsiombikas"; } 6.52 + const TCHAR *CopyrightMessage() { return copyright_str; } 6.53 + const TCHAR *OtherMessage1() { return L"bar1"; } 6.54 + const TCHAR *OtherMessage2() { return L"bar2"; } 6.55 + unsigned int Version() { return VERSION(VER_MAJOR, VER_MINOR); } 6.56 + void ShowAbout(HWND win) { MessageBoxA(win, "Goat3D anim exporter", "About this plugin", 0); } 6.57 6.58 -const TCHAR *GoatExporterStub::Ext(int n) 6.59 -{ 6.60 - return L"xml"; 6.61 -} 6.62 - 6.63 -const TCHAR *GoatExporterStub::LongDesc() 6.64 -{ 6.65 - return L"Goat3D scene file"; 6.66 -} 6.67 - 6.68 -const TCHAR *GoatExporterStub::ShortDesc() 6.69 -{ 6.70 - return L"Goat3D"; 6.71 -} 6.72 - 6.73 -const TCHAR *GoatExporterStub::AuthorName() 6.74 -{ 6.75 - return L"John Tsiombikas"; 6.76 -} 6.77 - 6.78 -const TCHAR *GoatExporterStub::CopyrightMessage() 6.79 -{ 6.80 - return L"Copyright 2013 (C) John Tsiombikas - GNU General Public License v3, see COPYING for details."; 6.81 -} 6.82 - 6.83 -const TCHAR *GoatExporterStub::OtherMessage1() 6.84 -{ 6.85 - return L"other1"; 6.86 -} 6.87 - 6.88 -const TCHAR *GoatExporterStub::OtherMessage2() 6.89 -{ 6.90 - return L"other2"; 6.91 -} 6.92 - 6.93 -unsigned int GoatExporterStub::Version() 6.94 -{ 6.95 - return VERSION(VER_MAJOR, VER_MINOR); 6.96 -} 6.97 - 6.98 -void GoatExporterStub::ShowAbout(HWND win) 6.99 -{ 6.100 - MessageBoxA(win, "Goat3D exporter stub", "About this plugin", 0); 6.101 -} 6.102 + int DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL silent = FALSE, DWORD opt = 0); 6.103 +}; 6.104 6.105 static const char *find_dll_dir() 6.106 { 6.107 @@ -128,10 +94,7 @@ 6.108 return path; 6.109 } 6.110 6.111 -/* TODO: open a dialog, let the user select goat3d or goat3danim, then load the correct dll 6.112 - */ 6.113 -int GoatExporterStub::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, 6.114 - BOOL non_interactive, DWORD opt) 6.115 +static int do_export(int which, const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL non_int, DWORD opt) 6.116 { 6.117 const char *dll_fname = "maxgoat.dll"; 6.118 char *dll_path; 6.119 @@ -170,8 +133,7 @@ 6.120 } 6.121 } 6.122 6.123 - // TODO: pass 1 for anim 6.124 - if(!(desc = get_class_desc(0))) { 6.125 + if(!(desc = get_class_desc(which))) { 6.126 fprintf(logfile, "failed to get the class descriptor\n"); 6.127 goto done; 6.128 } 6.129 @@ -196,6 +158,18 @@ 6.130 return result; 6.131 } 6.132 6.133 +int GoatExporterStub::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, 6.134 + BOOL non_interactive, DWORD opt) 6.135 +{ 6.136 + return do_export(0, name, eiface, iface, non_interactive, opt); 6.137 +} 6.138 + 6.139 + 6.140 +int GoatAnimExporterStub::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, 6.141 + BOOL non_interactive, DWORD opt) 6.142 +{ 6.143 + return do_export(1, name, eiface, iface, non_interactive, opt); 6.144 +} 6.145 6.146 // ------------------------------------------ 6.147 6.148 @@ -212,7 +186,22 @@ 6.149 HINSTANCE HInstance() { return hinst; } 6.150 }; 6.151 6.152 +class GoatAnimClassDesc : public ClassDesc2 { 6.153 +public: 6.154 + int IsPublic() { return TRUE; } 6.155 + void *Create(BOOL loading = FALSE) { return new GoatAnimExporterStub; } 6.156 + const TCHAR *ClassName() { return L"GoatAnimExporterStub"; } 6.157 + SClass_ID SuperClassID() { return SCENE_EXPORT_CLASS_ID; } 6.158 + Class_ID ClassID() { return Class_ID(0x75054666, 0x45487285); } 6.159 + const TCHAR *Category() { return L"Mutant Stargoat"; } 6.160 + 6.161 + const TCHAR *InternalName() { return L"GoatAnimExporterStub"; } 6.162 + HINSTANCE HInstance() { return hinst; } 6.163 +}; 6.164 + 6.165 + 6.166 static GoatClassDesc class_desc; 6.167 +static GoatAnimClassDesc anim_class_desc; 6.168 6.169 BOOL WINAPI DllMain(HINSTANCE inst_handle, ULONG reason, void *reserved) 6.170 { 6.171 @@ -232,12 +221,20 @@ 6.172 6.173 __declspec(dllexport) int LibNumberClasses() 6.174 { 6.175 - return 1; 6.176 + return 2; 6.177 } 6.178 6.179 __declspec(dllexport) ClassDesc *LibClassDesc(int i) 6.180 { 6.181 - return i == 0 ? &class_desc : 0; 6.182 + switch(i) { 6.183 + case 0: 6.184 + return &class_desc; 6.185 + case 1: 6.186 + return &anim_class_desc; 6.187 + default: 6.188 + break; 6.189 + } 6.190 + return 0; 6.191 } 6.192 6.193 __declspec(dllexport) ULONG LibVersion()