X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=plugins%2Fmodel%2Fplugin.cpp;h=d23809a6571a2514675542229a66bb4f78e55af4;hb=a8192282200b4691a016c4f7757638cbb132f2dc;hp=4fe73b01a7a9f1fae0b804d3af02153b4355a19d;hpb=231225d6f97d0b926b2e896e5783cccfbc7c5619;p=xonotic%2Fnetradiant.git diff --git a/plugins/model/plugin.cpp b/plugins/model/plugin.cpp index 4fe73b01..d23809a6 100644 --- a/plugins/model/plugin.cpp +++ b/plugins/model/plugin.cpp @@ -1,25 +1,23 @@ /* -Copyright (C) 2001-2006, William Joseph. -All Rights Reserved. + Copyright (C) 2001-2006, William Joseph. + All Rights Reserved. -This file is part of GtkRadiant. + This file is part of GtkRadiant. -GtkRadiant is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + GtkRadiant is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -GtkRadiant is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + GtkRadiant is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with GtkRadiant; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "plugin.h" + You should have received a copy of the GNU General Public License + along with GtkRadiant; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #include #include "picomodel.h" @@ -46,46 +44,43 @@ typedef unsigned char byte; #include "model.h" -void PicoPrintFunc( int level, const char *str ) -{ - if( str == 0 ) +void PicoPrintFunc( int level, const char *str ){ + if ( str == 0 ) { return; - switch( level ) + } + switch ( level ) { - case PICO_NORMAL: - globalOutputStream() << str << "\n"; - break; - - case PICO_VERBOSE: - //globalOutputStream() << "PICO_VERBOSE: " << str << "\n"; - break; - - case PICO_WARNING: - globalErrorStream() << "PICO_WARNING: " << str << "\n"; - break; - - case PICO_ERROR: - globalErrorStream() << "PICO_ERROR: " << str << "\n"; - break; - - case PICO_FATAL: - globalErrorStream() << "PICO_FATAL: " << str << "\n"; - break; + case PICO_NORMAL: + globalOutputStream() << str << "\n"; + break; + + case PICO_VERBOSE: + //globalOutputStream() << "PICO_VERBOSE: " << str << "\n"; + break; + + case PICO_WARNING: + globalErrorStream() << "PICO_WARNING: " << str << "\n"; + break; + + case PICO_ERROR: + globalErrorStream() << "PICO_ERROR: " << str << "\n"; + break; + + case PICO_FATAL: + globalErrorStream() << "PICO_FATAL: " << str << "\n"; + break; } } -void PicoLoadFileFunc( const char *name, byte **buffer, int *bufSize ) -{ - *bufSize = vfsLoadFile( name, (void**) buffer); +void PicoLoadFileFunc( const char *name, byte **buffer, int *bufSize ){ + *bufSize = vfsLoadFile( name, (void**) buffer ); } -void PicoFreeFileFunc( void* file ) -{ - vfsFreeFile(file); +void PicoFreeFileFunc( void* file ){ + vfsFreeFile( file ); } -void pico_initialise() -{ +void pico_initialise(){ PicoInit(); PicoSetMallocFunc( malloc ); PicoSetFreeFunc( free ); @@ -97,68 +92,60 @@ void pico_initialise() class PicoModelLoader : public ModelLoader { - const picoModule_t* m_module; +const picoModule_t* m_module; public: - PicoModelLoader(const picoModule_t* module) : m_module(module) - { - } - scene::Node& loadModel(ArchiveFile& file) - { - return loadPicoModel(m_module, file); - } +PicoModelLoader( const picoModule_t* module ) : m_module( module ){ +} +scene::Node& loadModel( ArchiveFile& file ){ + return loadPicoModel( m_module, file ); +} }; class ModelPicoDependencies : - public GlobalFileSystemModuleRef, - public GlobalOpenGLModuleRef, - public GlobalUndoModuleRef, - public GlobalSceneGraphModuleRef, - public GlobalShaderCacheModuleRef, - public GlobalSelectionModuleRef, - public GlobalFiletypesModuleRef + public GlobalFileSystemModuleRef, + public GlobalOpenGLModuleRef, + public GlobalUndoModuleRef, + public GlobalSceneGraphModuleRef, + public GlobalShaderCacheModuleRef, + public GlobalSelectionModuleRef, + public GlobalFiletypesModuleRef { }; class ModelPicoAPI : public TypeSystemRef { - PicoModelLoader m_modelLoader; +PicoModelLoader m_modelLoader; public: - typedef ModelLoader Type; - - ModelPicoAPI(const char* extension, const picoModule_t* module) : - m_modelLoader(module) - { - StringOutputStream filter(128); - filter << "*." << extension; - GlobalFiletypesModule::getTable().addType(Type::Name(), extension, filetype_t(module->displayName, filter.c_str())); - } - ModelLoader* getTable() - { - return &m_modelLoader; - } +typedef ModelLoader Type; + +ModelPicoAPI( const char* extension, const picoModule_t* module ) : + m_modelLoader( module ){ + StringOutputStream filter( 128 ); + filter << "*." << extension; + GlobalFiletypesModule::getTable().addType( Type::Name(), extension, filetype_t( module->displayName, filter.c_str() ) ); +} +ModelLoader* getTable(){ + return &m_modelLoader; +} }; class PicoModelAPIConstructor { - CopiedString m_extension; - const picoModule_t* m_module; +CopiedString m_extension; +const picoModule_t* m_module; public: - PicoModelAPIConstructor(const char* extension, const picoModule_t* module) : - m_extension(extension), m_module(module) - { - } - const char* getName() - { - return m_extension.c_str(); - } - ModelPicoAPI* constructAPI(ModelPicoDependencies& dependencies) - { - return new ModelPicoAPI(m_extension.c_str(), m_module); - } - void destroyAPI(ModelPicoAPI* api) - { - delete api; - } +PicoModelAPIConstructor( const char* extension, const picoModule_t* module ) : + m_extension( extension ), m_module( module ){ +} +const char* getName(){ + return m_extension.c_str(); +} +ModelPicoAPI* constructAPI( ModelPicoDependencies& dependencies ){ + return new ModelPicoAPI( m_extension.c_str(), m_module ); +} +void destroyAPI( ModelPicoAPI* api ){ + delete api; +} }; @@ -167,23 +154,21 @@ typedef std::list PicoModelModules; PicoModelModules g_PicoModelModules; -extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server) -{ - initialiseModule(server); - - pico_initialise(); - - const picoModule_t** modules = PicoModuleList( 0 ); - while(*modules != 0) - { - const picoModule_t* module = *modules++; - if(module->canload && module->load) - { - for(char*const* ext = module->defaultExts; *ext != 0; ++ext) - { - g_PicoModelModules.push_back(PicoModelModule(PicoModelAPIConstructor(*ext, module))); - g_PicoModelModules.back().selfRegister(); - } - } - } +extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){ + initialiseModule( server ); + + pico_initialise(); + + const picoModule_t** modules = PicoModuleList( 0 ); + while ( *modules != 0 ) + { + const picoModule_t* module = *modules++; + if ( module->canload && module->load ) { + for ( char*const* ext = module->defaultExts; *ext != 0; ++ext ) + { + g_PicoModelModules.push_back( PicoModelModule( PicoModelAPIConstructor( *ext, module ) ) ); + g_PicoModelModules.back().selfRegister(); + } + } + } }