/* ------------------------------------------------------------------
 * GEM - Graphics Environment for Multimedia
 *
 * SPDX-FileCopyrightText: © 1997, Mark Danks and the GEM contributors
 * SPDX-License-Identifier: GPL-2.0-or-later
 *
 * ------------------------------------------------------------------
 */

#ifndef _INCLUDE__GEM_GEOS_MULTIMODEL_H_
#define _INCLUDE__GEM_GEOS_MULTIMODEL_H_

#include "Base/GemBase.h"
#include "Gem/GemGL.h"
#include "Gem/Properties.h"
#include "Gem/model.h"
#include "RTE/Outlet.h"

#include <map>

/*-----------------------------------------------------------------
  -------------------------------------------------------------------
  CLASS
  multimodel

  read in a model file

  DESCRIPTION

  Inlet for a list - "multimodel"

  "open" - the 3D model to load

  -----------------------------------------------------------------*/
namespace gem
{
namespace plugins
{
class modelloader;
};
};

class GEM_EXTERN multimodel : public GemBase
{
  CPPEXTERN_HEADER(multimodel, GemBase);

public:

  //////////
  // Constructor
  multimodel(t_symbol* filename, t_floatarg baseModel, t_floatarg topModel,
             t_floatarg skipRate);

protected:

  //////////
  // Destructor
  virtual ~multimodel(void);

  //////////
  // When an open is received
  virtual void  openMess(const std::string&filename, float baseModel,
                         float topModel, float skipRate);
  virtual void  open(const std::string&filename, int baseModel, int topModel,
                     int skipRate);

  //////////
  // Change which model to display
  void          changeModel(int modelNum);

  void          close(void);

  virtual void applyProperties(void);

  //////////
  // When a rescale is received
  virtual void  rescaleMess(bool state);
  //////////
  // When a reverse is received
  virtual void  reverseMess(bool state);
  //////////
  // Which texture type (linear, spheric)
  virtual void  textureMess(int state);
  //////////
  // Set smoothing factor
  virtual void  smoothMess(t_float fsmooth);
  //////////
  // Set material mode
  virtual void  materialMess(int material);

  //////////
  // Set groups to render
  virtual void    groupMess(int group);

  //////////
  // draw type
  virtual void    drawMess(std::string);
  virtual void    drawMess(int);


  //////////
  // Set backend to use
  virtual void  backendMess(t_symbol*s, int argc, t_atom*argv);

  //////////
  virtual void  render(GemState *state);
  virtual void  startRendering();

  gem::plugins::modelloader*m_loader;
  std::vector<gem::modelGL>m_loaded;
  gem::modelGL*m_model; /* the currently active model */
  gem::Properties m_properties;

  gem::RTE::Outlet m_infoOut;
  std::vector<std::string> m_backends;

  bool m_update;

  GLenum m_drawType;
  std::map<std::string, GLenum>m_drawTypes;

  bool m_blend;
  GLfloat m_linewidth;
  bool m_useMaterial;
  enum gem::modelGL::texturetype m_texType;
  enum gem::modelGL::rescale m_rescale;

  std::vector<unsigned int> m_group;
};

#endif  // for header file
