Added a command-line tool for access to the mesh writer modules.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1207 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
da2958a592
commit
e9fe5ab4b6
|
@ -0,0 +1,38 @@
|
|||
# Makefile for Irrlicht Examples
|
||||
# It's usually sufficient to change just the target name and source file list
|
||||
# and be sure that CXX is set to a valid compiler
|
||||
Target = MeshConverter
|
||||
Sources = main.cpp
|
||||
|
||||
# general compiler settings
|
||||
CPPFLAGS = -I../../include -I/usr/X11R6/include
|
||||
CXXFLAGS = -O3 -ffast-math -Wall
|
||||
#CXXFLAGS = -g -Wall
|
||||
|
||||
#default target is Linux
|
||||
all: all_linux
|
||||
|
||||
ifeq ($(HOSTTYPE), x86_64)
|
||||
LIBSELECT=64
|
||||
endif
|
||||
|
||||
# target specific settings
|
||||
all_linux: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L../../lib/Linux -lIrrlicht -lGL -lGLU -lXxf86vm -lXext -lX11
|
||||
all_linux clean_linux: SYSTEM=Linux
|
||||
all_win32: LDFLAGS = -L../../lib/Win32-gcc -lIrrlicht -lopengl32 -lglu32 -lm
|
||||
all_win32 clean_win32: SYSTEM=Win32-gcc
|
||||
all_win32 clean_win32: SUF=.exe
|
||||
# name of the binary - only valid for targets which set SYSTEM
|
||||
DESTPATH = ../../bin/$(SYSTEM)/$(Target)$(SUF)
|
||||
|
||||
all_linux all_win32:
|
||||
$(warning Building...)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(Sources) -o $(DESTPATH) $(LDFLAGS)
|
||||
|
||||
clean: clean_linux clean_win32
|
||||
$(warning Cleaning...)
|
||||
|
||||
clean_linux clean_win32:
|
||||
@$(RM) $(DESTPATH)
|
||||
|
||||
.PHONY: all all_win32 clean clean_linux clean_win32
|
|
@ -0,0 +1,67 @@
|
|||
#include <irrlicht.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
using namespace core;
|
||||
using namespace scene;
|
||||
using namespace video;
|
||||
using namespace io;
|
||||
using namespace gui;
|
||||
|
||||
#ifdef _IRR_WINDOWS_
|
||||
#pragma comment(lib, "Irrlicht.lib")
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if ((argc < 3) ||
|
||||
((argc==3) && (argv[1][0]=='-')))
|
||||
{
|
||||
std::cout << "Usage: " << argv[0] << " [--format=irrmesh|collada|stl] <srcFile> <destFile>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
IrrlichtDevice *device = createDevice( video::EDT_NULL,
|
||||
dimension2d<s32>(800, 600), 32, false, false, false, 0);
|
||||
|
||||
device->setWindowCaption(L"Image Converter");
|
||||
|
||||
IVideoDriver* driver = device->getVideoDriver();
|
||||
|
||||
scene::EMESH_WRITER_TYPE type = EMWT_IRR_MESH;
|
||||
u32 srcmesh = 1;
|
||||
u32 destmesh = 2;
|
||||
if (argv[1][0]=='-')
|
||||
{
|
||||
core::stringc format = argv[1];
|
||||
if ((format.size() > 3) && format.equalsn("--format=",9))
|
||||
{
|
||||
++srcmesh;
|
||||
++destmesh;
|
||||
format = format.subString(9,format.size());
|
||||
if (format=="collada")
|
||||
type = EMWT_COLLADA;
|
||||
else
|
||||
if (format=="stl")
|
||||
type = EMWT_STL;
|
||||
else
|
||||
type = EMWT_IRR_MESH;
|
||||
}
|
||||
}
|
||||
std::cout << "Converting " << argv[srcmesh] << " to " << argv[destmesh] << std::endl;
|
||||
IAnimatedMesh* mesh = device->getSceneManager()->getMesh(argv[srcmesh]);
|
||||
if (!mesh)
|
||||
{
|
||||
std::cerr << "Could not load " << argv[srcmesh] << std::endl;
|
||||
return 1;
|
||||
}
|
||||
IMeshWriter* mw = device->getSceneManager()->createMeshWriter(type);
|
||||
IWriteFile* file = device->getFileSystem()->createAndWriteFile(argv[destmesh]);
|
||||
mw->writeMesh(file, mesh->getMesh(0));
|
||||
file->drop();
|
||||
mw->drop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue