コード例 #1
0
int CM_HandleDamageShader(int sideNum, int damage)
{
	CCMShader		*shader;
	CCMShader		*damageShader;
	cbrushside_t	*side;

	// Check to see if the face can be damaged
	side = cm.brushsides + sideNum;
	if(side->damage <= 0)
	{
		return(-1);
	}
	if((side->damage - damage <= 0) || (damage == -1))
	{
		// Damage the texture
		shader = CM_GetShaderInfo(side->shaderNum);
		if(shader->damageShaderNum)
		{
			damageShader = CM_GetShaderInfo(shader->damageShaderNum);
			if(damageShader)
			{
				side->shaderNum = shader->damageShaderNum;
				side->surfaceFlags = damageShader->surfaceFlags;
				side->damage = damageShader->damage;
				return(side->drawSurfNum);
			}
		}
		return(-1);
	}
	side->damage -= damage;
	return(-1);
}
コード例 #2
0
ファイル: cm_shader.cpp プロジェクト: 3ddy/Jedi-Outcast
void CM_SetupShaderProperties(void)
{
	int			i;
	const char	*def;
	CCMShader	*shader;

	// Add all basic shaders to the cmShaderTable
	for(i = 0; i < cmg.numShaders; i++)
	{
		cmShaderTable.insert(CM_GetShaderInfo(i));
	}
	// Go through and parse evaluate shader names to shadernums
	for(i = 0; i < cmg.numShaders; i++)
	{
		shader = CM_GetShaderInfo(i);
		def = CM_GetShaderText(shader->shader);
		if(def)
		{
			CM_ParseShader(shader, &def);
		}
	}
}
コード例 #3
0
/*
=================
CM_ParseShader

The current text pointer is at the explicit text definition of the
shader.  Parse it into the global shader variable.

This extracts all the info from the shader required for physics and collision
It is designed to *NOT* load any image files and not require any of the renderer to 
be initialised.
=================
*/
static void CM_ParseShader( CCMShader *shader, const char **text )
{
	char	*token;

	token = COM_ParseExt( text, qtrue );
	if ( token[0] != '{' )
	{
		Com_Printf( S_COLOR_YELLOW "WARNING: expecting '{', found '%s' instead in shader '%s'\n", token, shader->shader );
		return;
	}

	while ( true )
	{
		token = COM_ParseExt( text, qtrue );
		if ( !token[0] )
		{
			Com_Printf( S_COLOR_YELLOW "WARNING: no concluding '}' in shader %s\n", shader->shader );
			return;
		}

		// end of shader definition
		if ( token[0] == '}' )
		{
			break;
		}
		// stage definition
		else if ( token[0] == '{' )
		{
			SkipBracedSection( text );
			continue;
		}
		// material deprecated as of 11 Jan 01
		// material undeprecated as of 7 May 01 - q3map_material deprecated
		else if ( !Q_stricmp( token, "material" ) || !Q_stricmp( token, "q3map_material" ) )
		{
			SV_ParseMaterial( shader, text );
		}
		// sun parms
		// q3map_sun deprecated as of 11 Jan 01
		else if ( !Q_stricmp( token, "sun" ) || !Q_stricmp( token, "q3map_sun" ) ) 
		{
			float	a, b;

			token = COM_ParseExt( text, qfalse );
			shader->sunLight[0] = atof( token );
			token = COM_ParseExt( text, qfalse );
			shader->sunLight[1] = atof( token );
			token = COM_ParseExt( text, qfalse );
			shader->sunLight[2] = atof( token );
			
			VectorNormalize( shader->sunLight );

			token = COM_ParseExt( text, qfalse );
			a = atof( token );
			VectorScale( shader->sunLight, a, shader->sunLight);

			token = COM_ParseExt( text, qfalse );
			a = DEG2RAD(atof( token ));

			token = COM_ParseExt( text, qfalse );
			b = DEG2RAD(atof( token ));

			shader->sunDirection[0] = cos( a ) * cos( b );
			shader->sunDirection[1] = sin( a ) * cos( b );
			shader->sunDirection[2] = sin( b );
		}
		else if ( !Q_stricmp( token, "surfaceParm" ) ) 
		{
			SV_ParseSurfaceParm( shader, text );
			continue;
		}
		else if ( !Q_stricmp( token, "fogParms" ) ) 
		{
			if ( !CM_ParseVector( shader, text, 3, shader->fogColor ) ) 
			{
				return;
			}

			token = COM_ParseExt( text, qfalse );
			if ( !token[0] ) 
			{
				Com_Printf( S_COLOR_YELLOW "WARNING: missing parm for 'fogParms' keyword in shader '%s'\n", shader->shader );
				continue;
			}
			shader->depthForOpaque = atof( token );

			// skip any old gradient directions
			SkipRestOfLine( (const char **)text );
			continue;
		}
		else if ( !Q_stricmp( token, "damageShader" ) ) 
		{
			CCMShader	*damageShader;

			token = COM_ParseExt( text, qfalse );
			if ( !token[0] ) 
			{
				Com_Printf( S_COLOR_YELLOW "WARNING: missing parm for 'damageShader' keyword in shader '%s'\n", shader->shader );
				continue;
			}
			damageShader = CM_GetShaderInfo(token);
			if(damageShader)
			{
				shader->damageShaderNum = damageShader - cm.shaders;
			}

			token = COM_ParseExt( text, qfalse );
			if(token)
			{
				shader->damage = atof(token);
			}
			continue;
		}
		// 
		// location hit mesh load
		//
		else if ( !Q_stricmp( token, "hitLocation" ) )
		{
			// grab the filename of the hit location texture
			token = COM_ParseExt( text, qfalse );
			if ( !token[0] )
			{
				break;
			}
			Q_strncpyz(shader->hitLocation, token, MAX_QPATH);
			continue;
		}
		// 
		// location hit material mesh load
		//
		else if ( !Q_stricmp( token, "hitMaterial" ) )
		{
			// grab the filename of the hit location texture
			token = COM_ParseExt( text, qfalse );
			if ( !token[0] )
			{
				break;
			}
			Q_strncpyz(shader->hitMaterial, token, MAX_QPATH);
			continue;
		}
	}
	return;
}