#pragma once
#ifndef _SHAPESKIN_H_
#define _SHAPESKIN_H_

#include "MatrixStack.h"
#include <memory>
#include <vector>
#include <glm/glm.hpp>
#include "Material.h"

class Program;

struct vert
{
  glm::quat q;
  glm::vec3 p;
};

class ShapeSkin
{
public:
	ShapeSkin();
	virtual ~ShapeSkin();
	void loadMesh(const std::string &meshName);
	void loadAttachment(const std::string &filename);
  void loadSkeleton(const std::string &filename);
	void setProgram(std::shared_ptr<Program> p) { prog = p; }
	void init();
	void draw(float t, std::shared_ptr<MatrixStack> MV) const;
  void skin(float t);
  void setMaterial(Material m);
  Material getMaterial();
	
private:
	std::shared_ptr<Program> prog;
	std::vector<unsigned int> elemBuf;
	std::vector<float> posBuf;
	std::vector<float> norBuf;
	std::vector<float> texBuf;
	unsigned elemBufID;
	unsigned posBufID;
	unsigned norBufID;
	unsigned texBufID;
  Material m;
  std::vector<float> posBufInit;
  std::vector<std::vector<float> > boneInfluence;
  std::vector<std::vector<vert> > vertInfo;
  std::vector<std::vector<glm::mat4> > transMats;
  std::vector<std::vector<unsigned int> > indexes;
};

#endif
