本文整理汇总了C++中FIXED_TO_INT函数的典型用法代码示例。如果您正苦于以下问题:C++ FIXED_TO_INT函数的具体用法?C++ FIXED_TO_INT怎么用?C++ FIXED_TO_INT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FIXED_TO_INT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CG_UI_DrawProportionalString
/*
=================
CG_UI_DrawProportionalString
=================
*/
void CG_UI_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color ) {
vec4_t drawcolor;
int width;
gfixed sizeScale;
sizeScale = CG_UI_ProportionalSizeScale( style );
switch( style & UI_FORMATMASK ) {
case UI_CENTER:
width = FIXED_TO_INT(MAKE_GFIXED(CG_UI_ProportionalStringWidth( str ) ) * sizeScale);
x -= width / 2;
break;
case UI_RIGHT:
width = FIXED_TO_INT(MAKE_GFIXED(CG_UI_ProportionalStringWidth( str ) ) * sizeScale);
x -= width;
break;
case UI_LEFT:
default:
break;
}
if ( style & UI_DROPSHADOW ) {
drawcolor[0] = drawcolor[1] = drawcolor[2] = GFIXED_0;
drawcolor[3] = color[3];
CG_UI_DrawProportionalString2( x+2, y+2, str, drawcolor, sizeScale, cgs.media.charsetProp );
}
if ( style & UI_INVERSE ) {
drawcolor[0] = color[0] * GFIXED(0,8);
drawcolor[1] = color[1] * GFIXED(0,8);
drawcolor[2] = color[2] * GFIXED(0,8);
drawcolor[3] = color[3];
CG_UI_DrawProportionalString2( x, y, str, drawcolor, sizeScale, cgs.media.charsetProp );
return;
}
if ( style & UI_PULSE ) {
drawcolor[0] = color[0] * GFIXED(0,8);
drawcolor[1] = color[1] * GFIXED(0,8);
drawcolor[2] = color[2] * GFIXED(0,8);
drawcolor[3] = color[3];
CG_UI_DrawProportionalString2( x, y, str, color, sizeScale, cgs.media.charsetProp );
drawcolor[0] = color[0];
drawcolor[1] = color[1];
drawcolor[2] = color[2];
drawcolor[3] = GFIXED(0,5) + GFIXED(0,5) * FIXED_SIN( FIXED_INT32RATIO_G(cg.time,PULSE_DIVISOR) );
CG_UI_DrawProportionalString2( x, y, str, drawcolor, sizeScale, cgs.media.charsetPropGlow );
return;
}
CG_UI_DrawProportionalString2( x, y, str, color, sizeScale, cgs.media.charsetProp );
}
示例2: CG_BubbleTrail
/*
==================
CG_BubbleTrail
Bullets shot underwater
==================
*/
void CG_BubbleTrail( bvec3_t start, bvec3_t end, bfixed spacing ) {
bvec3_t move;
bvec3_t vec;
bfixed len;
int i;
if ( cg_noProjectileTrail.integer ) {
return;
}
VectorCopy (start, move);
VectorSubtract (end, start, vec);
len = VectorNormalize (vec);
// advance a random amount first
i = rand() % FIXED_TO_INT(spacing);
FIXED_VEC3MA( move, MAKE_BFIXED(i), vec, move );
FIXED_VEC3SCALE (vec, spacing, vec);
for ( ; MAKE_BFIXED(i) < len; i += FIXED_TO_INT(spacing) ) {
localEntity_t *le;
refEntity_t *re;
le = CG_AllocLocalEntity();
le->leFlags = LEF_PUFF_DONT_SCALE;
le->leType = LE_MOVE_SCALE_FADE;
le->startTime = cg.time;
le->endTime = cg.time + 1000 + FIXED_TO_INT(random() * GFIXED(250,0));
le->lifeRate = FIXED_INT32RATIO_G(1,( le->endTime - le->startTime ));
re = &le->refEntity;
re->shaderTime = MSECTIME_G(cg.time);
re->reType = RT_SPRITE;
re->rotation = AFIXED_0;
re->radius = BFIXED(3,0);
re->customShader = cgs.media.waterBubbleShader;
re->shaderRGBA[0] = 0xff;
re->shaderRGBA[1] = 0xff;
re->shaderRGBA[2] = 0xff;
re->shaderRGBA[3] = 0xff;
le->color[3] = GFIXED_1;
le->pos.trType = TR_LINEAR;
le->pos.trTime = cg.time;
VectorCopy( move, le->pos.trBase );
le->pos.trDelta[0] = crandom_b()*BFIXED(5,0);
le->pos.trDelta[1] = crandom_b()*BFIXED(5,0);
le->pos.trDelta[2] = crandom_b()*BFIXED(5,0) + BFIXED(6,0);
VectorAdd (move, vec, move);
}
}
示例3: dungeon2_wild_pokemon_sample_level_boundaries
void dungeon2_wild_pokemon_sample_level_boundaries(u8 *level_min, u8 *level_max, u8 mean,
u8 std_deviation, dungeon_generator2 *dg2) {
FIXED fx1 = FIXED_ADD(INT_TO_FIXED(mean), FIXED_MUL(INT_TO_FIXED(std_deviation),
dungeon2_rnd_normal(dg2)));
FIXED fx2 = FIXED_ADD(INT_TO_FIXED(mean), FIXED_MUL(INT_TO_FIXED(std_deviation),
dungeon2_rnd_normal(dg2)));
int x1 = min(100, max(2, FIXED_TO_INT(fx1)));
int x2 = min(100, max(2, FIXED_TO_INT(fx2)));
*level_min = (u8)min(x1, x2);
*level_max = (u8)max(x1, x2);
}
示例4: CG_CenterGiantLine
/*
================
CG_CenterGiantLine
================
*/
static void CG_CenterGiantLine( gfixed y, const char *string ) {
gfixed x;
vec4_t color;
color[0] = GFIXED_1;
color[1] = GFIXED_1;
color[2] = GFIXED_1;
color[3] = GFIXED_1;
x = GFIXED(0,5) * MAKE_GFIXED( 640 - GIANT_WIDTH * CG_DrawStrlen( string ) );
CG_DrawStringExt( FIXED_TO_INT(x), FIXED_TO_INT(y), string, color, qtrue, qtrue, GIANT_WIDTH, GIANT_HEIGHT, 0 );
}
示例5: _cmsBlessLUT8
// Precomputes tables for 8-bit on input devicelink.
//
LPLUT _cmsBlessLUT8(LPLUT Lut)
{
int i, j;
WORD StageABC[3];
Fixed32 v1, v2, v3;
LPL8PARAMS p8;
LPL16PARAMS p = &Lut ->CLut16params;
p8 = (LPL8PARAMS) malloc(sizeof(L8PARAMS));
if (p8 == NULL) return NULL;
// values comes * 257, so we can safely take first byte (x << 8 + x)
// if there are prelinearization, is already smelted in tables
for (i=0; i < 256; i++) {
StageABC[0] = StageABC[1] = StageABC[2] = RGB_8_TO_16(i);
if (Lut ->wFlags & LUT_HASTL1) {
for (j=0; j < 3; j++)
StageABC[i] = cmsLinearInterpLUT16(StageABC[i],
Lut -> L1[i],
&Lut -> In16params);
Lut ->wFlags &= ~LUT_HASTL1;
}
v1 = ToFixedDomain(StageABC[0] * p -> Domain);
v2 = ToFixedDomain(StageABC[1] * p -> Domain);
v3 = ToFixedDomain(StageABC[2] * p -> Domain);
p8 ->X0[i] = p->opta3 * FIXED_TO_INT(v1);
p8 ->Y0[i] = p->opta2 * FIXED_TO_INT(v2);
p8 ->Z0[i] = p->opta1 * FIXED_TO_INT(v3);
p8 ->rx[i] = (WORD) FIXED_REST_TO_INT(v1);
p8 ->ry[i] = (WORD) FIXED_REST_TO_INT(v2);
p8 ->rz[i] = (WORD) FIXED_REST_TO_INT(v3);
}
Lut -> CLut16params.p8 = p8;
Lut -> CLut16params.Interp3D = cmsTetrahedralInterp8;
return Lut;
}
示例6: CG_LaunchExplode
/*
==================
CG_LaunchGib
==================
*/
void CG_LaunchExplode( bvec3_t origin, bvec3_t velocity, qhandle_t hModel ) {
localEntity_t *le;
refEntity_t *re;
le = CG_AllocLocalEntity();
re = &le->refEntity;
le->leType = LE_FRAGMENT;
le->startTime = cg.time;
le->endTime = le->startTime + 10000 + FIXED_TO_INT(random() * GFIXED(6000,0));
VectorCopy( origin, re->origin );
AxisCopy( aaxisDefault, re->axis );
re->hModel = hModel;
le->pos.trType = TR_GRAVITY;
VectorCopy( origin, le->pos.trBase );
VectorCopy( velocity, le->pos.trDelta );
le->pos.trTime = cg.time;
le->bounceFactor = BFIXED(0,1);
le->leBounceSoundType = LEBS_BRASS;
le->leMarkType = LEMT_NONE;
}
示例7: CheckArmor
/*
================
CheckArmor
================
*/
int CheckArmor (gentity_t *ent, int damage, int dflags)
{
gclient_t *client;
int save;
int count;
if (!damage)
return 0;
client = ent->client;
if (!client)
return 0;
if (dflags & DAMAGE_NO_ARMOR)
return 0;
// armor
count = client->ps.stats[STAT_ARMOR];
save = FIXED_TO_INT(FIXED_CEIL( MAKE_GFIXED(damage) * ARMOR_PROTECTION ));
if (save >= count)
save = count;
if (!save)
return 0;
client->ps.stats[STAT_ARMOR] -= save;
return save;
}
示例8: Eval8Inputs
static
void Eval8Inputs(WORD StageABC[], WORD StageLMN[], WORD LutTable[], LPL16PARAMS p16)
{
Fixed32 fk;
Fixed32 k0, rk;
int K0, K1;
LPWORD T;
int i;
WORD Tmp1[MAXCHANNELS], Tmp2[MAXCHANNELS];
fk = ToFixedDomain((Fixed32) StageABC[0] * p16 -> Domain);
k0 = FIXED_TO_INT(fk);
rk = FIXED_REST_TO_INT(fk);
K0 = p16 -> opta8 * k0;
K1 = p16 -> opta8 * (k0 + (StageABC[0] != 0xFFFFU ? 1 : 0));
p16 -> nInputs = 7;
T = LutTable + K0;
Eval7Inputs(StageABC + 1, Tmp1, T, p16);
T = LutTable + K1;
Eval7Inputs(StageABC + 1, Tmp2, T, p16);
p16 -> nInputs = 8;
for (i=0; i < p16 -> nOutputs; i++)
{
StageLMN[i] = (WORD) FixedLERP(rk, Tmp1[i], Tmp2[i]);
}
}
示例9: CG_AddSpriteExplosion
/*
================
CG_AddSpriteExplosion
================
*/
static void CG_AddSpriteExplosion( localEntity_t *le ) {
refEntity_t re;
gfixed c;
re = le->refEntity;
c = FIXED_INT32RATIO_G(( le->endTime - cg.time ),( le->endTime - le->startTime ));
if ( c > GFIXED_1 ) {
c = GFIXED_1; // can happen during connection problems
}
re.shaderRGBA[0] = 255;
re.shaderRGBA[1] = 255;
re.shaderRGBA[2] = 255;
re.shaderRGBA[3] = FIXED_TO_INT(GFIXED(255,0) * c * GFIXED(0,33));
re.reType = RT_SPRITE;
re.radius = BFIXED(42,0) * MAKE_BFIXED( GFIXED_1 - c ) + BFIXED(30,0);
_CG_trap_R_AddRefEntityToScene( &re );
// add the dlight
if ( FIXED_NOT_ZERO(le->light) ) {
gfixed light;
light = FIXED_INT32RATIO_G(( cg.time - le->startTime ),( le->endTime - le->startTime ));
if ( light < GFIXED(0,5) ) {
light = GFIXED_1;
} else {
light = GFIXED_1 - ( light - GFIXED(0,5) ) * GFIXED(2,0);
}
light = le->light * light;
_CG_trap_R_AddLightToScene(re.origin, light, le->lightColor[0], le->lightColor[1], le->lightColor[2] );
}
}
示例10: CG_AddFallScaleFade
/*
=================
CG_AddFallScaleFade
This is just an optimized CG_AddMoveScaleFade
For blood mists that drift down, fade out, and are
removed if the view passes through them.
There are often 100+ of these, so it needs to be simple.
=================
*/
static void CG_AddFallScaleFade( localEntity_t *le ) {
refEntity_t *re;
gfixed c;
bvec3_t delta;
bfixed len;
re = &le->refEntity;
// fade time
c = MAKE_GFIXED( le->endTime - cg.time ) * le->lifeRate;
re->shaderRGBA[3] = FIXED_TO_INT(GFIXED(255,0) * c * le->color[3]);
re->origin[2] = le->pos.trBase[2] - MAKE_BFIXED( GFIXED_1 - c ) * le->pos.trDelta[2];
re->radius = le->radius * MAKE_BFIXED( GFIXED_1 - c ) + BFIXED(16,0);
// if the view would be "inside" the sprite, kill the sprite
// so it doesn't add too much overdraw
VectorSubtract( re->origin, cg.refdef.vieworg, delta );
len = FIXED_VEC3LEN( delta );
if ( len < le->radius ) {
CG_FreeLocalEntity( le );
return;
}
_CG_trap_R_AddRefEntityToScene( re );
}
示例11: UI_SetBestScore
/*
===============
UI_SetBestScore
Set the player's best finish for a level
===============
*/
void UI_SetBestScore( int level, int score ) {
int skill;
int oldScore;
char arenaKey[16];
char scores[MAX_INFO_VALUE];
// validate score
if( score < 1 || score > 8 ) {
return;
}
// validate skill
skill = FIXED_TO_INT(_UI_trap_Cvar_VariableValue( "g_spSkill" ));
if( skill < 1 || skill > 5 ) {
return;
}
// get scores
_UI_trap_Cvar_VariableStringBuffer( va( "g_spScores%i", skill ), scores, MAX_INFO_VALUE );
// see if this is better
Com_sprintf( arenaKey, sizeof( arenaKey ), "l%i", level );
oldScore = atoi( Info_ValueForKey( scores, arenaKey ) );
if( oldScore && oldScore <= score ) {
return;
}
// update scores
Info_SetValueForKey( scores, arenaKey, va( "%i", score ) );
_UI_trap_Cvar_Set( va( "g_spScores%i", skill ), scores );
}
示例12: CG_AddFadeRGB
/*
====================
CG_AddFadeRGB
====================
*/
void CG_AddFadeRGB( localEntity_t *le ) {
refEntity_t *re;
gfixed c;
re = &le->refEntity;
c = MAKE_GFIXED( le->endTime - cg.time ) * le->lifeRate;
c *= GFIXED(255,0);
re->shaderRGBA[0] = FIXED_TO_INT(le->color[0] * c);
re->shaderRGBA[1] = FIXED_TO_INT(le->color[1] * c);
re->shaderRGBA[2] = FIXED_TO_INT(le->color[2] * c);
re->shaderRGBA[3] = FIXED_TO_INT(le->color[3] * c);
_CG_trap_R_AddRefEntityToScene( re );
}
示例13: CG_ReflectVelocity
/*
================
CG_ReflectVelocity
================
*/
void CG_ReflectVelocity( localEntity_t *le, trace_t *trace ) {
bvec3_t velocity;
bfixed dot;
int hitTime;
// reflect the velocity on the trace plane
hitTime = cg.time - cg.frametime + FIXED_TO_INT(MAKE_GFIXED(cg.frametime) * trace->fraction);
BG_EvaluateTrajectoryDelta( &le->pos, hitTime, velocity );
dot = FIXED_VEC3DOT( velocity, trace->plane.normal );
FIXED_VEC3MA_R( velocity, -BFIXED(2,0)*dot, trace->plane.normal, le->pos.trDelta );
FIXED_VEC3SCALE( le->pos.trDelta, le->bounceFactor, le->pos.trDelta );
VectorCopy( trace->endpos, le->pos.trBase );
le->pos.trTime = cg.time;
// check for stop, making sure that even on low FPS systems it doesn't bobble
if ( trace->allsolid ||
( trace->plane.normal[2] > AFIXED_0 &&
( le->pos.trDelta[2] < BFIXED(40,0) || le->pos.trDelta[2] < -MAKE_BFIXED(cg.frametime) * le->pos.trDelta[2] ) ) ) {
le->pos.trType = TR_STATIONARY;
} else {
}
}
示例14: playerUpdate
void playerUpdate(PlayerData* pData, unsigned long dt) {
Note note;
if (pData->pNote == 0) {
// end of data reached
return;
}
pData->elapsedMsec += FIXED_MAKE(dt);
if (pData->elapsedMsec < pData->t) {
dprintf(
"interpolate: elapsedMsec=%d t=%d\n",
FIXED_TO_INT(pData->elapsedMsec), FIXED_TO_INT(pData->t));
// interpolate
FIXED tt = (pData->t == 0) ? FIXED_MAKE(1) : FIXED_DIV(pData->elapsedMsec, pData->t);
pData->r = lerp(pData->r0, pData->r1, tt);
pData->g = lerp(pData->g0, pData->g1, tt);
pData->b = lerp(pData->b0, pData->b1, tt);
} else {
while (pData->elapsedMsec >= pData->t) {
// advance index and see if end of data reached
++pData->pNote;
memcpy_P(¬e, pData->pNote, sizeof(note));
if (note.msec < 0) {
// set the final color
pData->r = pData->r1;
pData->g = pData->g1;
pData->b = pData->b1;
pData->pNote = 0;
return;
}
pData->r = pData->r0 = pData->r1;
pData->g = pData->g0 = pData->g1;
pData->b = pData->b0 = pData->b1;
pData->r1 = FIXED_MAKE(note.r);
pData->g1 = FIXED_MAKE(note.g);
pData->b1 = FIXED_MAKE(note.b);
pData->t = FIXED_MAKE(note.msec);
pData->elapsedMsec -= pData->t;
}
}
}
示例15: AAS_Setup
//===========================================================================
// called when the library is first loaded
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
int AAS_Setup(void)
{
aasworld.maxclients = FIXED_TO_INT(LibVarValue("maxclients", "128"));
aasworld.maxentities = FIXED_TO_INT(LibVarValue("maxentities", "1024"));
// as soon as it's set to 1 the routing cache will be saved
saveroutingcache = LibVar("saveroutingcache", "0");
//allocate memory for the entities
if (aasworld.entities) FreeMemory(aasworld.entities);
aasworld.entities = (aas_entity_t *) GetClearedHunkMemory(aasworld.maxentities * sizeof(aas_entity_t));
//invalidate all the entities
AAS_InvalidateEntities();
//force some recalculations
//LibVarSet("forceclustering", "1"); //force clustering calculation
//LibVarSet("forcereachability", "1"); //force reachability calculation
aasworld.numframes = 0;
return BLERR_NOERROR;
} //end of the function AAS_Setup