本文整理汇总了C++中FIX2FLT函数的典型用法代码示例。如果您正苦于以下问题:C++ FIX2FLT函数的具体用法?C++ FIX2FLT怎么用?C++ FIX2FLT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FIX2FLT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
char *storage_serialize_sf(void *ptr, u32 fieldType)
{
char szVal[50];
switch (fieldType) {
case GF_SG_VRML_SFBOOL:
sprintf(szVal, "%d", *((SFBool *)ptr) ? 1 : 0);
return gf_strdup(szVal);
case GF_SG_VRML_SFINT32:
sprintf(szVal, "%d", *((SFInt32 *)ptr) );
return gf_strdup(szVal);
case GF_SG_VRML_SFTIME:
sprintf(szVal, "%g", *((SFTime *)ptr) );
return gf_strdup(szVal);
case GF_SG_VRML_SFFLOAT:
sprintf(szVal, "%g", FIX2FLT( *((SFFloat *)ptr) ) );
return gf_strdup(szVal);
case GF_SG_VRML_SFVEC2F:
sprintf(szVal, "%g %g", FIX2FLT( ((SFVec2f *)ptr)->x), FIX2FLT( ((SFVec2f *)ptr)->y) );
return gf_strdup(szVal);
case GF_SG_VRML_SFVEC3F:
sprintf(szVal, "%g %g %g", FIX2FLT( ((SFVec3f *)ptr)->x), FIX2FLT( ((SFVec3f *)ptr)->y) , FIX2FLT( ((SFVec3f *)ptr)->z) );
return gf_strdup(szVal);
case GF_SG_VRML_SFSTRING:
return gf_strdup( ((SFString *)ptr)->buffer ? ((SFString *)ptr)->buffer : "");
default:
break;
}
return NULL;
}
示例2: A_LeafCheck
void C_DECL A_LeafCheck(mobj_t *actor)
{
int n;
actor->special1++;
if(actor->special1 >= 20)
{
P_MobjChangeState(actor, S_NULL);
return;
}
if(P_Random() > 64)
{
if(FEQUAL(actor->mom[MX], 0) && FEQUAL(actor->mom[MY], 0))
{
P_ThrustMobj(actor, actor->target->angle,
FIX2FLT(P_Random() << 9) + 1);
}
return;
}
P_MobjChangeState(actor, S_LEAF1_8);
n = P_Random();
actor->mom[MZ] = FIX2FLT(n << 9) + 1;
P_ThrustMobj(actor, actor->target->angle, FIX2FLT(P_Random() << 9) + 2);
actor->flags |= MF_MISSILE;
}
示例3: camera_frustum_from_matrix
static void camera_frustum_from_matrix(GF_Camera *cam, GF_Matrix *mx)
{
u32 i;
cam->planes[FRUS_LEFT_PLANE].normal.x = mx->m[3] + mx->m[0];
cam->planes[FRUS_LEFT_PLANE].normal.y = mx->m[7] + mx->m[4];
cam->planes[FRUS_LEFT_PLANE].normal.z = mx->m[11] + mx->m[8];
cam->planes[FRUS_LEFT_PLANE].d = mx->m[15] + mx->m[12];
cam->planes[FRUS_RIGHT_PLANE].normal.x = mx->m[3] - mx->m[0];
cam->planes[FRUS_RIGHT_PLANE].normal.y = mx->m[7] - mx->m[4];
cam->planes[FRUS_RIGHT_PLANE].normal.z = mx->m[11] - mx->m[8];
cam->planes[FRUS_RIGHT_PLANE].d = mx->m[15] - mx->m[12];
cam->planes[FRUS_BOTTOM_PLANE].normal.x = mx->m[3] + mx->m[1];
cam->planes[FRUS_BOTTOM_PLANE].normal.y = mx->m[7] + mx->m[5];
cam->planes[FRUS_BOTTOM_PLANE].normal.z = mx->m[11] + mx->m[9];
cam->planes[FRUS_BOTTOM_PLANE].d = mx->m[15] + mx->m[13];
cam->planes[FRUS_TOP_PLANE].normal.x = mx->m[3] - mx->m[1];
cam->planes[FRUS_TOP_PLANE].normal.y = mx->m[7] - mx->m[5];
cam->planes[FRUS_TOP_PLANE].normal.z = mx->m[11] - mx->m[9];
cam->planes[FRUS_TOP_PLANE].d = mx->m[15] - mx->m[13];
cam->planes[FRUS_FAR_PLANE].normal.x = mx->m[3] - mx->m[2];
cam->planes[FRUS_FAR_PLANE].normal.y = mx->m[7] - mx->m[6];
cam->planes[FRUS_FAR_PLANE].normal.z = mx->m[11] - mx->m[10];
cam->planes[FRUS_FAR_PLANE].d = mx->m[15] - mx->m[14];
cam->planes[FRUS_NEAR_PLANE].normal.x = mx->m[3] + mx->m[2];
cam->planes[FRUS_NEAR_PLANE].normal.y = mx->m[7] + mx->m[6];
cam->planes[FRUS_NEAR_PLANE].normal.z = mx->m[11] + mx->m[10];
cam->planes[FRUS_NEAR_PLANE].d = mx->m[15] + mx->m[14];
for (i=0; i<6; ++i) {
#ifdef GPAC_FIXED_POINT
/*after some testing, it's just safer to move back to float here, the smallest drift will
result in completely wrong culling...*/
Float vx, vy, vz, nor;
vx = FIX2FLT(cam->planes[i].normal.x);
vy = FIX2FLT(cam->planes[i].normal.y);
vz = FIX2FLT(cam->planes[i].normal.z);
nor = (Float) sqrt(vx*vx + vy*vy + vz*vz);
vx /= nor;
vy /= nor;
vz /= nor;
cam->planes[i].d = FLT2FIX (FIX2FLT(cam->planes[i].d) / nor);
cam->planes[i].normal.x = FLT2FIX(vx);
cam->planes[i].normal.y = FLT2FIX(vy);
cam->planes[i].normal.z = FLT2FIX(vz);
#else
Float len = (Float)(1.0f / gf_vec_len(cam->planes[i].normal));
cam->planes[i].normal = gf_vec_scale(cam->planes[i].normal, len);
cam->planes[i].d *= len;
#endif
/*compute p-vertex idx*/
cam->p_idx[i] = gf_plane_get_p_vertex_idx(&cam->planes[i]);
}
}
示例4: print
/**
* Debug print
*/
void print ( void )
{
lprintfln( "{%f, %f, %f}",
FIX2FLT( m_x ),
FIX2FLT( m_y ),
FIX2FLT( m_z ) );
}
示例5: A_FogMove
void C_DECL A_FogMove(mobj_t* actor)
{
coord_t speed = (coord_t) actor->args[0];
uint an;
if(!(actor->args[4]))
return;
if(actor->args[3]-- <= 0)
{
P_MobjChangeStateNoAction(actor, P_GetState(actor->type, SN_DEATH));
return;
}
// Move the fog slightly/slowly up and down. Some fog patches are supposed
// to move higher and some are supposed to stay close to the ground.
// Unlike in the original Hexen, the move is done by applying momentum
// to the cloud so that the movement is smooth.
if((actor->args[3] % 4) == 0)
{
uint weaveindex = actor->special2;
actor->mom[VZ] = FLOATBOBOFFSET(weaveindex) / TICSPERSEC;
actor->special2 = (weaveindex + 1) & 63;
}
an = actor->angle >> ANGLETOFINESHIFT;
actor->mom[MX] = speed * FIX2FLT(finecosine[an]);
actor->mom[MY] = speed * FIX2FLT(finesine[an]);
}
示例6: c2d_gl_fill_alpha
static void c2d_gl_fill_alpha(void *cbk, u32 x, u32 y, u32 run_h_len, GF_Color color, u8 alpha)
{
#if defined(GPAC_USE_OGL_ES)
GLfloat line[4];
line[0] = FIX2FLT(x);
line[1] = FIX2FLT(y);
line[2] = FIX2FLT(x+run_h_len);
line[3] = line[1];
glEnable(GL_BLEND);
glColor4ub(GF_COL_R(color), GF_COL_G(color), GF_COL_B(color), (u8) alpha);
glVertexPointer(2, GL_FLOAT, 0, line);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawArrays(GL_LINES, 0, 2);
glDisableClientState(GL_VERTEX_ARRAY);
glDisable(GL_BLEND);
#else
glEnable(GL_BLEND);
glColor4ub(GF_COL_R(color), GF_COL_G(color), GF_COL_B(color), (u8) alpha);
glBegin(GL_LINES);
glVertex2i(x,y);
glVertex2i(x+run_h_len,y);
glEnd();
glDisable(GL_BLEND);
#endif
}
示例7: A_PotteryExplode
void C_DECL A_PotteryExplode(mobj_t* actor)
{
int i, maxBits = (P_Random() & 3) + 3;
mobj_t* potteryBit;
for(i = 0; i < maxBits; ++i)
{
if((potteryBit = P_SpawnMobj(MT_POTTERYBIT1, actor->origin, P_Random() << 24, 0)))
{
P_MobjChangeState(potteryBit, P_GetState(potteryBit->type, SN_SPAWN) + (P_Random() % 5));
potteryBit->mom[MZ] = FIX2FLT(((P_Random() & 7) + 5) * (3 * FRACUNIT / 4));
potteryBit->mom[MX] = FIX2FLT((P_Random() - P_Random()) << 10);
potteryBit->mom[MY] = FIX2FLT((P_Random() - P_Random()) << 10);
}
}
S_StartSound(SFX_POTTERY_EXPLODE, potteryBit);
if(actor->args[0])
{
// Spawn an item.
if(!G_Ruleset_NoMonsters() ||
!(MOBJINFO[TranslateThingType[actor->args[0]]].
flags & MF_COUNTKILL))
{
// Only spawn monsters if not -nomonsters.
P_SpawnMobj(TranslateThingType[actor->args[0]], actor->origin,
actor->angle, 0);
}
}
P_MobjRemove(actor, false);
}
示例8: A_LeafSpawn
void C_DECL A_LeafSpawn(mobj_t* actor)
{
coord_t pos[3];
mobj_t* mo;
int i;
for(i = (P_Random() & 3) + 1; i; i--)
{
pos[VX] = actor->origin[VX];
pos[VY] = actor->origin[VY];
pos[VZ] = actor->origin[VZ];
pos[VX] += FIX2FLT((P_Random() - P_Random()) << 14);
pos[VY] += FIX2FLT((P_Random() - P_Random()) << 14);
pos[VZ] += FIX2FLT(P_Random() << 14);
/// @todo We should not be using the original indices to determine
/// the mobjtype. Use a local table instead.
if((mo = P_SpawnMobj(MT_LEAF1 + (P_Random() & 1), pos,
actor->angle, 0)))
{
P_ThrustMobj(mo, actor->angle, FIX2FLT(P_Random() << 9) + 3);
mo->target = actor;
mo->special1 = 0;
}
}
}
示例9: swf_svg_print_color
static void swf_svg_print_color(SWFReader *read, u32 ARGB)
{
SFColor val;
val.red = INT2FIX((ARGB>>16)&0xFF) / 255*100;
val.green = INT2FIX((ARGB>>8)&0xFF) / 255*100;
val.blue = INT2FIX((ARGB)&0xFF) / 255*100;
swf_svg_print(read, "rgb(%g%%,%g%%,%g%%)", FIX2FLT(val.red), FIX2FLT(val.green), FIX2FLT(val.blue));
}
示例10: BE_WriteSFFloat
void BE_WriteSFFloat(GF_BifsEncoder *codec, Fixed val, GF_BitStream *bs, char *com)
{
if (codec->ActiveQP && codec->ActiveQP->useEfficientCoding) {
gf_bifs_enc_mantissa_float(codec, val, bs);
} else {
gf_bs_write_float(bs, FIX2FLT(val));
GF_LOG(GF_LOG_DEBUG, GF_LOG_CODING, ("[BIFS] SFFloat\t\t32\t\t%g\t\t%s\n", FIX2FLT(val), com ? com : "") );
}
}
示例11: print
void print ( void )
{
for ( int i = 0; i < 4; i++ )
printf( "{%f, %f, %f, %f}",
FIX2FLT( m_matrix[i][0] ),
FIX2FLT( m_matrix[i][1] ),
FIX2FLT( m_matrix[i][2] ),
FIX2FLT( m_matrix[i][3] ) );
}
示例12: gf_cache_remove_entry
static Bool gf_cache_remove_entry(GF_Compositor *compositor, GF_Node *node, GroupingNode2D *group)
{
u32 bytes_remove = 0;
GF_List *cache_candidates = compositor->cached_groups;
/*auto mode*/
if (!group) {
group = gf_list_get(cache_candidates, 0);
if (!group) return 0;
/*remove entry*/
gf_list_rem(cache_candidates, 0);
node = NULL;
} else {
/*remove entry if present*/
if (gf_list_del_item(cache_candidates, group)<0)
return 0;
}
/*disable the caching flag of the group if it was marked as such*/
if(group->flags & GROUP_IS_CACHABLE) {
group->flags &= ~GROUP_IS_CACHABLE;
/*the discarded bytes*/
bytes_remove = group->cached_size;
}
/*indicates cache destruction for next frame*/
if (group->cache && (group->flags & GROUP_IS_CACHED)) {
group->flags &= ~GROUP_IS_CACHED;
/*the discarded bytes*/
bytes_remove = group->cached_size;
}
if (bytes_remove == 0) return 0;
assert(compositor->video_cache_current_size >= bytes_remove);
compositor->video_cache_current_size -= bytes_remove;
GF_LOG(GF_LOG_DEBUG, GF_LOG_CACHE, ("[CACHE] Removing cache %s:\t Objects: %d\tSlope: %g\tBytes: %d\tTime: %d\n",
gf_node_get_log_name(node),
group->nb_objects,
FIX2FLT(group->priority),
group->cached_size,
FIX2FLT(group->traverse_time)));
GF_LOG(GF_LOG_DEBUG, GF_LOG_CACHE, ("[CACHE] Status (B): Max: %d\tUsed: %d\tNb Groups: %d\n",
compositor->video_cache_max_size,
compositor->video_cache_current_size,
gf_list_count(compositor->cached_groups)
));
return 1;
}
示例13: switch
/**
* Get a pointer to the value of a variable. Added for 64-bit support.
*/
void *G_GetVariable(int id)
{
static float bob[2];
switch(id)
{
case DD_GAME_NAME:
return GAMENAMETEXT;
case DD_GAME_NICENAME:
return GAME_NICENAME;
case DD_GAME_ID:
return GAMENAMETEXT " " GAME_VERSION_TEXT;
case DD_GAME_MODE:
return gameModeString;
case DD_GAME_CONFIG:
return gameConfigString;
case DD_VERSION_SHORT:
return GAME_VERSION_TEXT;
case DD_VERSION_LONG:
return GAME_VERSION_TEXTLONG "\n" GAME_DETAILS;
case DD_ACTION_LINK:
return actionlinks;
case DD_XGFUNC_LINK:
return xgClasses;
case DD_PSPRITE_BOB_X:
bob[VX] = 1 + (cfg.bobWeapon * players[CONSOLEPLAYER].bob) *
FIX2FLT(finecosine[(128 * mapTime) & FINEMASK]);
return &bob[VX];
case DD_PSPRITE_BOB_Y:
bob[VY] = 32 + (cfg.bobWeapon * players[CONSOLEPLAYER].bob) *
FIX2FLT(finesine[(128 * mapTime) & FINEMASK & (FINEANGLES / 2 - 1)]);
return &bob[VY];
default:
break;
}
// ID not recognized, return NULL.
return 0;
}
示例14: swf_svg_print_shape_record_to_path_d
static void swf_svg_print_shape_record_to_path_d(SWFReader *read, SWFShapeRec *srec)
{
u32 pt_idx;
u32 i;
pt_idx = 0;
for (i=0; i<srec->path->nbType; i++) {
switch (srec->path->types[i]) {
/*moveTo*/
case 0:
swf_svg_print(read, "M%g,%g", FIX2FLT(srec->path->pts[pt_idx].x), FIX2FLT(srec->path->pts[pt_idx].y));
pt_idx++;
break;
/*lineTo*/
case 1:
swf_svg_print(read, "L%g,%g", FIX2FLT(srec->path->pts[pt_idx].x), FIX2FLT(srec->path->pts[pt_idx].y));
pt_idx++;
break;
/*curveTo*/
case 2:
swf_svg_print(read, "Q%g,%g", FIX2FLT(srec->path->pts[pt_idx].x), FIX2FLT(srec->path->pts[pt_idx].y));
pt_idx++;
swf_svg_print(read, ",%g,%g", FIX2FLT(srec->path->pts[pt_idx].x), FIX2FLT(srec->path->pts[pt_idx].y));
pt_idx++;
break;
}
}
}
示例15: gdip_set_vertex_center
static
GF_Err gdip_set_vertex_center (GF_STENCIL _this, Fixed cx, Fixed cy, u32 color)
{
GpStatus ret;
GPSTEN();
CHECK_RET(GF_STENCIL_VERTEX_GRADIENT);
if (!_sten->pRadial) return GF_BAD_PARAM;
_sten->center.X = FIX2FLT(cx);
_sten->center.Y = FIX2FLT(cy);
ret = GdipSetPathGradientCenterPoint(_sten->pRadial, &_sten->center);
ret = GdipSetPathGradientCenterColor(_sten->pRadial, (ARGB) color);
return GF_OK;
}