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


C++ ToFloat函数代码示例

本文整理汇总了C++中ToFloat函数的典型用法代码示例。如果您正苦于以下问题:C++ ToFloat函数的具体用法?C++ ToFloat怎么用?C++ ToFloat使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ToFloat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OrthographicCam

 /*void OrthoCamCreator( ResourceManager& res,Task* t)
 {
 	int width=(int)ToFloat(GetElement(t,"width","OrthoCam",res,false,""));
 	int height=(int)ToFloat(GetElement(t,"height","OrthoCam",res,false,""));
 	
 	res.Add(t->name,new OrthographicCam(width,height));
 }*/
 void ConicCamCreator( ResourceManager& res,Task* t)
 {
 	int width=(int)ToFloat(GetElement(t,"width","ConicCam",res,false,""));
 	int height=(int)ToFloat(GetElement(t,"height","ConicCam",res,false,""));
 	
 	res.Add(t->name,new ConicCam(width,height));
 }
开发者ID:rtshadow,项目名称:miscs,代码行数:14,代码来源:executor.cpp

示例2: ToVector3

//converts string like 'a,b,c' into Vector3(a,b,c)
Vector3 ToVector3(std::string value)
{
	std::vector<std::string> el=Split(value,",");
	if(el.size()!=3)
		Log::AddMessage("Point in 3D space should consist of 3 coordinates",Log::ERR);
	return Vector3(ToFloat(el[0]),ToFloat(el[1]),ToFloat(el[2]));
}
开发者ID:rtshadow,项目名称:miscs,代码行数:8,代码来源:executor.cpp

示例3: ASSERT

//----------------------------------------------------------------------------------------
// ConvertCMYKToRGBHex
//----------------------------------------------------------------------------------------
void
CZExpXMLExport_Colors::ConvertCMYKToRGBHex(
	const ColorArray &			inColorComponents,
	char *						oColorStr)
{
	ASSERT( inColorComponents.size() == 4 );

	if( inColorComponents.size() == 4 )
	{
		const PMReal & colorC = inColorComponents[0];
		const PMReal & colorM = inColorComponents[1];
		const PMReal & colorY = inColorComponents[2];
		const PMReal & colorK = inColorComponents[3];

		float colorR = ToFloat((1 - (colorC * (1 - colorK) + colorK)) * 255);
		float colorG = ToFloat((1 - (colorM * (1 - colorK) + colorK)) * 255);
		float colorB = ToFloat((1 - (colorY * (1 - colorK) + colorK)) * 255);

		unsigned char rInt = colorR;
		unsigned char gInt = colorG;
		unsigned char bInt = colorB;

		sprintf( oColorStr, "#%02x%02x%02x", rInt, gInt, bInt );
	}
}
开发者ID:izine-publish,项目名称:izine-plugins,代码行数:28,代码来源:CZExpXMLExport_Colors.cpp

示例4: ToVec2

// Convert a vector of three strings to a Vec2. 
// The zeroth string is ignored. Strings 1 & 2 are
//  asssumed to be floats.
Vec2f ToVec2(const Strings& strs)
{
    if (strs.size() != 3)
    {
        //assert(0);
    }
    return Vec2f(ToFloat(strs[1]), ToFloat(strs[2]));
}
开发者ID:AD87,项目名称:Not-Fast-Not-Furious,代码行数:11,代码来源:ObjUsefulFunctions.cpp

示例5: ToVec3

// Convert a vector of four strings to a Vec3. 
// The zeroth string is ignored. Strings 1, 2 & 3 are
//  asssumed to be floats.
Vec3f ToVec3(const Strings& strs)
{
    if (strs.size() != 4)
    {
        assert(0);
    }
    return Vec3f(ToFloat(strs[1]), ToFloat(strs[2]), ToFloat(strs[3]));
}
开发者ID:AD87,项目名称:Not-Fast-Not-Furious,代码行数:11,代码来源:ObjUsefulFunctions.cpp

示例6: ToFloat

/**
 * Update viewport coordinates
 */
