当前位置: 首页>>代码示例>>C++>>正文


C++ Com_Clamp函数代码示例

本文整理汇总了C++中Com_Clamp函数的典型用法代码示例。如果您正苦于以下问题:C++ Com_Clamp函数的具体用法?C++ Com_Clamp怎么用?C++ Com_Clamp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Com_Clamp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MakeSkyVec

static void MakeSkyVec( float s, float t, int axis, vec2_t st, vec3_t xyz )
{
	// 1 = s, 2 = t, 3 = zfar
	static const int st_to_vec[6][3] =
	{
		{  3, -1,  2 },
		{ -3,  1,  2 },

		{  1,  3,  2 },
		{ -1, -3,  2 },

		{ -2, -1,  3 },		// 0 degrees yaw, look straight up
		{  2, -1, -3 }		// look straight down
	};

	vec3_t b;
	float boxSize = backEnd.viewParms.zFar / 1.75;		// div sqrt(3)
	b[0] = boxSize * s;
	b[1] = boxSize * t;
	b[2] = boxSize;

	for (int i = 0; i < 3; ++i) {
		int k = st_to_vec[axis][i];
		xyz[i] = (k < 0) ? -b[-k - 1] : b[k - 1];
	}

	// convert our -1:1 range (and inverted t) into GL TCs
	if ( st ) {
		st[0] = Com_Clamp( 0, 1, (s+1) * 0.5 );
		st[1] = 1.0 - Com_Clamp( 0, 1, (t+1) * 0.5 );
	}
}
开发者ID:DaTa-,项目名称:cnq3x,代码行数:32,代码来源:tr_sky.cpp

示例2: DrawSkyBox

static void DrawSkyBox( const shader_t* shader )
{
//	Com_Memset( s_skyTexCoords, 0, sizeof( s_skyTexCoords ) );

	for (int i = 0; i < 6; ++i)
	{
		int sky_mins_subd[2], sky_maxs_subd[2];

		if ( ( sky_mins_st[i][0] >= sky_maxs_st[i][0] ) || ( sky_mins_st[i][1] >= sky_maxs_st[i][1] ) ) {
			continue;
		}

		sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS * Com_Clamp( -1, 1, sky_mins_st[i][0] );
		sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS * Com_Clamp( -1, 1, sky_mins_st[i][1] );
		sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS * Com_Clamp( -1, 1, sky_maxs_st[i][0] );
		sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS * Com_Clamp( -1, 1, sky_maxs_st[i][1] );

		//
		// iterate through the subdivisions
		//
		for (int t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; ++t)
		{
			for (int s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; ++s)
			{
				MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
							( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
							i, s_skyTexCoords[t][s], s_skyPoints[t][s] );
			}
		}

		DrawSkySide( shader->sky.outerbox[i], sky_mins_subd, sky_maxs_subd );
	}
}
开发者ID:DaTa-,项目名称:cnq3x,代码行数:33,代码来源:tr_sky.cpp

示例3: S_Base_StartBackgroundTrack

/*
======================
S_StartBackgroundTrack
======================
*/
void S_Base_StartBackgroundTrack( const char *intro, const char *loop, float volume, float loopVolume ) {
	if ( !intro ) {
		intro = "";
	}
	if ( !loop || !loop[0] ) {
		loop = intro;
	}
	Com_DPrintf( "S_StartBackgroundTrack( %s, %s, %f, %f )\n", intro, loop, volume, loopVolume );

	if(!*intro)
	{
		S_Base_StopBackgroundTrack();
		return;
	}

	s_backgroundVolume = Com_Clamp(0, 10, volume);
	s_backgroundLoopVolume = Com_Clamp(0, 10, loopVolume);

	if( !loop ) {
		s_backgroundLoop[0] = 0;
	} else {
		Q_strncpyz( s_backgroundLoop, loop, sizeof( s_backgroundLoop ) );
	}

	S_OpenBackgroundStream( intro );
}
开发者ID:mecwerks,项目名称:spearmint-ios,代码行数:31,代码来源:snd_dma.c

示例4: Preferences_SetMenuItems

