void tune_remap(const Ivector& in_values, Ivector& out_values)
{
	if (pInput->iGetAsyncKeyState(DIK_LSHIFT) || pInput->iGetAsyncKeyState(DIK_RSHIFT))
	{
		out_values = in_values;
	}else
	if( pInput->iGetAsyncKeyState(DIK_Z) )
	{ //strict by X
		out_values.x = in_values.y;
		out_values.y = 0;
		out_values.z = 0;
	}else
	if( pInput->iGetAsyncKeyState(DIK_X) )
	{ //strict by Y
		out_values.x = 0;
		out_values.y = in_values.y;
		out_values.z = 0;
	}else
	if( pInput->iGetAsyncKeyState(DIK_C) )
	{ //strict by Z
		out_values.x = 0;
		out_values.y = 0;
		out_values.z = in_values.y;
	}else
	{
		out_values.set(0,0,0);
	}
}
Пример #2
0
Ivector	vpack			(Fvector src)
{
	Fvector			_v;
	int	bx			= fpack	(src.x);
	int by			= fpack	(src.y);
	int bz			= fpackZ(src.z);
	// dumb test
	float	e_best	= flt_max;
	int		r=bx,g=by,b=bz;
#ifdef DEBUG
	int		d=0;
#else
	int		d=3;
#endif
	for (int x=_max(bx-d,0); x<=_min(bx+d,255); x++)
	for (int y=_max(by-d,0); y<=_min(by+d,255); y++)
	for (int z=_max(bz-d,0); z<=_min(bz+d,255); z++)
	{
		_v				= vunpack(x,y,z);
		float	m		= _v.magnitude();
		float	me		= _abs(m-1.f);
		if	(me>0.03f)	continue;
		_v.div	(m);
		float	e		= _abs(src.dotproduct(_v)-1.f);
		if (e<e_best)	{
			e_best		= e;
			r=x,g=y,b=z;
		}
	}
	Ivector		ipck;
	ipck.set	(r,g,b);
	return		ipck;
}