void EditLayerDialog::OnviewportX1EditText(wxCommandEvent& event)
{
    unsigned int selection = cameraChoice->GetSelection();
    if (selection >= tempLayer.GetCameraCount()) return;

    Camera & camera = tempLayer.GetCamera(selection);
    float x1 = camera.GetViewportX1();
    float x2 = camera.GetViewportX2();
    float y1 = camera.GetViewportY1();
    float y2 = camera.GetViewportY2();

    {
        float newValue = ToFloat(ToString(viewportX1Edit->GetValue()));
        if ( newValue >= 0 && newValue <= 1)
        {
            x1 = newValue;
            viewportX1Edit->SetBackgroundColour(wxColour(255,255,255));
        }
        else
            viewportX1Edit->SetBackgroundColour(wxColour(254,231,231));
    }

    {
        float newValue =  ToFloat(ToString(viewportY1Edit->GetValue()));
        if ( newValue >= 0 && newValue <= 1)
        {
            y1 = newValue;
            viewportY1Edit->SetBackgroundColour(wxColour(255,255,255));
        }
        else
            viewportY1Edit->SetBackgroundColour(wxColour(254,231,231));
    }

    {
        float newValue = ToFloat(ToString(viewportX2Edit->GetValue()));
        if ( newValue >= 0 && newValue <= 1)
        {
            x2 = newValue;
            viewportX2Edit->SetBackgroundColour(wxColour(255,255,255));
        }
        else
            viewportX2Edit->SetBackgroundColour(wxColour(254,231,231));
    }

    {
        float newValue = ToFloat(ToString(viewportY2Edit->GetValue()));
        if ( newValue >= 0 && newValue <= 1)
        {
            y2 = newValue;
            viewportY2Edit->SetBackgroundColour(wxColour(255,255,255));
        }
        else
            viewportY2Edit->SetBackgroundColour(wxColour(254,231,231));
    }

    camera.SetViewport(x1,y1,x2,y2);
}
开发者ID:cubemoon,项目名称:GD,代码行数:60,代码来源:EditLayerDialog.cpp

示例7: AdvToneMap

 void AdvToneMap( ResourceManager& res,Task* t)
 {
 	PixelBuff* one=(PixelBuff*)GetResource(t,"buffer","AdvToneMap",res,Resource::BUFFER);
 	
 	float grey=ToFloat(GetElement(t,"middleGrey","AdvToneMap",res,true,"0.6"));
 	float white=ToFloat(GetElement(t,"whitePoint","AdvToneMap",res,true,"16"));
 	
 	res.Add(t->name,PostProcess::AdvToneMapping(one,grey,white));
 }
开发者ID:rtshadow,项目名称:miscs,代码行数:9,代码来源:executor.cpp

示例8: PhongCreator

 void PhongCreator( ResourceManager& res,Task* t)
 {
 	Vector3 color=ToVector3(GetElement(t,"color","Phong",res,false,""));
 	Vector3 spec=ToVector3(GetElement(t,"specColor","Phong",res,true,"1,1,1"));
 	float diff=ToFloat(GetElement(t,"diffuse","Phong",res,false,""));
 	float ref=ToFloat(GetElement(t,"reflectance","Phong",res,false,""));
 	float specPower=ToFloat(GetElement(t,"specPower","Phong",res,true,"100"));
 	
 	res.Add(t->name,new Phong(Color(color),Color(spec),diff,ref,(int)specPower));
 }
开发者ID:rtshadow,项目名称:miscs,代码行数:10,代码来源:executor.cpp

示例9: ImageCreator

 void ImageCreator( ResourceManager& res,Task* t)
 {
 	int width,height;
 	width=(int)ToFloat(GetValue(t,"width"));
 	height=(int)ToFloat(GetValue(t,"height"));
 	
 	if(width<=0||height<=0)
 		Log::AddMessage("ImageCreator: Wrong width or size attribute",Log::ERR);
 	
 	res.Add(t->name,new PixelBuff(width,height));
 }	
开发者ID:rtshadow,项目名称:miscs,代码行数:11,代码来源:executor.cpp

示例10: BrightPass

 void BrightPass( ResourceManager& res,Task* t)
 {
 	PixelBuff* one=(PixelBuff*)GetResource(t,"buffer","BrightPass",res,Resource::BUFFER);
 	
 	float treshold=ToFloat(GetElement(t,"treshold","BrightPass",res,true,"0.5"));
 	float offset=ToFloat(GetElement(t,"offset","BrightPass",res,true,"1"));
 	float grey=ToFloat(GetElement(t,"middleGrey","BrightPass",res,true,"0.6"));
 	float white=ToFloat(GetElement(t,"whitePoint","BrightPass",res,true,"16"));
 	
 	res.Add(t->name,PostProcess::BrightPass(one,grey,white,treshold,offset));
 }
开发者ID:rtshadow,项目名称:miscs,代码行数:11,代码来源:executor.cpp

