void warpin_queue_render(draw_list *scene, object *obj, matrix *orient, vec3d *pos, int texture_bitmap_num, float radius, float life_percent, float max_radius, int warp_3d) { vec3d center; vec3d vecs[5]; vertex verts[5]; vm_vec_scale_add( ¢er, pos, &orient->vec.fvec, -(max_radius/2.5f)/3.0f ); if (Warp_glow_bitmap >= 0) { float r = radius; bool render_it = true; #define OUT_PERCENT1 0.80f #define OUT_PERCENT2 0.90f #define IN_PERCENT1 0.10f #define IN_PERCENT2 0.20f if (Cmdline_warp_flash) { if ( (life_percent >= IN_PERCENT1) && (life_percent < IN_PERCENT2) ) { r *= (life_percent - IN_PERCENT1) / (IN_PERCENT2 - IN_PERCENT1); //render_it = true; } else if ( (life_percent >= OUT_PERCENT1) && (life_percent < OUT_PERCENT2) ) { r *= (OUT_PERCENT2 - life_percent) / (OUT_PERCENT2 - OUT_PERCENT1); //render_it = true; } } if (render_it) { // Add in noise int noise_frame = fl2i(Missiontime/15.0f) % NOISE_NUM_FRAMES; r *= (0.40f + Noise[noise_frame] * 0.30f); // Bobboau's warp thingie, toggled by cmdline if (Cmdline_warp_flash) { r += powf((2.0f * life_percent) - 1.0f, 24.0f) * max_radius * 1.5f; } vecs[4] = center; verts[4].texture_position.u = 0.5f; verts[4].texture_position.v = 0.5f; g3_transfer_vertex( &verts[4], &vecs[4] ); float alpha = (The_mission.flags[Mission::Mission_Flags::Fullneb]) ? (1.0f - neb2_get_fog_intensity(obj)) : 1.0f; batch_add_bitmap(Warp_glow_bitmap, TMAP_FLAG_TEXTURED | TMAP_HTL_3D_UNLIT | TMAP_FLAG_EMISSIVE , &verts[4], 0, r, alpha); } } if ( (Warp_model >= 0) && (warp_3d || Cmdline_3dwarp) ) { model_render_params render_info; float scale = radius / 25.0f; vec3d warp_scale; warp_scale.xyz.x = warp_scale.xyz.y = warp_scale.xyz.z = scale; float dist = vm_vec_dist_quick( pos, &Eye_position ); render_info.set_warp_params(texture_bitmap_num, radius/max_radius, warp_scale); render_info.set_detail_level_lock((int)(dist / (radius * 10.0f))); render_info.set_flags(MR_NO_LIGHTING | MR_NORMAL | MR_NO_FOGGING | MR_NO_CULL | MR_NO_BATCH); model_render_queue( &render_info, scene, Warp_model, orient, pos); } else { float Grid_depth = radius/2.5f; // gr_set_bitmap( texture_bitmap_num, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 1.0f ); vm_vec_scale_add( &vecs[0], ¢er, &orient->vec.uvec, radius ); vm_vec_scale_add2( &vecs[0], &orient->vec.rvec, -radius ); vm_vec_scale_add2( &vecs[0], &orient->vec.fvec, Grid_depth ); vm_vec_scale_add( &vecs[1], ¢er, &orient->vec.uvec, radius ); vm_vec_scale_add2( &vecs[1], &orient->vec.rvec, radius ); vm_vec_scale_add2( &vecs[1], &orient->vec.fvec, Grid_depth ); vm_vec_scale_add( &vecs[2], ¢er, &orient->vec.uvec, -radius ); vm_vec_scale_add2( &vecs[2], &orient->vec.rvec, radius ); vm_vec_scale_add2( &vecs[2], &orient->vec.fvec, Grid_depth ); vm_vec_scale_add( &vecs[3], ¢er, &orient->vec.uvec, -radius ); vm_vec_scale_add2( &vecs[3], &orient->vec.rvec, -radius ); vm_vec_scale_add2( &vecs[3], &orient->vec.fvec, Grid_depth ); // vm_vec_scale_add( &vecs[4], ¢er, &orient->vec.fvec, -Grid_depth ); vecs[4] = center; verts[0].texture_position.u = 0.01f; verts[0].texture_position.v = 0.01f; verts[1].texture_position.u = 0.99f; verts[1].texture_position.v = 0.01f; verts[2].texture_position.u = 0.99f; verts[2].texture_position.v = 0.99f; verts[3].texture_position.u = 0.01f; verts[3].texture_position.v = 0.99f; verts[4].texture_position.u = 0.5f; verts[4].texture_position.v = 0.5f; g3_transfer_vertex( &verts[0], &vecs[0] ); g3_transfer_vertex( &verts[1], &vecs[1] ); g3_transfer_vertex( &verts[2], &vecs[2] ); g3_transfer_vertex( &verts[3], &vecs[3] ); g3_transfer_vertex( &verts[4], &vecs[4] ); warpin_batch_draw_face( texture_bitmap_num, &verts[0], &verts[4], &verts[1] ); warpin_batch_draw_face( texture_bitmap_num, &verts[1], &verts[4], &verts[2] ); warpin_batch_draw_face( texture_bitmap_num, &verts[4], &verts[3], &verts[2] ); warpin_batch_draw_face( texture_bitmap_num, &verts[0], &verts[3], &verts[4] ); } if (Warp_ball_bitmap > -1 && Cmdline_warp_flash == 1) { //flash_ball warp_ball(20, .1f,.25f, &vmd_z_vector, &vmd_zero_vector, 4.0f, 0.5f); flash_ball warp_ball(20, .1f,.25f, &orient->vec.fvec, pos, 4.0f, 0.5f); float adg = (2.0f * life_percent) - 1.0f; float pct = (powf(adg, 4.0f) - powf(adg, 128.0f)) * 4.0f; if (pct > 0.00001f) { warp_ball.render(Warp_ball_bitmap, max_radius * pct * 0.5f, adg * adg, adg * adg * 6.0f); } } }
void particle_render_all() { ubyte flags; float pct_complete; float alpha; vertex pos; vec3d ts, te, temp; int rotate = 1; int framenum, cur_frame; bool render_batch = false; int tmap_flags = TMAP_FLAG_TEXTURED | TMAP_HTL_3D_UNLIT | TMAP_FLAG_SOFT_QUAD; if ( !Particles_enabled ) return; MONITOR_INC( NumParticlesRend, Num_particles ); if ( Particles.empty() ) return; for (SCP_vector<particle*>::iterator p = Particles.begin(); p != Particles.end(); ++p) { particle* part = *p; // skip back-facing particles (ripped from fullneb code) // Wanderer - add support for attached particles vec3d p_pos; if (part->attached_objnum >= 0) { vm_vec_unrotate(&p_pos, &part->pos, &Objects[part->attached_objnum].orient); vm_vec_add2(&p_pos, &Objects[part->attached_objnum].pos); } else { p_pos = part->pos; } if ( vm_vec_dot_to_point(&Eye_matrix.vec.fvec, &Eye_position, &p_pos) <= 0.0f ) { continue; } // calculate the alpha to draw at alpha = get_current_alpha(&p_pos); // if it's transparent then just skip it if (alpha <= 0.0f) { continue; } // make sure "rotate" is enabled for this particle rotate = 1; // if this is a tracer style particle, calculate tracer vectors if (part->tracer_length > 0.0f) { ts = p_pos; temp = part->velocity; vm_vec_normalize_quick(&temp); vm_vec_scale_add(&te, &ts, &temp, part->tracer_length); // don't bother rotating rotate = 0; } // rotate the vertex if (rotate) { flags = g3_rotate_vertex( &pos, &p_pos ); if ( flags ) { continue; } if (!Cmdline_nohtl) g3_transfer_vertex(&pos, &p_pos); } // pct complete for the particle pct_complete = part->age / part->max_life; // figure out which frame we should be using if (part->nframes > 1) { framenum = fl2i(pct_complete * part->nframes + 0.5); CLAMP(framenum, 0, part->nframes-1); cur_frame = part->reverse ? (part->nframes - framenum - 1) : framenum; } else { cur_frame = 0; } if (part->type == PARTICLE_DEBUG) { gr_set_color( 255, 0, 0 ); g3_draw_sphere_ez( &p_pos, part->radius ); } else { framenum = part->optional_data; Assert( cur_frame < part->nframes ); // if this is a tracer style particle if (part->tracer_length > 0.0f) { batch_add_laser( framenum + cur_frame, &ts, part->radius, &te, part->radius ); } // draw as a regular bitmap else { batch_add_bitmap( framenum + cur_frame, tmap_flags, &pos, part->particle_index % 8, part->radius, alpha ); } render_batch = true; } } profile_begin("Batch Render"); if (render_batch) { batch_render_all(Particle_buffer_object); } profile_end("Batch Render"); }