//*******************************************************************
//
// File: Asura_Platform_Botanical_Game_Render_Instance_Inline.h
//
// Created: 15 December 2006 DLH
//
// Description: 
//
//*******************************************************************

#ifndef __ASURA_PLATFORM_BOTANICAL_GAME_RENDER_INSTANCE_INLINE_H__
#define __ASURA_PLATFORM_BOTANICAL_GAME_RENDER_INSTANCE_INLINE_H__

// other libraries

// internal dependencies

// forward declarations

//*******************************************************************
// Constants
//*******************************************************************


//*******************************************************************
// Class Definitions
//*******************************************************************


//*******************************************************************
// Inline Function Definitions
//*******************************************************************

inline void Asura_BGR_Instance::GetInstancePosition( Asura_AVector3& xInstancePosition) const
{
	xInstancePosition = this->m_xPosition;
}

inline void Asura_BGR_Instance::GetInstancePosition( Asura_Vector_3& xInstancePosition) const
{
	xInstancePosition = this->m_xPosition;
}

#if 0
inline void Asura_BGR_Instance::GetInstanceUp( Asura_AVector3& xInstanceUp) const
{
	const D3DXMATRIX& xTransformMatrix = this->m_xTransformMatrix;

	xInstanceUp.SetX( xTransformMatrix._12);
	xInstanceUp.SetY( xTransformMatrix._22);
	xInstanceUp.SetZ( xTransformMatrix._32);
}
#endif

inline void Asura_BGR_Instance::GetOrientation( Asura_AMatrix3x3& xInstanceOrientation) const
{
	xInstanceOrientation.SetColumn0( Asura_AVector3( this->m_xRenderData.m_axTransformMatrix[0], this->m_xRenderData.m_axTransformMatrix[4], this->m_xRenderData.m_axTransformMatrix[8]));
	xInstanceOrientation.SetColumn1( Asura_AVector3( this->m_xRenderData.m_axTransformMatrix[1], this->m_xRenderData.m_axTransformMatrix[5], this->m_xRenderData.m_axTransformMatrix[9]));
	xInstanceOrientation.SetColumn2( Asura_AVector3( this->m_xRenderData.m_axTransformMatrix[2], this->m_xRenderData.m_axTransformMatrix[6], this->m_xRenderData.m_axTransformMatrix[10]));
}

inline void Asura_BGR_Instance::GetOrientationTransposed( Asura_AMatrix3x3& xInstanceOrientation) const
{
	xInstanceOrientation.SetColumn0( Asura_AVector3( this->m_xRenderData.m_axTransformMatrix[0], this->m_xRenderData.m_axTransformMatrix[1], this->m_xRenderData.m_axTransformMatrix[2]));
	xInstanceOrientation.SetColumn1( Asura_AVector3( this->m_xRenderData.m_axTransformMatrix[4], this->m_xRenderData.m_axTransformMatrix[5], this->m_xRenderData.m_axTransformMatrix[6]));
	xInstanceOrientation.SetColumn2( Asura_AVector3( this->m_xRenderData.m_axTransformMatrix[8], this->m_xRenderData.m_axTransformMatrix[9], this->m_xRenderData.m_axTransformMatrix[10]));
}

inline void Asura_BGR_Instance::GetOrientation( Asura_Matrix_3x3& xInstanceOrientation) const
{
	xInstanceOrientation.e11 = this->m_xRenderData.m_axTransformMatrix[0];
	xInstanceOrientation.e12 = this->m_xRenderData.m_axTransformMatrix[1];
	xInstanceOrientation.e13 = this->m_xRenderData.m_axTransformMatrix[2];
						   
	xInstanceOrientation.e21 = this->m_xRenderData.m_axTransformMatrix[4];
	xInstanceOrientation.e22 = this->m_xRenderData.m_axTransformMatrix[5];
	xInstanceOrientation.e23 = this->m_xRenderData.m_axTransformMatrix[6];
						   
	xInstanceOrientation.e31 = this->m_xRenderData.m_axTransformMatrix[8];
	xInstanceOrientation.e32 = this->m_xRenderData.m_axTransformMatrix[9];
	xInstanceOrientation.e33 = this->m_xRenderData.m_axTransformMatrix[10];
}

inline void Asura_BGR_Instance::GetOrientationTransposed( Asura_Matrix_3x3& xInstanceOrientation) const
{
	xInstanceOrientation.e11 = this->m_xRenderData.m_axTransformMatrix[0];
	xInstanceOrientation.e21 = this->m_xRenderData.m_axTransformMatrix[4];
	xInstanceOrientation.e31 = this->m_xRenderData.m_axTransformMatrix[8];
							   
	xInstanceOrientation.e12 = this->m_xRenderData.m_axTransformMatrix[1];
	xInstanceOrientation.e22 = this->m_xRenderData.m_axTransformMatrix[5];
	xInstanceOrientation.e32 = this->m_xRenderData.m_axTransformMatrix[9];
							   
	xInstanceOrientation.e13 = this->m_xRenderData.m_axTransformMatrix[2];
	xInstanceOrientation.e23 = this->m_xRenderData.m_axTransformMatrix[6];
	xInstanceOrientation.e33 = this->m_xRenderData.m_axTransformMatrix[10];
}

inline void Asura_BGR_Instance::GetOrientationInversed( Asura_Matrix_3x3& xInstanceOrientation) const
{
	const float fLength = Asura_Vector_3( this->m_xRenderData.m_axTransformMatrix[0], this->m_xRenderData.m_axTransformMatrix[4], this->m_xRenderData.m_axTransformMatrix[8]).Magnitude();
	const float fScale = 1.0f / (fLength * fLength);
	
	xInstanceOrientation.e11 = fScale * this->m_xRenderData.m_axTransformMatrix[0];
	xInstanceOrientation.e12 = fScale * this->m_xRenderData.m_axTransformMatrix[4];
	xInstanceOrientation.e13 = fScale * this->m_xRenderData.m_axTransformMatrix[8];
																			   
	xInstanceOrientation.e21 = fScale * this->m_xRenderData.m_axTransformMatrix[1];
	xInstanceOrientation.e22 = fScale * this->m_xRenderData.m_axTransformMatrix[5];
	xInstanceOrientation.e23 = fScale * this->m_xRenderData.m_axTransformMatrix[9];
																			   
	xInstanceOrientation.e31 = fScale * this->m_xRenderData.m_axTransformMatrix[2];
	xInstanceOrientation.e32 = fScale * this->m_xRenderData.m_axTransformMatrix[6];
	xInstanceOrientation.e33 = fScale * this->m_xRenderData.m_axTransformMatrix[10];
}

inline float Asura_BGR_Instance::GetScale(void) const
{	
	return Asura_Vector_3(this->m_xRenderData.m_axTransformMatrix[0], this->m_xRenderData.m_axTransformMatrix[4], this->m_xRenderData.m_axTransformMatrix[8]).Magnitude();	
};

#if 0
inline void Asura_BGR_Instance::GetInstanceSpherical( float* afSphericalR, float* afSphericalG, float* afSphericalB) const
{
	afSphericalR[ 0] = this->m_afSphericalR[0];
	afSphericalR[ 1] = this->m_afSphericalR[1];
	afSphericalR[ 2] = this->m_afSphericalR[2];
	afSphericalR[ 3] = this->m_afSphericalR[3];

	afSphericalG[ 0] = this->m_afSphericalG[0];
	afSphericalG[ 1] = this->m_afSphericalG[1];
	afSphericalG[ 2] = this->m_afSphericalG[2];
	afSphericalG[ 3] = this->m_afSphericalG[3];

	afSphericalB[ 0] = this->m_afSphericalB[0];
	afSphericalB[ 1] = this->m_afSphericalB[1];
	afSphericalB[ 2] = this->m_afSphericalB[2];
	afSphericalB[ 3] = this->m_afSphericalB[3];
}
#endif

#if 0
template< class Tdata>
inline void Asura_BGR_Instance::GetInstanceData( Tdata& tData) const
{
	tData.m_afSphericalR[0] = this->m_afSphericalR[0];
	tData.m_afSphericalR[1] = this->m_afSphericalR[1];
	tData.m_afSphericalR[2] = this->m_afSphericalR[2];
	tData.m_afSphericalR[3] = this->m_afSphericalR[3];

	tData.m_afSphericalG[0] = this->m_afSphericalG[0];
	tData.m_afSphericalG[1] = this->m_afSphericalG[1];
	tData.m_afSphericalG[2] = this->m_afSphericalG[2];
	tData.m_afSphericalG[3] = this->m_afSphericalG[3];

	tData.m_afSphericalB[0] = this->m_afSphericalB[0];
	tData.m_afSphericalB[1] = this->m_afSphericalB[1];
	tData.m_afSphericalB[2] = this->m_afSphericalB[2];
	tData.m_afSphericalB[3] = this->m_afSphericalB[3];

	{
		const D3DXMATRIX& xTransformMatrix = this->m_xTransformMatrix;

		tData.m_afTransform0[0] = xTransformMatrix._11;
		tData.m_afTransform0[1] = xTransformMatrix._21;
		tData.m_afTransform0[2] = xTransformMatrix._31;
		tData.m_afTransform0[3] = xTransformMatrix._41;

		tData.m_afTransform1[0] = xTransformMatrix._12;
		tData.m_afTransform1[1] = xTransformMatrix._22;
		tData.m_afTransform1[2] = xTransformMatrix._32;
		tData.m_afTransform1[3] = xTransformMatrix._42;

		tData.m_afTransform2[0] = xTransformMatrix._13;
		tData.m_afTransform2[1] = xTransformMatrix._23;
		tData.m_afTransform2[2] = xTransformMatrix._33;
		tData.m_afTransform2[3] = xTransformMatrix._43;
	}
}
#endif


//*******************************************************************
//
// (c) 2006 Rebellion
//
// Warning: This computer program is protected by copyright law and 
// international treaties. Unauthorized reproduction or distribution
// of this program, or any portion of it, may result in severe civil and
// criminal penalties, and will be prosecuted to the maximum extent 
// possible under the law.
//
//*******************************************************************

#endif // __ASURA_PLATFORM_BOTANICAL_GAME_RENDER_INSTANCE_INLINE_H__
