/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2008.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: src/domains/graphics/camera/camera.cpp

*/

#include "sgx/core/core.hpp"
#include "domains/graphics/camera/camera.hpp"

sgxCamera::sgxCamera()
{
	setDefaults();
}

/**
If we want to use constant literals then this prototype is fine, if 
we want to remove this possibility, use &x.

BOOKNOTE: prototypes vary according to the interface we want/need to supply
*/
sgxCamera::sgxCamera(const tREAL32 x, const tREAL32 y, const tREAL32 z)
{
	setDefaults();
	m_vFrom.x = x;
	m_vFrom.y = y;
	m_vFrom.z = z;
}

sgxCamera::sgxCamera(const sgxCamera &cam) : 
	m_vFrom(cam.m_vFrom), 
	m_vAt(cam.m_vAt),
	m_fFarPlane(cam.m_fFarPlane),
	m_fNearPlane(cam.m_fNearPlane),
	m_fFov(cam.m_fFov),
	m_fRoll(cam.m_fRoll)
{
}

sgxCamera::sgxCamera(const sgxVector3 &from, const sgxVector3 &to)
{
	setDefaults();
	m_vFrom = from;
	m_vAt = to;
}

bool 
sgxCamera::operator!=(const sgxCamera &rhs)
{
	if (m_fFov != rhs.m_fFov) { 
		return TRUE; 
	}
	if (m_fRoll != rhs.m_fRoll)	{
		return TRUE; 
	}
	if (m_fNearPlane != rhs.m_fNearPlane) {
		return TRUE; 
	}
	if (m_fFarPlane != rhs.m_fFarPlane)	{
		return TRUE; 
	}
	if (m_vFrom != rhs.m_vFrom) { 
		return TRUE; 
	}
	if (m_vAt != rhs.m_vAt) { 
		return TRUE; 
	}
	return FALSE;
}

void 
sgxCamera::setDefaults()
{
	// These are arbitrary defaults. 
	m_vFrom	= sgxVector3(0,0,-10);
	m_vAt	= sgxVector3(0,0,10);
	m_fFov	= 60.0f;
	m_fRoll	= SGX_PI;
	m_fNearPlane = 2.0f;
	m_fFarPlane = 4000.0f;
}

sgxVector3	
sgxCamera::up() const
{
	return sgxVector3(m_fRoll);
}
