Ejemplo n.º 1
0
void recalcLightViewMats(light_t *l){
//	printf("updatin");
	//todo if it is attached, just grab the attached matrix (same as entities do it)
	Matrix4x4_CreateRotate(&l->view, l->angle[2], 0.0f, 0.0f, 1.0f);
	Matrix4x4_ConcatRotate(&l->view, l->angle[0], 1.0f, 0.0f, 0.0f);
	Matrix4x4_ConcatRotate(&l->view, l->angle[1], 0.0f, 1.0f, 0.0f);
	Matrix4x4_ConcatTranslate(&l->view, -l->pos[0], -l->pos[1], -l->pos[2]);
//	Matrix4x4_CreateFromQuakeEntity(&l->cam, l->pos[0], l->pos[1], l->pos[2], l->angle[2], l->angle[1], l->angle[0], 1.0);
//	Matrix4x4_CreateFromQuakeEntity(&l->cam, l->pos[0], l->pos[1], l->pos[2], l->angle[2], l->angle[1], l->angle[0], l->scale);
	Matrix4x4_Invert_Simple(&l->cam, &l->view); //temp? hack

}
Ejemplo n.º 2
0
/*
=============
R_SetupModelviewMatrix
=============
*/
static void R_SetupModelviewMatrix( const ref_params_t *fd, matrix4x4 m )
{
#if 0
	Matrix4x4_LoadIdentity( m );
	Matrix4x4_ConcatRotate( m, -90, 1, 0, 0 );
	Matrix4x4_ConcatRotate( m, 90, 0, 0, 1 );
#else
	Matrix4x4_CreateModelview( m );
#endif
	Matrix4x4_ConcatRotate( m, -fd->viewangles[2], 1, 0, 0 );
	Matrix4x4_ConcatRotate( m, -fd->viewangles[0], 0, 1, 0 );
	Matrix4x4_ConcatRotate( m, -fd->viewangles[1], 0, 0, 1 );
	Matrix4x4_ConcatTranslate( m, -fd->vieworg[0], -fd->vieworg[1], -fd->vieworg[2] );
}
Ejemplo n.º 3
0
/**
 * @see View::render(View *, Renderer *)
 */
static void render(View *self, Renderer *renderer) {

	super(View, self, render, renderer);

	PlayerModelView *this = (PlayerModelView *) self;

	if (this->client.torso == NULL) {
		$(self, updateBindings);
	}

	if (this->client.torso) {
		$(this, animate);

		cgi.PushMatrix(R_MATRIX_PROJECTION);
		cgi.PushMatrix(R_MATRIX_MODELVIEW);

		const SDL_Rect viewport = $(self, viewport);
		cgi.SetViewport(viewport.x, viewport.y, viewport.w, viewport.h, false);

		// create projection matrix
		const vec_t aspect = (vec_t) viewport.w / (vec_t) viewport.h;

		const vec_t ymax = NEAR_Z * tan(Radians(35));
		const vec_t ymin = -ymax;

		const vec_t xmin = ymin * aspect;
		const vec_t xmax = ymax * aspect;
		matrix4x4_t mat;

		Matrix4x4_FromFrustum(&mat, xmin, xmax, ymin, ymax, NEAR_Z, FAR_Z);

		cgi.SetMatrix(R_MATRIX_PROJECTION, &mat);

		// create base modelview matrix
		Matrix4x4_CreateIdentity(&mat);

		// Quake is retarded: rotate so that Z is up
		Matrix4x4_ConcatRotate(&mat, -90.0, 1.0, 0.0, 0.0);
		Matrix4x4_ConcatRotate(&mat,  90.0, 0.0, 0.0, 1.0);
		Matrix4x4_ConcatTranslate(&mat, 64.0, 0.0, -8.0);

		Matrix4x4_ConcatRotate(&mat, cgi.client->unclamped_time * 0.08, 0.0, 0.0, 1.0);

		cgi.SetMatrix(R_MATRIX_MODELVIEW, &mat);

		cgi.EnableDepthTest(true);
		cgi.DepthRange(0.0, 0.1);

		renderMeshEntity(&this->legs);
		renderMeshEntity(&this->torso);
		renderMeshEntity(&this->head);
		renderMeshEntity(&this->weapon);

		cgi.DepthRange(0.0, 1.0);
		cgi.EnableDepthTest(false);

		cgi.SetViewport(0, 0, cgi.context->width, cgi.context->height, false);

		cgi.PopMatrix(R_MATRIX_MODELVIEW);
		cgi.PopMatrix(R_MATRIX_PROJECTION);
	}
}