static void Preferences_SetMenuItems( void ) {
	float textScale;

	s_preferences.crosshair.curvalue		= (int)trap_Cvar_VariableValue( "cg_drawCrosshair" ) % NUM_CROSSHAIRS;
	s_preferences.crosshairhealth.curvalue	= trap_Cvar_VariableValue( "cg_crosshairHealth" ) != 0;
	s_preferences.viewbob.curvalue			= trap_Cvar_VariableValue( "cg_viewbob" ) != 0;
	s_preferences.simpleitems.curvalue		= trap_Cvar_VariableValue( "cg_simpleItems" ) != 0;
	s_preferences.brass.curvalue			= trap_Cvar_VariableValue( "cg_brassTime" ) != 0;
	s_preferences.wallmarks.curvalue		= trap_Cvar_VariableValue( "cg_marks" ) != 0;
	s_preferences.identifytarget.curvalue	= trap_Cvar_VariableValue( "cg_drawCrosshairNames" ) != 0;
	s_preferences.dynamiclights.curvalue	= trap_Cvar_VariableValue( "r_dynamiclight" ) != 0;
	s_preferences.highqualitysky.curvalue	= trap_Cvar_VariableValue ( "r_fastsky" ) == 0;
	s_preferences.synceveryframe.curvalue	= trap_Cvar_VariableValue( "r_finish" ) != 0;
	s_preferences.forcemodel.curvalue		= trap_Cvar_VariableValue( "cg_forcemodel" ) != 0;
	s_preferences.drawteamoverlay.curvalue	= Com_Clamp( 0, 3, trap_Cvar_VariableValue( "cg_drawTeamOverlay" ) );
	s_preferences.allowdownload.curvalue	= trap_Cvar_VariableValue( "cl_allowDownload" ) != 0;
	s_preferences.splitvertical.curvalue	= trap_Cvar_VariableValue( "cg_splitviewVertical" ) != 0;

	textScale = trap_Cvar_VariableValue( "cg_splitviewTextScale" );
	if ( textScale <= 1.0f ) {
		s_preferences.splittextsize.curvalue	= 0;
	} else if ( textScale <= 1.5f ) {
		s_preferences.splittextsize.curvalue	= 1;
	} else {
		s_preferences.splittextsize.curvalue	= 2;
	}

	s_preferences.thirdsize.curvalue		= trap_Cvar_VariableValue( "cg_splitviewThirdEqual" ) != 0;
}
开发者ID:zturtleman,项目名称:mint-arena,代码行数:29,代码来源:ui_preferences.c

示例5: SCR_DrawSpree

/*
=================
SCR_DrawSpree
=================
*/
void SCR_DrawSpree(void) {
    
    if (cl.snap.ps.persistant[PERS_TEAM] == TEAM_SPECTATOR || cl.snap.ps.pm_type > 4 || 
        cl_paused->value || !cl_drawSpree->integer || cl.snap.ps.clientNum != clc.clientNum ||
        !Cvar_VariableIntegerValue("cg_draw2d")) {
            return;
    }

    int x;
    int y = 450;
    int spacing = 2;
    int size = 20;
    int width;
    int max = 12;
    int i;

    width = size * cl.spreeCount + spacing * (cl.spreeCount - 1);
    x = 320 - width / 2;
    
    for (i = 0; i < (int)Com_Clamp(0, max, cl.spreeCount); i++) {
        SCR_DrawNamedPic(x, y, size, size, "skull.tga");
        x += spacing + size;
    }

}
开发者ID:danielepantaleone,项目名称:ioq3-UrT,代码行数:30,代码来源:cl_scrn.c

示例6: Punkbuster_ConfirmEnable

/*
=================
PunkBuster_Confirm
=================
*/
static void Punkbuster_ConfirmEnable( bool result ) {
	if (result)
	{		
//		trap->SetPbClStatus(1);
	}
	g_arenaservers.punkbuster.curvalue = Com_Clamp( 0, 1, cvarSystem->VariableValue( "cl_punkbuster" ) );
}
开发者ID:ensiform,项目名称:q3pp,代码行数:12,代码来源:ui_servers2.cpp

示例7: CL_KeyState

