goat3d

annotate goatview/src/main.cc @ 76:9785847d52d4

bounding boxes calculation (untested) and automatic camera placement in goatview
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 08 May 2014 13:43:45 +0300
parents 76dea247f75c
children 70b7c41a4f17
rev   line source
nuclear@73 1 #include <QtWidgets/QtWidgets>
nuclear@75 2 #include <QtCore/QtCore>
nuclear@73 3 #include "goatview.h"
nuclear@73 4
nuclear@73 5 int main(int argc, char **argv)
nuclear@73 6 {
nuclear@73 7 QApplication app(argc, argv);
nuclear@75 8 app.setOrganizationName("Mutant Stargoat");
nuclear@75 9 app.setOrganizationDomain("mutantstargoat.com");
nuclear@75 10 app.setApplicationName("GoatView");
nuclear@75 11 settings = new QSettings;
nuclear@75 12
nuclear@75 13 QCommandLineParser argparse;
nuclear@75 14 argparse.addHelpOption();
nuclear@75 15
nuclear@75 16 argparse.addPositionalArgument("scene", "scene file to open");
nuclear@75 17 argparse.addOption(QCommandLineOption("a", "add animation file"));
nuclear@75 18 argparse.process(app);
nuclear@75 19
nuclear@75 20 const QStringList &args = argparse.positionalArguments();
nuclear@75 21 if(!args.isEmpty()) {
nuclear@75 22 if(args.count() > 1) {
nuclear@75 23 fprintf(stderr, "please specify at most one scene file to open\n");
nuclear@75 24 return 1;
nuclear@75 25 }
nuclear@75 26 std::string fname = args.at(0).toStdString();
nuclear@75 27 printf("loading scene file: %s ...\n", fname.c_str());
nuclear@76 28 if(!load_scene(fname.c_str())) {
nuclear@75 29 fprintf(stderr, "failed to load scene: %s\n", fname.c_str());
nuclear@75 30 return 1;
nuclear@75 31 }
nuclear@75 32 }
nuclear@75 33
nuclear@75 34 const QStringList &anims = argparse.values("a");
nuclear@75 35 QStringList::const_iterator it = anims.begin();
nuclear@75 36 while(it != anims.end()) {
nuclear@75 37 std::string fname = it++->toStdString();
nuclear@75 38 printf("loading animation file: %s ...\n", fname.c_str());
nuclear@75 39
nuclear@75 40 if(goat3d_load_anim(scene, fname.c_str()) == -1) {
nuclear@75 41 fprintf(stderr, "failed to load animation: %s\n", fname.c_str());
nuclear@75 42 return 1;
nuclear@75 43 }
nuclear@75 44 }
nuclear@73 45
nuclear@73 46 GoatView gview;
nuclear@73 47 gview.show();
nuclear@73 48
nuclear@73 49 return app.exec();
nuclear@73 50 }