示例#1
0
/*!
	Create a normalized direction vector for an arbitraty set of rotation angles.
	
	\param[in,out] dst The resulting direction vector will be stored in this variable.
	\param[in] up_axis The up axis.
	\param[in] rotx The X angle in degree.
	\param[in] roty The Y angle in degree.
	\param[in] rotz The Z angle in degree.
*/
void create_direction_vector( vec3 *dst, vec3 *up_axis, float rotx, float roty, float rotz )
{
	vec4 rotation;

	mat4 m;

	mat4_identity( &m );

	rotation.z = 1.0f;
	rotation.x =
	rotation.y = 0.0f;
	rotation.w = rotz;

	mat4_rotate( &m, &m, &rotation );

	rotation.y = 1.0f;
	rotation.x =
	rotation.z = 0.0f;
	rotation.w = roty;

	mat4_rotate( &m, &m, &rotation );

	rotation.x = 1.0f;
	rotation.y =
	rotation.z = 0.0f;
	rotation.w = rotx;

	mat4_rotate( &m, &m, &rotation );

	vec3_invert( up_axis, up_axis );

	vec3_multiply_mat4( dst, up_axis, &m );
}
示例#2
0
void LAMP_get_direction_in_eye_space( LAMP *lamp, mat4 *m, vec3 *direction )
{
	vec3_multiply_mat4( direction,
						&lamp->direction,
						m );
		
	vec3_invert( direction, direction );
}