#pragma once

#include "MGL.h"
#include "IndexedGeometry_TEIFace.h"

namespace Aftr
{
   class IndexedGeometry;

   class MGLIndexedGeometry_TE : public MGL
   {
   public:
      static MGLIndexedGeometry_TE* New( WO* parent );
      virtual ~MGLIndexedGeometry_TE() {};
      virtual void render( const Camera& cam );
      virtual void renderSelection( const Camera& cam, GLubyte red, GLubyte green, GLubyte blue );
      virtual void setIndexedGeometry( IndexedGeometry_TEIFace&& geom );
      virtual IndexedGeometry_TEIFace const& getIndexedGeometry() const noexcept { return this->geom; }

      /// Returns a pointer to a list containing all verticies within this model.
      /// This list is indexed by the corresponding CompositeIndexList.
      virtual const std::vector< Vector >& getCompositeVertexList() const noexcept override;

      /// Returns a pointer to a list containing all indicies into the corresponding
      /// CompositeVertexList.
      virtual const std::vector< unsigned int >& getCompositeIndexList() const noexcept override;

      /**
         Same as getModel(), but is templated so the user does not need to perform
         a static_cast<T> on the return type. This is simply a convenience method.
      */
      template< typename T, typename R = std::remove_pointer_t<T> > 
      R& getIndexedGeometryT()
      {
         return geom.get_erased_type<R>();
      }

      template< typename T, typename R = std::remove_pointer_t<T> > 
      R const& getIndexedGeometryT() const
      {
         return geom.get_erased_type<R>();
      }

   protected:
      MGLIndexedGeometry_TE( WO* parent );
      virtual void onCreate();

      IndexedGeometry_TEIFace geom;
   };

}

