// PointLightProps.cpp : implementation file
//

#include "stdafx.h"
#include "mfc gos.h"
#include "PointLightProps.h"


/////////////////////////////////////////////////////////////////////////////
// CPointLightProps dialog


CPointLightProps::CPointLightProps(CWnd* pParent /*=NULL*/)
	: CDialog(CPointLightProps::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPointLightProps)
	m_Alpha = 0.0f;
	m_Blue = 0.0f;
	m_Green = 0.0f;
	m_Intensity = 0.0f;
	m_LocX = 0.0f;
	m_LocY = 0.0f;
	m_LocZ = 0.0f;
	m_Red = 0.0f;
	m_InnerRange = 0.0f;
	m_OuterRange = 0.0f;
	//}}AFX_DATA_INIT
}


void CPointLightProps::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPointLightProps)
	DDX_Text(pDX, IDC_ALPHA, m_Alpha);
	DDX_Text(pDX, IDC_BLUE, m_Blue);
	DDX_Text(pDX, IDC_GREEN, m_Green);
	DDX_Text(pDX, IDC_INTENSITY, m_Intensity);
	DDX_Text(pDX, IDC_LOCX, m_LocX);
	DDX_Text(pDX, IDC_LOCY, m_LocY);
	DDX_Text(pDX, IDC_LOCZ, m_LocZ);
	DDX_Text(pDX, IDC_RED, m_Red);
	DDX_Text(pDX, IDC_INNERRANGE, m_InnerRange);
	DDX_Text(pDX, IDC_OUTERRANGE, m_OuterRange);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPointLightProps, CDialog)
	//{{AFX_MSG_MAP(CPointLightProps)
		// NOTE: the ClassWizard will add message map macros here
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPointLightProps message handlers
void CPointLightProps::SetData(MLRPointLight *light)
{
Light=*light;

m_Intensity=Light.GetIntensity();
Light.GetColor(m_Red,m_Green,m_Blue);
Point3D loc;
Light.GetInWorldPosition(loc);
m_LocX=loc.x;
m_LocY=loc.y;
m_LocZ=loc.z;
m_InnerRange=Light.GetFalloffNear();
m_OuterRange=Light.GetFalloffFar();
}

MLRPointLight &CPointLightProps::GetData()
{
Light.SetIntensity(m_Intensity);
Light.SetColor(m_Red,m_Green,m_Blue);
Point3D loc(m_LocX,m_LocY,m_LocZ);
Stuff::LinearMatrix4D mat(loc);
Light.SetLightToWorldMatrix(mat);
Light.SetFalloffDistance(m_InnerRange,m_OuterRange);
return Light;
}
