本文整理汇总了C++中MEngine::getTexturesAnimLoader方法的典型用法代码示例。如果您正苦于以下问题:C++ MEngine::getTexturesAnimLoader方法的具体用法?C++ MEngine::getTexturesAnimLoader怎么用?C++ MEngine::getTexturesAnimLoader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MEngine
的用法示例。
在下文中一共展示了MEngine::getTexturesAnimLoader方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
void MaratisPlayer::start(void)
{
// MEngine
{
MEngine * engine = MEngine::getInstance();
// package manager
engine->setPackageManager(m_packageManager);
m_packageManager->init();
// contexts
engine->setSoundContext(m_soundContext); // sound context
engine->setRenderingContext(m_render); // rendering context
engine->setPhysicsContext(m_physics); // physics context
engine->setScriptContext(m_script); // script context
engine->setInputContext(m_input); // input context
engine->setSystemContext(m_system); // system context
// loaders
engine->getImageLoader()->addLoader(M_loadImage); // image loader
engine->getSoundLoader()->addLoader(M_loadSound); // sound loader
engine->getLevelLoader()->addLoader(xmlLevelLoad); // level loader
engine->getFontLoader()->addLoader(M_loadFont); // font loader
engine->getFontLoader()->addLoader(M_loadBinFont); // bin font loader
// add behaviors
engine->getBehaviorManager()->addBehavior(MBLookAt::getStaticName(), M_OBJECT3D_CAMERA, MBLookAt::getNew);
engine->getBehaviorManager()->addBehavior(MBFollow::getStaticName(), M_OBJECT3D, MBFollow::getNew);
// add renderers
engine->getRendererManager()->addRenderer(MStandardRenderer::getStaticName(), MStandardRenderer::getNew);
engine->getRendererManager()->addRenderer(MFixedRenderer::getStaticName(), MFixedRenderer::getNew);
// mesh loader
engine->getMeshLoader()->addLoader(xmlMeshLoad);
engine->getMeshLoader()->addLoader(M_loadBinMesh);
engine->getArmatureAnimLoader()->addLoader(xmlArmatureAnimLoad);
engine->getArmatureAnimLoader()->addLoader(M_loadBinArmatureAnim);
engine->getTexturesAnimLoader()->addLoader(xmlTextureAnimLoad);
engine->getTexturesAnimLoader()->addLoader(M_loadBinTexturesAnim);
engine->getMaterialsAnimLoader()->addLoader(xmlMaterialAnimLoad);
engine->getMaterialsAnimLoader()->addLoader(M_loadBinMaterialsAnim);
// level
engine->setLevel(m_level);
// game
engine->setGame(m_game);
// set default renderer (standard)
if(m_renderer == NULL)
m_renderer = new MStandardRenderer();
engine->setRenderer(m_renderer);
engine->setSaveFileFactory(MSaveFileImpl::getNew);
}
}
示例2: update
void MTexturesAnimRef::update(void)
{
MEngine * engine = MEngine::getInstance();
if(! m_texturesAnim)
m_texturesAnim = MTexturesAnim::getNew();
engine->getTexturesAnimLoader()->loadData(getFilename(), m_texturesAnim);
}
示例3: clear
void MaratisPlayer::clear(void)
{
MEngine * engine = MEngine::getInstance();
// level
m_level->clear();
if(m_renderer){
m_renderer->destroy();
m_renderer = NULL;
}
// plugins
SAFE_DELETE(m_gamePlugin);
unsigned int i;
unsigned int pSize = m_plugins.size();
for(i=0; i<pSize; i++)
SAFE_DELETE(m_plugins[i]);
m_plugins.clear();
// MEngine
{
// loaders
engine->getImageLoader()->clear();
engine->getSoundLoader()->clear();
engine->getLevelLoader()->clear();
engine->getFontLoader()->clear();
engine->getFontLoader()->clear();
// behaviors
engine->getBehaviorManager()->clear();
// renderer
engine->getRendererManager()->clear();
// mesh loader
engine->getMeshLoader()->clear();
engine->getArmatureAnimLoader()->clear();
engine->getTexturesAnimLoader()->clear();
engine->getMaterialsAnimLoader()->clear();
}
}
示例4: execute
void execute(const char* projName)
{
MEngine* engine = MEngine::getInstance();
MSystemContext* system = engine->getSystemContext();
MPackageManager* packageManager = engine->getPackageManager();
char directory[256], localFilename[256];
getGlobalFilename(directory, system->getWorkingDirectory(), "meshs");
vector<string> files;
readDirectory(directory, &files, 1, 1);
MLevel* currentLevel = engine->getLevel();
MLevel* tempLevel = new MLevel();
engine->setLevel(tempLevel);
MMesh* mesh = MMesh::getNew();
MArmatureAnim* armAnim = MArmatureAnim::getNew();
MTexturesAnim* texAnim = MTexturesAnim::getNew();
MMaterialsAnim* matAnim = MMaterialsAnim::getNew();
// open package and scan meshes
MPackage package = openProjectPackage(projName);
for(int i = 0; i < files.size(); ++i)
{
bool binarized = false;
if(strstr(files[i].c_str(), "._bin") != 0)
continue;
// export bin
if(strstr(files[i].c_str(), ".mesh") != 0)
{
if(engine->getMeshLoader()->loadData(files[i].c_str(), mesh))
binarized = exportMeshBin((files[i] + "._bin").c_str(), mesh);
}
else if (strstr(files[i].c_str(), ".maa") != 0)
{
if(engine->getArmatureAnimLoader()->loadData(files[i].c_str(), armAnim))
binarized = exportArmatureAnimBin((files[i] + "._bin").c_str(), armAnim);
}
else if (strstr(files[i].c_str(), ".mma") != 0)
{
if(engine->getMaterialsAnimLoader()->loadData(files[i].c_str(), matAnim))
binarized = exportMaterialsAnimBin((files[i] + "._bin").c_str(), matAnim);
}
else if (strstr(files[i].c_str(), ".mta") != 0)
{
if(engine->getTexturesAnimLoader()->loadData(files[i].c_str(), texAnim))
binarized = exportTexturesAnimBin((files[i] + "._bin").c_str(), texAnim);
}
else
{
// try to export unknow format
if(engine->getMeshLoader()->loadData(files[i].c_str(), mesh))
{
binarized = exportMeshBin((files[i] + "._bin").c_str(), mesh);
// try to export animation
MArmatureAnimRef * maaRef = mesh->getArmatureAnimRef();
if(maaRef)
{
exportArmatureAnimBin((files[i] + ".maa._bin").c_str(), maaRef->getArmatureAnim());
getLocalFilename(localFilename, system->getWorkingDirectory(), (files[i] + ".maa").c_str());
packageManager->addFileToPackage((files[i] + ".maa._bin").c_str(), package, localFilename);
}
}
}
tempLevel->clear();
// pack file
getLocalFilename(localFilename, system->getWorkingDirectory(), files[i].c_str());
if(binarized)
packageManager->addFileToPackage((files[i] + "._bin").c_str(), package, localFilename); // pack bin file
else
packageManager->addFileToPackage(files[i].c_str(), package, localFilename); // pack original file
}
packageManager->closePackage(package);
// clear mesh
mesh->destroy();
armAnim->destroy();
texAnim->destroy();
matAnim->destroy();
// remove bin
for(int i = 0; i < files.size(); ++i)
{
remove((files[i] + "._bin").c_str());
remove((files[i] + ".maa._bin").c_str());
}
// restore level
engine->setLevel(currentLevel);
SAFE_DELETE(tempLevel);
}
示例5: main
// main
int main(int argc, char **argv)
{
setlocale(LC_NUMERIC, "C");
unsigned int width = 800;
unsigned int height = 400;
bool fullscreen = false;
// get engine
MEngine* engine = MEngine::getInstance();
// get window
MWindow* window = MWindow::getInstance();
window->setPointerEvent(windowEvents); // window events
// create window
if(! window->create("Maratis - ManualUse example", width, height, 32, fullscreen))
{
MLOG(4, "window create failed");
return 0;
}
if(fullscreen)
window->hideCursor();
// set current directory
{
char rep[256];
getRepertory(rep, argv[0]);
window->setCurrentDirectory(rep);
}
// create virtual contexts
MSoundContext * soundContext = new MALContext();
MRenderingContext * render = new MGLContext();
MPhysicsContext * physics = new MBulletContext();
MScriptContext * script = new MScript();
MInputContext * input = new MInput();
MSystemContext * system = new MWinContext();
MLOG(5, "Render version: " << render->getRendererVersion());
// create default Level and Game
MLevel * level = new MLevel();
MGame * game = new MyGame(); // MyGame
// init MEngine (you can replace all contexts by others and add or use different data loaders)
engine->setSoundContext(soundContext); // sound context
engine->setRenderingContext(render); // rendering context
engine->setPhysicsContext(physics); // physics context
engine->setScriptContext(script); // script context
engine->setInputContext(input); // input context
engine->setSystemContext(system); // system context
engine->getImageLoader()->addLoader(M_loadImage); // image loader
engine->getSoundLoader()->addLoader(M_loadSound); // sound loader
// engine->getLevelLoader()->addLoader(xmlLevelLoad); // level loader : uncomment if wanted
engine->getFontLoader()->addLoader(M_loadFont); // font loader
// engine->getFontLoader()->addLoader(M_loadBinFont); // bin font loader : uncomment if wanted
// add some default "Maratis" behaviors : uncomment if wanted or add custom
// engine->getBehaviorManager()->addBehavior(MBLookAt::getStaticName(), M_OBJECT3D_CAMERA, MBLookAt::getNew);
// engine->getBehaviorManager()->addBehavior(MBFollow::getStaticName(), M_OBJECT3D, MBFollow::getNew);
// add renderers
engine->getRendererManager()->addRenderer(MStandardRenderer::getStaticName(), MStandardRenderer::getNew);
engine->getRendererManager()->addRenderer(MFixedRenderer::getStaticName(), MFixedRenderer::getNew);
// mesh loader
engine->getMeshLoader()->addLoader(xmlMeshLoad);
engine->getArmatureAnimLoader()->addLoader(xmlArmatureAnimLoad);
engine->getTexturesAnimLoader()->addLoader(xmlTextureAnimLoad);
engine->getMaterialsAnimLoader()->addLoader(xmlMaterialAnimLoad);
// set level
engine->setLevel(level);
// set game
engine->setGame(game);
// set renderer (standard)
MRenderer * renderer = engine->getRendererManager()->getRendererByName("StandardRenderer")->getNewRenderer();
engine->setRenderer(renderer);
// begin game
game->begin();
// time
unsigned int frequency = 60;
unsigned long previousFrame = 0;
unsigned long startTick = window->getSystemTick();
// on events
while(window->isActive())
{
// on events
if(window->onEvents())
{
// compute target tick
//.........这里部分代码省略.........
示例6: main
// main
int main(int argc, char **argv)
{
setlocale(LC_NUMERIC, "C");
char dir[256];
getDirectory(dir, argv[0]);
MGUI_setCurrentDirectory(dir);
// get engine
MEngine *engine = MEngine::getInstance();
// init
if (!MGUI_init())
return EXIT_FAILURE;
// add loaders
M_initFreeImage();
engine->getImageLoader()->addLoader(M_loadImage); // image loader
//engine->getSoundLoader()->addLoader(M_loadSound); // sound loader
//engine->getLevelLoader()->addLoader(xmlLevelLoad); // level loader : uncomment if wanted
engine->getFontLoader()->addLoader(M_loadFont); // font loader
//engine->getFontLoader()->addLoader(M_loadBinFont); // bin font loader : uncomment if wanted
// mesh loader
engine->getMeshLoader()->addLoader(xmlMeshLoad);
engine->getArmatureAnimLoader()->addLoader(xmlArmatureAnimLoad);
engine->getTexturesAnimLoader()->addLoader(xmlTextureAnimLoad);
engine->getMaterialsAnimLoader()->addLoader(xmlMaterialAnimLoad);
// create main window
MWindow *window = MGUI_createWindow("Manual Use", 10, 10, 800, 600, winEvents);
if (!window)
{
MGUI_close();
M_closeFreeImage();
return EXIT_FAILURE;
}
window->setDrawCallback(drawCallback);
const float frequency = 60.0;
double currentTick, startTick = MGUI_getTime();
unsigned int numFrame = 0;
unsigned int currFrame = 0;
unsigned int prevFrame = startTick * frequency;
unsigned int steps, i;
// update
while (1)
{
++numFrame;
currentTick = MGUI_getTime();
if (currentTick - startTick >= 1.0)
{
startTick += 1.0;
MLOG(6, "fps: " << numFrame << ", ft: " << 1000.0f / numFrame << "ms");
numFrame = 0;
}
currFrame = currentTick * frequency;
steps = currFrame - prevFrame;
prevFrame = currFrame;
for (i = 0; i < steps; i++)
game->update();
if (!MGUI_update())
break;
}
MGUI_close();
M_closeFreeImage();
return EXIT_SUCCESS;
}