Given an object, renders the representation of this splinter
| 33 | |
| 34 | // Given an object, renders the representation of this splinter |
| 35 | void DrawSplinterObject(object *obj) { |
| 36 | ASSERT(obj->type == OBJ_SPLINTER); |
| 37 | int i; |
| 38 | poly_model *pm = &Poly_models[obj->id]; |
| 39 | bsp_info *sm = &pm->submodel[obj->ctype.splinter_info.subobj_num]; |
| 40 | int facenum = obj->ctype.splinter_info.facenum; |
| 41 | vector world_verts[MAX_VERTS_PER_SPLINTER]; |
| 42 | vector temp_vec; |
| 43 | g3Point pnts[MAX_VERTS_PER_SPLINTER]; |
| 44 | g3Point *pntlist[MAX_VERTS_PER_SPLINTER]; |
| 45 | |
| 46 | int limit = std::min<int>(MAX_VERTS_PER_SPLINTER, sm->faces[facenum].nverts); |
| 47 | float lifenorm = 1.0 - ((obj->lifetime - obj->lifeleft) / obj->lifetime); |
| 48 | |
| 49 | rend_SetLighting(LS_NONE); |
| 50 | rend_SetAlphaType(AT_CONSTANT); |
| 51 | rend_SetAlphaValue(255 * lifenorm); |
| 52 | rend_SetTextureType(TT_LINEAR); |
| 53 | |
| 54 | lifenorm = 1.0; |
| 55 | |
| 56 | for (i = 0; i < limit; i++) { |
| 57 | // Scale a vert based on the life of the object |
| 58 | temp_vec = obj->ctype.splinter_info.verts[i] * lifenorm; |
| 59 | |
| 60 | vm_MatrixMulVector(&world_verts[i], &temp_vec, &obj->orient); |
| 61 | |
| 62 | world_verts[i] += obj->pos; |
| 63 | g3_RotatePoint(&pnts[i], &world_verts[i]); |
| 64 | pntlist[i] = &pnts[i]; |
| 65 | pnts[i].p3_u = sm->faces[facenum].u[i]; |
| 66 | pnts[i].p3_v = sm->faces[facenum].v[i]; |
| 67 | } |
| 68 | |
| 69 | int bm_handle = GetTextureBitmap(pm->textures[sm->faces[facenum].texnum], 0); |
| 70 | g3_DrawPoly(limit, pntlist, bm_handle); |
| 71 | } |
| 72 | |
| 73 | // do whatever needs to be done for this piece of splinter for this frame |
| 74 | void DoSplinterFrame(object *obj) { |
no test coverage detected