/*-------------------------------------------------------------------------------------
Copyright (c) 2006 John Judnich

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
-------------------------------------------------------------------------------------*/

#ifndef __EntityPage_H__
#define __EntityPage_H__

#include "PagedGeometry.h"
#include "PropertyMaps.h"
#include "RandomTable.h"

#include "OgrePrerequisites.h"
#include "OgreMaterial.h"
#include "OgrePixelFormat.h"
#include "OgreStringConverter.h"


namespace Forests {
/** \brief A page type using independent scene nodes and entities, in special cases when batching is less fast

You can use this in your own project if you want, but remember that no optimizations
are performed. The given entity is simply cloned and attached to a new scene node as
quickly and simply as possible (this means there's no batching overhead as in BatchPage,
but it also means potentially poor performance if you don't know what you're doing).
*/
class EntityPage : public GeometryPage
{
public:
    void init(PagedGeometry *geom, const Ogre::Any &data);
    ~EntityPage();

    void addEntity(Ogre::Entity *ent, const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, const Ogre::Vector3 &scale, const Ogre::ColourValue &color);
    void removeEntities();
    void setFade(bool enabled, Ogre::Real visibleDist, Ogre::Real invisibleDist) {}
    void setVisible(bool visible);

    void setCastShadows(bool castShadows){}

    virtual void setVisibilityFlags(Ogre::uint32 visibilityFlags){}
private:
    Ogre::SceneManager *sceneMgr;
    Ogre::SceneNode *rootNode;

    std::list<Ogre::SceneNode*> nodeList;

    static unsigned long GUID;
    static inline Ogre::String getUniqueID()
    {
        return "EntityPage" + Ogre::StringConverter::toString(++GUID);
    }
};
}
#endif