Esempio n. 1
0
void matrix_init_orthographic(float *m, float left, float right, float bottom, float top, float near, float far)
{
	float mo[4*4], mp[4*4];

	mo[0x0] = 2.0f/(right-left);
	mo[0x1] = 0.0f;
	mo[0x2] = 0.0f;
	mo[0x3] = -(right+left)/(right-left);

	mo[0x4] = 0.0f;
	mo[0x5] = 2.0f/(top-bottom);
	mo[0x6] = 0.0f;
	mo[0x7] = -(top+bottom)/(top-bottom);

	mo[0x8] = 0.0f;
	mo[0x9] = 0.0f;
	mo[0xA] = -2.0f/(far-near);
	mo[0xB] = (far+near)/(far-near);

	mo[0xC] = 0.0f;
	mo[0xD] = 0.0f;
	mo[0xE] = 0.0f;
	mo[0xF] = 1.0f;

	matrix_identity4x4(mp);
	mp[0xA] = 0.5;
	mp[0xB] = -0.5;

	//Convert Z [-1, 1] to [-1, 0] (PICA shiz)
	matrix_mult4x4(mp, mo, m);
	// Rotate 180 degrees
	matrix_rotate_z(m, M_PI);
	// Swap X and Y axis
	matrix_swap_xy(m);
}
Esempio n. 2
0
void matrix_rotate_z(float *m, float rad)
{
	float mr[4*4], mt[4*4];
	matrix_set_z_rotation(mr, rad);
	matrix_mult4x4(mr, m, mt);
	matrix_copy(m, mt);
}
Esempio n. 3
0
void matrix_translate_xyz(float *m, float x, float y, float z)
{
	float mr[4*4], mt[4*4];
	matrix_set_xyz_translation(mr, x, y, z);
	matrix_mult4x4(m, mr, mt);
	matrix_copy(m, mt);
}
Esempio n. 4
0
void matrix_swap_xy(float *m)
{
	float ms[4*4], mt[4*4];
	matrix_identity4x4(ms);

	ms[0] = 0.0f;
	ms[1] = 1.0f;
	ms[4] = 1.0f;
	ms[5] = 0.0f;

	matrix_mult4x4(ms, m, mt);
	matrix_copy(m, mt);
}