//
//  SuperTuxKart - a fun racing game with go-kart
//  Copyright (C) 2009-2013 Joerg Henrichs
//
//  This program 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 3
//  of the License, or (at your option) any later version.
//
//  This program 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 this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

#ifndef HEADER_LOAD_MAP
#define HEADER_LOAD_MAP

#include <irrlicht.h>
#include <string>
#include <map>
#include <vector>

namespace irr
{
    namespace video { class ITexture; class SColor;       }
    namespace scene { class IMesh; class ILightSceneNode; }
}
using namespace irr;

#include <irrString.h>
#include <IXMLReader.h>
#include <SColor.h>
#include <vector2d.h>
#include <vector3d.h>
#include <path.h>
#include <iostream>


#include "../main.h"
#include "../utils/no_copy.h"
#include "../utils/log.h"
#include "../utils/types.h"
#include "../io/file_manager.h"
#include "../io/xml_node.h"





class Map
{


private:
             /** The base dir of all files of this track. */
    std::string              m_root;
    std::string              m_ident;
    std::string              m_dirname;
    std::string         m_name;


    /** The list of all nodes. */
    std::vector<scene::ISceneNode*> m_all_nodes;
    video::SColor       m_default_ambient_color;

    std::vector<scene::IMesh*>      m_all_cached_meshes;



public:
    Map(const std::string &dirname);
    void               update(float dt);
    void reset();

    bool checkNodeForTextures(irr::scene::IMesh * mesh);
    bool loadMainMap(const XMLNode &node);
    void               loadMapModel  ();

            // ------------------------------------------------------------------------
    /** Returns a unique identifier for this track (the directory name). */
    const std::string& getIdent          () const {return m_ident;            }

    void               removeCachedData  ();

            // ------------------------------------------------------------------------
    /** Returns the default ambient color. */
    const video::SColor &getDefaultAmbientColor() const
                                            { return m_default_ambient_color; }

    void addCachedMesh(scene::IMesh* mesh) { m_all_cached_meshes.push_back(mesh); }



};   // XMLNode

#endif
