Main.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #include <Ogre.h>
  2. #include "common/OgreBase.h"
  3. #include "common/Logger.h"
  4. #include "BsxFile.h"
  5. #include "DatFile.h"
  6. std::vector< Field > fields;
  7. void
  8. fill_names()
  9. {
  10. Unit unit;
  11. unit.name = "";
  12. Field field;
  13. Ogre::ConfigFile cf;
  14. cf.load( "export.cfg" );
  15. Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
  16. while( seci.hasMoreElements() )
  17. {
  18. field.name = seci.peekNextKey();
  19. Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
  20. if( field.name != "" )
  21. {
  22. Ogre::ConfigFile::SettingsMultiMap::iterator i;
  23. for( i = settings->begin(); i != settings->end(); ++i )
  24. {
  25. if( i->second != "" )
  26. {
  27. Ogre::StringVector export_data = Ogre::StringUtil::split( i->second, ":", 1 );
  28. unit.name = export_data[ 0 ];
  29. Ogre::StringVector animations = Ogre::StringUtil::split( export_data[ 1 ], ",", 0 );
  30. //LOGGER->Log(LOGGER_INFO, "Export %s: %s", field.name.c_str(), unit.name.c_str());
  31. for( int i = 0; i < animations.size(); ++i )
  32. {
  33. unit.animations.push_back( animations[ i ] );
  34. }
  35. }
  36. field.units.push_back(unit);
  37. unit.name = "";
  38. unit.animations.clear();
  39. }
  40. //LOGGER->Log(LOGGER_INFO, "Add export field %s", field.name.c_str());
  41. fields.push_back(field);
  42. field.units.clear();
  43. }
  44. }
  45. }
  46. int
  47. main( int argc, char *argv[] )
  48. {
  49. InitializeOgreBase( "FFVII Field Model Exporter" );
  50. fill_names();
  51. for( int f = 0; f < fields.size(); ++f )
  52. {
  53. BsxFile model( "data/field/" + fields[ f ].name + ".bsx" );
  54. DatFile dat( "data/field/" + fields[ f ].name + ".dat" );
  55. for( int i = 0; i < fields[ f ].units.size(); ++i )
  56. {
  57. if( fields[ f ].units[ i ].name != "" )
  58. {
  59. Ogre::Entity* entity = NULL;
  60. for( int j = 0; j < entitys.size(); ++j )
  61. {
  62. if( fields[ f ].units[ i ].name == entitys[ j ]->getName() )
  63. {
  64. entity = entitys[ j ];
  65. }
  66. }
  67. DatModelData data;
  68. dat.GetModelData( i, data );
  69. Ogre::Entity* exported_entity = model.GetModel( entity, i, fields[ f ].units[ i ], data );
  70. if( exported_entity != NULL )
  71. {
  72. entitys.push_back( exported_entity );
  73. }
  74. }
  75. }
  76. }
  77. entitys[ 0 ]->setVisible(true);
  78. Ogre::Root::getSingleton().startRendering();
  79. DeinitializeOgreBase();
  80. return 0;
  81. }