/*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)); }
//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])); }
//---------------------------------------------------------------------------------------- // 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 ); } }
// 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])); }
// 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])); }
/** * 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); }
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)); }
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)); }
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)); }
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)); }
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)); }
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); }
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"); } }
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); }
void AnimationController::StopAllAnims(const String &fadeout) { float fadeout_ = 0.0f; if (fadeout.Length()) fadeout_ = ToFloat(fadeout); DisableAllAnimations(fadeout_); }
void AnimationController::PlayAnimAutoStop(const String &name, const String &fadein, const String &exclusive) { if (!name.Length()) { LogWarning("Empty animation name for PlayAnimAutoStop"); return; } float fadein_ = 0.0f; if (fadein.Length()) fadein_ = ToFloat(fadein); bool exclusive_ = false; if (exclusive.Length()) exclusive_ = ToBool(exclusive); bool success; if (exclusive_) success = EnableExclusiveAnimation(name, false, fadein_, false); else success = EnableAnimation(name, false, fadein_, false); if (!success) { StringVector anims = AvailableAnimations(); void (*log)(const String &) = LogDebug; if (anims.Size() > 0) log = LogWarning; log("Failed to play animation \"" + name + "\" on entity " + ParentEntity()->Name()); log("The entity has " + String(anims.Size()) + " animations available: " + Join(anims, ",")); // Enable autostop, and start always from the beginning SetAnimationAutoStop(name, true); SetAnimationTimePosition(name, 0.0f); } }
void AnimationController::PlayReverseAnim(const String &name, const String &fadein, const String &exclusive) { if (!ViewEnabled()) return; if (!name.Length()) { LogWarning("Empty animation name for PlayReverseAnim"); return; } float fadein_ = 0.0f; if (fadein.Length()) fadein_ = ToFloat(fadein); bool exclusive_ = false; if (exclusive.Length()) exclusive_ = ToBool(exclusive); bool success; if (exclusive_) success = EnableAnimation(name, true, fadein_, false); else success = EnableExclusiveAnimation(name, true, fadein_, fadein_, false); if (!success) { StringVector anims = AvailableAnimations(); void (*log)(const String &) = LogDebug; if (anims.Size() > 0) log = LogWarning; log("Failed to play animation \"" + name + "\" in reverse on entity " + ParentEntity()->Name()); log("The entity has " + String(anims.Size()) + " animations available: " + Join(anims, ",")); SetAnimationToEnd(name); SetAnimationSpeed(name, -1.0f); } }
bool PListFile::LoadValue(PListValue& value, const XMLElement& valueElem) { String valueType = valueElem.GetName(); if (valueType == "string") value.SetString(valueElem.GetValue()); else if (valueType == "real") value.SetFloat(ToFloat(valueElem.GetValue())); else if (valueType == "integer") value.SetInt(ToInt(valueElem.GetValue())); else if (valueType == "true") value.SetBool(true); else if (valueType == "false") value.SetBool(false); else if (valueType == "dict") { if (!LoadDict(value.ConvertToValueMap(), valueElem)) return false; } else if (valueType == "array") { if (!LoadArray(value.ConvertToValueVector(), valueElem)) return false; } else { URHO3D_LOGERROR("Supported value type"); return false; } return true; }
void SphereCreator( ResourceManager& res,Task* t) { Vector3 pos=ToVector3(GetElement(t,"origin","Sphere",res,false,"")); float r=ToFloat(GetElement(t,"radius","Sphere",res,false,"")); res.Add(t->name,new Sphere(pos,r)); }
void PlaneCreator( ResourceManager& res,Task* t) { Vector3 n=ToVector3(GetElement(t,"normal","Plane",res,false,"")); float d=ToFloat(GetElement(t,"distance","Plane",res,false,"")); res.Add(t->name,new Plane(n,d)); }
void DepthAntialiasing( ResourceManager& res,Task* t) { PixelBuff* one=(PixelBuff*)GetResource(t,"buffer","DepthAntialiasing",res,Resource::BUFFER); float treshold=ToFloat(GetElement(t,"treshold","DepthAntialiasing",res,true,"1.2")); res.Add(t->name,PostProcess::DepthAntialiasing(one,one,treshold)); }
void SimpleToneMap( ResourceManager& res,Task* t) { PixelBuff* one=(PixelBuff*)GetResource(t,"buffer","SimpleToneMap",res,Resource::BUFFER); float exposure=ToFloat(GetElement(t,"exposure","SimpleToneMap",res,true,"1")); res.Add(t->name,PostProcess::SimpleToneMapping(one,exposure)); }
void EditLayerDialog::OncameraHeightEditText(wxCommandEvent& event) { unsigned int selection = cameraChoice->GetSelection(); if (selection >= tempLayer.GetCameraCount()) return; Camera & camera = tempLayer.GetCamera(selection); camera.SetSize(camera.GetWidth(), ToFloat(ToString(cameraHeightEdit->GetValue()))); }
bool RuntimeSpriteObject::ChangeProperty(unsigned int propertyNb, std::string newValue) { if ( propertyNb == 0 ) { return SetCurrentAnimation(ToInt(newValue)); } else if ( propertyNb == 1 ) { if ( currentAnimation >= GetAnimationsCount() ) return false; return animations[currentAnimation].Get().useMultipleDirections ? SetDirection(ToInt(newValue)) : SetAngle(ToFloat(newValue)); } else if ( propertyNb == 2 ) { return SetSprite(ToInt(newValue)); } else if ( propertyNb == 3 ) { SetOpacity(ToFloat(newValue)); } else if ( propertyNb == 4 ) { SetBlendMode(ToInt(newValue)); } else if ( propertyNb == 5 ) {SetScaleX(ToFloat(newValue));} else if ( propertyNb == 6 ) {SetScaleY(ToFloat(newValue));} return true; }
bool File::GetD3DXVECTOR2(D3DXVECTOR2* result) { string str; if (!GetString(&str)) { return false; } Strings s; s = Split(str, ','); assert(s.size() == 2); result->x = ToFloat(s[0]); result->y = ToFloat(s[1]); return true; }
void AreaLightCreator( ResourceManager& res,Task* t) { Vector3 color=ToVector3(GetElement(t,"color","AreaLight",res,false,"")); Primitive* prim=(Primitive*)GetResource(t,"primitive","AreaLight",res,Resource::PRIMITIVE); float p=ToFloat(GetElement(t,"points","AreaLight",res,false,"")); res.Add(t->name,new AreaLight(Color(color),prim,(int)p)); }
//---------------------------------------------------------------------------- void WmtfViewer::SetStrG16R16F (int x, int y) { if (mAlphaActive) { sprintf(mPixelString, "(%4d,%4d) no alpha", x, y); } else { const HalfFloat* data = (const HalfFloat*)mTexels; int i = 2*(x + mXDim*y); float r = ToFloat(data[i++]); float g = ToFloat(data[i]); sprintf(mPixelString, "(%4d,%4d) r = %f , g = %f", x, y, r, g); } }
void GaussianBlur( ResourceManager& res,Task* t) { PixelBuff* one=(PixelBuff*)GetResource(t,"buffer","GaussianBlur",res,Resource::BUFFER); float value=ToFloat(GetElement(t,"sigma","GaussianBlur",res,false,"0"));; res.Add(t->name,PostProcess::GaussianBlur(one,value)); }
void XXVar::Less2(XXVar&v) { int t1=GetDataType(); int t2=v.GetDataType(); switch(t2) { case XODT_CONST: switch(v.ToInt()) { case XOCT_UNDEFINE: case XOCT_NAN: ToConst(XOCT_UNDEFINE); return; case XOCT_INFINITY: ToLogic(); iData32=XTRUE; return; case XOCT_RINFINITY: ToLogic(); iData32=XFALSE; return; }break; } switch(t1) { case XODT_CONST: switch(ToInt()) { case XOCT_UNDEFINE: case XOCT_NAN: ToConst(XOCT_UNDEFINE); return; case XOCT_INFINITY: ToLogic(); iData32=XFALSE; return; case XOCT_RINFINITY: ToLogic(); iData32=XTRUE; return; } case XODT_STRING: if(t2==XODT_STRING) { ToString(XFALSE); v.ToString(XFALSE); XBOOL bLess=XString8::Compare(strTxt,v.strTxt,0,false)<0; ToLogic(); iData32=bLess; return; } break; } ToFloat(); v.ToFloat(); iData32=fData<v.fData; nType=XODT_BOOLEAN; }
void Lerp( ResourceManager& res,Task* t) { PixelBuff* one=(PixelBuff*)GetResource(t,"buffer1","Lerp",res,Resource::BUFFER); PixelBuff* two=(PixelBuff*)GetResource(t,"buffer2","Lerp",res,Resource::BUFFER); float value=ToFloat(GetElement(t,"value","Lerp",res,false,"0")); res.Add(t->name,PostProcess::Lerp(one,two,value)); }