#ifndef ENVIRONMENTPROBE_H
#define ENVIRONMENTPROBE_H

#include "rendertarget.h"
#include "moddefs.h"
#include "smartptr.h"
#include "scenenode.h"

namespace VRUT
{
	class EnvironmentProbe : public RenderTarget
	{
		ENVIRONMENT_PROBE_ID epid;
		NODE_ID attachedNodeID;
		float nearPlaneDistance, farPlaneDistance;
		int textureDimension;
		bool enabled;
		bool singleShot;
	public:
		EnvironmentProbe(ENVIRONMENT_PROBE_ID epid, NODE_ID attachedNodeID, float nearPlaneDistance, float farPlaneDistance, int textureDimension, bool enabled, bool singleShot) : 
		  epid(epid), attachedNodeID(attachedNodeID), nearPlaneDistance(nearPlaneDistance), farPlaneDistance(farPlaneDistance), textureDimension(textureDimension), enabled(enabled), singleShot(singleShot)
		{
		}

		  EnvironmentProbe(const EnvironmentProbe& environmentProbe) : RenderTarget(environmentProbe)
		  {
			  epid = environmentProbe.epid;
			  attachedNodeID = environmentProbe.attachedNodeID;
			  nearPlaneDistance = environmentProbe.nearPlaneDistance;
			  farPlaneDistance = environmentProbe.farPlaneDistance;
			  textureDimension = environmentProbe.textureDimension;
			  enabled = environmentProbe.enabled;
			  singleShot = environmentProbe.singleShot;
		  }

		int GetTextureDimension() const { return textureDimension; }
		float GetNearPlaneDistance() const { return nearPlaneDistance; }
		float GetFarPlaneDistance() const { return farPlaneDistance; }
		bool IsEnabled() const { return enabled; }
		bool GetSingleShot() const { return singleShot; }
		void SetSingleShot(bool singleShot) { this->singleShot = singleShot; }
#ifndef VRUT_HPC
		bool SetupAttachments();
#endif
		void Enable(bool enable) { enabled = enable; }
		void CaptureSingleShot() { singleShot = true; }
		NODE_ID GetAttachedNodeID() const { return attachedNodeID; }
		ENVIRONMENT_PROBE_ID GetID() const { return epid; }
		EnvironmentProbe *Clone()
		{
			return new EnvironmentProbe(*this);
		}

		bool IsSameAs(const EnvironmentProbe * ep) const
		{
			bool result = true;
			if (nearPlaneDistance != ep->nearPlaneDistance)
				result = false;
			if (farPlaneDistance != ep->farPlaneDistance)
				result = false;
			if (textureDimension != ep->textureDimension)
				result = false;
		    if (enabled != ep->enabled)
				result = false;
			if (singleShot != ep->singleShot)
				result = false;
			return result;
		}

		///Builds the environment probe name
		static wxString BuildEnvironmentProbeName(const smart_pointer<SceneNode>& sceneNode);
		static const wxString CubeMapNameSuffix;

		friend class Scene;
	};
}

#endif
