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


C++ F32函数代码示例

本文整理汇总了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;
}
开发者ID:03050903,项目名称:Torque3D,代码行数:8,代码来源:tsTransform.cpp

示例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 );
}
开发者ID:campadrenalin,项目名称:terminal-overload,代码行数:48,代码来源:gfxD3D9Device.cpp

示例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;
}
开发者ID:CouleeApps,项目名称:MBExtender,代码行数:48,代码来源:mQuat.cpp

示例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);
}
开发者ID:campadrenalin,项目名称:terminal-overload,代码行数:29,代码来源:winRedbook.cpp

示例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;
	}
}
开发者ID:HyangZhao,项目名称:NaCl-main,代码行数:27,代码来源:llmediadataclient.cpp

示例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);
      }
    }
  }  
}
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:31,代码来源:wallobj.cpp

示例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();
}
开发者ID:zod331,项目名称:nucleus,代码行数:30,代码来源:rsx_pgraph.cpp

示例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;
}
开发者ID:AnsonX10,项目名称:bitfighter,代码行数:19,代码来源:statistics.cpp

示例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;
}
开发者ID:nev7n,项目名称:Torque3D,代码行数:60,代码来源:stdGameProcess.cpp

示例10: Mesh

//
// Adjust resource display
//
void ResourceObj::AdjustResource()
{
  if (Mesh().curCycle)
  {
    Mesh().SetFrame((Mesh().curCycle->maxFrame - 1) * (1.0f - (F32(resource) * ResourceType()->GetResourceMaxInv())));
  }
}
开发者ID:grasmanek94,项目名称:darkreign2,代码行数:10,代码来源:resourceobj.cpp

示例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));
         }
      }
   }
开发者ID:parhelia512,项目名称:tge-152-fork,代码行数:28,代码来源:appIfl.cpp

示例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
}
开发者ID:LibreGames,项目名称:bitfighter,代码行数:27,代码来源:GaugeRenderer.cpp

示例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;
        }
      }
    }

  }
开发者ID:grasmanek94,项目名称:darkreign2,代码行数:37,代码来源:strategic_base_recycler.cpp

示例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));
}
开发者ID:grasmanek94,项目名称:darkreign2,代码行数:30,代码来源:beamrender_plain.cpp

示例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;
}
开发者ID:HwakyoungLee,项目名称:opentnl,代码行数:30,代码来源:osxInput.cpp


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