/*
===============
CL_KeyState

Returns the fraction of the frame that the key was down
===============
*/
float CL_KeyState( localPlayer_t *player, kbutton_t *key ) {
	float digital, analog;

	CL_KeyStateSeparate( player, key, &digital, &analog );

	return Com_Clamp( 0, 1, digital + analog );
}
开发者ID:KuehnhammerTobias,项目名称:ioid3-game,代码行数:14,代码来源:cg_input.c

示例8: Punkbuster_ConfirmEnable

/*
=================
PunkBuster_Confirm
=================
*/
static void Punkbuster_ConfirmEnable( qboolean result ) {
	if (result)
	{		
		trap_SetPbClStatus(1);
	}
	g_arenaservers.punkbuster.curvalue = Com_Clamp( 0, 1, trap_Cvar_VariableValue( "cl_punkbuster" ) );
}
开发者ID:ghostmod,项目名称:ioquake3_sql_log,代码行数:12,代码来源:ui_servers2.c

示例9: SetFarClip

/*
** SetFarClip
*/
static void SetFarClip( void )
{
	float	farthestCornerDistance = 0;
	int		i;

	// if not rendering the world (icons, menus, etc)
	// set a 2k far clip plane
	if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) {
		tr.viewParms.zFar = 2048;
		return;
	}

	//
	// set far clipping planes dynamically
	//
	for ( i = 0; i < 8; i++ )
	{
		vec3_t v;
		float distance;

		if ( i & 1 )
		{
			v[0] = tr.viewParms.visBounds[0][0];
		}
		else
		{
			v[0] = tr.viewParms.visBounds[1][0];
		}

		if ( i & 2 )
		{
			v[1] = tr.viewParms.visBounds[0][1];
		}
		else
		{
			v[1] = tr.viewParms.visBounds[1][1];
		}

		if ( i & 4 )
		{
			v[2] = tr.viewParms.visBounds[0][2];
		}
		else
		{
			v[2] = tr.viewParms.visBounds[1][2];
		}

		distance = DistanceSquared(tr.viewParms.or.origin, v);

		if ( distance > farthestCornerDistance )
		{
			farthestCornerDistance = distance;
		}
	}
	// Bring in the zFar to the distanceCull distance
	// The sky renders at zFar so need to move it out a little
	// ...and make sure there is a minimum zfar to prevent problems
	tr.viewParms.zFar = Com_Clamp(2048.0f, tr.distanceCull * (1.732), sqrtf( farthestCornerDistance ));
}
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:62,代码来源:tr_main.cpp

示例10: StartServer_InGame_Old_Init

/*
=================
StartServer_InGame_Old_Init
=================
*/
static void StartServer_InGame_Old_Init( void )
{
	int 		i, j;
	qboolean 	disabled;
	qboolean 	init;
	groupinfo_t* 	group;
	int 		type, t;

	s_itemcontrols_old.enabled = ingame_enabled_old;
	s_itemcontrols_old.grouptype = ingame_grouptype_old;

	// get the cvars currently set
	for (i = 0; i < ITEM_COUNT; i++)
	{
		disabled = (int)Com_Clamp(0, 1, trap_Cvar_VariableValue(va("disable_%s", server_itemlist[i].mapitem)));
		if (disabled)
			s_itemcontrols_old.enabled[i] = qfalse;
		else
			s_itemcontrols_old.enabled[i] = qtrue;
	}

	// all groups are custom by default, just in case a group
	// doesn't have a master control (we want the control visible and editable)
	for (i = 0; i < ITEMGROUP_COUNT; i++)
	{
		s_itemcontrols_old.grouptype[i] = ALLGROUPS_CUSTOM;
	}

	// now scan through the master controls to see how they should be setup
	for (i = 0; i < masterControl_old_Size; i++)
	{
		if (!masterControl_old[i].control)
			continue;

		// check each group for a contrary enable state
		init = qfalse;
		for (j = 0; j < groupInfo_Size; j++)
		{
			group = groupInfo[j].group;
			if (group->ident != masterControl_old[i].ident)
				continue;

			t = StartServer_InGame_Old_FindGroupType(group->itemlist, group->size);

			if (init) {
				type = t;
				init = qfalse;
			}
			else {
				if (t != type)
					type = ALLGROUPS_CUSTOM;
			}
		}

		s_itemcontrols_old.grouptype[ masterControl_old[i].ident ] = type;
	}

	StartServer_BothItemPage_Old_InitControls();
}
开发者ID:themuffinator,项目名称:fnq3,代码行数:64,代码来源:ui_startserver_items_old.c