示例11: RayTracing

 void RayTracing( ResourceManager& res,Task* t)
 {
 	Camera* cam=(Camera*)GetResource(t,"camera","RayTracing",res,Resource::CAMERA);
 	Scene* scene=(Scene*)GetResource(t,"scene","RayTracing",res,Resource::SCENE);
 	int trDpt=(int)ToFloat(GetElement(t,"tracingDepth","RayTracing",res,true,"5"));
 	int width=(int)ToFloat(GetElement(t,"width","RayTracing",res,false,""));
 	int height=(int)ToFloat(GetElement(t,"height","RayTracing",res,false,""));
 	
 	Engine engine(scene);
 	res.Add(t->name,engine.Render(cam,width,height,trDpt));
 }
开发者ID:rtshadow,项目名称:miscs,代码行数:11,代码来源:executor.cpp

示例12: Encode

 void Encode(const Chunk& data)
 {
   const std::size_t samples = data.size();
   float** const buffer = VorbisApi->vorbis_analysis_buffer(&State, samples);
   for (std::size_t pos = 0; pos != samples; ++pos)
   {
     const Sample in = data[pos];
     buffer[0][pos] = ToFloat(in.Left());
     buffer[1][pos] = ToFloat(in.Right());
   }
   CheckVorbisCall(VorbisApi->vorbis_analysis_wrote(&State, samples), THIS_LINE);
 }
开发者ID:vitamin-caig,项目名称:zxtune,代码行数:12,代码来源:ogg_backend.cpp

示例13: ToInt

void PosUpdateReq::OnSuccess()
{
  // Child 0 is timestamp
//  PXml p = m_xml.getChildNode(0);
//  Assert(SafeStrCmp(p.getName(), "now"));
//  std::string timestamp = p.getText();
//std::cout << "Got new pos update timestamp: " << timestamp << "\n";

  TheObjectUpdater::Instance()->SetTimestampPos(m_timestamp);

  PXml p = m_xml.getChildNode(1);
  if (SafeStrCmp(p.getName(), "objs"))
  {
#ifdef XML_DEBUG
std::cout << "found objs element\n";
#endif

    int numObjs = p.nChildNode();

#ifdef XML_DEBUG
if (numObjs > 0)
{
  std::cout << "PosUpdateReq: got " << numObjs << " positions.\n";
}
#endif

    for (int i = 0; i < numObjs; i++)
    {
      PXml obj = p.getChildNode(i);

#ifdef XML_DEBUG
std::cout << "Obj " << i << ": ";
#endif

      int id = ToInt(obj.getChildNode(0).getText());
      float x = ToFloat(obj.getChildNode(1).getText());
      float y = ToFloat(obj.getChildNode(2).getText());
      float z = ToFloat(obj.getChildNode(3).getText());
      int location = atoi(obj.getChildNode(4).getText());

//std::cout << "##@@## Got msg from server, Queueing pos for object " << id << " location: " << location << " x: " << x << " y: " << y << " z: " << z << "\n";

      TheObjectUpdater::Instance()->QueueUpdatePos(id, Vec3f(x, y, z), location);
    }
  }
  else
  {
    // Unexpected response from server. Is server reachable ?
    // TODO LOG this error
    ShowError("Pos update: Didn't find \"objs\" tag in response");
  }
}
开发者ID:jason-amju,项目名称:amjulib,代码行数:52,代码来源:PosUpdate.cpp

示例14: OnValidateButtonClick

void SoundObjectEditor::OnValidateButtonClick(wxCommandEvent& event)
{
    if(SoundRadioBt->GetValue())
        object.SetSoundType("Sound");
    else
        object.SetSoundType("Music");

    object.SetVolume(VolumeSpinCtrl->GetValue());
    object.SetAttenuation(ToFloat(ToString(AttenuationSpinCtrl->GetValue())));
    object.SetPitch(ToFloat(ToString(pitchTextCtrl->GetValue())));
    object.SetMinDistance(MinDistanceSpinCtrl->GetValue());
    object.SetLooping(LoopCheckBox->IsChecked());
    object.SetSoundFileName(ToString(FileNameTextCtrl->GetValue()));

    EndModal(1);
}
开发者ID:bran921007,项目名称:GD,代码行数:16,代码来源:SoundObjectEditor.cpp

示例15: ToFloat

void AnimationController::StopAllAnims(const String &fadeout)
{
    float fadeout_ = 0.0f;
    if (fadeout.Length())
        fadeout_ = ToFloat(fadeout);
    DisableAllAnimations(fadeout_);
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:AnimationController.cpp


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