本文整理汇总了C++中F32函数的典型用法代码示例。如果您正苦于以下问题:C++ F32函数的具体用法?C++ F32怎么用?C++ F32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了F32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: F32
QuatF & Quat16::getQuatF( QuatF * q ) const
{
q->x = F32( x ) / F32(MAX_VAL);
q->y = F32( y ) / F32(MAX_VAL);
q->z = F32( z ) / F32(MAX_VAL);
q->w = F32( w ) / F32(MAX_VAL);
return *q;
}
示例2: pos
void GFXD3D9Device::setClipRect( const RectI &inRect )
{
// We transform the incoming rect by the view
// matrix first, so that it can be used to pan
// and scale the clip rect.
//
// This is currently used to take tiled screenshots.
Point3F pos( inRect.point.x, inRect.point.y, 0.0f );
Point3F extent( inRect.extent.x, inRect.extent.y, 0.0f );
getViewMatrix().mulP( pos );
getViewMatrix().mulV( extent );
RectI rect( pos.x, pos.y, extent.x, extent.y );
// Clip the rect against the renderable size.
Point2I size = mCurrentRT->getSize();
RectI maxRect(Point2I(0,0), size);
rect.intersect(maxRect);
mClipRect = rect;
F32 l = F32( mClipRect.point.x );
F32 r = F32( mClipRect.point.x + mClipRect.extent.x );
F32 b = F32( mClipRect.point.y + mClipRect.extent.y );
F32 t = F32( mClipRect.point.y );
// Set up projection matrix,
static Point4F pt;
pt.set(2.0f / (r - l), 0.0f, 0.0f, 0.0f);
mTempMatrix.setColumn(0, pt);
pt.set(0.0f, 2.0f/(t - b), 0.0f, 0.0f);
mTempMatrix.setColumn(1, pt);
pt.set(0.0f, 0.0f, 1.0f, 0.0f);
mTempMatrix.setColumn(2, pt);
pt.set((l+r)/(l-r), (t+b)/(b-t), 1.0f, 1.0f);
mTempMatrix.setColumn(3, pt);
setProjectionMatrix( mTempMatrix );
// Set up world/view matrix
mTempMatrix.identity();
setWorldMatrix( mTempMatrix );
setViewport( mClipRect );
}
示例3: mAcos
QuatF & QuatF::interpolate( const QuatF & q1, const QuatF & q2, F32 t )
{
//-----------------------------------
// Calculate the cosine of the angle:
double cosOmega = q1.dot( q2 );
//-----------------------------------
// adjust signs if necessary:
F32 sign2;
if ( cosOmega < 0.0 )
{
cosOmega = -cosOmega;
sign2 = -1.0f;
}
else
sign2 = 1.0f;
//-----------------------------------
// calculate interpolating coeffs:
double scale1, scale2;
if ( (1.0 - cosOmega) > 0.00001 )
{
// standard case
double omega = mAcos(cosOmega);
double sinOmega = mSin(omega);
scale1 = mSin((1.0 - t) * omega) / sinOmega;
scale2 = sign2 * mSin(t * omega) / sinOmega;
}
else
{
// if quats are very close, just do linear interpolation
scale1 = 1.0 - t;
scale2 = sign2 * t;
}
//-----------------------------------
// actually do the interpolation:
x = F32(scale1 * q1.x + scale2 * q2.x);
y = F32(scale1 * q1.y + scale2 * q2.y);
z = F32(scale1 * q1.z + scale2 * q2.z);
w = F32(scale1 * q1.w + scale2 * q2.w);
return *this;
}
示例4: setLastError
bool Win32RedBookDevice::getVolume(F32 * volume)
{
if(!mAcquired)
{
setLastError("Device has not been acquired");
return(false);
}
if(!mVolumeInitialized)
{
setLastError("Volume failed to initialize");
return(false);
}
U32 vol = 0;
if(mUsingMixer)
{
mixerGetControlDetails(mVolumeDeviceId, &mMixerVolumeDetails, MIXER_GETCONTROLDETAILSF_VALUE);
vol = mMixerVolumeValue.dwValue;
}
else
auxGetVolume(mAuxVolumeDeviceId, (unsigned long *)&vol);
vol &= 0xffff;
*volume = F32(vol) / 65535.f;
setLastError("");
return(true);
}
示例5: LL_INFOS
/*virtual*/
void LLMediaDataClient::Responder::error(U32 status, const std::string& reason)
{
if (status == HTTP_SERVICE_UNAVAILABLE)
{
F32 retry_timeout = mRequest->getRetryTimerDelay();
mRequest->incRetryCount();
if (mRequest->getRetryCount() < mRequest->getMaxNumRetries())
{
LL_INFOS("LLMediaDataClient") << *mRequest << " got SERVICE_UNAVAILABLE...retrying in " << retry_timeout << " seconds" << LL_ENDL;
// Start timer (instances are automagically tracked by
// InstanceTracker<> and LLEventTimer)
new RetryTimer(F32(retry_timeout/*secs*/), this);
}
else {
LL_INFOS("LLMediaDataClient") << *mRequest << " got SERVICE_UNAVAILABLE...retry count "
<< mRequest->getRetryCount() << " exceeds " << mRequest->getMaxNumRetries() << ", not retrying" << LL_ENDL;
}
}
else {
std::string msg = boost::lexical_cast<std::string>(status) + ": " + reason;
LL_WARNS("LLMediaDataClient") << *mRequest << " http error(" << msg << ")" << LL_ENDL;
}
}
示例6: ASSERT
//
// GetNearbyWalls
//
// Get walls within link distance of the given position
//
void WallObjType::GetNearbyWalls(Team *team, const Vector &p, WallObjList &list, WallObj *filter)
{
ASSERT(WorldCtrl::MetreOnMap(p.x, p.z))
// What range should we search in
F32 range = F32(GetRangeStraight() + 1) * WorldCtrl::CellSize();
// Generate a unit iterator
UnitObjIter::Tactical i(NULL, UnitObjIter::FilterData(team, Relation::ALLY, p, range));
UnitObj *obj;
// Check each unit
while ((obj = i.Next()) != NULL)
{
// Is this a wall
if (WallObj *wall = Promote::Object<WallObjType, WallObj>(obj))
{
// Should we add it
if (wall != filter)
{
list.Append(wall);
}
}
}
}
示例7: F32
void PGRAPH::ClearSurface(U32 mask) {
// Avoid clearing empty surfaces
if (surface.width == 0 || surface.height == 0) {
return;
}
const F32 color[4] = {
((clear_color >> 24) & 0xFF) / 255.0f, // Red
((clear_color >> 16) & 0xFF) / 255.0f, // Green
((clear_color >> 8) & 0xFF) / 255.0f, // Blue
((clear_color >> 0) & 0xFF) / 255.0f, // Alpha
};
const F32 depth = clear_depth / F32(0xFFFFFF);
const U08 stencil = clear_stencil;
if (mask & RSX_CLEAR_BIT_COLOR) {
auto* colorTarget = getColorTarget(surface.colorOffset[0]);
cmdBuffer->cmdClearColor(colorTarget, color);
}
if (mask & (RSX_CLEAR_BIT_DEPTH | RSX_CLEAR_BIT_STENCIL)) {
// TODO: Depth-exclusive or stencil-exclusive clears are unimplemented
auto* depthTarget = getDepthStencilTarget(surface.depthOffset);
cmdBuffer->cmdClearDepthStencil(depthTarget, depth, stencil);
}
// TODO: Check if cmdBuffer is empty
cmdBuffer->finalize();
cmdQueue->submit(cmdBuffer, fence);
fence->wait();
cmdBuffer->reset();
}
示例8: F32
// Return a measure of a player's strength.
// Right now this is roughly a kill - death / kill + death ratio
// Better might be: https://secure.wikimedia.org/wikipedia/en/wiki/Elo_rating_system
F32 Statistics::getCalculatedRating()
{
// Total kills = mKills + mFratricides (but we won't count mFratricides)
// Counted deaths = mDeaths - mSuicides (mSuicides are included in mDeaths and we want to ignore them)
// Use F32 here so we don't underflow with U32 math; probably not necessary
F32 deathsDueToEnemyAction = F32(mTotalDeaths) - F32(mTotalSuicides);
F32 totalTotalKillsAndDeaths = F32(mTotalKills) + deathsDueToEnemyAction;
// Initial case: you haven't killed or died -- go out and prove yourself, lad!
if(totalTotalKillsAndDeaths == 0)
return 0;
// Standard case
else
return ((F32)mTotalKills - deathsDueToEnemyAction) / totalTotalKillsAndDeaths;
}
示例9: PROFILE_SCOPE
bool StdClientProcessList::advanceTime( SimTime timeDelta )
{
PROFILE_SCOPE( StdClientProcessList_AdvanceTime );
if ( doBacklogged( timeDelta ) )
return false;
bool ret = Parent::advanceTime( timeDelta );
ProcessObject *obj = NULL;
AssertFatal( mLastDelta >= 0.0f && mLastDelta <= 1.0f, "mLastDelta is not zero to one.");
obj = mHead.mProcessLink.next;
while ( obj != &mHead )
{
if ( obj->isTicking() )
obj->interpolateTick( mLastDelta );
obj = obj->mProcessLink.next;
}
for (U32 i = 0; i < UpdateInterface::all.size(); i++)
{
Component *comp = dynamic_cast<Component*>(UpdateInterface::all[i]);
if (!comp->isClientObject() || !comp->isActive())
continue;
UpdateInterface::all[i]->interpolateTick(mLastDelta);
}
// Inform objects of total elapsed delta so they can advance
// client side animations.
F32 dt = F32(timeDelta) / 1000;
// Update camera FX.
gCamFXMgr.update( dt );
obj = mHead.mProcessLink.next;
while ( obj != &mHead )
{
obj->advanceTime( dt );
obj = obj->mProcessLink.next;
}
for (U32 i = 0; i < UpdateInterface::all.size(); i++)
{
Component *comp = dynamic_cast<Component*>(UpdateInterface::all[i]);
if (comp)
{
if (!comp->isClientObject() || !comp->isActive())
continue;
}
UpdateInterface::all[i]->advanceTime(dt);
}
return ret;
}
示例10: Mesh
//
// Adjust resource display
//
void ResourceObj::AdjustResource()
{
if (Mesh().curCycle)
{
Mesh().SetFrame((Mesh().curCycle->maxFrame - 1) * (1.0f - (F32(resource) * ResourceType()->GetResourceMaxInv())));
}
}
示例11: strnew
AppIfl::AppIfl(const char * fullPath)
{
mIflFile = strnew(fullPath);
// load in duration and names
std::ifstream is;
is.open(fullPath);
char buffer[256];
char name[256];
S32 duration;
while (is.good() && !is.eof())
{
is.getline(buffer,sizeof(buffer));
S32 num = sscanf(buffer,"%s %i",name,&duration);
if (num==1)
{
mNames.push_back(strnew(name));
mDurations.push_back(AppTime(1.0f/30.0f,0));
}
else if (num==2)
{
mNames.push_back(strnew(name));
mDurations.push_back(AppTime(F32(duration)/30.0f,0));
}
}
}
示例12: F32
void EnergyGaugeRenderer::render(S32 energy)
{
// Create fade
static const F32 colors[] = {
Colors::blue.r, Colors::blue.g, Colors::blue.b, 1, // Fade from
Colors::blue.r, Colors::blue.g, Colors::blue.b, 1,
Colors::cyan.r, Colors::cyan.g, Colors::cyan.b, 1, // Fade to
Colors::cyan.r, Colors::cyan.g, Colors::cyan.b, 1,
};
GaugeRenderer::render(energy, Ship::EnergyMax, colors, GaugeBottomMargin, GaugeHeight, Ship::EnergyCooldownThreshold);
#ifdef SHOW_SERVER_SITUATION
ServerGame *serverGame = GameManager::getServerGame();
if((serverGame && serverGame->getClientInfo(0)->getConnection()->getControlObject()))
{
S32 actDiff = static_cast<Ship *>(serverGame->getClientInfo(0)->getConnection()->getControlObject())->getEnergy();
S32 p = F32(actDiff) / Ship::EnergyMax * GaugeWidth;
glColor(Colors::magenta);
drawVertLine(xul + p, yul - SafetyLineExtend - 1, yul + GaugeHeight + SafetyLineExtend);
//Or, perhaps, just this:
//renderGauge(energy, Ship::EnergyMax, Colors::blue, Colors::cyan, GaugeBottomMargin, GaugeHeight);
}
#endif
}
示例13: U32
//
// Process the recycler
//
void Base::Recycler::Process()
{
// Work out how much resource is pending from refunds
U32 refund = 0;
for (UnitObjList::Iterator u(&state.GetBase().GetManager().GetRefunds()); *u; ++u)
{
refund += U32(F32((**u)->GetResourceValue() * (**u)->UnitType()->GetRecyclePercentage()));
}
Object &object = state.GetBase().GetObject();
Team *team = object.GetTeam();
U32 resource = team->GetResourceStore();
// Do we have less cash now than the limit ?
if ((resource + refund) < cash)
{
for (NList<Type>::Iterator t(&types); *t; ++t)
{
const NList<UnitObj> *units = team->GetUnitObjects((*t)->type->GetNameCrc());
if (units && units->GetCount() > (*t)->minimum)
{
// Order this unit to be recycled
UnitObj *unit = units->GetHead();
Orders::Game::ClearSelected::Generate(object);
Orders::Game::AddSelected::Generate(object, unit);
Orders::Game::Recycle::Generate(object);
state.GetBase().GetManager().AddRefund(unit);
break;
}
}
}
}
示例14: F32
// strait twisty beam
//
void BeamRenderPlain::Setup()
{
// get beam rendering class
BeamRenderPlainClass * sc = (BeamRenderPlainClass *)proto;
F32 t = paramAnim.Current().scale;
if (t <= 1)
{
offset = sc->data.vector * t;
}
Quaternion r = angle * rotation;
const Vector & p0 = particle->matrix.posit;
Vector * p = points.data, * pe = points.data + points.count - 1;
*p++ = p0;
Vector dof = offset * (1.0f / F32(points.count - 1)), off = dof;
//LOG_DIAG((""))
//LOG_DIAG((""))
//LOG_DIAG(("p: %f,%f,%f", p->x, p->y, p->z));
for (F32 h = 0; p < pe; p++, off += dof, r *= twist)
{
*p = p0 + off + r.GetRight() * sc->distance;
//LOG_DIAG(("p: %f,%f,%f", p->x, p->y, p->z));
}
*p = p0 + off;
//LOG_DIAG(("p: %f,%f,%f", p->x, p->y, p->z));
}
示例15: ReadJoystick
bool ReadJoystick(F32 axes[MaxJoystickAxes], U32 &buttonMask, U32 &hatMask)
{
if(!gJoystickInit)
return false;
S32 i;
for(i = 0; i < MaxJoystickAxes; i++)
{
ControllerElement *e = &gController.axes[i];
S32 elementValue = getElementValue(e);
S32 diff = e->maxValue - e->minValue;
if(diff != 0)
{
axes[i] = (elementValue - e->minValue) * 2 / F32(diff);
axes[i] -= 1;
}
else
axes[i] = 0;
}
buttonMask = 0;
for(i = 0; i < gController.buttons.size(); i++)
{
ControllerElement *e = &gController.buttons[i];
S32 value = getElementValue(e);
if(value)
buttonMask |= (1 << i);
}
return true;
}