示例11: IN_GetUIMousePosition

/*
===============
IN_GetUIMousePosition
===============
*/
static void IN_GetUIMousePosition( int localPlayerNum, int *x, int *y )
{
	if( cgvm )
	{
		int pos = VM_Call( cgvm, CG_MOUSE_POSITION, localPlayerNum );
		*x = Com_Clamp(0, cls.glconfig.vidWidth - 1, pos & 0xFFFF);
		*y = Com_Clamp(0, cls.glconfig.vidHeight - 1, ( pos >> 16 ) & 0xFFFF);
	}
	else
	{
开发者ID:coltongit,项目名称:spearmint,代码行数:15,代码来源:sdl_input.c

示例12: FillCloudBox

static void FillCloudBox( const shader_t* shader, int stage )
{
	// skybox surfs are ordered RLBFUD, so don't draw clouds on the last one

	for (int i = 0; i < 5; ++i)
	{
		int s, t;
		int sky_mins_subd[2], sky_maxs_subd[2];

		if ( ( sky_mins_st[i][0] >= sky_maxs_st[i][0] ) || ( sky_mins_st[i][1] >= sky_maxs_st[i][1] ) ) {
			//ri.Printf( PRINT_ALL, "clipped cloudside %i\n", i );
			continue;
		}

		sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS * Com_Clamp( -1, 1, sky_mins_st[i][0] );
		sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS * Com_Clamp( -1, 1, sky_mins_st[i][1] );
		sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS * Com_Clamp( -1, 1, sky_maxs_st[i][0] );
		sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS * Com_Clamp( -1, 1, sky_maxs_st[i][1] );

		//
		// iterate through the subdivisions
		//
		for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ )
		{
			for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ )
			{
				MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
							( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
							i,
							NULL,
							s_skyPoints[t][s] );

				s_skyTexCoords[t][s][0] = s_cloudTexCoords[i][t][s][0];
				s_skyTexCoords[t][s][1] = s_cloudTexCoords[i][t][s][1];
			}
		}

		// only add indexes for first stage
		FillCloudySkySide( sky_mins_subd, sky_maxs_subd, (qbool)(stage == 0) );
	}
}
开发者ID:DaTa-,项目名称:cnq3x,代码行数:41,代码来源:tr_sky.cpp

示例13: Svcmd_AddBot_f

/*
===============
Svcmd_AddBot_f
===============
*/
void Svcmd_AddBot_f( void ) {
	float			skill;
	int				delay;
	char			name[MAX_TOKEN_CHARS];
	char			altname[MAX_TOKEN_CHARS];
	char			string[MAX_TOKEN_CHARS];
	char			team[MAX_TOKEN_CHARS];

	// are bots enabled?
	if ( !trap_Cvar_VariableIntegerValue( "bot_enable" ) ) {
		return;
	}

	// name
	trap_Argv( 1, name, sizeof( name ) );
	if ( !name[0] ) {
		trap_Print( "Usage: Addbot <botname> [skill 1-5] [team] [msec delay] [altname]\n" );
		return;
	}

	// skill
	trap_Argv( 2, string, sizeof( string ) );
	if ( !string[0] ) {
		skill = 4;
	}
	else {
		skill = Com_Clamp( 1, 5, atof( string ) );
	}

	// team
	trap_Argv( 3, team, sizeof( team ) );

	// delay
	trap_Argv( 4, string, sizeof( string ) );
	if ( !string[0] ) {
		delay = 0;
	}
	else {
		delay = atoi( string );
	}

	// alternative name
	trap_Argv( 5, altname, sizeof( altname ) );

	G_AddBot( name, skill, team, delay, altname );

	// if this was issued during gameplay and we are playing locally,
	// go ahead and load the bot's media immediately
	if ( level.time - level.startTime > 1000 &&
		trap_Cvar_VariableIntegerValue( "cl_running" ) ) {
		trap_SendServerCommand( -1, "loaddefered\n" );	// FIXME: spelled wrong, but not changing for demo
	}
}
开发者ID:eserozvataf,项目名称:q3now,代码行数:58,代码来源:g_bot.c

