#pragma once
#include "modelclass.h"
#include <WICTextureLoader.h>
#include <SimpleMath.h>

enum class ObjectType
{
	Sphere,
	Cube,
	Unknown
};

enum class ShaderType
{
	CEL_SHADING,
	LIGHTING,
	NORMAL_MAPPING,
	SPECULAR_MAPPING,
	REFLECTION,
	REFRACTION,
	TEXTURE,
	SKYBOX,
	SUNLIGHT,
	ALPHA_MAPPING
};

class Object : public ModelClass
{
public:
	Object();
	~Object();

	void SetScaleMatrix(XMMATRIX scaleMatrix);
	void SetRotateMatrix(XMMATRIX rotateMatrix);
	void SetTranslateMatrix(XMMATRIX translateMatrix);
	void SetSRMatrix(XMMATRIX srMatrix);
	void SetWorldMatrix(XMMATRIX worldMatrix);

	void SetPosition(XMVECTOR position);
	void SetRotation(XMVECTOR rotation);
	void SetScale(XMVECTOR scale);

	XMMATRIX GetScaleMatrix() const;
	XMMATRIX GetRotateMatrix() const;
	XMMATRIX GetTranslateMatrix() const;
	XMMATRIX GetSRMatrix() const;
	XMMATRIX GetWorldMatrix() const;

	XMVECTOR GetPosition();
	XMVECTOR GetRotation();
	XMVECTOR GetScale();

	void SetVelocity(XMVECTOR);
	void AddVelocity(float deltaTime);
	XMVECTOR GetVelocity() const;
	void SetAcceleration(XMVECTOR);
	XMVECTOR GetAcceleration() const;
	void SetMass(float);
	float GetMass() const;
	void SetGrounded(bool);
	bool IsGrounded() const;
	bool IsPhysicsEnabled() const;
	void SetPhysicsEnabled(bool state);


	void UpdateWorldMatrix();
	void UpdateSRMatrix();
	void UpdateScaleMatrix();
	void UpdateRotateMatrix();
	void UpdateTranslateMatrix();

	void UpdatePosition(float deltaTime);

	void Update();

	std::string GetName();
	void SetName(std::string name);
	int SetId(int id);
	int GetId() const;
	void SetType(ObjectType type);
	ObjectType GetType() const { return m_type; };

	ShaderType GetActiveShader() const { return m_activeShader; };
	void SetActiveShader(ShaderType activeShader) { m_activeShader = activeShader; };

	float GetBoundingRadius() const;
	void SetBoundingRadius(float radius) { m_boundingRadius = radius; }

	void SetModelPath(std::wstring& path) { m_modelPath = path; }
	std::wstring& GetModelPath() { return m_modelPath; }

	ShaderType StringToShaderType(const std::string& shaderType);
	std::string ShaderTypeToString(ShaderType shaderType);

	ObjectType StringToObjectType(const std::string& objectType);
	std::string ObjectTypeToString(ObjectType objectType);

public :
	bool m_demoSpinning = false;
	XMVECTOR m_previousPosition;
	XMVECTOR m_velocity;
	int m_id;

private:
	XMMATRIX m_scaleMatrix;
	XMMATRIX m_rotateMatrix;
	XMMATRIX m_translateMatrix;
	XMMATRIX m_srMatrix;
	XMMATRIX m_worldMatrix;

	XMVECTOR m_acceleration;
	float m_mass;
	bool m_isGrounded;
	bool m_isPhysicsEnabled;

	std::string m_name;
	ObjectType m_type = ObjectType::Unknown;
	

	ShaderType m_activeShader = ShaderType::LIGHTING;

	float m_boundingRadius;
	std::wstring m_modelPath;
};
