//
// $Id: Material.h,v 1.1 2003/07/24 20:00:30 sarfata Exp $
//
// Copyright vNET Project <vnet@vnet-project.org>
//
// 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 2 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; see the file COPYING.  If not, write to:
//   The Free Software Foundation, Inc.
//   59 Temple Place, Suite 330
//   Boston, MA 02111 USA
//


#ifndef MATERIAL_H
#define MATERIAL_H

#include "Texture.h"
#include "Color.h"
#include <string>
#include "3d/vec.h"

namespace V3d
{
  class Material {
  public:
    //constructors
    Material();
    ~Material();
    Material(const std::string&);
    Material(const std::string &map_name , const Color4 &amb, const Color4 &diff, 
	     const Color4 &spec, float shin, float transp);
    Material(const std::string &map_name , const Color4 &amb, const Color4 &diff, 
	     const Color4 &spec, float shin, float transp,bool repeat);
    //interface
    void set_diffuse(const Color4 &diff)
    { diffuse = diff; useAdvanced = true;}
    void set_ambient(const Color4 &amb)
    { ambient = amb; useAdvanced = true; }
    void set_specular(const Color4 &spec)
    { specular = spec;useAdvanced = true; }
    void set_transparency(float t)
    { transparency = t; useAdvanced = true; }
    void set_shininess(float shine)
    { shininess = shine; useAdvanced = true; }
    bool is_transparent() const
    { return (transparency!=0);};
    float get_transparency()
    { return transparency; }
    int getWidth(void)			const
    {return tex->getWidth();};
    int getHeight(void)			const
    {return tex->getHeight();};
    void set_map_name(std::string name)
    { set(name);}
    //functions
    void use();
    const Texture* get_texture() const {return tex;};
    void set_repeat(std::string map_name);
    void set_repeat_no_mip(std::string map_name);
  protected:
    void set(std::string map_name);
    bool useAdvanced;
    Texture *tex;
    float shininess, transparency;
    Color4 diffuse;
    Color4 specular;
    Color4 ambient;
  };
}

#endif