/******************************************************************************
** Copyright (c) 2022 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/

//! \file DtModelDefinitionRecord.h
//! \brief Contains makVrv::DtModelDefinitionRecord class.
//! \ingroup makArchives

#pragma once

#include <makArchives/makArchives.h>
#include <string>

namespace makArchives
{
   //! \brief A DtModelDefinitionRecord will serialize a terrain patch model
   //! definition
   //! \ingroup makArchives
   class DT_DLL_MAKARCHIVES DtModelDefinitionRecord
   {

   public:

      //! \brief CTOR
      DtModelDefinitionRecord();

      //! \brief Copy CTOR
      DtModelDefinitionRecord(const DtModelDefinitionRecord& orig);

      bool operator==(const DtModelDefinitionRecord& orig) const;
      bool operator!=(const DtModelDefinitionRecord& orig) const;

      //! \brief Assignment OP
      DtModelDefinitionRecord& operator=(const DtModelDefinitionRecord& orig);

      //! \brief DTOR
      ~DtModelDefinitionRecord();

      //! \brief Return the name of this model definition
      const std::string& name() const;

      //! \brief Return the schema of this model definition
      const std::string& schema() const;

      //! \brief Return the filename of this model definition
      const std::string& filename() const;

      //! The coordinate system type of this model definition
      const std::string& coordinateSystem() const;

      //! The coordinate system parameters.
      const std::string& coordinateSystemParameters() const;

      //! Whether or not DDS textures are flipped for this terrain
      bool flipDds() const;

      //! Alpha to Coverage Setting for this terrain.
      int alphaToCoverageState() const;

      //! get whether or not to use indirect rendering for this terrain patch
      bool indirectEnabled() const;

      //! get whether or not we want to discard the vertex color when we read an FBX terrain patch
      bool discardVertexColor() const;

      //! Set the name.
      void setName(const std::string& name);

      //! Set the schema.
      void setSchema(const std::string& schema);

      //! Set the filename.
      void setFilename(const std::string& name);

      //! Set the current coordinate system.
      void setCoordinateSystem(const std::string& cs);

      //! Set the current coordinate system parameters.
      //! The format of the parameters varies for each coordinate system type
      void setCoordinateSystemParameters(const std::string& csp);

      //! Set whether or not DDS textures are flipped for this terrain
      void setFlipDds(bool flip_dds);

      //! Sets the alpha to Coverage Setting for this terrain.
      //! Three valid values 0 = use global, 1 = force off, 2 = force on
      void setAlphaToCoverageState(int state);

      //! set whether or not to use indirect rendering for this terrain patch
      void setIndirectEnabled(bool indirectEnabled);

      //! set whether or not we want to discard the vertex color when we read an FBX model
      void setDiscardVertexColor(bool indirectEnabled);

   protected:

      friend class boost::serialization::access;

      //! When the class Archive corresponds to an output archive, the
      //! & operator is defined similar to <<.  Likewise, when the class Archive
      //! is a type of input archive the & operator is defined similar to >>.
      template<class Archive>
      void serialize(Archive & ar, const unsigned int version)
      {
         ar & BOOST_SERIALIZATION_NVP(myName);
         ar & BOOST_SERIALIZATION_NVP(myFilename);
         ar & BOOST_SERIALIZATION_NVP(mySchema);
         ar & BOOST_SERIALIZATION_NVP(myCoordinateSystem);
         ar & BOOST_SERIALIZATION_NVP(myCoordinateSystemParameters);

         if (version >= 1)
         {
            ar & BOOST_SERIALIZATION_NVP(myFlipDds);
         }
         if (version >= 2)
         {
            ar & BOOST_SERIALIZATION_NVP(myAlphaToCoverageState);
         }
         if (version >= 3)
         {
            ar & BOOST_SERIALIZATION_NVP(myIndirectEnabled);
         }
         if (version >= 4)
         {
            ar & BOOST_SERIALIZATION_NVP(myDiscardVertexColor);
         }
      }


   protected:

      std::string myName;
      std::string myFilename;
      std::string mySchema;
      std::string myCoordinateSystem;
      std::string myCoordinateSystemParameters;
      bool myFlipDds;
      int myAlphaToCoverageState;
      bool myIndirectEnabled;
      bool myDiscardVertexColor;
   };
}

BOOST_CLASS_VERSION(makArchives::DtModelDefinitionRecord, 4)
