Back to index

supertuxkart  0.5+dfsg1
loader.hpp
Go to the documentation of this file.
00001 //  $Id: loader.hpp 1610 2008-03-01 03:18:53Z hikerstk $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2004 Steve Baker <sjbaker1@airmail.net>
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #ifndef HEADER_LOADER_H
00021 #define HEADER_LOADER_H
00022 
00023 #include <plib/ssg.h>
00024 #include <string>
00025 #include <vector>
00026 #include <set>
00027 #include "callback_manager.hpp"
00028 
00029 class Loader : public ssgLoaderOptions
00030 {
00031 private:
00032     bool                        m_is_full_path;
00033     std::string                 m_root_dir;
00034     std::vector<std::string>    m_texture_search_path,
00035                                 m_model_search_path,
00036                                 m_music_search_path;
00037     bool findFile               (std::string& full_path,
00038                                  const std::string& fname, 
00039                                  const std::vector<std::string>& search_path) const;
00040 public:
00041     Loader();
00042     ~Loader();
00043 
00044     virtual void makeModelPath  (char* path, const char* fname) const;
00045 
00046     ssgEntity *load(const std::string& filename, CallbackType t, bool optimise=true,
00047                     bool is_full_path=false);
00048     void         setCallbackType(CallbackType t)   {m_current_callback_type=t;}
00049 private:
00050     CallbackType m_current_callback_type;
00051 
00052     void         makePath     (std::string& path, const std::string& dir, 
00053                                const std::string& fname) const;
00054     ssgBranch   *createBranch (char *data) const;
00055     void         preProcessObj( ssgEntity *n, bool mirror );
00056     ssgBranch   *animInit     (char *data) const;
00057 };
00058 
00059 extern Loader* loader;
00060 
00061 #endif
00062