| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- #include <fstream>
- //#include <boost/test/unit_test.hpp>
- #include <Ogre.h>
- #include "common/TypeDefine.h"
- #include "data/worldmap/MapFileSerializer.h"
- #include "data/worldmap/MapFile.h"
- #include "data/worldmap/MapFileManager.h"
- #include "data/VGearsTexCodec.h"
- #include <functional>
- #include "data/VGearsLGPArchiveFactory.h"
- using namespace Ogre;
- static void createReferenceFileInstance(std::function<void(Ogre::DataStreamPtr& stream, VGears::WorldMapFile& file)> callBack)
- {
- class TestFile : public VGears::WorldMapFile
- {
- public:
- TestFile() : VGears::WorldMapFile( NULL, "", 0, "" ) {}
- };
- const char* file_name = "/home/paul/vgears/v-gears/Tests/FinalFantasy7/misc/reference.map";
- std::ifstream ifs( file_name, std::ifstream::binary );
- {
- // BOOST_REQUIRE( ifs.is_open() );
- Ogre::DataStreamPtr stream( OGRE_NEW Ogre::FileStreamDataStream( &ifs, false ) );
- // BOOST_REQUIRE( stream->isReadable() );
- //Ogre::LogManager log;
- TestFile f;
- // log.createLog( "Default Log", true, true, true );
- callBack(stream, f);
- // log.destroyLog( "Default Log" );
- }
- }
- /*
- BOOST_AUTO_TEST_CASE( file_size_is_multiple_of_block_size )
- {
- createReferenceFileInstance([&](Ogre::DataStreamPtr& stream, VGears::WorldMapFile& file)
- {
- VGears::MapFileSerializer s;
- s.importMapFile( stream, file );
- });
- }
- // compare meshes to hand picked data that we know should be in the block
- BOOST_AUTO_TEST_CASE( parse_16_meshes_in_one_block )
- {
- }
- BOOST_AUTO_TEST_CASE( parsing_whole_map )
- {
- }
- BOOST_AUTO_TEST_CASE( replace_story_meshes )
- {
- }
- */
- Camera *mainCam = nullptr;
- class GameFrameListener : public Ogre::FrameListener
- {
- public:
- using Ogre::FrameListener::FrameListener;
- bool frameStarted( const Ogre::FrameEvent& evt )
- {
- auto pos = mainCam->getPosition();
- //pos.x += 1.0f;
- //pos.z += 1.0f;
- mainCam->setPosition(pos);
- return true;
- }
- };
- int main(int argc, char **argv)
- {
- Root *root = new Root();
- // choose renderer
- // IVV
- /*if(!root->showConfigDialog())
- {
- return 0;
- }*/
- // initialise root
- root->initialise(false);
- // create main window
- RenderWindow *renderWindow = root->createRenderWindow("Main",320,240,false);
- // create the scene
- SceneManager *sceneMgr = root->createSceneManager(Ogre::ST_GENERIC);
- // add a camera
- mainCam = sceneMgr->createCamera("MainCam");
- // add viewport
- Viewport *vp = renderWindow->addViewport(mainCam);
- Ogre::ArchiveManager::getSingleton().addArchiveFactory( new VGears::LGPArchiveFactory() );
- Ogre::TextureManager* tm = root->getTextureManager();
- VGears::MapFileManager* worldManager = new VGears::MapFileManager();
- ResourceGroupManager::getSingleton().addResourceLocation(".", "FileSystem");
- ResourceGroupManager::getSingleton().addResourceLocation("/home/paul/vgears/data/cd1pc/wm", "FileSystem", "TEST");
- ResourceGroupManager::getSingleton().addResourceLocation("/home/paul/vgears/data/cd1pc/wm/world_us.lgp", VGears::LGPArchiveFactory::ARCHIVE_TYPE, "TEST");
- VGears::TexCodec::install();
- VGears::TexCodec::initialise();
- ResourceGroupManager::getSingleton().declareResource("bridge.tex", "Texture", "TEST");
- ResourceGroupManager::getSingleton().declareResource("wm0.map", VGears::WorldMapFile::RESOURCE_TYPE, "TEST");
- ResourceGroupManager::getSingleton().declareResource("wm1.map", VGears::WorldMapFile::RESOURCE_TYPE, "TEST");
- ResourceGroupManager::getSingleton().declareResource("wm2.map", VGears::WorldMapFile::RESOURCE_TYPE, "TEST");
- ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
- Ogre::ResourcePtr f = worldManager->load("wm0.map", "TEST");
- //worldManager->load("wm/wm0.map", "TEST");
- TexturePtr p = tm->load("bridge.tex", "TEST");
- int th = p->getSrcHeight();
- int tw = p->getSrcWidth();
- /*
- GameFrameListener *frameListener= new GameFrameListener();
- // frameListener->showDebugOverlay(true);
- // Create an Entity
- Ogre::Entity* ogreHead = sceneMgr->createEntity("axes", "axes.mesh");
- // Create a SceneNode and attach the Entity to it
- Ogre::SceneNode* headNode = sceneMgr->getRootSceneNode()->createChildSceneNode("HeadNode");
- headNode->attachObject(ogreHead);
- headNode->setPosition( 0, 0, 0 );
- // createColourCube(sceneMgr);
- mainCam->setPolygonMode(PM_WIREFRAME);
- mainCam->setFarClipDistance(900000.0f);
- mainCam->setPosition( 50, 500, 500 );
- mainCam->lookAt( 0, 0, 0);
- root->addFrameListener(frameListener);
- root->startRendering();
- */
- return 0;
- }
|