3 #include <fegdk/f_error.h>
4 #include <fegdk/f_engine.h>
5 #include <fegdk/f_application.h>
6 #include <fegdk/f_console.h>
7 #include "simplemodel.h"
12 // Revision 1.10 2004/11/10 01:22:32 waker
15 // Revision 1.9 2003/11/09 10:56:47 waker
16 // changed copyright message, added engine support (due to memleaks)
18 // Revision 1.8 2003/06/10 10:02:00 waker
19 // fixed fgp to recompile under new engine rev
21 // Revision 1.7 2002/12/02 17:10:45 waker
22 // help fixed a bit, played with tgs data
24 // Revision 1.6 2002/12/02 12:05:03 waker
25 // help updated, tiny code cleanup took place
28 void nextarg (int &i
, int &argc
)
32 throw fe::genericError ("invalid command line");
35 void printCommandsHelp (void)
37 printf ("fgp commands are:\n");
38 printf ("\tmcvt\tconverts model from text .mdl format to binary .bmdl format\n");
39 printf ("\tsmd\tconverts model from text .mdl format to binary .smd format (simple model)\n");
40 printf ("\tnmap\tbuilds normalmap texture from pair of hi and low poly models\n");
41 printf (" (specify the --help global option for a list of other help options)\n");
44 void printOptionsHelp (void)
46 printf ("No options available.\n");
49 void printCommandHelp (const char *cmd
)
51 if (!strcmp (cmd
, "mcvt"))
53 printf ("Usage: fgp mcvt file.mdl\n");
55 else if (!strcmp (cmd
, "nmap"))
57 printf ("Usage: fgp nmap texwidth texheight hipoly poly\n");
59 else if (!strcmp (cmd
, "smd"))
61 printf ("Usage: fgp smd [-f [-be]] file.mdl\n");
62 printf (" -f fixed-point format\n");
63 printf (" -be big-endian byte order\n");
73 printf ("usage: fgp.exe [options] command [command-options-and-arguments]\n");
74 printf (" where options are [...], etc.\n");
75 printf (" (specify --help-options for a list of options)\n");
76 printf (" where command are nmap, mcvt, etc.\n");
77 printf (" (specify --help-commands for a list of commands)\n");
78 printf (" where command-options-and-arguments depend on the specific command\n");
79 printf (" (specify --help followed by a command name for command-specific help)\n");
80 printf (" specify --help to recieve this message\n");
81 printf ("\nfgp-%s (FE Geometry Processor)\n"), VERSION
;
82 printf ("written by waker (c) 2001-2005.\n");
83 printf ("licensed under the terms of GNU General Public License.\n");
86 int execute (int argc
, char *argv
[])
97 bool normalmap
= false;
104 bool convertmodel
= false;
108 bool convert_smd
= false;
112 for (int i
= 1; i
< argc
; i
++)
114 if (!strcmp (argv
[i
], "nmap"))
118 nmapw
= atoi (argv
[i
]);
120 nmaph
= atoi (argv
[i
]);
128 else if (!strcmp (argv
[i
], "mcvt"))
130 // convert model to binary fmt
132 printf ("setting mdlname to %s...\n", argv
[i
]);
137 else if (!strcmp (argv
[i
], "smd"))
139 // convert model to binary fmt
147 if (!strcmp (argv
[i
], "-f"))
148 smd_flags
|= SMF_FIXED
;
149 else if (!strcmp (argv
[i
], "-be"))
150 smd_flags
|= SMF_BIGENDIAN
;
159 else if (!strcmp (argv
[i
], "--help"))
167 printCommandHelp (argv
[i
]);
170 else if (!strcmp (argv
[i
], "--help-commands"))
172 printCommandsHelp ();
174 else if (!strcmp (argv
[i
], "--help-options"))
182 printf ("normalmap generation is temporarily disabled\n");
183 // ExportNormalMap (nmapw, nmaph, hipolymdl, lopolymdl);
187 ConvertModel (mdlname
);
190 ConvertSimpleModel (mdlname
, smd_flags
);
192 // MakeLevelFile (argc, argv);
196 class DummyApp
: public fe::application
205 void configure (void)
207 fe::g_engine
->getConsole ()->command ("sys_int_mainloop 0");
208 fe::g_engine
->getConsole ()->command ("sys_profile null");
216 const char* appName (void) const
218 return PACKAGE
" " VERSION
;
220 const char* dataPath (void) const
227 int main (int argc
, char *argv
[])
229 fe::engine
*eng
= new fe::engine ();
230 DummyApp
*app
= new DummyApp ();
231 eng
->run (app
, argc
, argv
);
232 int res
= execute (argc
, argv
);
234 #if defined(_DEBUG) && defined(_WIN32)
235 _CrtDumpMemoryLeaks ();