Ejemplo n.º 1
0
/*
===============
CG_AddSmokeJunc

  returns the index of the trail junction created
===============
*/
int CG_AddSmokeJunc(int headJuncIndex, qhandle_t shader, vec3_t pos, int trailLife, float alpha, float startWidth, float endWidth)
{
#define ST_RATIO    4.0     // sprite image: width / height
	trailJunc_t *j, *headJunc;

	if(headJuncIndex > 0)
	{
		headJunc = &trailJuncs[headJuncIndex - 1];

		if(!headJunc->inuse)
		{
			headJunc = NULL;
		}
	}
	else
	{
		headJunc = NULL;
	}

	j = CG_SpawnTrailJunc(headJunc);

	if(!j)
	{
		return 0;
	}

	// setup the trail junction
	j->shader = shader;
	j->sType = STYPE_REPEAT;
	VectorCopy(pos, j->pos);
	j->flags = TJFL_FADEIN;

	j->spawnTime = cg.time;
	j->endTime = cg.time + trailLife;

	// VectorSet(j->colorStart, 0.2, 0.2, 0.2);
	VectorSet(j->colorStart, 0.0, 0.0, 0.0);
	// VectorSet(j->colorEnd, 0.1, 0.1, 0.1);
	VectorSet(j->colorEnd, 0.0, 0.0, 0.0);

	j->alphaStart = alpha;
	j->alphaEnd = 0.0;

	j->widthStart = startWidth;
	j->widthEnd = endWidth;

	if(headJunc)
	{
		j->sTex = headJunc->sTex + ((Distance(headJunc->pos, pos) / ST_RATIO) / j->widthEnd);
	}
	else
	{
		// first junction, so this will become the "tail" very soon, make it fade out
		j->sTex = 0;
		j->alphaStart = 0.0;
		j->alphaEnd = 0.0;
	}

	return ((int)(j - trailJuncs) + 1);
}
Ejemplo n.º 2
0
/*
===============
CG_AddTrailJunc

  returns the index of the trail junction created

  Used for generic trails
===============
*/
int CG_AddTrailJunc(int headJuncIndex, qhandle_t shader, int spawnTime, int sType, vec3_t pos, int trailLife, float alphaStart, float alphaEnd, float startWidth, float endWidth, int flags, vec3_t colorStart, vec3_t colorEnd, float sRatio, float animSpeed)
{
	trailJunc_t	*j, *headJunc;

	if (headJuncIndex < 0 || headJuncIndex >= MAX_TRAILJUNCS) {
	    return 0;
	}
	
	if (headJuncIndex > 0) {
		headJunc = &trailJuncs[headJuncIndex-1];

		if (!headJunc->inuse)
			headJunc = NULL;
	}
	else
		headJunc = NULL;

	j = CG_SpawnTrailJunc(headJunc);
	if (!j) {
//		CG_Printf("couldnt spawn trail junc\n");
		return 0;
	}

	if (alphaStart > 1.0) alphaStart = 1.0;
	if (alphaStart < 0.0) alphaStart = 0.0;
	if (alphaEnd > 1.0) alphaEnd = 1.0;
	if (alphaEnd < 0.0) alphaEnd = 0.0;

	// setup the trail junction
	j->shader = shader;
	j->sType = sType;
	VectorCopy( pos, j->pos );
	j->flags = flags;

	j->spawnTime = spawnTime;
	j->endTime = spawnTime + trailLife;

	VectorCopy( colorStart, j->colorStart );
	VectorCopy( colorEnd, j->colorEnd );

	j->alphaStart = alphaStart;
	j->alphaEnd = alphaEnd;

	j->widthStart = startWidth;
	j->widthEnd = endWidth;

	if (sType == STYPE_REPEAT) {
		if (headJunc) {
			j->sTex = headJunc->sTex + ((Distance( headJunc->pos, pos ) / sRatio) / j->widthEnd);
		} else {
			// FIXME: need a way to specify offset timing
			j->sTex = (animSpeed * (1.0 - ((float)(cg.time%1000) / 1000.0))) / (sRatio);
//			j->sTex = 0;
		}
	}

	return ((int)(j - trailJuncs) + 1);
}
Ejemplo n.º 3
0
/*
===============
CG_AddSparkJunc

  returns the index of the trail junction created
===============
*/
int CG_AddSparkJunc(int headJuncIndex, void *usedby, qhandle_t shader, vec3_t pos, int trailLife, float alphaStart,
					float alphaEnd, float startWidth, float endWidth)
{
	trailJunc_t    *j, *headJunc;

	if(headJuncIndex < 0 || headJuncIndex >= MAX_TRAILJUNCS)
	{
		return 0;
	}

	if(headJuncIndex > 0)
	{
		headJunc = &trailJuncs[headJuncIndex - 1];

		// rain - zinx's trail fix
		if(!headJunc->inuse || headJunc->usedby != usedby)
		{
			headJunc = NULL;
		}
	}
	else
	{
		headJunc = NULL;
	}

	j = CG_SpawnTrailJunc(headJunc);
	if(!j)
	{
		return 0;
	}

	j->usedby = usedby;

	// setup the trail junction
	j->shader = shader;
	j->sType = STYPE_STRETCH;
	VectorCopy(pos, j->pos);
	j->flags = TJFL_NOCULL;		// don't worry about fading up close

	j->spawnTime = cg.time;
	j->endTime = cg.time + trailLife;

	VectorSet(j->colorStart, 1.0, 0.8 + 0.2 * alphaStart, 0.4 + 0.4 * alphaStart);
	VectorSet(j->colorEnd, 1.0, 0.8 + 0.2 * alphaEnd, 0.4 + 0.4 * alphaEnd);
//  VectorScale( j->colorStart, alphaStart, j->colorStart );
//  VectorScale( j->colorEnd, alphaEnd, j->colorEnd );

	j->alphaStart = alphaStart * 2;
	j->alphaEnd = alphaEnd * 2;
//  j->alphaStart = 1.0;
//  j->alphaEnd = 1.0;

	j->widthStart = startWidth;
	j->widthEnd = endWidth;

	return ((int)(j - trailJuncs) + 1);
}
Ejemplo n.º 4
0
/*
===============
CG_AddTrailJunc

  returns the index of the trail junction created

  Used for generic trails
===============
*/
int CG_AddTrailJunc(int headJuncIndex, void *usedby, qhandle_t shader, int spawnTime, int sType, vec3_t pos, int trailLife, float alphaStart, float alphaEnd, float startWidth, float endWidth, int flags, vec3_t colorStart, vec3_t colorEnd, float sRatio, float animSpeed) {
	trailJunc_t *j, *headJunc;

	if (headJuncIndex < 0 || headJuncIndex >= MAX_TRAILJUNCS) {
		return 0;
	}

	if (headJuncIndex > 0) {
		headJunc = &trailJuncs[headJuncIndex - 1];

		// rain - zinx's trail fix
		if (!headJunc->inuse || headJunc->usedby != usedby) {
			headJunc = NULL;
		}
	} else {
		headJunc = NULL;
	}

	j = CG_SpawnTrailJunc(headJunc);
	if (!j) {
		return 0;
	}

	// rain - zinx's trail fix - mark who's using this trail so that
	// we can handle the someone-else-stole-our-trail case
	j->usedby = usedby;

	if (alphaStart > 1.0) {
		alphaStart = 1.0;
	}
	if (alphaStart < 0.0) {
		alphaStart = 0.0;
	}
	if (alphaEnd > 1.0) {
		alphaEnd = 1.0;
	}
	if (alphaEnd < 0.0) {
		alphaEnd = 0.0;
	}

	// setup the trail junction
	j->shader = shader;
	j->sType  = sType;
	VectorCopy(pos, j->pos);
	j->flags = flags;

	j->spawnTime = spawnTime;
	j->endTime   = spawnTime + trailLife;

	VectorCopy(colorStart, j->colorStart);
	VectorCopy(colorEnd, j->colorEnd);

	j->alphaStart = alphaStart;
	j->alphaEnd   = alphaEnd;

	j->widthStart = startWidth;
	j->widthEnd   = endWidth;

	if (sType == STYPE_REPEAT) {
		if (headJunc) {
			j->sTex = headJunc->sTex + ((Distance(headJunc->pos, pos) / sRatio) / j->widthEnd);
		} else {
			// FIXME: need a way to specify offset timing
			j->sTex = (animSpeed * (1.0 - ((float)(cg.time % 1000) / 1000.0))) / (sRatio);
		}
	}

	return (int)(j - trailJuncs) + 1;
}