rev |
line source |
nuclear@5
|
1 #include <stdio.h>
|
nuclear@5
|
2 #include <string.h>
|
nuclear@27
|
3 #include <stdlib.h>
|
nuclear@5
|
4 #include <errno.h>
|
nuclear@27
|
5 #include <map>
|
nuclear@5
|
6 #include <windows.h>
|
nuclear@5
|
7 #include <shlobj.h>
|
nuclear@5
|
8 #include "max.h"
|
nuclear@5
|
9 #include "impexp.h" // SceneExport
|
nuclear@5
|
10 #include "iparamb2.h" // ClassDesc2
|
nuclear@5
|
11 #include "plugapi.h"
|
nuclear@5
|
12 #include "IGame.h"
|
nuclear@5
|
13 #include "IGameExport.h"
|
nuclear@5
|
14 #include "IConversionmanager.h"
|
nuclear@25
|
15 #include "goat3d.h"
|
nuclear@10
|
16 #include "config.h"
|
nuclear@5
|
17
|
nuclear@5
|
18
|
nuclear@5
|
19 #pragma comment (lib, "core.lib")
|
nuclear@5
|
20 #pragma comment (lib, "geom.lib")
|
nuclear@5
|
21 #pragma comment (lib, "gfx.lib")
|
nuclear@5
|
22 #pragma comment (lib, "mesh.lib")
|
nuclear@5
|
23 #pragma comment (lib, "maxutil.lib")
|
nuclear@5
|
24 #pragma comment (lib, "maxscrpt.lib")
|
nuclear@5
|
25 #pragma comment (lib, "paramblk2.lib")
|
nuclear@5
|
26 #pragma comment (lib, "msxml2.lib")
|
nuclear@5
|
27 #pragma comment (lib, "igame.lib")
|
nuclear@5
|
28 #pragma comment (lib, "comctl32.lib")
|
nuclear@5
|
29
|
nuclear@5
|
30
|
nuclear@10
|
31 #define VERSION(major, minor) \
|
nuclear@10
|
32 ((major) * 100 + ((minor) < 10 ? (minor) * 10 : (minor)))
|
nuclear@10
|
33
|
nuclear@5
|
34 static FILE *logfile;
|
nuclear@5
|
35 static HINSTANCE hinst;
|
nuclear@5
|
36
|
nuclear@5
|
37 class GoatExporter : public SceneExport {
|
nuclear@27
|
38 private:
|
nuclear@28
|
39 std::map<IGameMaterial*, goat3d_material*> mtlmap;
|
nuclear@28
|
40 std::map<IGameNode*, goat3d_node*> nodemap;
|
nuclear@27
|
41
|
nuclear@5
|
42 public:
|
nuclear@5
|
43 IGameScene *igame;
|
nuclear@5
|
44
|
nuclear@5
|
45 int ExtCount();
|
nuclear@5
|
46 const TCHAR *Ext(int n);
|
nuclear@5
|
47 const TCHAR *LongDesc();
|
nuclear@5
|
48 const TCHAR *ShortDesc();
|
nuclear@5
|
49 const TCHAR *AuthorName();
|
nuclear@5
|
50 const TCHAR *CopyrightMessage();
|
nuclear@5
|
51 const TCHAR *OtherMessage1();
|
nuclear@5
|
52 const TCHAR *OtherMessage2();
|
nuclear@5
|
53 unsigned int Version();
|
nuclear@5
|
54 void ShowAbout(HWND win);
|
nuclear@5
|
55
|
nuclear@5
|
56 int DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL silent = FALSE, DWORD opt = 0);
|
nuclear@5
|
57
|
nuclear@27
|
58 void process_materials(goat3d *goat);
|
nuclear@27
|
59
|
nuclear@27
|
60 void process_node(goat3d *goat, goat3d_node *parent, IGameNode *maxnode);
|
nuclear@27
|
61
|
nuclear@27
|
62 void process_mesh(goat3d *goat, goat3d_mesh *mesh, IGameObject *maxobj);
|
nuclear@27
|
63 void process_light(goat3d *goat, goat3d_light *light, IGameObject *maxobj);
|
nuclear@27
|
64 void process_camera(goat3d *goat, goat3d_camera *cam, IGameObject *maxobj);
|
nuclear@5
|
65 };
|
nuclear@5
|
66
|
nuclear@5
|
67
|
nuclear@5
|
68 int GoatExporter::ExtCount()
|
nuclear@5
|
69 {
|
nuclear@5
|
70 return 1;
|
nuclear@5
|
71 }
|
nuclear@5
|
72
|
nuclear@5
|
73 const TCHAR *GoatExporter::Ext(int n)
|
nuclear@5
|
74 {
|
nuclear@27
|
75 return L"xml";
|
nuclear@5
|
76 }
|
nuclear@5
|
77
|
nuclear@5
|
78 const TCHAR *GoatExporter::LongDesc()
|
nuclear@5
|
79 {
|
nuclear@5
|
80 return L"Goat3D scene file";
|
nuclear@5
|
81 }
|
nuclear@5
|
82
|
nuclear@5
|
83 const TCHAR *GoatExporter::ShortDesc()
|
nuclear@5
|
84 {
|
nuclear@5
|
85 return L"Goat3D";
|
nuclear@5
|
86 }
|
nuclear@5
|
87
|
nuclear@5
|
88 const TCHAR *GoatExporter::AuthorName()
|
nuclear@5
|
89 {
|
nuclear@5
|
90 return L"John Tsiombikas";
|
nuclear@5
|
91 }
|
nuclear@5
|
92
|
nuclear@5
|
93 const TCHAR *GoatExporter::CopyrightMessage()
|
nuclear@5
|
94 {
|
nuclear@5
|
95 return L"Copyright 2013 (C) John Tsiombikas - GNU General Public License v3, see COPYING for details.";
|
nuclear@5
|
96 }
|
nuclear@5
|
97
|
nuclear@5
|
98 const TCHAR *GoatExporter::OtherMessage1()
|
nuclear@5
|
99 {
|
nuclear@5
|
100 return L"other1";
|
nuclear@5
|
101 }
|
nuclear@5
|
102
|
nuclear@5
|
103 const TCHAR *GoatExporter::OtherMessage2()
|
nuclear@5
|
104 {
|
nuclear@5
|
105 return L"other2";
|
nuclear@5
|
106 }
|
nuclear@5
|
107
|
nuclear@5
|
108 unsigned int GoatExporter::Version()
|
nuclear@5
|
109 {
|
nuclear@10
|
110 return VERSION(VER_MAJOR, VER_MINOR);
|
nuclear@5
|
111 }
|
nuclear@5
|
112
|
nuclear@5
|
113 void GoatExporter::ShowAbout(HWND win)
|
nuclear@5
|
114 {
|
nuclear@5
|
115 MessageBoxA(win, "Goat3D exporter plugin", "About this plugin", 0);
|
nuclear@5
|
116 }
|
nuclear@5
|
117
|
nuclear@5
|
118 int GoatExporter::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface,
|
nuclear@5
|
119 BOOL non_interactive, DWORD opt)
|
nuclear@5
|
120 {
|
nuclear@28
|
121 mtlmap.clear();
|
nuclear@28
|
122 nodemap.clear();
|
nuclear@27
|
123
|
nuclear@5
|
124 char fname[512];
|
nuclear@5
|
125 wcstombs(fname, name, sizeof fname - 1);
|
nuclear@5
|
126
|
nuclear@58
|
127 fprintf(logfile, "Exporting Goat3D Scene (text) file: %s\n", fname);
|
nuclear@5
|
128 if(!(igame = GetIGameInterface())) {
|
nuclear@5
|
129 fprintf(logfile, "failed to get the igame interface\n");
|
nuclear@5
|
130 return IMPEXP_FAIL;
|
nuclear@5
|
131 }
|
nuclear@5
|
132 IGameConversionManager *cm = GetConversionManager();
|
nuclear@5
|
133 cm->SetCoordSystem(IGameConversionManager::IGAME_OGL);
|
nuclear@5
|
134 igame->InitialiseIGame();
|
nuclear@5
|
135 igame->SetStaticFrame(0);
|
nuclear@5
|
136
|
nuclear@25
|
137 goat3d *goat = goat3d_create();
|
nuclear@5
|
138
|
nuclear@27
|
139 process_materials(goat);
|
nuclear@27
|
140
|
nuclear@27
|
141 // process all nodes
|
nuclear@27
|
142 for(int i=0; i<igame->GetTopLevelNodeCount(); i++) {
|
nuclear@27
|
143 IGameNode *node = igame->GetTopLevelNode(i);
|
nuclear@27
|
144 process_node(goat, 0, node);
|
nuclear@27
|
145 }
|
nuclear@5
|
146
|
nuclear@25
|
147 if(goat3d_save(goat, fname) == -1) {
|
nuclear@25
|
148 goat3d_free(goat);
|
nuclear@25
|
149 return IMPEXP_FAIL;
|
nuclear@25
|
150 }
|
nuclear@25
|
151
|
nuclear@25
|
152 goat3d_free(goat);
|
nuclear@5
|
153 return IMPEXP_SUCCESS;
|
nuclear@5
|
154 }
|
nuclear@5
|
155
|
nuclear@25
|
156 static const char *max_string(const MCHAR *wstr)
|
nuclear@25
|
157 {
|
nuclear@25
|
158 if(!wstr) return 0;
|
nuclear@25
|
159 static char str[512];
|
nuclear@25
|
160 wcstombs(str, wstr, sizeof str - 1);
|
nuclear@25
|
161 return str;
|
nuclear@25
|
162 }
|
nuclear@25
|
163
|
nuclear@27
|
164 void GoatExporter::process_materials(goat3d *goat)
|
nuclear@5
|
165 {
|
nuclear@5
|
166 IGameProperty *prop;
|
nuclear@5
|
167
|
nuclear@5
|
168 int num_mtl = igame->GetRootMaterialCount();
|
nuclear@25
|
169 for(int i=0; i<num_mtl; i++) {
|
nuclear@25
|
170 IGameMaterial *maxmtl = igame->GetRootMaterial(i);
|
nuclear@25
|
171 if(maxmtl) {
|
nuclear@25
|
172 goat3d_material *mtl = goat3d_create_mtl();
|
nuclear@5
|
173
|
nuclear@25
|
174 const char *name = max_string(maxmtl->GetMaterialName());
|
nuclear@25
|
175 if(name) {
|
nuclear@25
|
176 goat3d_set_mtl_name(mtl, name);
|
nuclear@5
|
177 }
|
nuclear@5
|
178
|
nuclear@25
|
179 // diffuse
|
nuclear@25
|
180 if((prop = maxmtl->GetDiffuseData())) {
|
nuclear@25
|
181 Point3 diffuse(1, 1, 1);
|
nuclear@5
|
182 prop->GetPropertyValue(diffuse);
|
nuclear@25
|
183 goat3d_set_mtl_attrib3f(mtl, GOAT3D_MAT_ATTR_DIFFUSE, diffuse[0],
|
nuclear@25
|
184 diffuse[1], diffuse[2]);
|
nuclear@5
|
185 }
|
nuclear@25
|
186 // specular
|
nuclear@25
|
187 if((prop = maxmtl->GetSpecularData())) {
|
nuclear@25
|
188 Point3 specular(0, 0, 0);
|
nuclear@5
|
189 prop->GetPropertyValue(specular);
|
nuclear@25
|
190
|
nuclear@25
|
191 float sstr = 1.0;
|
nuclear@25
|
192 if((prop = maxmtl->GetSpecularLevelData())) {
|
nuclear@25
|
193 prop->GetPropertyValue(sstr);
|
nuclear@25
|
194 }
|
nuclear@25
|
195 goat3d_set_mtl_attrib3f(mtl, GOAT3D_MAT_ATTR_SPECULAR, specular[0] * sstr,
|
nuclear@25
|
196 specular[1] * sstr, specular[2] * sstr);
|
nuclear@5
|
197 }
|
nuclear@25
|
198 // shininess
|
nuclear@25
|
199 if((prop = maxmtl->GetGlossinessData())) {
|
nuclear@25
|
200 float shin;
|
nuclear@5
|
201 prop->GetPropertyValue(shin);
|
nuclear@25
|
202 goat3d_set_mtl_attrib1f(mtl, GOAT3D_MAT_ATTR_SHININESS, shin * 100.0);
|
nuclear@5
|
203 }
|
nuclear@5
|
204
|
nuclear@25
|
205 // textures
|
nuclear@25
|
206 for(int j=0; j<maxmtl->GetNumberOfTextureMaps(); j++) {
|
nuclear@25
|
207 IGameTextureMap *tex = maxmtl->GetIGameTextureMap(j);
|
nuclear@5
|
208
|
nuclear@25
|
209 const char *fname = max_string(tex->GetBitmapFileName());
|
nuclear@25
|
210 if(!fname) {
|
nuclear@25
|
211 continue;
|
nuclear@25
|
212 }
|
nuclear@25
|
213
|
nuclear@25
|
214 int slot = tex->GetStdMapSlot();
|
nuclear@25
|
215 switch(slot) {
|
nuclear@25
|
216 case ID_DI: // diffuse
|
nuclear@25
|
217 goat3d_set_mtl_attrib_map(mtl, GOAT3D_MAT_ATTR_DIFFUSE, fname);
|
nuclear@25
|
218 break;
|
nuclear@25
|
219
|
nuclear@25
|
220 case ID_SP:
|
nuclear@25
|
221 case ID_SS:
|
nuclear@25
|
222 goat3d_set_mtl_attrib_map(mtl, GOAT3D_MAT_ATTR_SPECULAR, fname);
|
nuclear@25
|
223 break;
|
nuclear@25
|
224
|
nuclear@25
|
225 case ID_SH:
|
nuclear@25
|
226 goat3d_set_mtl_attrib_map(mtl, GOAT3D_MAT_ATTR_SHININESS, fname);
|
nuclear@25
|
227 break;
|
nuclear@25
|
228
|
nuclear@25
|
229 case ID_BU:
|
nuclear@25
|
230 goat3d_set_mtl_attrib_map(mtl, GOAT3D_MAT_ATTR_NORMAL, fname);
|
nuclear@25
|
231 break;
|
nuclear@25
|
232
|
nuclear@25
|
233 case ID_RL:
|
nuclear@25
|
234 goat3d_set_mtl_attrib_map(mtl, GOAT3D_MAT_ATTR_REFLECTION, fname);
|
nuclear@25
|
235 break;
|
nuclear@25
|
236
|
nuclear@25
|
237 case ID_RR:
|
nuclear@25
|
238 goat3d_set_mtl_attrib_map(mtl, GOAT3D_MAT_ATTR_TRANSMISSION, fname);
|
nuclear@25
|
239 break;
|
nuclear@25
|
240
|
nuclear@25
|
241 default:
|
nuclear@25
|
242 break;
|
nuclear@5
|
243 }
|
nuclear@5
|
244 }
|
nuclear@25
|
245
|
nuclear@25
|
246 goat3d_add_mtl(goat, mtl);
|
nuclear@28
|
247 mtlmap[maxmtl] = mtl;
|
nuclear@5
|
248 }
|
nuclear@5
|
249 }
|
nuclear@25
|
250 }
|
nuclear@5
|
251
|
nuclear@27
|
252 void GoatExporter::process_node(goat3d *goat, goat3d_node *parent, IGameNode *maxnode)
|
nuclear@25
|
253 {
|
nuclear@27
|
254 goat3d_node *node = goat3d_create_node();
|
nuclear@27
|
255 goat3d_add_node(goat, node);
|
nuclear@25
|
256
|
nuclear@27
|
257 const char *name = max_string(maxnode->GetName());
|
nuclear@27
|
258 if(name) {
|
nuclear@27
|
259 goat3d_set_node_name(node, name);
|
nuclear@27
|
260 }
|
nuclear@27
|
261
|
nuclear@27
|
262 // no animation yet, just get the static PRS
|
nuclear@27
|
263 GMatrix maxmatrix = maxnode->GetObjectTM();
|
nuclear@27
|
264 Point3 trans = maxmatrix.Translation();
|
nuclear@27
|
265 Quat rot = maxmatrix.Rotation();
|
nuclear@27
|
266 Point3 scale = maxmatrix.Scaling();
|
nuclear@27
|
267
|
nuclear@27
|
268 goat3d_set_node_position(node, trans.x, trans.y, trans.z, 0);
|
nuclear@27
|
269 goat3d_set_node_rotation(node, rot.x, rot.y, rot.z, rot.w, 0);
|
nuclear@27
|
270 goat3d_set_node_scaling(node, scale.x, scale.y, scale.z, 0);
|
nuclear@27
|
271
|
nuclear@27
|
272 IGameObject *maxobj = maxnode->GetIGameObject();
|
nuclear@27
|
273 IGameObject::ObjectTypes type = maxobj->GetIGameType();
|
nuclear@27
|
274
|
nuclear@27
|
275 switch(type) {
|
nuclear@27
|
276 case IGameObject::IGAME_MESH:
|
nuclear@27
|
277 {
|
nuclear@27
|
278 goat3d_mesh *mesh = goat3d_create_mesh();
|
nuclear@27
|
279 if(name) goat3d_set_mesh_name(mesh, name);
|
nuclear@27
|
280 goat3d_set_node_object(node, GOAT3D_NODE_MESH, mesh);
|
nuclear@27
|
281
|
nuclear@27
|
282 // get the node material and assign it to the mesh
|
nuclear@27
|
283 IGameMaterial *maxmtl = maxnode->GetNodeMaterial();
|
nuclear@28
|
284 goat3d_material *mtl = mtlmap[maxmtl];
|
nuclear@27
|
285 if(mtl) {
|
nuclear@27
|
286 goat3d_set_mesh_mtl(mesh, mtl);
|
nuclear@27
|
287 }
|
nuclear@27
|
288
|
nuclear@27
|
289 process_mesh(goat, mesh, maxobj);
|
nuclear@30
|
290 goat3d_add_mesh(goat, mesh);
|
nuclear@27
|
291 }
|
nuclear@27
|
292 break;
|
nuclear@27
|
293
|
nuclear@27
|
294 case IGameObject::IGAME_LIGHT:
|
nuclear@27
|
295 {
|
nuclear@27
|
296 goat3d_light *light = goat3d_create_light();
|
nuclear@27
|
297 //if(name) goat3d_set_light_name(light, name);
|
nuclear@27
|
298 goat3d_set_node_object(node, GOAT3D_NODE_LIGHT, light);
|
nuclear@27
|
299
|
nuclear@27
|
300 process_light(goat, light, maxobj);
|
nuclear@30
|
301 goat3d_add_light(goat, light);
|
nuclear@27
|
302 }
|
nuclear@27
|
303 break;
|
nuclear@27
|
304
|
nuclear@27
|
305 case IGameObject::IGAME_CAMERA:
|
nuclear@27
|
306 {
|
nuclear@27
|
307 goat3d_camera *cam = goat3d_create_camera();
|
nuclear@27
|
308 //if(name) goat3d_set_camera_name(camera, name);
|
nuclear@27
|
309 goat3d_set_node_object(node, GOAT3D_NODE_CAMERA, cam);
|
nuclear@27
|
310
|
nuclear@27
|
311 process_camera(goat, cam, maxobj);
|
nuclear@30
|
312 goat3d_add_camera(goat, cam);
|
nuclear@27
|
313 }
|
nuclear@27
|
314 break;
|
nuclear@27
|
315
|
nuclear@27
|
316 default:
|
nuclear@27
|
317 // otherwise don't assign an object, essentially treating it as a null node
|
nuclear@27
|
318 break;
|
nuclear@27
|
319 }
|
nuclear@27
|
320
|
nuclear@27
|
321
|
nuclear@27
|
322 for(int i=0; i<maxnode->GetChildCount(); i++) {
|
nuclear@27
|
323 process_node(goat, node, maxnode->GetNodeChild(i));
|
nuclear@25
|
324 }
|
nuclear@5
|
325 }
|
nuclear@5
|
326
|
nuclear@27
|
327 void GoatExporter::process_mesh(goat3d *goat, goat3d_mesh *mesh, IGameObject *maxobj)
|
nuclear@27
|
328 {
|
nuclear@27
|
329 IGameMesh *maxmesh = (IGameMesh*)maxobj;
|
nuclear@27
|
330
|
nuclear@27
|
331 maxmesh->SetCreateOptimizedNormalList(); // not needed any more according to docs
|
nuclear@27
|
332 maxobj->InitializeData();
|
nuclear@27
|
333
|
nuclear@27
|
334 int num_verts = maxmesh->GetNumberOfVerts();
|
nuclear@30
|
335 int num_faces = maxmesh->GetNumberOfFaces();
|
nuclear@28
|
336 //assert(maxmesh->GetNumberOfTexVerts() == num_verts);
|
nuclear@27
|
337
|
nuclear@27
|
338 float *vertices = new float[num_verts * 3];
|
nuclear@27
|
339 float *normals = new float[num_verts * 3];
|
nuclear@28
|
340 //float *texcoords = new float[num_verts * 2];
|
nuclear@30
|
341 int *indices = new int[num_faces * 3];
|
nuclear@27
|
342
|
nuclear@27
|
343 for(int i=0; i<num_verts; i++) {
|
nuclear@27
|
344 Point3 v = maxmesh->GetVertex(i, true);
|
nuclear@27
|
345 vertices[i * 3] = v.x;
|
nuclear@27
|
346 vertices[i * 3 + 1] = v.y;
|
nuclear@27
|
347 vertices[i * 3 + 2] = v.z;
|
nuclear@27
|
348 }
|
nuclear@27
|
349
|
nuclear@27
|
350 for(int i=0; i<maxmesh->GetNumberOfNormals(); i++) {
|
nuclear@27
|
351 Point3 norm = maxmesh->GetNormal(i);
|
nuclear@27
|
352
|
nuclear@27
|
353 int vidx = maxmesh->GetNormalVertexIndex(i);
|
nuclear@27
|
354 normals[vidx * 3] = norm.x;
|
nuclear@27
|
355 normals[vidx * 3 + 1] = norm.y;
|
nuclear@27
|
356 normals[vidx * 3 + 2] = norm.z;
|
nuclear@27
|
357 }
|
nuclear@27
|
358
|
nuclear@28
|
359 /*for(int i=0; i<maxmesh->GetNumberOfTexVerts(); i++) {
|
nuclear@27
|
360 Point3 tex = maxmesh->GetTexVertex(i);
|
nuclear@27
|
361
|
nuclear@27
|
362 texcoords[i * 2] = tex.x;
|
nuclear@27
|
363 texcoords[i * 2 + 1] = tex.y;
|
nuclear@28
|
364 }*/
|
nuclear@27
|
365
|
nuclear@30
|
366 // get the faces
|
nuclear@30
|
367 for(int i=0; i<num_faces; i++) {
|
nuclear@30
|
368 FaceEx *face = maxmesh->GetFace(i);
|
nuclear@30
|
369 indices[i * 3] = face->vert[0];
|
nuclear@30
|
370 indices[i * 3 + 1] = face->vert[1];
|
nuclear@30
|
371 indices[i * 3 + 2] = face->vert[2];
|
nuclear@30
|
372 // TODO at some point I'll have to split based on normal/texcoord indices
|
nuclear@30
|
373 }
|
nuclear@30
|
374
|
nuclear@27
|
375 goat3d_set_mesh_attribs(mesh, GOAT3D_MESH_ATTR_VERTEX, vertices, num_verts);
|
nuclear@27
|
376 goat3d_set_mesh_attribs(mesh, GOAT3D_MESH_ATTR_NORMAL, normals, num_verts);
|
nuclear@28
|
377 //goat3d_set_mesh_attribs(mesh, GOAT3D_MESH_ATTR_TEXCOORD, texcoords, num_verts);
|
nuclear@30
|
378 goat3d_set_mesh_faces(mesh, indices, num_faces);
|
nuclear@27
|
379
|
nuclear@27
|
380 delete [] vertices;
|
nuclear@27
|
381 delete [] normals;
|
nuclear@28
|
382 //delete [] texcoords;
|
nuclear@30
|
383 delete [] indices;
|
nuclear@27
|
384 }
|
nuclear@27
|
385
|
nuclear@27
|
386 void GoatExporter::process_light(goat3d *goat, goat3d_light *light, IGameObject *maxobj)
|
nuclear@27
|
387 {
|
nuclear@27
|
388 }
|
nuclear@27
|
389
|
nuclear@27
|
390 void GoatExporter::process_camera(goat3d *goat, goat3d_camera *cam, IGameObject *maxobj)
|
nuclear@27
|
391 {
|
nuclear@27
|
392 }
|
nuclear@27
|
393
|
nuclear@27
|
394
|
nuclear@5
|
395 // ------------------------------------------
|
nuclear@5
|
396
|
nuclear@5
|
397 class GoatClassDesc : public ClassDesc2 {
|
nuclear@5
|
398 public:
|
nuclear@5
|
399 int IsPublic() { return TRUE; }
|
nuclear@5
|
400 void *Create(BOOL loading = FALSE) { return new GoatExporter; }
|
nuclear@5
|
401 const TCHAR *ClassName() { return L"GoatExporter"; }
|
nuclear@5
|
402 SClass_ID SuperClassID() { return SCENE_EXPORT_CLASS_ID; }
|
nuclear@5
|
403 Class_ID ClassID() { return Class_ID(0x77050f0d, 0x7d4c5ab5); }
|
nuclear@5
|
404 const TCHAR *Category() { return L"Mutant Stargoat"; }
|
nuclear@5
|
405
|
nuclear@5
|
406 const TCHAR *InternalName() { return L"GoatExporter"; }
|
nuclear@5
|
407 HINSTANCE HInstance() { return hinst; }
|
nuclear@5
|
408 };
|
nuclear@5
|
409
|
nuclear@58
|
410 // TODO: make 2 class descriptors, one for goat3d, one for goat3danim
|
nuclear@5
|
411 static GoatClassDesc class_desc;
|
nuclear@5
|
412
|
nuclear@5
|
413 BOOL WINAPI DllMain(HINSTANCE inst_handle, ULONG reason, void *reserved)
|
nuclear@5
|
414 {
|
nuclear@5
|
415 if(reason == DLL_PROCESS_ATTACH) {
|
nuclear@5
|
416 hinst = inst_handle;
|
nuclear@5
|
417 DisableThreadLibraryCalls(hinst);
|
nuclear@5
|
418 }
|
nuclear@5
|
419 return TRUE;
|
nuclear@5
|
420 }
|
nuclear@5
|
421
|
nuclear@5
|
422 extern "C" {
|
nuclear@5
|
423
|
nuclear@5
|
424 __declspec(dllexport) const TCHAR *LibDescription()
|
nuclear@5
|
425 {
|
nuclear@5
|
426 return L"test exporter";
|
nuclear@5
|
427 }
|
nuclear@5
|
428
|
nuclear@5
|
429 __declspec(dllexport) int LibNumberClasses()
|
nuclear@5
|
430 {
|
nuclear@5
|
431 return 1;
|
nuclear@5
|
432 }
|
nuclear@5
|
433
|
nuclear@5
|
434 __declspec(dllexport) ClassDesc *LibClassDesc(int i)
|
nuclear@5
|
435 {
|
nuclear@5
|
436 return i == 0 ? &class_desc : 0;
|
nuclear@5
|
437 }
|
nuclear@5
|
438
|
nuclear@5
|
439 __declspec(dllexport) ULONG LibVersion()
|
nuclear@5
|
440 {
|
nuclear@5
|
441 return Get3DSMAXVersion();
|
nuclear@5
|
442 }
|
nuclear@5
|
443
|
nuclear@5
|
444 __declspec(dllexport) int LibInitialize()
|
nuclear@5
|
445 {
|
nuclear@5
|
446 static char path[1024];
|
nuclear@5
|
447
|
nuclear@5
|
448 SHGetFolderPathA(0, CSIDL_PERSONAL, 0, 0, path);
|
nuclear@5
|
449 strcat(path, "/testexp.log");
|
nuclear@5
|
450
|
nuclear@5
|
451 if((logfile = fopen(path, "w"))) {
|
nuclear@5
|
452 setvbuf(logfile, 0, _IONBF, 0);
|
nuclear@5
|
453 }
|
nuclear@5
|
454 return TRUE;
|
nuclear@5
|
455 }
|
nuclear@5
|
456
|
nuclear@5
|
457 __declspec(dllexport) int LibShutdown()
|
nuclear@5
|
458 {
|
nuclear@5
|
459 if(logfile) {
|
nuclear@5
|
460 fclose(logfile);
|
nuclear@5
|
461 logfile = 0;
|
nuclear@5
|
462 }
|
nuclear@5
|
463 return TRUE;
|
nuclear@5
|
464 }
|
nuclear@5
|
465
|
nuclear@5
|
466 } // extern "C" |