light_t createLight(const char * name){ light_t newlight; memset(&newlight, 0, sizeof(light_t)); newlight.type = 1; newlight.name = malloc(strlen(name)+1); // todo maybe put this somewhere else... strcpy(newlight.name, name); newlight.scale = 1.0; // Matrix4x4_CreateIdentity(&newlight.view); Matrix4x4_CreateIdentity(&newlight.projection); // Matrix4x4_CreateIdentity(&newlight.cam); // Matrix4x4_CreateIdentity(&newlight.fixproj); newlight.needsupdate = 3; return newlight; //todo }
/** * @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); } }