示例14: FX_LightUpdateRGB

void FX_LightUpdateRGB(fxLight_t *_self, float frac)
{
	if(!VectorCompare(_self->startRGB, _self->endRGB))		// This changes based on time, so do some sort of magic lerping
	{
		// TODO: wave/clamp/nonlinear. BLAH.
		if(_self->RGBflags & FXTLF_NONLINEAR)
		{
			VectorCopy(_self->startRGB, _self->RGB);
		}
		else if(_self->RGBflags & FXTLF_LINEAR)
		{
			_self->RGB[0] = _self->startRGB[0] + frac * _self->endRGB[0];
			_self->RGB[1] = _self->startRGB[1] + frac * _self->endRGB[1];
			_self->RGB[2] = _self->startRGB[2] + frac * _self->endRGB[2];
		}
		else
		{
			VectorCopy(_self->startRGB, _self->RGB);
		}
	}
	else
		VectorCopy(_self->startRGB, _self->RGB);
#if 0
	float invfrac = 1.0f - frac;
	int i;

	for(i = 0; i < 3; i++)
	{
		_self->RGB[i] = Com_Clamp( 0.0f, 1.0f, ( _self->startRGB[i] * invfrac + _self->endRGB[i] * frac ) );
		
		/*
		_self->RGB[i] = ( _self->startRGB[i] * invfrac + _self->endRGB[i] * frac );

		// Has been explicitely flagged to use the alpha channel
		if ( !(m_flags & FXF_USE_ALPHA_CHAN) )
		{
			_self->RGB[i] *= _self->alpha;
		}

		if (_self->RGB[i] < 0.0f)
			_self->RGB[i] = 0.0f;

		if (_self->RGB[i] > 1.0f)
			_self->RGB[i] = 1.0f;
		*/
	}
#endif
}
开发者ID:dmead,项目名称:jkaq3,代码行数:48,代码来源:fx_primitive_light.c

示例15: FX_qFlash

void FX_qFlash( centity_t* cent, vec3_t org, int timeIndex ) {
	trace_t		tr;
	refEntity_t	flare;
	float		frac;	

	if ( cg.predictedPlayerState.clientNum != cent->currentState.clientNum ) {
		CG_Trace( &tr, cg.refdef.vieworg, NULL, NULL, 
				cent->lerpOrigin, cg.predictedPlayerState.clientNum, CONTENTS_SOLID );
		if ( tr.fraction != 1 ) {
			return;
		}
	}

	memset( &flare, 0, sizeof( flare ) );

	flare.reType = RT_SPRITE;
	flare.shaderRGBA[0] = 0xff;
	flare.shaderRGBA[1] = 0xff;
	flare.shaderRGBA[2] = 0xff;
	flare.shaderRGBA[3] = 0xff;

	flare.data.sprite.rotation = 0;
	flare.nonNormalizedAxes = qtrue; //needed for effective scaling

	flare.customShader = cgs.media.qFlashSprite;

	flare.renderfx |= RF_DEPTHHACK;

	VectorCopy( org, flare.origin );

	//find the basic ratio
	frac = (float)(cg.time - timeIndex) / (float)( Q_FLASH_TIME );
	//apply a sine function to it to make it less linear
	//calculated using the fine graph prog @ http://math.umn.edu/~garrett/a08/Graph.html
	frac = ( 0.65f * sin( 4.5f * frac - 0.6f ) + 0.35f );

	frac = Com_Clamp( 0.0f, 1.0f, frac );

	//CG_Printf( "%f\n", frac );

	flare.data.sprite.radius = (float)Q_FLASH_SIZE * frac;

	trap_R_AddRefEntityToScene( &flare );
}
开发者ID:UberGames,项目名称:RPG-X2-rpgxEF,代码行数:44,代码来源:fx_misc.c


注:本文中的Com_Clamp函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。