static void _makeWalls( const QgsCurve &ring, bool ccw, float extrusionHeight, QVector<float> &data, bool addNormals, double originX, double originY ) { // we need to find out orientation of the ring so that the triangles we generate // face the right direction // (for exterior we want clockwise order, for holes we want counter-clockwise order) bool is_counter_clockwise = _isRingCounterClockWise( ring ); QgsVertexId::VertexType vt; QgsPoint pt; QgsPoint ptPrev; ring.pointAt( is_counter_clockwise == ccw ? 0 : ring.numPoints() - 1, ptPrev, vt ); for ( int i = 1; i < ring.numPoints(); ++i ) { ring.pointAt( is_counter_clockwise == ccw ? i : ring.numPoints() - i - 1, pt, vt ); float x0 = ptPrev.x() - originX, y0 = ptPrev.y() - originY; float x1 = pt.x() - originX, y1 = pt.y() - originY; float z0 = ptPrev.z(); float z1 = pt.z(); // make a quad make_quad( x0, y0, z0, x1, y1, z1, extrusionHeight, data, addNormals ); ptPrev = pt; } }
char * print_arg(int fd, struct syscall_args *sc, unsigned long *args) { char *tmp = NULL; switch (sc->type & ARG_MASK) { case Hex: tmp = malloc(12); sprintf(tmp, "0x%lx", args[sc->offset]); break; case Octal: tmp = malloc(13); sprintf(tmp, "0%lo", args[sc->offset]); break; case Int: tmp = malloc(12); sprintf(tmp, "%ld", args[sc->offset]); break; case String: { char *tmp2; tmp2 = get_string(fd, (void*)args[sc->offset], 0); tmp = malloc(strlen(tmp2) + 3); sprintf(tmp, "\"%s\"", tmp2); free(tmp2); } break; case Quad: { unsigned long long t; unsigned long l1, l2; l1 = args[sc->offset]; l2 = args[sc->offset+1]; t = make_quad(l1, l2); tmp = malloc(24); sprintf(tmp, "0x%qx", t); break; } case Ptr: tmp = malloc(12); sprintf(tmp, "0x%lx", args[sc->offset]); break; case Ioctl: { const char *temp = ioctlname(args[sc->offset]); if (temp) tmp = strdup(temp); else { tmp = malloc(12); sprintf(tmp, "0x%lx", args[sc->offset]); } } break; case Signal: { long sig; sig = args[sc->offset]; tmp = malloc(12); if (sig > 0 && sig < NSIG) { int i; sprintf(tmp, "sig%s", sys_signame[sig]); for (i = 0; tmp[i] != '\0'; ++i) tmp[i] = toupper(tmp[i]); } else { sprintf(tmp, "%ld", sig); } } break; case Sockaddr: { struct sockaddr_storage ss; char addr[64]; struct sockaddr_in *lsin; struct sockaddr_in6 *lsin6; struct sockaddr_un *sun; struct sockaddr *sa; char *p; u_char *q; int i; /* yuck: get ss_len */ if (get_struct(fd, (void *)args[sc->offset], &ss, sizeof(ss.ss_len) + sizeof(ss.ss_family)) == -1) err(1, "get_struct %p", (void *)args[sc->offset]); /* sockaddr_un never have the length filled in! */ if (ss.ss_family == AF_UNIX) { if (get_struct(fd, (void *)args[sc->offset], &ss, sizeof(*sun)) == -1) err(2, "get_struct %p", (void *)args[sc->offset]); } else { if (get_struct(fd, (void *)args[sc->offset], &ss, ss.ss_len < sizeof(ss) ? ss.ss_len : sizeof(ss)) == -1) err(2, "get_struct %p", (void *)args[sc->offset]); } switch (ss.ss_family) { case AF_INET: lsin = (struct sockaddr_in *)&ss; inet_ntop(AF_INET, &lsin->sin_addr, addr, sizeof addr); asprintf(&tmp, "{ AF_INET %s:%d }", addr, htons(lsin->sin_port)); break; case AF_INET6: lsin6 = (struct sockaddr_in6 *)&ss; inet_ntop(AF_INET6, &lsin6->sin6_addr, addr, sizeof addr); asprintf(&tmp, "{ AF_INET6 [%s]:%d }", addr, htons(lsin6->sin6_port)); break; case AF_UNIX: sun = (struct sockaddr_un *)&ss; asprintf(&tmp, "{ AF_UNIX \"%s\" }", sun->sun_path); break; default: sa = (struct sockaddr *)&ss; asprintf(&tmp, "{ sa_len = %d, sa_family = %d, sa_data = {%n%*s } }", (int)sa->sa_len, (int)sa->sa_family, &i, 6 * (int)(sa->sa_len - ((char *)&sa->sa_data - (char *)sa)), ""); if (tmp != NULL) { p = tmp + i; for (q = (u_char *)&sa->sa_data; q < (u_char *)sa + sa->sa_len; q++) p += sprintf(p, " %#02x,", *q); } } } break; } return tmp; }
void R_DrawSprite (void) { entity_t *ent = currententity; msprite_t *sprite = (msprite_t *) ent->model->cache.data; mspriteframe_t *frame1, *frame2; float blend, sr, cr, dot, angle; vec3_t tvec; vec3_t svpn, svright, svup; static quat_t color = { 1, 1, 1, 1}; float vertsa[6][3], vertsb[6][3]; static float uvab[6][4] = { { 0, 0, 0, 0 }, { 1, 0, 1, 0 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 1, 1, 1, 1 }, { 0, 1, 0, 1 }, }; switch (sprite->type) { case SPR_FACING_UPRIGHT: // generate the sprite's exes with svup straight up in worldspace // and svright perpendicular to r_origin. This will not work if the // view direction is very close to straight up or down because the // cross product will be between two nearly parallel vectors and // starts to approach an undefined staate, so we don't draw if the // two vectors are less than 1 degree apart VectorNegate (r_origin, tvec); VectorNormalize (tvec); dot = tvec[2]; // same as DotProcut (tvec, svup) because // svup is 0, 0, 1 if ((dot > 0.999848) || (dot < -0.99848)) // cos (1 degree) return; VectorSet (0, 0, 1, svup); // CrossProduct (svup, -r_origin, svright) VectorSet (tvec[1], -tvec[0], 0, svright); VectorNormalize (svright); // CrossProduct (svright, svup, svpn); VectorSet (-svright[1], svright[0], 0, svpn); break; case SPR_VP_PARALLEL: // generate the prite's axes completely parallel to the viewplane. // There are no problem situations, because the prite is always in // the same position relative to the viewer. VectorCopy (vup, svup); VectorCopy (vright, svright); VectorCopy (vpn, svpn); break; case SPR_VP_PARALLEL_UPRIGHT: // generate the sprite's axes with svup straight up in worldspace, // and svright parallel to the viewplane. This will not work if the // view diretion iss very close to straight up or down because the // cross prodcut will be between two nearly parallel vectors and // starts to approach an undefined state, so we don't draw if the // two vectros are less that 1 degree apart dot = vpn[2]; if ((dot > 0.999848) || (dot < -0.99848)) // cos (1 degree) return; VectorSet (0, 0, 1, svup); // CrossProduct (svup, -r_origin, svright) VectorSet (vpn[1], -vpn[0], 0, svright); VectorNormalize (svright); // CrossProduct (svright, svup, svpn); VectorSet (-svright[1], svright[0], 0, svpn); break; case SPR_ORIENTED: // generate the prite's axes according to the sprite's world // orientation VectorCopy (currententity->transform + 0, svpn); VectorNegate (currententity->transform + 4, svright); VectorCopy (currententity->transform + 8, svup); break; case SPR_VP_PARALLEL_ORIENTED: // generate the sprite's axes parallel to the viewplane, but // rotated in that plane round the center according to the sprite // entity's roll angle. Thus svpn stays the same, but svright and // svup rotate angle = currententity->angles[ROLL] * (M_PI / 180); sr = sin (angle); cr = cos (angle); VectorCopy (vpn, svpn); VectorScale (vright, cr, svright); VectorMultAdd (svright, sr, vup, svright); VectorScale (vup, cr, svup); VectorMultAdd (svup, -sr, vright, svup); break; default: Sys_Error ("R_DrawSprite: Bad sprite type %d", sprite->type); } R_GetSpriteFrames (ent, sprite, &frame1, &frame2, &blend); qfeglActiveTexture (GL_TEXTURE0 + 0); qfeglBindTexture (GL_TEXTURE_2D, frame1->gl_texturenum); qfeglActiveTexture (GL_TEXTURE0 + 1); qfeglBindTexture (GL_TEXTURE_2D, frame2->gl_texturenum); qfeglVertexAttrib4fv (quake_sprite.colora.location, color); qfeglVertexAttrib4fv (quake_sprite.colorb.location, color); qfeglVertexAttrib1f (quake_sprite.blend.location, blend); make_quad (frame1, svpn, svright, svup, vertsa); make_quad (frame2, svpn, svright, svup, vertsb); qfeglVertexAttribPointer (quake_sprite.vertexa.location, 3, GL_FLOAT, 0, 0, vertsa); qfeglVertexAttribPointer (quake_sprite.vertexb.location, 3, GL_FLOAT, 0, 0, vertsb); qfeglVertexAttribPointer (quake_sprite.uvab.location, 4, GL_FLOAT, 0, 0, uvab); qfeglDrawArrays (GL_TRIANGLES, 0, 6); }