2009-07-17 22:28:16 +00:00
/*
Copyright ( C ) 1996 - 1997 Id Software , Inc .
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation ; either version 2
of the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
See the included ( GNU . txt ) GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
2008-11-09 22:29:28 +00:00
# include "quakedef.h"
# ifdef PSET_CLASSIC
# include "glquake.h"
2009-11-04 21:16:50 +00:00
# include "shader.h"
# include "renderque.h"
2008-11-09 22:29:28 +00:00
2011-10-27 15:46:36 +00:00
# define POLYS
2015-08-20 03:17:47 +00:00
# ifdef FTE_TARGET_WEB
# define rand myrand //emscripten's libc is doing a terrible job of this.
static int rand ( void )
{ //ripped from glibc
static int state = 0xdeadbeef ;
int val = ( ( state * 1103515245 ) + 12345 ) & 0x7fffffff ;
state = val ;
return val ;
}
# endif
2008-11-09 22:29:28 +00:00
typedef enum {
DODGY ,
ROCKET_TRAIL ,
ALT_ROCKET_TRAIL ,
BLOOD_TRAIL ,
GRENADE_TRAIL ,
BIG_BLOOD_TRAIL ,
TRACER1_TRAIL ,
TRACER2_TRAIL ,
VOOR_TRAIL ,
2015-03-03 07:54:10 +00:00
BRIGHTFIELD_POINT ,
2008-11-09 22:29:28 +00:00
BLOBEXPLOSION_POINT ,
LAVASPLASH_POINT ,
EXPLOSION_POINT ,
2015-08-20 03:17:47 +00:00
EXPLOSION2_POINT ,
2008-11-09 22:29:28 +00:00
TELEPORTSPLASH_POINT ,
2014-10-05 20:04:11 +00:00
MUZZLEFLASH_POINT ,
2008-11-09 22:29:28 +00:00
EFFECTTYPE_MAX
} effect_type_t ;
2009-11-04 21:16:50 +00:00
typedef struct cparticle_s
{
avec3_t org ;
float die ;
avec3_t vel ;
float ramp ;
enum
{
2008-11-09 22:29:28 +00:00
pt_static ,
pt_fire ,
pt_explode ,
pt_explode2 ,
pt_blob ,
pt_blob2 ,
pt_grav ,
2015-03-03 07:54:10 +00:00
pt_slowgrav ,
pt_oneframe
2008-11-09 22:29:28 +00:00
} type ;
2011-06-29 18:39:11 +00:00
unsigned int rgb ;
2008-11-09 22:29:28 +00:00
struct cparticle_s * next ;
} cparticle_t ;
# define DEFAULT_NUM_PARTICLES 2048
# define ABSOLUTE_MIN_PARTICLES 512
# define ABSOLUTE_MAX_PARTICLES 8192
static int r_numparticles ;
2015-08-20 03:17:47 +00:00
static cparticle_t * particles , * active_particles , * free_particles ;
2014-09-02 02:44:43 +00:00
extern cvar_t r_part_density , r_part_classic_expgrav ;
2008-11-09 22:29:28 +00:00
2015-03-03 07:54:10 +00:00
static unsigned int particleframe ;
2011-06-29 18:39:11 +00:00
extern qbyte default_quakepal [ ] ; /*for ramps more than anything else*/
2008-11-09 22:29:28 +00:00
static int ramp1 [ 8 ] = { 0x6f , 0x6d , 0x6b , 0x69 , 0x67 , 0x65 , 0x63 , 0x61 } ;
static int ramp2 [ 8 ] = { 0x6f , 0x6e , 0x6d , 0x6c , 0x6b , 0x6a , 0x68 , 0x66 } ;
static int ramp3 [ 8 ] = { 0x6d , 0x6b , 6 , 5 , 4 , 3 } ;
2011-06-29 18:39:11 +00:00
# define qpal(q) ((default_quakepal[(q)*3+0]<<0) | (default_quakepal[(q)*3+1]<<8) | (default_quakepal[(q)*3+2]<<16))
2008-11-09 22:29:28 +00:00
2011-10-27 15:46:36 +00:00
# ifndef POLYS
2009-11-04 21:16:50 +00:00
# define BUFFERVERTS 2048*3
static vecV_t classicverts [ BUFFERVERTS ] ;
static union c
{
byte_vec4_t b ;
unsigned int i ;
} classiccolours [ BUFFERVERTS ] ;
static vec2_t classictexcoords [ BUFFERVERTS ] ;
2010-07-11 02:22:39 +00:00
static index_t classicindexes [ BUFFERVERTS ] ;
2014-03-30 08:55:06 +00:00
static mesh_t classicmesh ;
2011-10-27 15:46:36 +00:00
# endif
2009-11-04 21:16:50 +00:00
static shader_t * classicshader ;
2008-11-09 22:29:28 +00:00
//obtains an index for the name, even if it is unknown (one can be loaded after. will only fail if the effect limit is reached)
//technically this function is not meant to fail often, but thats fine so long as the other functions are meant to safely reject invalid effect numbers.
2014-03-30 08:55:06 +00:00
static int PClassic_FindParticleType ( const char * name )
2008-11-09 22:29:28 +00:00
{
if ( ! stricmp ( " tr_rocket " , name ) )
return ROCKET_TRAIL ;
if ( ! stricmp ( " tr_altrocket " , name ) )
return ALT_ROCKET_TRAIL ;
if ( ! stricmp ( " tr_slightblood " , name ) )
return BLOOD_TRAIL ;
if ( ! stricmp ( " tr_grenade " , name ) )
return GRENADE_TRAIL ;
if ( ! stricmp ( " tr_blood " , name ) )
return BIG_BLOOD_TRAIL ;
if ( ! stricmp ( " tr_wizspike " , name ) )
return TRACER1_TRAIL ;
if ( ! stricmp ( " tr_knightspike " , name ) )
return TRACER2_TRAIL ;
if ( ! stricmp ( " tr_vorespike " , name ) )
return VOOR_TRAIL ;
if ( ! stricmp ( " te_tarexplosion " , name ) )
return BLOBEXPLOSION_POINT ;
if ( ! stricmp ( " te_lavasplash " , name ) )
return LAVASPLASH_POINT ;
if ( ! stricmp ( " te_explosion " , name ) )
return EXPLOSION_POINT ;
2015-08-20 03:17:47 +00:00
if ( ! strnicmp ( " te_explosion2_ " , name , 14 ) )
{
char * e ;
int start = strtoul ( name + 14 , & e , 10 ) ;
int len = strtoul ( ( * e = = ' _ ' ) ? e + 1 : e , & e , 10 ) ;
if ( ! * e & & start > = 0 & & start < = 255 & & len > = 0 & & len < = 255 )
return EXPLOSION2_POINT | ( start < < 8 ) | ( len < < 16 ) ;
}
2008-11-09 22:29:28 +00:00
if ( ! stricmp ( " te_teleport " , name ) )
return TELEPORTSPLASH_POINT ;
2014-10-05 20:04:11 +00:00
if ( ! stricmp ( " te_muzzleflash " , name ) )
return MUZZLEFLASH_POINT ;
2015-03-03 07:54:10 +00:00
if ( ! stricmp ( " ef_brightfield " , name ) )
return BRIGHTFIELD_POINT ;
2008-11-09 22:29:28 +00:00
return P_INVALID ;
}
2014-03-30 08:55:06 +00:00
static qboolean PClassic_Query ( int type , int body , char * outstr , int outstrlen )
2012-01-17 07:57:46 +00:00
{
char * n = NULL ;
2015-08-20 03:17:47 +00:00
switch ( type & 0xff )
2012-01-17 07:57:46 +00:00
{
case ROCKET_TRAIL :
n = " tr_rocket " ;
break ;
case ALT_ROCKET_TRAIL :
n = " tr_altrocket " ;
break ;
case BLOOD_TRAIL :
n = " tr_slightblood " ;
break ;
case GRENADE_TRAIL :
n = " tr_grenade " ;
break ;
case BIG_BLOOD_TRAIL :
n = " tr_blood " ;
break ;
case TRACER1_TRAIL :
n = " tr_wizspike " ;
break ;
case TRACER2_TRAIL :
n = " tr_knightspike " ;
break ;
case VOOR_TRAIL :
n = " tr_vorespike " ;
break ;
case BLOBEXPLOSION_POINT :
n = " te_tarexplosion " ;
break ;
case LAVASPLASH_POINT :
n = " te_lavasplash " ;
break ;
case EXPLOSION_POINT :
n = " te_explosion " ;
break ;
2015-08-20 03:17:47 +00:00
case EXPLOSION2_POINT :
n = va ( " te_explosion2_%i_%i " , ( type > > 8 ) & 0xff , ( type > > 16 ) & 0xff ) ;
break ;
2012-01-17 07:57:46 +00:00
case TELEPORTSPLASH_POINT :
n = " te_teleport " ;
break ;
2015-03-03 07:54:10 +00:00
case BRIGHTFIELD_POINT :
n = " ef_brightfield " ;
break ;
2012-01-17 07:57:46 +00:00
}
if ( ! n )
return false ;
if ( body = = 0 )
{
Q_strncpyz ( outstr , n , outstrlen ) ;
return true ;
}
return false ;
}
2008-11-09 22:29:28 +00:00
//a convienience function.
static int PClassic_RunParticleEffectTypeString ( vec3_t org , vec3_t dir , float count , char * name )
{
int efnum = P_FindParticleType ( name ) ;
return P_RunParticleEffectState ( org , dir , count , efnum , NULL ) ;
}
//DP extension: add particles within a box that look like rain or snow.
static void PClassic_RunParticleWeather ( vec3_t minb , vec3_t maxb , vec3_t dir , float count , int colour , char * efname )
{
}
//DP extension: add particles within a box.
2013-12-29 22:48:28 +00:00
static void PClassic_RunParticleCube ( int ptype , vec3_t minb , vec3_t maxb , vec3_t dir_min , vec3_t dir_max , float count , int colour , qboolean gravity , float jitter )
2008-11-09 22:29:28 +00:00
{
}
//hexen2 support: add particles flying out from a point with a randomized speed
static void PClassic_RunParticleEffect2 ( vec3_t org , vec3_t dmin , vec3_t dmax , int color , int effect , int count )
{
}
//hexen2 support: add particles within a box.
static void PClassic_RunParticleEffect3 ( vec3_t org , vec3_t box , int color , int effect , int count )
{
}
//hexen2 support: add particles around the spot in a radius. no idea what the 'effect' field is.
static void PClassic_RunParticleEffect4 ( vec3_t org , float radius , int color , int effect , int count )
{
}
//this function is used as a fallback in case a trail effect is unknown.
static void PClassic_ParticleTrailIndex ( vec3_t start , vec3_t end , int color , int crnd , trailstate_t * * tsk )
{
}
//this function is called to tell the particle system about surfaces that might emit particles at map startup.
2010-12-18 17:02:47 +00:00
static void PClassic_EmitSkyEffectTris ( model_t * mod , msurface_t * fa , int ptype )
2008-11-09 22:29:28 +00:00
{
}
//the one-time initialisation function, called no mater which renderer is active.
2010-07-11 02:22:39 +00:00
static qboolean PClassic_InitParticles ( void )
2008-11-09 22:29:28 +00:00
{
int i ;
2009-11-04 21:16:50 +00:00
if ( ( i = COM_CheckParm ( " -particles " ) ) & & i + 1 < com_argc )
{
2008-11-09 22:29:28 +00:00
r_numparticles = ( int ) ( Q_atoi ( com_argv [ i + 1 ] ) ) ;
r_numparticles = bound ( ABSOLUTE_MIN_PARTICLES , r_numparticles , ABSOLUTE_MAX_PARTICLES ) ;
2009-11-04 21:16:50 +00:00
}
else
{
2008-11-09 22:29:28 +00:00
r_numparticles = DEFAULT_NUM_PARTICLES ;
}
2008-11-28 20:34:51 +00:00
particles = ( cparticle_t * ) BZ_Malloc ( r_numparticles * sizeof ( cparticle_t ) ) ;
2008-11-09 22:29:28 +00:00
2011-10-27 15:46:36 +00:00
# ifndef POLYS
2009-11-04 21:16:50 +00:00
for ( i = 0 ; i < BUFFERVERTS ; i + = 3 )
{
classictexcoords [ i + 1 ] [ 0 ] = 1 ;
classictexcoords [ i + 2 ] [ 1 ] = 1 ;
classicindexes [ i + 0 ] = i + 0 ;
classicindexes [ i + 1 ] = i + 1 ;
classicindexes [ i + 2 ] = i + 2 ;
}
classicmesh . xyz_array = classicverts ;
classicmesh . st_array = classictexcoords ;
classicmesh . colors4b_array = ( byte_vec4_t * ) classiccolours ;
classicmesh . indexes = classicindexes ;
2011-10-27 15:46:36 +00:00
# endif
2013-08-21 07:14:39 +00:00
classicshader = R_RegisterShader ( " particles_classic " , SUF_NONE ,
2009-11-04 21:16:50 +00:00
" { \n "
2011-12-23 03:12:29 +00:00
" program defaultsprite \n "
2010-11-02 23:17:25 +00:00
" nomipmaps \n "
2014-08-15 02:20:41 +00:00
" surfaceparm nodlight \n "
2009-11-04 21:16:50 +00:00
" { \n "
2014-08-15 02:20:41 +00:00
" if r_part_classic_square \n "
" map classicparticle_square \n "
" else \n "
" map classicparticle \n "
" endif \n "
2009-11-04 21:16:50 +00:00
" rgbgen vertex \n "
" alphagen vertex \n "
" blendfunc blend \n "
" } \n "
" } \n "
) ;
2010-07-11 02:22:39 +00:00
return true ;
2008-11-09 22:29:28 +00:00
}
static void PClassic_ShutdownParticles ( void )
{
BZ_Free ( particles ) ;
2010-12-18 17:02:47 +00:00
particles = NULL ;
2008-11-09 22:29:28 +00:00
}
2011-06-18 13:05:14 +00:00
// a classic trailstate is really just a float stored in a pointer variable...
// assuming float alignment/size is more strict than pointer
static float Classic_GetLeftover ( trailstate_t * * tsk )
{
float * f = ( float * ) tsk ;
if ( ! f )
return 0 ;
return * f ;
}
static void Classic_SetLeftover ( trailstate_t * * tsk , float leftover )
{
float * f = ( float * ) tsk ;
if ( f )
* f = leftover ;
}
2008-11-09 22:29:28 +00:00
//called when an entity is removed from the world, taking its trailstate with it.
static void PClassic_DelinkTrailstate ( trailstate_t * * tsk )
{
2011-06-18 13:05:14 +00:00
* tsk = NULL ;
2008-11-09 22:29:28 +00:00
}
//wipes all the particles ready for the next map.
static void PClassic_ClearParticles ( void )
{
int i ;
free_particles = & particles [ 0 ] ;
active_particles = NULL ;
for ( i = 0 ; i < r_numparticles ; i + + )
particles [ i ] . next = & particles [ i + 1 ] ;
particles [ r_numparticles - 1 ] . next = NULL ;
}
2015-03-03 07:54:10 +00:00
//some particles (brightfield) must last only one frame
static void PClassic_ClearPerFrame ( void )
{
if ( particleframe ! = - 1 & & particleframe ! = cl_framecount )
{
cparticle_t * * link , * kill ;
for ( link = & active_particles ; * link ; )
{
if ( ( * link ) - > type = = pt_oneframe )
{
kill = * link ;
* link = kill - > next ;
kill - > next = free_particles ;
free_particles = kill ;
}
else
link = & ( * link ) - > next ;
}
}
}
2008-11-09 22:29:28 +00:00
//draws all the active particles.
static void PClassic_DrawParticles ( void )
{
cparticle_t * p , * kill ;
int i ;
float time2 , time3 , time1 , dvel , frametime , grav ;
vec3_t up , right ;
2008-11-28 20:34:51 +00:00
float dist , scale , r_partscale = 0 ;
2011-10-27 15:46:36 +00:00
# ifdef POLYS
scenetris_t * scenetri ;
# else
union c usecolours ;
# endif
static float oldtime ;
2009-11-04 21:16:50 +00:00
RSpeedMark ( ) ;
2008-11-09 22:29:28 +00:00
if ( ! active_particles )
2009-03-03 01:52:30 +00:00
{
2011-12-05 15:23:40 +00:00
oldtime = cl . time ;
2008-11-09 22:29:28 +00:00
return ;
2009-03-03 01:52:30 +00:00
}
2008-11-09 22:29:28 +00:00
2015-03-03 07:54:10 +00:00
if ( particleframe ! = - 1 & & particleframe ! = cl_framecount )
{
PClassic_ClearPerFrame ( ) ;
particleframe = - 1 ;
}
2015-06-12 14:44:50 +00:00
if ( r_refdef . useperspective )
r_partscale = 0.004 * tan ( r_refdef . fov_x * ( M_PI / 180 ) * 0.5f ) ;
else
r_partscale = 0 ;
2009-11-04 21:16:50 +00:00
VectorScale ( vup , 1.5 , up ) ;
VectorScale ( vright , 1.5 , right ) ;
2008-11-09 22:29:28 +00:00
2011-10-27 15:46:36 +00:00
frametime = cl . time - oldtime ;
oldtime = cl . time ;
frametime = bound ( 0 , frametime , 1 ) ;
2010-07-11 02:22:39 +00:00
if ( cl . paused | | r_secondaryview | | r_refdef . recurse )
2008-11-09 22:29:28 +00:00
frametime = 0 ;
time3 = frametime * 15 ;
time2 = frametime * 10 ; // 15;
time1 = frametime * 5 ;
grav = frametime * 800 * 0.05 ;
dvel = 4 * frametime ;
2011-10-27 15:46:36 +00:00
# ifdef POLYS
2015-03-03 00:14:43 +00:00
// if (cl_numstris && cl_stris[cl_numstris-1].shader == classicshader && cl_stris[cl_numstris-1].numvert + 8 <= MAX_INDICIES)
// scenetri = &cl_stris[cl_numstris-1];
// else
2011-10-27 15:46:36 +00:00
{
if ( cl_numstris = = cl_maxstris )
{
cl_maxstris + = 8 ;
cl_stris = BZ_Realloc ( cl_stris , sizeof ( * cl_stris ) * cl_maxstris ) ;
}
scenetri = & cl_stris [ cl_numstris + + ] ;
scenetri - > shader = classicshader ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
scenetri - > flags = BEF_NODLIGHT | BEF_NOSHADOWS ;
2011-10-27 15:46:36 +00:00
scenetri - > firstidx = cl_numstrisidx ;
scenetri - > firstvert = cl_numstrisvert ;
scenetri - > numvert = 0 ;
scenetri - > numidx = 0 ;
}
# endif
2008-11-09 22:29:28 +00:00
while ( 1 )
{
kill = active_particles ;
if ( kill & & kill - > die < cl . time )
{
active_particles = kill - > next ;
kill - > next = free_particles ;
free_particles = kill ;
continue ;
}
break ;
}
for ( p = active_particles ; p ; p = p - > next )
{
while ( 1 )
{
kill = p - > next ;
if ( kill & & kill - > die < cl . time )
{
p - > next = kill - > next ;
kill - > next = free_particles ;
free_particles = kill ;
continue ;
}
break ;
}
2011-10-27 15:46:36 +00:00
// hack a scale up to keep particles from disapearing
dist = ( p - > org [ 0 ] - r_origin [ 0 ] ) * vpn [ 0 ] + ( p - > org [ 1 ] - r_origin [ 1 ] ) * vpn [ 1 ] + ( p - > org [ 2 ] - r_origin [ 2 ] ) * vpn [ 2 ] ;
scale = 1 + dist * r_partscale ;
# ifdef POLYS
if ( cl_numstrisvert + 3 > cl_maxstrisvert )
{
2012-04-24 07:59:11 +00:00
cl_maxstrisvert + = 1024 * 3 ;
2011-10-27 15:46:36 +00:00
cl_strisvertv = BZ_Realloc ( cl_strisvertv , sizeof ( * cl_strisvertv ) * cl_maxstrisvert ) ;
cl_strisvertt = BZ_Realloc ( cl_strisvertt , sizeof ( * cl_strisvertt ) * cl_maxstrisvert ) ;
cl_strisvertc = BZ_Realloc ( cl_strisvertc , sizeof ( * cl_strisvertc ) * cl_maxstrisvert ) ;
}
2011-12-23 03:12:29 +00:00
// Vector4Set(cl_strisvertc[cl_numstrisvert+0],1,1,1,1);
// Vector4Set(cl_strisvertc[cl_numstrisvert+1],1,1,1,1);
// Vector4Set(cl_strisvertc[cl_numstrisvert+2],1,1,1,1);
2011-10-27 15:46:36 +00:00
Vector4Set ( cl_strisvertc [ cl_numstrisvert + 0 ] , ( ( p - > rgb & 0xff ) > > 0 ) / 256.0 , ( ( p - > rgb & 0xff00 ) > > 8 ) / 256.0 , ( ( p - > rgb & 0xff0000 ) > > 16 ) / 256.0 , ( ( p - > type = = pt_fire ) ? ( ( 6 - p - > ramp ) * 0.166666 ) : 1.0 ) ) ;
Vector4Copy ( cl_strisvertc [ cl_numstrisvert + 0 ] , cl_strisvertc [ cl_numstrisvert + 1 ] ) ;
Vector4Copy ( cl_strisvertc [ cl_numstrisvert + 0 ] , cl_strisvertc [ cl_numstrisvert + 2 ] ) ;
Vector2Set ( cl_strisvertt [ cl_numstrisvert + 0 ] , 0 , 0 ) ;
Vector2Set ( cl_strisvertt [ cl_numstrisvert + 1 ] , 1 , 0 ) ;
Vector2Set ( cl_strisvertt [ cl_numstrisvert + 2 ] , 0 , 1 ) ;
VectorCopy ( p - > org , cl_strisvertv [ cl_numstrisvert + 0 ] ) ;
VectorMA ( p - > org , scale , up , cl_strisvertv [ cl_numstrisvert + 1 ] ) ;
VectorMA ( p - > org , scale , right , cl_strisvertv [ cl_numstrisvert + 2 ] ) ;
if ( cl_numstrisidx + 3 > cl_maxstrisidx )
{
2012-04-24 07:59:11 +00:00
cl_maxstrisidx + = 1024 * 3 ;
2011-10-27 15:46:36 +00:00
cl_strisidx = BZ_Realloc ( cl_strisidx , sizeof ( * cl_strisidx ) * cl_maxstrisidx ) ;
}
cl_strisidx [ cl_numstrisidx + + ] = ( cl_numstrisvert - scenetri - > firstvert ) + 0 ;
cl_strisidx [ cl_numstrisidx + + ] = ( cl_numstrisvert - scenetri - > firstvert ) + 1 ;
cl_strisidx [ cl_numstrisidx + + ] = ( cl_numstrisvert - scenetri - > firstvert ) + 2 ;
cl_numstrisvert + = 3 ;
scenetri - > numvert + = 3 ;
scenetri - > numidx + = 3 ;
# else
2009-11-04 21:16:50 +00:00
if ( classicmesh . numvertexes > = BUFFERVERTS - 3 )
2008-11-09 22:29:28 +00:00
{
2009-11-04 21:16:50 +00:00
classicmesh . numindexes = classicmesh . numvertexes ;
2011-04-20 23:34:13 +00:00
BE_DrawMesh_Single ( classicshader , & classicmesh , NULL , & classicshader - > defaulttextures , 0 ) ;
2009-11-04 21:16:50 +00:00
classicmesh . numvertexes = 0 ;
}
2011-06-29 18:39:11 +00:00
usecolours . i = p - > rgb ;
2009-11-04 21:16:50 +00:00
if ( p - > type = = pt_fire )
usecolours . b [ 3 ] = 255 * ( 6 - p - > ramp ) / 6 ;
else
usecolours . b [ 3 ] = 255 ;
classiccolours [ classicmesh . numvertexes ] . i = usecolours . i ;
VectorCopy ( p - > org , classicverts [ classicmesh . numvertexes ] ) ;
classicmesh . numvertexes + + ;
classiccolours [ classicmesh . numvertexes ] . i = usecolours . i ;
VectorMA ( p - > org , scale , up , classicverts [ classicmesh . numvertexes ] ) ;
classicmesh . numvertexes + + ;
classiccolours [ classicmesh . numvertexes ] . i = usecolours . i ;
VectorMA ( p - > org , scale , right , classicverts [ classicmesh . numvertexes ] ) ;
classicmesh . numvertexes + + ;
2011-10-27 15:46:36 +00:00
# endif
2008-11-09 22:29:28 +00:00
p - > org [ 0 ] + = p - > vel [ 0 ] * frametime ;
p - > org [ 1 ] + = p - > vel [ 1 ] * frametime ;
p - > org [ 2 ] + = p - > vel [ 2 ] * frametime ;
switch ( p - > type )
{
2015-03-03 07:54:10 +00:00
case pt_oneframe :
2008-11-09 22:29:28 +00:00
case pt_static :
break ;
case pt_fire :
p - > ramp + = time1 ;
if ( p - > ramp > = 6 )
p - > die = - 1 ;
else
2011-06-29 18:39:11 +00:00
p - > rgb = qpal ( ramp3 [ ( int ) p - > ramp ] ) ;
2008-11-09 22:29:28 +00:00
p - > vel [ 2 ] + = grav ;
break ;
case pt_explode :
p - > ramp + = time2 ;
if ( p - > ramp > = 8 )
p - > die = - 1 ;
else
2011-06-29 18:39:11 +00:00
p - > rgb = qpal ( ramp1 [ ( int ) p - > ramp ] ) ;
2008-11-09 22:29:28 +00:00
for ( i = 0 ; i < 3 ; i + + )
p - > vel [ i ] + = p - > vel [ i ] * dvel ;
2014-09-02 02:44:43 +00:00
p - > vel [ 2 ] - = grav * r_part_classic_expgrav . value ;
2008-11-09 22:29:28 +00:00
break ;
case pt_explode2 :
p - > ramp + = time3 ;
if ( p - > ramp > = 8 )
p - > die = - 1 ;
else
2011-06-29 18:39:11 +00:00
p - > rgb = qpal ( ramp2 [ ( int ) p - > ramp ] ) ;
2008-11-09 22:29:28 +00:00
for ( i = 0 ; i < 3 ; i + + )
p - > vel [ i ] - = p - > vel [ i ] * frametime ;
2014-09-02 02:44:43 +00:00
p - > vel [ 2 ] - = grav * r_part_classic_expgrav . value ;
2008-11-09 22:29:28 +00:00
break ;
case pt_blob :
for ( i = 0 ; i < 3 ; i + + )
p - > vel [ i ] + = p - > vel [ i ] * dvel ;
p - > vel [ 2 ] - = grav ;
break ;
case pt_blob2 :
for ( i = 0 ; i < 2 ; i + + )
p - > vel [ i ] - = p - > vel [ i ] * dvel ;
p - > vel [ 2 ] - = grav ;
break ;
case pt_slowgrav :
case pt_grav :
p - > vel [ 2 ] - = grav ;
break ;
}
}
2011-10-27 15:46:36 +00:00
# ifndef POLYS
2009-11-04 21:16:50 +00:00
if ( classicmesh . numvertexes )
2008-11-09 22:29:28 +00:00
{
2009-11-04 21:16:50 +00:00
classicmesh . numindexes = classicmesh . numvertexes ;
2011-04-20 23:34:13 +00:00
BE_DrawMesh_Single ( classicshader , & classicmesh , NULL , & classicshader - > defaulttextures , 0 ) ;
2009-11-04 21:16:50 +00:00
classicmesh . numvertexes = 0 ;
2008-11-09 22:29:28 +00:00
}
2011-10-27 15:46:36 +00:00
# endif
2008-11-09 22:29:28 +00:00
RSpeedEnd ( RSPEED_PARTICLESDRAW ) ;
}
static void Classic_ParticleExplosion ( vec3_t org )
{
int i , j ;
cparticle_t * p ;
2012-04-24 07:59:11 +00:00
int count ;
count = 1024 * r_part_density . value ;
2008-11-09 22:29:28 +00:00
2012-04-24 07:59:11 +00:00
for ( i = 0 ; i < count ; i + + )
2008-11-09 22:29:28 +00:00
{
if ( ! free_particles )
return ;
p = free_particles ;
free_particles = p - > next ;
p - > next = active_particles ;
active_particles = p ;
p - > die = cl . time + 5 ;
2011-06-29 18:39:11 +00:00
p - > rgb = d_8to24rgbtable [ ramp1 [ 0 ] ] ;
2008-11-09 22:29:28 +00:00
p - > ramp = rand ( ) & 3 ;
if ( i & 1 )
{
p - > type = pt_explode ;
for ( j = 0 ; j < 3 ; j + + )
{
p - > org [ j ] = org [ j ] + ( ( rand ( ) % 32 ) - 16 ) ;
p - > vel [ j ] = ( rand ( ) % 512 ) - 256 ;
}
}
else
{
p - > type = pt_explode2 ;
for ( j = 0 ; j < 3 ; j + + )
{
p - > org [ j ] = org [ j ] + ( ( rand ( ) % 32 ) - 16 ) ;
p - > vel [ j ] = ( rand ( ) % 512 ) - 256 ;
}
}
}
}
2015-08-20 03:17:47 +00:00
static void Classic_ParticleExplosion2 ( vec3_t org , int colorStart , int colorLength )
{
int i , j ;
cparticle_t * p ;
int colorMod = 0 ;
for ( i = 0 ; i < 512 ; i + + )
{
if ( ! free_particles )
return ;
p = free_particles ;
free_particles = p - > next ;
p - > next = active_particles ;
active_particles = p ;
p - > die = cl . time + 0.3 ;
p - > rgb = d_8to24rgbtable [ ( colorStart + ( colorMod % colorLength ) ) & 255 ] ;
colorMod + + ;
p - > type = pt_blob ;
for ( j = 0 ; j < 3 ; j + + )
{
p - > org [ j ] = org [ j ] + ( ( rand ( ) % 32 ) - 16 ) ;
p - > vel [ j ] = ( rand ( ) % 512 ) - 256 ;
}
}
}
2008-11-09 22:29:28 +00:00
static void Classic_BlobExplosion ( vec3_t org )
{
int i , j ;
cparticle_t * p ;
2012-04-24 07:59:11 +00:00
int count ;
count = 1024 * r_part_density . value ;
2008-11-09 22:29:28 +00:00
2012-04-24 07:59:11 +00:00
for ( i = 0 ; i < count ; i + + )
2008-11-09 22:29:28 +00:00
{
if ( ! free_particles )
return ;
p = free_particles ;
free_particles = p - > next ;
p - > next = active_particles ;
active_particles = p ;
p - > die = cl . time + 1 + ( rand ( ) & 8 ) * 0.05 ;
if ( i & 1 )
{
p - > type = pt_blob ;
2011-06-29 18:39:11 +00:00
p - > rgb = d_8to24rgbtable [ 66 + rand ( ) % 6 ] ;
2008-11-09 22:29:28 +00:00
for ( j = 0 ; j < 3 ; j + + )
{
p - > org [ j ] = org [ j ] + ( ( rand ( ) % 32 ) - 16 ) ;
p - > vel [ j ] = ( rand ( ) % 512 ) - 256 ;
}
}
else
{
p - > type = pt_blob2 ;
2011-06-29 18:39:11 +00:00
p - > rgb = d_8to24rgbtable [ 150 + rand ( ) % 6 ] ;
2008-11-09 22:29:28 +00:00
for ( j = 0 ; j < 3 ; j + + )
{
p - > org [ j ] = org [ j ] + ( ( rand ( ) % 32 ) - 16 ) ;
p - > vel [ j ] = ( rand ( ) % 512 ) - 256 ;
}
}
}
}
static void Classic_RunParticleEffect ( vec3_t org , vec3_t dir , int color , int count )
{
int i , j , scale ;
cparticle_t * p ;
if ( ! dir )
dir = vec3_origin ;
scale = ( count > 130 ) ? 3 : ( count > 20 ) ? 2 : 1 ;
2012-04-24 07:59:11 +00:00
count * = r_part_density . value ;
2008-11-09 22:29:28 +00:00
for ( i = 0 ; i < count ; i + + )
{
if ( ! free_particles )
return ;
p = free_particles ;
free_particles = p - > next ;
p - > next = active_particles ;
active_particles = p ;
p - > die = cl . time + 0.1 * ( rand ( ) % 5 ) ;
2011-06-29 18:39:11 +00:00
p - > rgb = d_8to24rgbtable [ ( color & ~ 7 ) + ( rand ( ) & 7 ) ] ;
2008-11-09 22:29:28 +00:00
p - > type = pt_grav ;
for ( j = 0 ; j < 3 ; j + + )
{
p - > org [ j ] = org [ j ] + scale * ( ( rand ( ) & 15 ) - 8 ) ;
p - > vel [ j ] = dir [ j ] * 15 ;
}
}
}
static void Classic_LavaSplash ( vec3_t org )
{
int i , j , k ;
cparticle_t * p ;
float vel ;
vec3_t dir ;
for ( i = - 16 ; i < 16 ; i + + )
{
for ( j = - 16 ; j < 16 ; j + + )
{
for ( k = 0 ; k < 1 ; k + + )
{
if ( ! free_particles )
return ;
p = free_particles ;
free_particles = p - > next ;
p - > next = active_particles ;
active_particles = p ;
p - > die = cl . time + 2 + ( rand ( ) & 31 ) * 0.02 ;
2011-06-29 18:39:11 +00:00
p - > rgb = d_8to24rgbtable [ 224 + ( rand ( ) & 7 ) ] ;
2008-11-09 22:29:28 +00:00
p - > type = pt_grav ;
dir [ 0 ] = j * 8 + ( rand ( ) & 7 ) ;
dir [ 1 ] = i * 8 + ( rand ( ) & 7 ) ;
dir [ 2 ] = 256 ;
p - > org [ 0 ] = org [ 0 ] + dir [ 0 ] ;
p - > org [ 1 ] = org [ 1 ] + dir [ 1 ] ;
p - > org [ 2 ] = org [ 2 ] + ( rand ( ) & 63 ) ;
VectorNormalizeFast ( dir ) ;
vel = 50 + ( rand ( ) & 63 ) ;
VectorScale ( dir , vel , p - > vel ) ;
}
}
}
}
static void Classic_TeleportSplash ( vec3_t org )
{
int i , j , k ;
cparticle_t * p ;
float vel ;
vec3_t dir ;
2012-04-24 07:59:11 +00:00
int st = 4 / r_part_density . value ;
if ( st = = 0 )
st = 1 ;
for ( i = - 16 ; i < 16 ; i + = st )
2008-11-09 22:29:28 +00:00
{
2012-04-24 07:59:11 +00:00
for ( j = - 16 ; j < 16 ; j + = st )
2008-11-09 22:29:28 +00:00
{
2012-04-24 07:59:11 +00:00
for ( k = - 24 ; k < 32 ; k + = st )
2008-11-09 22:29:28 +00:00
{
if ( ! free_particles )
return ;
p = free_particles ;
free_particles = p - > next ;
p - > next = active_particles ;
active_particles = p ;
p - > die = cl . time + 0.2 + ( rand ( ) & 7 ) * 0.02 ;
2011-06-29 18:39:11 +00:00
p - > rgb = d_8to24rgbtable [ 7 + ( rand ( ) & 7 ) ] ;
2008-11-09 22:29:28 +00:00
p - > type = pt_grav ;
dir [ 0 ] = j * 8 ;
dir [ 1 ] = i * 8 ;
dir [ 2 ] = k * 8 ;
p - > org [ 0 ] = org [ 0 ] + i + ( rand ( ) & 3 ) ;
p - > org [ 1 ] = org [ 1 ] + j + ( rand ( ) & 3 ) ;
p - > org [ 2 ] = org [ 2 ] + k + ( rand ( ) & 3 ) ;
VectorNormalizeFast ( dir ) ;
vel = 50 + ( rand ( ) & 63 ) ;
VectorScale ( dir , vel , p - > vel ) ;
}
}
}
}
2015-03-03 07:54:10 +00:00
# define NUMVERTEXNORMALS 162
//vec3_t avelocity = {23, 7, 3};
//float partstep = 0.01;
//float timescale = 0.01;
static vec3_t avelocities [ NUMVERTEXNORMALS ] ;
static void Classic_BrightField ( vec3_t org )
{
extern float r_avertexnormals [ NUMVERTEXNORMALS ] [ 3 ] ;
float beamlength = 16 ;
int i ;
cparticle_t * p ;
float angle ;
2016-02-15 06:01:17 +00:00
float sp , sy , cp , cy ;
2015-03-03 07:54:10 +00:00
vec3_t forward ;
float dist ;
PClassic_ClearPerFrame ( ) ;
particleframe = cl_framecount ;
dist = 64 ;
if ( ! avelocities [ 0 ] [ 0 ] )
{
2016-02-15 06:01:17 +00:00
for ( i = 0 ; i < NUMVERTEXNORMALS ; i + + )
{
avelocities [ i ] [ 0 ] = ( rand ( ) & 255 ) * 0.01 ;
avelocities [ i ] [ 1 ] = ( rand ( ) & 255 ) * 0.01 ;
avelocities [ i ] [ 2 ] = ( rand ( ) & 255 ) * 0.01 ;
}
2015-03-03 07:54:10 +00:00
}
for ( i = 0 ; i < NUMVERTEXNORMALS ; i + + )
{
if ( ! free_particles )
return ;
p = free_particles ;
free_particles = p - > next ;
p - > next = active_particles ;
active_particles = p ;
angle = cl . time * avelocities [ i ] [ 0 ] ;
sy = sin ( angle ) ;
cy = cos ( angle ) ;
angle = cl . time * avelocities [ i ] [ 1 ] ;
sp = sin ( angle ) ;
cp = cos ( angle ) ;
2016-02-15 06:01:17 +00:00
//fixme: is roll important?
2015-03-03 07:54:10 +00:00
forward [ 0 ] = cp * cy ;
forward [ 1 ] = cp * sy ;
forward [ 2 ] = - sp ;
p - > die = cl . time ; // + 0.01;
p - > rgb = d_8to24rgbtable [ 0x6f ] ;
p - > type = pt_oneframe ;
p - > org [ 0 ] = org [ 0 ] + r_avertexnormals [ i ] [ 0 ] * dist + forward [ 0 ] * beamlength ;
p - > org [ 1 ] = org [ 1 ] + r_avertexnormals [ i ] [ 1 ] * dist + forward [ 1 ] * beamlength ;
p - > org [ 2 ] = org [ 2 ] + r_avertexnormals [ i ] [ 2 ] * dist + forward [ 2 ] * beamlength ;
}
}
//svc_tempentity support: this is the function that handles 'special' point effects.
//use the trail state so fast/slow frames keep the correct particle counts on certain every-frame effects
static int PClassic_RunParticleEffectState ( vec3_t org , vec3_t dir , float count , int typenum , trailstate_t * * tsk )
{
2015-08-20 03:17:47 +00:00
switch ( typenum & 0xff )
2015-03-03 07:54:10 +00:00
{
case BRIGHTFIELD_POINT :
Classic_BrightField ( org ) ;
break ;
case BLOBEXPLOSION_POINT :
Classic_BlobExplosion ( org ) ;
break ;
case LAVASPLASH_POINT :
Classic_LavaSplash ( org ) ;
break ;
case EXPLOSION_POINT :
Classic_ParticleExplosion ( org ) ;
break ;
2015-08-20 03:17:47 +00:00
case EXPLOSION2_POINT :
Classic_ParticleExplosion2 ( org , ( typenum > > 8 ) & 0xff , ( typenum > > 16 ) & 0xff ) ;
break ;
2015-03-03 07:54:10 +00:00
case TELEPORTSPLASH_POINT :
Classic_TeleportSplash ( org ) ;
break ;
case MUZZLEFLASH_POINT :
{
dlight_t * dl = CL_AllocDlight ( 0 ) ;
if ( dir )
VectorCopy ( dir , dl - > axis [ 0 ] ) ;
else
VectorSet ( dir , 0 , 0 , 1 ) ;
VectorVectors ( dl - > axis [ 0 ] , dl - > axis [ 1 ] , dl - > axis [ 2 ] ) ;
VectorInverse ( dl - > axis [ 1 ] ) ;
if ( dir )
VectorMA ( org , 15 , dl - > axis [ 0 ] , dl - > origin ) ;
else
VectorCopy ( org , dl - > origin ) ;
dl - > radius = 200 + ( rand ( ) & 31 ) ;
dl - > minlight = 32 ;
dl - > die = cl . time + 0.1 ;
dl - > color [ 0 ] = 1.5 ;
dl - > color [ 1 ] = 1.3 ;
dl - > color [ 2 ] = 1.0 ;
dl - > channelfade [ 0 ] = 1.5 ;
dl - > channelfade [ 1 ] = 0.75 ;
dl - > channelfade [ 2 ] = 0.375 ;
dl - > decay = 1000 ;
# ifdef RTLIGHTS
dl - > lightcolourscales [ 2 ] = 4 ;
# endif
}
break ;
default :
return 1 ;
}
return 0 ;
}
2011-06-18 13:05:14 +00:00
static float Classic_ParticleTrail ( vec3_t start , vec3_t end , float leftover , effect_type_t type )
2008-11-09 22:29:28 +00:00
{
vec3_t point , delta , dir ;
2011-06-18 13:05:14 +00:00
float len , rlen , scale ;
2008-11-09 22:29:28 +00:00
int i , j , num_particles ;
cparticle_t * p ;
static int tracercount ;
2015-03-03 07:54:10 +00:00
if ( type > = BRIGHTFIELD_POINT )
{
PClassic_RunParticleEffectState ( end , vec3_origin , 1 , type , NULL ) ;
return 0 ;
}
2008-11-09 22:29:28 +00:00
VectorCopy ( start , point ) ;
VectorSubtract ( end , start , delta ) ;
if ( ! ( len = VectorLength ( delta ) ) )
goto done ;
VectorScale ( delta , 1 / len , dir ) ; //unit vector in direction of trail
2011-09-03 03:49:43 +00:00
VectorMA ( point , - leftover , dir , point ) ;
2011-06-18 13:05:14 +00:00
len + = leftover ;
rlen = len ;
2009-11-04 21:16:50 +00:00
switch ( type )
{
2008-11-09 22:29:28 +00:00
case ALT_ROCKET_TRAIL :
2011-06-18 13:05:14 +00:00
scale = 1.5 ; break ;
2008-11-09 22:29:28 +00:00
case BLOOD_TRAIL :
2011-06-18 13:05:14 +00:00
scale = 6 ; break ;
2008-11-09 22:29:28 +00:00
default :
2011-06-18 15:00:56 +00:00
scale = 3 ; break ;
2014-03-30 08:55:06 +00:00
case TRACER1_TRAIL :
case TRACER2_TRAIL :
scale = ( r_part_density . value < 0.5 ) ? 6 * r_part_density . value : 3 ;
break ;
2008-11-09 22:29:28 +00:00
}
2012-04-24 07:59:11 +00:00
scale / = r_part_density . value ;
2011-09-03 03:49:43 +00:00
VectorScale ( dir , scale , dir ) ;
2011-06-18 15:00:56 +00:00
2011-06-18 13:05:14 +00:00
len / = scale ;
leftover = rlen - ( ( int ) ( len ) * scale ) ;
2011-09-03 03:49:43 +00:00
num_particles = ( int ) len ;
2008-11-09 22:29:28 +00:00
2009-11-04 21:16:50 +00:00
for ( i = 0 ; i < num_particles & & free_particles ; i + + )
{
2008-11-09 22:29:28 +00:00
p = free_particles ;
free_particles = p - > next ;
p - > next = active_particles ;
active_particles = p ;
VectorClear ( p - > vel ) ;
p - > die = cl . time + 2 ;
2009-11-04 21:16:50 +00:00
switch ( type )
{
2008-11-09 22:29:28 +00:00
case GRENADE_TRAIL :
p - > ramp = ( rand ( ) & 3 ) + 2 ;
2011-06-29 18:39:11 +00:00
p - > rgb = d_8to24rgbtable [ ramp3 [ ( int ) p - > ramp ] ] ;
2008-11-09 22:29:28 +00:00
p - > type = pt_fire ;
for ( j = 0 ; j < 3 ; j + + )
p - > org [ j ] = point [ j ] + ( ( rand ( ) % 6 ) - 3 ) ;
break ;
case BLOOD_TRAIL :
p - > type = pt_slowgrav ;
2011-06-29 18:39:11 +00:00
p - > rgb = d_8to24rgbtable [ 67 + ( rand ( ) & 3 ) ] ;
2008-11-09 22:29:28 +00:00
for ( j = 0 ; j < 3 ; j + + )
p - > org [ j ] = point [ j ] + ( ( rand ( ) % 6 ) - 3 ) ;
break ;
case BIG_BLOOD_TRAIL :
p - > type = pt_slowgrav ;
2011-06-29 18:39:11 +00:00
p - > rgb = d_8to24rgbtable [ 67 + ( rand ( ) & 3 ) ] ;
2008-11-09 22:29:28 +00:00
for ( j = 0 ; j < 3 ; j + + )
p - > org [ j ] = point [ j ] + ( ( rand ( ) % 6 ) - 3 ) ;
break ;
case TRACER1_TRAIL :
case TRACER2_TRAIL :
p - > die = cl . time + 0.5 ;
p - > type = pt_static ;
if ( type = = TRACER1_TRAIL )
2011-06-29 18:39:11 +00:00
p - > rgb = d_8to24rgbtable [ 52 + ( ( tracercount & 4 ) < < 1 ) ] ;
2008-11-09 22:29:28 +00:00
else
2011-06-29 18:39:11 +00:00
p - > rgb = d_8to24rgbtable [ 230 + ( ( tracercount & 4 ) < < 1 ) ] ;
2008-11-09 22:29:28 +00:00
tracercount + + ;
VectorCopy ( point , p - > org ) ;
2009-11-04 21:16:50 +00:00
if ( tracercount & 1 )
{
2008-11-09 22:29:28 +00:00
p - > vel [ 0 ] = 90 * dir [ 1 ] ;
p - > vel [ 1 ] = 90 * - dir [ 0 ] ;
2009-11-04 21:16:50 +00:00
}
else
{
2008-11-09 22:29:28 +00:00
p - > vel [ 0 ] = 90 * - dir [ 1 ] ;
p - > vel [ 1 ] = 90 * dir [ 0 ] ;
}
break ;
case VOOR_TRAIL :
2011-06-29 18:39:11 +00:00
p - > rgb = d_8to24rgbtable [ 9 * 16 + 8 + ( rand ( ) & 3 ) ] ;
2008-11-09 22:29:28 +00:00
p - > type = pt_static ;
p - > die = cl . time + 0.3 ;
for ( j = 0 ; j < 3 ; j + + )
p - > org [ j ] = point [ j ] + ( ( rand ( ) & 15 ) - 8 ) ;
break ;
case ALT_ROCKET_TRAIL :
p - > ramp = ( rand ( ) & 3 ) ;
2011-06-29 18:39:11 +00:00
p - > rgb = d_8to24rgbtable [ ramp3 [ ( int ) p - > ramp ] ] ;
2008-11-09 22:29:28 +00:00
p - > type = pt_fire ;
for ( j = 0 ; j < 3 ; j + + )
p - > org [ j ] = point [ j ] + ( ( rand ( ) % 6 ) - 3 ) ;
break ;
case ROCKET_TRAIL :
default :
p - > ramp = ( rand ( ) & 3 ) ;
2011-06-29 18:39:11 +00:00
p - > rgb = d_8to24rgbtable [ ramp3 [ ( int ) p - > ramp ] ] ;
2008-11-09 22:29:28 +00:00
p - > type = pt_fire ;
for ( j = 0 ; j < 3 ; j + + )
p - > org [ j ] = point [ j ] + ( ( rand ( ) % 6 ) - 3 ) ;
break ;
}
2011-09-03 03:49:43 +00:00
VectorAdd ( point , dir , point ) ;
2008-11-09 22:29:28 +00:00
}
done :
2011-06-18 13:05:14 +00:00
return leftover ;
2008-11-09 22:29:28 +00:00
}
//builds a trail from here to there. The trail state can be used to remember how far you got last frame.
2014-10-05 20:04:11 +00:00
static int PClassic_ParticleTrail ( vec3_t startpos , vec3_t end , int type , int dlkey , vec3_t dlaxis [ 3 ] , trailstate_t * * tsk )
2008-11-09 22:29:28 +00:00
{
2011-06-18 13:05:14 +00:00
float leftover ;
2008-11-09 22:29:28 +00:00
if ( type = = P_INVALID )
return 1 ;
2011-06-18 13:05:14 +00:00
leftover = Classic_ParticleTrail ( startpos , end , Classic_GetLeftover ( tsk ) , type ) ;
Classic_SetLeftover ( tsk , leftover ) ;
2008-11-09 22:29:28 +00:00
return 0 ;
}
//svc_particle support: add X particles with the given colour, velocity, and aproximate origin.
static void PClassic_RunParticleEffect ( vec3_t org , vec3_t dir , int color , int count )
{
Classic_RunParticleEffect ( org , dir , color , count ) ;
}
2015-12-28 17:41:39 +00:00
static void PClassic_RunParticleEffectPalette ( const char * nameprefix , vec3_t org , vec3_t dir , int color , int count )
{
Classic_RunParticleEffect ( org , dir , color , count ) ;
}
2008-11-09 22:29:28 +00:00
particleengine_t pe_classic =
{
" Classic " ,
NULL ,
PClassic_FindParticleType ,
2012-01-17 07:57:46 +00:00
PClassic_Query ,
2008-11-09 22:29:28 +00:00
PClassic_RunParticleEffectTypeString ,
PClassic_ParticleTrail ,
PClassic_RunParticleEffectState ,
PClassic_RunParticleWeather ,
PClassic_RunParticleCube ,
PClassic_RunParticleEffect ,
PClassic_RunParticleEffect2 ,
PClassic_RunParticleEffect3 ,
PClassic_RunParticleEffect4 ,
2015-12-28 17:41:39 +00:00
PClassic_RunParticleEffectPalette ,
2008-11-09 22:29:28 +00:00
PClassic_ParticleTrailIndex ,
PClassic_EmitSkyEffectTris ,
PClassic_InitParticles ,
PClassic_ShutdownParticles ,
PClassic_DelinkTrailstate ,
PClassic_ClearParticles ,
2009-11-04 21:16:50 +00:00
PClassic_DrawParticles
2008-11-09 22:29:28 +00:00
} ;
# endif