本文整理汇总了C++中FixMul函数的典型用法代码示例。如果您正苦于以下问题:C++ FixMul函数的具体用法?C++ FixMul怎么用?C++ FixMul使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FixMul函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FlashFrame
//cycle the flashing light for when mine destroyed
void FlashFrame (void)
{
static fixang flash_ang = 0;
if (!(gameData.reactor.bDestroyed || gameStates.gameplay.seismic.nMagnitude)) {
gameStates.render.nFlashScale = I2X (1);
return;
}
if (gameStates.app.bEndLevelSequence)
return;
if (paletteManager.BlueEffect () > 10) //whiting out
return;
// flash_ang += FixMul(FLASH_CYCLE_RATE, gameData.time.xFrame);
if (gameStates.gameplay.seismic.nMagnitude) {
fix xAddedFlash = abs(gameStates.gameplay.seismic.nMagnitude);
if (xAddedFlash < I2X (1))
xAddedFlash *= 16;
flash_ang += (fixang) FixMul (gameStates.render.nFlashRate, FixMul(gameData.time.xFrame, xAddedFlash+I2X (1)));
FixFastSinCos (flash_ang, &gameStates.render.nFlashScale, NULL);
gameStates.render.nFlashScale = (gameStates.render.nFlashScale + I2X (3))/4; // gets in range 0.5 to 1.0
}
else {
flash_ang += (fixang) FixMul (gameStates.render.nFlashRate, gameData.time.xFrame);
FixFastSinCos (flash_ang, &gameStates.render.nFlashScale, NULL);
gameStates.render.nFlashScale = (gameStates.render.nFlashScale + I2X (1))/2;
if (gameStates.app.nDifficultyLevel == 0)
gameStates.render.nFlashScale = (gameStates.render.nFlashScale+I2X (3))/4;
}
}
示例2: SeismicDisturbanceFrame
void SeismicDisturbanceFrame (void)
{
if (gameStates.gameplay.seismic.nShakeFrequency) {
if (((gameStates.gameplay.seismic.nStartTime < gameData.time.xGame) &&
(gameStates.gameplay.seismic.nEndTime > gameData.time.xGame)) || StartSeismicDisturbance()) {
fix deltaTime = gameData.time.xGame - gameStates.gameplay.seismic.nStartTime;
int fc, rx, rz;
fix h;
fc = abs(deltaTime - (gameStates.gameplay.seismic.nEndTime - gameStates.gameplay.seismic.nStartTime) / 2);
fc /= F1_0 / 16;
if (fc > 16)
fc = 16;
else if (fc == 0)
fc = 1;
gameStates.gameplay.seismic.nVolume += fc;
h = 3 * F1_0 / 16 + (F1_0 * (16 - fc)) / 32;
rx = FixMul(d_rand() - 16384, h);
rz = FixMul(d_rand() - 16384, h);
gameData.objs.console->mType.physInfo.rotVel.p.x += rx;
gameData.objs.console->mType.physInfo.rotVel.p.z += rz;
// Shake the buddy!
if (gameData.escort.nObjNum != -1) {
gameData.objs.objects[gameData.escort.nObjNum].mType.physInfo.rotVel.p.x += rx*4;
gameData.objs.objects[gameData.escort.nObjNum].mType.physInfo.rotVel.p.z += rz*4;
}
// Shake a guided missile!
gameStates.gameplay.seismic.nMagnitude += rx;
}
}
}
示例3: ScaleMatrix
//------------------------------------------------------------------------------
//performs aspect scaling on global view matrix
void ScaleMatrix (int bOglScale)
{
viewInfo.view [1] = viewInfo.view [0]; //so we can use unscaled if we want
viewInfo.viewf [1] = viewInfo.viewf [0]; //so we can use unscaled if we want
viewInfo.scale = viewInfo.windowScale;
if (viewInfo.zoom <= f1_0) //xZoom in by scaling z
viewInfo.scale[Z] = FixMul (viewInfo.scale[Z], viewInfo.zoom);
else { //xZoom out by scaling x&y
fix s = FixDiv (f1_0, viewInfo.zoom);
viewInfo.scale[X] = FixMul (viewInfo.scale[X], s);
viewInfo.scale[Y] = FixMul (viewInfo.scale[Y], s);
}
viewInfo.scalef = viewInfo.scale.ToFloat();
//viewInfo.scale[X] = viewInfo.scale[Y] = viewInfo.scale[Z] = F1_0;
//now scale matrix elements
if (bOglScale) {
//glScalef (X2F (viewInfo.scale[X]), X2F (viewInfo.scale[Y]), -X2F (viewInfo.scale[Z]));
glScalef (1, 1, -1);
}
else {
//VmVecScale (&viewInfo.view [0].rVec, viewInfo.scale[X]);
//VmVecScale (&viewInfo.view [0].uVec, viewInfo.scale[Y]);
//viewInfo.scale[X] = viewInfo.scale[Y] = viewInfo.scale[Z] = F1_0;
viewInfo.view [0][FVEC] *= (-viewInfo.scale[Z]);
glScalef (1, 1, 1);
}
viewInfo.viewf[0] = viewInfo.view[0].ToFloat();
}
示例4: ComputeHeadlightLightOnObject
fix ComputeHeadlightLightOnObject (tObject *objP)
{
int i;
fix light;
// Let's just illuminate players and robots for speed reasons, ok?
if ((objP->nType != OBJ_ROBOT) && (objP->nType != OBJ_PLAYER))
return 0;
light = 0;
for (i = 0; i < nHeadLights; i++) {
fix dot, dist;
vmsVector vecToObj;
tObject *lightObjP;
lightObjP = Headlights [i];
VmVecSub (&vecToObj, &objP->position.vPos, &lightObjP->position.vPos);
dist = VmVecNormalize (&vecToObj);
if (dist > 0) {
dot = VmVecDot (&lightObjP->position.mOrient.fVec, &vecToObj);
if (dot < F1_0/2)
light += FixDiv (HEADLIGHT_SCALE, FixMul (HEADLIGHT_SCALE, dist)); // Do the normal thing, but darken around headlight.
else
light += FixMul (FixMul (dot, dot), HEADLIGHT_SCALE)/8;
}
}
return light;
}
示例5: ScaleMatrix
//------------------------------------------------------------------------------
//performs aspect scaling on global view matrix
void ScaleMatrix (int bOglScale)
{
viewInfo.view [1] = viewInfo.view [0]; //so we can use unscaled if we want
viewInfo.viewf [1] = viewInfo.viewf [0]; //so we can use unscaled if we want
viewInfo.scale = viewInfo.windowScale;
if (viewInfo.zoom <= f1_0) //xZoom in by scaling z
viewInfo.scale.p.z = FixMul (viewInfo.scale.p.z, viewInfo.zoom);
else { //xZoom out by scaling x&y
fix s = FixDiv (f1_0, viewInfo.zoom);
viewInfo.scale.p.x = FixMul (viewInfo.scale.p.x, s);
viewInfo.scale.p.y = FixMul (viewInfo.scale.p.y, s);
}
//viewInfo.scale.p.x = viewInfo.scale.p.y = viewInfo.scale.p.z = F1_0;
//now scale matrix elements
if (bOglScale)
//glScalef (f2fl (viewInfo.scale.p.x), f2fl (viewInfo.scale.p.y), -f2fl (viewInfo.scale.p.z));
glScalef (1, 1, -1);
else {
//VmVecScale (&viewInfo.view [0].rVec, viewInfo.scale.p.x);
//VmVecScale (&viewInfo.view [0].uVec, viewInfo.scale.p.y);
//viewInfo.scale.p.x = viewInfo.scale.p.y = viewInfo.scale.p.z = F1_0;
VmVecScale (&viewInfo.view [0].fVec, -viewInfo.scale.p.z);
glScalef (1, 1, 1);
}
VmsMatToFloat (viewInfo.viewf, viewInfo.view);
}
示例6: WiggleObject
void WiggleObject (CObject *objP)
{
fix xWiggle;
int nParent;
CObject *pParent;
if (gameStates.render.nShadowPass == 2)
return;
if (gameOpts->app.bEpilepticFriendly)
return;
if (!gameStates.app.bNostalgia && (!EGI_FLAG (nDrag, 0, 0, 0) || !EGI_FLAG (bWiggle, 1, 0, 1)))
return;
nParent = gameData.objs.parentObjs [objP->Index ()];
pParent = (nParent < 0) ? NULL : OBJECTS + nParent;
FixFastSinCos (fix (gameData.time.xGame / gameStates.gameplay.slowmo [1].fSpeed), &xWiggle, NULL);
if (gameData.time.xFrame < I2X (1))// Only scale wiggle if getting at least 1 FPS, to avoid causing the opposite problem.
xWiggle = FixMul (xWiggle * 20, gameData.time.xFrame); //make wiggle fps-independent (based on pre-scaled amount of wiggle at 20 FPS)
if (SPECTATOR (objP))
OBJPOS (objP)->vPos += (OBJPOS (objP)->mOrient.UVec () * FixMul (xWiggle, gameData.pig.ship.player->wiggle)) * (I2X (1) / 20);
else if ((objP->info.nType == OBJ_PLAYER) || !pParent)
objP->mType.physInfo.velocity += objP->info.position.mOrient.UVec () * FixMul (xWiggle, gameData.pig.ship.player->wiggle);
else {
objP->mType.physInfo.velocity += pParent->info.position.mOrient.UVec () * FixMul (xWiggle, gameData.pig.ship.player->wiggle);
objP->info.position.vPos += objP->mType.physInfo.velocity * gameData.time.xFrame;
}
}
示例7: FixDiv
void CShrapnel::Move (void)
{
fix xSpeed = FixDiv (m_info.xSpeed, I2X (25) / 1000);
CFixVector vOffs;
time_t nTicks;
if ((nTicks = gameStates.app.nSDLTicks - m_info.tUpdate) < 25)
return;
xSpeed = (fix) (xSpeed / gameStates.gameplay.slowmo [0].fSpeed);
for (; nTicks >= 25; nTicks -= 25) {
if (--(m_info.nTurn))
vOffs = m_info.vOffs;
else {
m_info.nTurn = ((m_info.xTTL > I2X (1) / 2) ? 2 : 4) + d_rand () % 4;
vOffs = m_info.vDir;
vOffs [X] = FixMul (vOffs [X], 2 * d_rand ());
vOffs [Y] = FixMul (vOffs [Y], 2 * d_rand ());
vOffs [Z] = FixMul (vOffs [Z], 2 * d_rand ());
CFixVector::Normalize (vOffs);
m_info.vOffs = vOffs;
}
vOffs *= xSpeed;
m_info.vPos += vOffs;
}
if (m_info.nSmoke >= 0)
particleManager.SetPos (m_info.nSmoke, &m_info.vPos, NULL, -1);
m_info.tUpdate = gameStates.app.nSDLTicks - nTicks;
}
示例8: MixSoundSlot
static void MixSoundSlot (struct sound_slot *sl, Uint8 *sldata, Uint8 *stream, int len)
{
Uint8 *streamend = stream + len;
Uint8 *slend = sldata - sl->position + sl->length;
Uint8 *sp = stream, s;
signed char v;
fix vl, vr;
int x;
if ((x = sl->pan) & 0x8000) {
vl = 0x20000 - x * 2;
vr = 0x10000;
}
else {
vl = 0x10000;
vr = x * 2;
}
vl = FixMul (vl, (x = sl->volume));
vr = FixMul (vr, x);
while (sp < streamend) {
if (sldata == slend) {
if (!sl->looped) {
sl->playing = 0;
break;
}
sldata = sl->samples;
}
v = *(sldata++) - 0x80;
s = *sp;
*(sp++) = mix8 [s + FixMul (v, vl) + 0x80];
s = *sp;
*(sp++) = mix8 [s + FixMul (v, vr) + 0x80];
}
sl->position = (int) (sldata - sl->samples);
}
示例9: Blend
int Blend (int i1, int i2)
{
Fixed smallFix, bigFix, tempFix;
smallFix = ONE * i1;
bigFix = ONE * i2;
tempFix = FixMul (fract, bigFix) +FixMul (ONE-fract, smallFix);
return (FixRound (tempFix));
}
示例10: AIFrameAnimation
// ------------------------------------------------------------------------------------------
// Move all sub-gameData.objs.objects in an tObject towards their goals.
// Current orientation of tObject is at: polyObjInfo.animAngles
// Goal orientation of tObject is at: aiInfo.goalAngles
// Delta orientation of tObject is at: aiInfo.deltaAngles
void AIFrameAnimation (tObject *objP)
{
int nObject = OBJ_IDX (objP);
int joint;
int nJoints = gameData.models.polyModels [objP->rType.polyObjInfo.nModel].nModels;
for (joint=1; joint<nJoints; joint++) {
fix delta_to_goal;
fix scaled_delta_angle;
vmsAngVec *curangp = &objP->rType.polyObjInfo.animAngles [joint];
vmsAngVec *goalangp = &gameData.ai.localInfo [nObject].goalAngles [joint];
vmsAngVec *deltaangp = &gameData.ai.localInfo [nObject].deltaAngles [joint];
Assert (nObject >= 0);
delta_to_goal = goalangp->p - curangp->p;
if (delta_to_goal > 32767)
delta_to_goal = delta_to_goal - 65536;
else if (delta_to_goal < -32767)
delta_to_goal = 65536 + delta_to_goal;
if (delta_to_goal) {
scaled_delta_angle = FixMul (deltaangp->p, gameData.time.xFrame) * DELTA_ANG_SCALE;
curangp->p += (fixang) scaled_delta_angle;
if (abs (delta_to_goal) < abs (scaled_delta_angle))
curangp->p = goalangp->p;
}
delta_to_goal = goalangp->b - curangp->b;
if (delta_to_goal > 32767)
delta_to_goal = delta_to_goal - 65536;
else if (delta_to_goal < -32767)
delta_to_goal = 65536 + delta_to_goal;
if (delta_to_goal) {
scaled_delta_angle = FixMul (deltaangp->b, gameData.time.xFrame) * DELTA_ANG_SCALE;
curangp->b += (fixang) scaled_delta_angle;
if (abs (delta_to_goal) < abs (scaled_delta_angle))
curangp->b = goalangp->b;
}
delta_to_goal = goalangp->h - curangp->h;
if (delta_to_goal > 32767)
delta_to_goal = delta_to_goal - 65536;
else if (delta_to_goal < -32767)
delta_to_goal = 65536 + delta_to_goal;
if (delta_to_goal) {
scaled_delta_angle = FixMul (deltaangp->h, gameData.time.xFrame) * DELTA_ANG_SCALE;
curangp->h += (fixang) scaled_delta_angle;
if (abs (delta_to_goal) < abs (scaled_delta_angle))
curangp->h = goalangp->h;
}
}
}
示例11: OmegaEnergy
fix OmegaEnergy (fix xDeltaCharge)
{
fix xEnergyUsed;
if (xDeltaCharge < 0)
return -1;
xEnergyUsed = FixMul (OMEGA_ENERGY_RATE, xDeltaCharge);
if (gameStates.app.nDifficultyLevel < 2)
xEnergyUsed = FixMul (xEnergyUsed, i2f (gameStates.app.nDifficultyLevel + 2) / 4);
return xEnergyUsed;
}
示例12: I2X
void CObject::RandomBump (fix xScale, fix xForce, bool bSound)
{
fix angle;
angle = (d_rand () - I2X (1) / 4);
mType.physInfo.rotVel [X] += FixMul (angle, xScale);
angle = (d_rand () - I2X (1) / 4);
mType.physInfo.rotVel [Z] += FixMul (angle, xScale);
CFixVector vRand = CFixVector::Random ();
Bump (vRand, xForce);
if (bSound)
audio.CreateObjectSound (SOUND_PLAYER_HIT_WALL, SOUNDCLASS_GENERIC, Index ());
}
示例13: G3DrawBitMap
bool G3DrawBitMap(vms_vector *pos,fix width,fix height,grs_bitmap *bm, int orientation)
{
vms_vector pv,v1;
int i;
r_bitmapc++;
v1.z=0;
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
OglBindBmTex(bm);
OglTexWrap(bm->glTexture,GL_CLAMP);
glBegin(GL_QUADS);
glColor3d(1.0,1.0,1.0);
width = FixMul(width,viewInfo.scale.x);
height = FixMul(height,viewInfo.scale.y);
for (i = 0; i < 4; i++) {
VmVecSub(&v1,pos,&viewInfo.position);
VmVecRotate(&pv,&v1,&viewInfo.view);
switch (i) {
case 0:
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0);
pv.x+=-width;
pv.y+=height;
break;
case 1:
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, bm->glTexture->u, 0.0);
pv.x+=width;
pv.y+=height;
break;
case 2:
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, bm->glTexture->u, bm->glTexture->v);
pv.x+=width;
pv.y+=-height;
break;
case 3:
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0.0, bm->glTexture->v);
pv.x+=-width;
pv.y+=-height;
break;
}
glVertex3d (f2glf(pv.x), f2glf(pv.y), -f2glf(pv.z));
}
glEnd();
//These next lines are important for later leave these here - Lehm 4/26/05
//glActiveTextureARB(GL_TEXTURE0_ARB);
//glBindTexture(GL_TEXTURE_2D,0);
//glDisable(GL_TEXTURE_2D);
return 0;
}
示例14: AudioMixCallback
//changed on 980905 by adb to cleanup, add pan support and optimize mixer
static void _CDECL_ AudioMixCallback(void *userdata, Uint8 *stream, int len)
{
Uint8 *streamend = stream + len;
struct sound_slot *sl;
if (!gameStates.sound.digi.bInitialized)
return;
memset(stream, 0x80, len); // fix "static" sound bug on Mac OS X
for (sl = SoundSlots; sl < SoundSlots + MAX_SOUND_SLOTS; sl++) {
if (sl->playing && sl->samples && sl->length) {
#if 0
MixSoundSlot (sl, sl->samples + sl->position, stream, len);
#else
Uint8 *sldata = sl->samples + sl->position, *slend = sl->samples + sl->length;
Uint8 *sp = stream, s;
signed char v;
fix vl, vr;
int x;
if ((x = sl->pan) & 0x8000) {
vl = 0x20000 - x * 2;
vr = 0x10000;
}
else {
vl = 0x10000;
vr = x * 2;
}
vl = FixMul (vl, (x = sl->volume));
vr = FixMul (vr, x);
while (sp < streamend) {
if (sldata == slend) {
if (!sl->looped) {
sl->playing = 0;
break;
}
sldata = sl->samples;
}
v = *(sldata++) - 0x80;
s = *sp;
*(sp++) = mix8 [s + FixMul (v, vl) + 0x80];
s = *sp;
*(sp++) = mix8 [s + FixMul (v, vr) + 0x80];
}
sl->position = (int) (sldata - sl->samples);
#endif
}
}
}
示例15: Assert
//------------------------------------------------------------------------------
//process a continuously-spinning CObject
void CObject::Spin (void)
{
CAngleVector rotangs;
CFixMatrix rotmat, new_pm;
Assert (info.movementType == MT_SPINNING);
rotangs = CAngleVector::Create((fixang) FixMul (mType.spinRate [X], gameData.time.xFrame),
(fixang) FixMul (mType.spinRate [Y], gameData.time.xFrame),
(fixang) FixMul (mType.spinRate [Z], gameData.time.xFrame));
rotmat = CFixMatrix::Create (rotangs);
new_pm = info.position.mOrient * rotmat;
info.position.mOrient = new_pm;
info.position.mOrient.CheckAndFix();
}