#include "cameramodule.h"

namespace VRUT
{
	CameraModule::CameraModule(const MODULE_ID & _id, const wxString & _name, unsigned _type, Kernel * _kernel) : ManipulatorModule(_id, _name, (_type | MODULE_TYPE_CAMERA), _kernel, SceneNode::CreateClassMask<Camera>())
	{
		wxString windowIDTmp(wxString::Format(wxT("%lu"), (unsigned long)RENDER_WINDOW_ID_NONE));
		REGISTER_PARAM_GUI_TEXTCONTROL(windowIDParamID, wxT("windowID"), windowIDTmp, wxT("ID of renderer window."));
		int windowIDTmpI;
		TextParser(windowIDTmp.utf8_str()).ParseInt(&windowIDTmpI);
		windowID = (RENDER_WINDOW_ID)windowIDTmpI;
		REGISTER_LISTENER(Event::EVT_RENDER_WIN_CLOSED);
	}

	void CameraModule::processEvent(Event * evt)
	{
		ManipulatorModule::processEvent(evt);
		switch (evt->type)
		{
		case Event::EVT_PARAM_SET:
			UPDATE_PARAM_FROM_EVENT_ID(windowIDParamID, windowID, evt);
			break;
		/*case Event::EVT_SCENE_NODE_REMOVED:
			if ((((EventSceneNodeRemoved*)evt)->sceneID == sceneID) && (((EventSceneNodeRemoved*)evt)->nodeID == nodeID))
			{
				///If camera is released -> release me
				PostToKernel(GET_EVT_MODULE_RELEASE(GetID()));
			}
			break;*/
		default:
			break;
		}
	}
}
