Created
October 8, 2018 18:09
-
-
Save Benau/0d6256785267900acf09d0916fb13fd9 to your computer and use it in GitHub Desktop.
replace main.cpp in stk-editor for universal mesh file to obj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <irrlicht.h> | |
#include <string> | |
#include <iostream> | |
#include "../lib/irrlicht/source/Irrlicht/COBJMeshWriter.h" | |
#include "spm/sp_mesh_loader.hpp" | |
int main(int argc, char* argv[]) | |
{ | |
if (argc != 2) | |
{ | |
std::cout << "Usage objmaker mesh.xxx" << std::endl; | |
return 0; | |
} | |
using namespace irr; | |
IrrlichtDevice* device = createDevice(video::EDT_NULL); | |
if (!device) | |
exit(-1); | |
scene::ISceneManager* sm = device->getSceneManager(); | |
SPMeshLoader* spml = new SPMeshLoader(sm); | |
sm->addExternalMeshLoader(spml); | |
spml->drop(); | |
std::string str = argv[1]; | |
scene::IAnimatedMesh* mesh = sm->getMesh(str.c_str()); | |
if (!mesh) | |
exit(-1); | |
size_t lastindex = str.find_last_of("."); | |
std::string new_name = str.substr(0, lastindex); | |
new_name += ".obj"; | |
io::IWriteFile* write = sm->getFileSystem()->createAndWriteFile(new_name.c_str()); | |
if (!write) | |
exit(-1); | |
scene::COBJMeshWriter* mw = new scene::COBJMeshWriter(sm, sm->getFileSystem()); | |
mw->writeMesh(write, mesh); | |
mw->drop(); | |
write->drop(); | |
device->drop(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment