/*****************************************************************************
 * $Id: eng_deprecated.cc,v 1.5 2006/07/23 00:44:38 devel Exp $
 * @file
 * @author	Jim E. Brooks  http://www.jimbrooks.org
 * @brief	Deprecated/obsolete code which may be useful as a reference.
 *//*
 * LEGAL:	COPYRIGHT (C) 2004 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE (GPL).
 *****************************************************************************/

#if 0

/*****************************************************************************
 * -- Was superceded by matrix multiplication, but helps to understand transformations --
 *
 * Vertex transformation: local --> world --> eye
 * This does 2 transformations thru 2 matrixs.
 * @param	ve
 * @param	vl
 * @param	vcnt
 * @param	m[]
 *			Typically a Dyna (world) matrix.
 *          The second matrix (m2) is implied as the Eye's matrix.
 *****************************************************************************/
// Transform an array of vertexs.
static inline void
TRANSFORM_VERTEX( EyeVertex* ev, const LocalVertex* vl, const uint vcnt, const Matrix& m )
{
#define m2 gEng.mEye.mCm

	// Local --> world is rotate/translate.
	// World --> eye   is translate/rotate.
	// This optimization combines the two translation steps.
	fp ox = m[Ox] + m2[Ox];
	fp oy = m[Oy] + m2[Oy];
	fp oz = m[Oz] + m2[Oz];
	for ( uint i = 0; i < vcnt; ++i )
	{
		// Local --> world
		fp x = vl[i].x;
		fp y = vl[i].y;
		fp z = vl[i].z;
		fp x2 = x * m[Xx] + y * m[Xy] + z * m[Xz];
		fp y2 = x * m[Yx] + y * m[Yy] + z * m[Yz];
		fp z2 = x * m[Zx] + y * m[Zy] + z * m[Zz];

		// Two combined translations: local --> world --> eye
		x2 += ox;
		y2 += oy;
		z2 += oz;

		// World --> eye
		ev[i].x = x2 * m2[Xx] + y2 * m2[Xy] + z2 * m2[Xz];
		ev[i].y = x2 * m2[Yx] + y2 * m2[Yy] + z2 * m2[Yz];
		ev[i].z = x2 * m2[Zx] + y2 * m2[Zy] + z2 * m2[Zz];
	}

#undef m2
}

#endif
