Main.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #include <Ogre.h>
  2. #include "../../common/OgreBase.h"
  3. #include "../../common/Logger.h"
  4. #include "ModelFile.h"
  5. std::vector< ModelInfo > models;
  6. void
  7. fill_names()
  8. {
  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. MeshData data;
  47. data.name = "zidane";
  48. data.tex_width = 512;
  49. data.tex_height = 256;
  50. ModelInfo model;
  51. model.data = data;
  52. model.animations.push_back( "5/1b/1/3/1.animation" ); model.animations_name.push_back( "Walk" );
  53. model.animations.push_back( "5/1b/1/3/2.animation" ); model.animations_name.push_back( "Run" );
  54. model.animations.push_back( "5/1b/1/3/3.animation" ); model.animations_name.push_back( "TurnLeft" );
  55. model.animations.push_back( "5/1b/1/3/4.animation" ); model.animations_name.push_back( "TurnRight" );
  56. model.animations.push_back( "5/1b/1/3/5.animation" ); model.animations_name.push_back( "Idle" );
  57. model.animations.push_back( "15.animation" ); model.animations_name.push_back( "Carry" );
  58. models.push_back( model );
  59. }
  60. int
  61. main( int argc, char* argv[] )
  62. {
  63. InitializeOgreBase( "FFIX Exporter" );
  64. fill_names();
  65. /*
  66. for( int f = 0; f < fields.size(); ++f )
  67. {
  68. BsxFile model( "data/field/" + fields[f].name + ".bsx" );
  69. DatFile dat( "data/field/" + fields[f].name + ".dat" );
  70. for (int i = 0; i < fields[f].units.size(); ++i)
  71. {
  72. if (fields[f].units[i].name != "")
  73. {
  74. Ogre::Entity* entity = NULL;
  75. for (int j = 0; j < entitys.size(); ++j)
  76. {
  77. if (fields[f].units[i].name == entitys[j]->getName())
  78. {
  79. entity = entitys[j];
  80. }
  81. }
  82. DatModelData data;
  83. dat.GetModelData(i, data);
  84. Ogre::Entity* exported_entity = model.GetModel(entity, i, fields[f].units[i], data);
  85. if (exported_entity != NULL)
  86. {
  87. entitys.push_back(exported_entity);
  88. }
  89. }
  90. }
  91. }
  92. entitys[ 0 ]->setVisible(true);
  93. */
  94. // TEMP
  95. ModelFile model( "./data/field/5/1b/1/2/1.model" ); // zidane
  96. Ogre::Entity* exported_entity = model.GetModel( models[ 0 ] );
  97. if( exported_entity != NULL )
  98. {
  99. entitys.push_back( exported_entity );
  100. entitys[ 0 ]->setVisible( true );
  101. }
  102. Ogre::Root::getSingleton().startRendering();
  103. DeinitializeOgreBase();
  104. return 0;
  105. }