void copy_rect(ahm::PropertyValue *pTarget, ahm::PropertyValue *pSource) { if(isRect(pTarget) && isRect(pSource)) { // same types! if( pTarget->derivedType() == ahm::PropertyValue::TYPE_RECT && pSource->derivedType() == ahm::PropertyValue::TYPE_RECT) { ahm::PropertyValueRect* pSourceRect = (ahm::PropertyValueRect* ) pSource; ahm::PropertyValueRect* pTargetRect = (ahm::PropertyValueRect* ) pTarget; copy_scalar(pTargetRect->left(), pSourceRect->left()); copy_scalar(pTargetRect->top(), pSourceRect->top()); copy_scalar(pTargetRect->right(), pSourceRect->right()); copy_scalar(pTargetRect->bottom(), pSourceRect->bottom()); } else if( pTarget->derivedType() == ahm::PropertyValue::TYPE_FLOAT_RECT && pSource->derivedType() == ahm::PropertyValue::TYPE_FLOAT_RECT) { ahm::PropertyValueFloatRect* pSourceFloatRect = (ahm::PropertyValueFloatRect* ) pSource; ahm::PropertyValueFloatRect* pTargetFloatRect = (ahm::PropertyValueFloatRect* ) pTarget; ahm::FLOAT_RECT frect = { 0,0,0,0}; pSourceFloatRect->getValue(frect); pTargetFloatRect->setValue(frect); } // different types else if( pTarget->derivedType() == ahm::PropertyValue::TYPE_RECT && pSource->derivedType() == ahm::PropertyValue::TYPE_FLOAT_RECT) { ahm::PropertyValueFloatRect* pSourceFloatRect = (ahm::PropertyValueFloatRect* ) pSource; ahm::PropertyValueRect* pTargetRect = (ahm::PropertyValueRect* ) pTarget; ahm::FLOAT_RECT frect = { 0,0,0,0 }; setFloat(pTargetRect->left(), frect.left); setFloat(pTargetRect->top(), frect.top); setFloat(pTargetRect->right(), frect.right); setFloat(pTargetRect->bottom(), frect.bottom); } else if( pTarget->derivedType() == ahm::PropertyValue::TYPE_FLOAT_RECT && pSource->derivedType() == ahm::PropertyValue::TYPE_RECT) { ahm::PropertyValueRect* pSourceRect = (ahm::PropertyValueRect* ) pSource; ahm::PropertyValueFloatRect* pTargetFloatRect = (ahm::PropertyValueFloatRect* ) pTarget; ahm::FLOAT_RECT frect = { 0,0,0,0 }; getFloat(frect.left, pSourceRect->left()); getFloat(frect.top, pSourceRect->top()); getFloat(frect.right, pSourceRect->right()); getFloat(frect.bottom, pSourceRect->bottom()); pTargetFloatRect->setValue(frect); } } }
Material::Material() { setTexture("diffuse", Texture::makePtr(new Texture("res/textures/Grid.png"))); setTexture("normalMap", Texture::makePtr(new Texture("res/textures/default_normal.jpg"))); setTexture("dispMap", Texture::makePtr(new Texture("res/textures/default_disp.png"))); setFloat("dispMapScale", 0.04f); setFloat("dispMapBias", 0.0f); setFloat("opacity", 1.0f); }
/** * <summary>Arrange island in the scene. * The window is divided in 4 imaginary quadrant. In order to avoid collision between island, each quadrant will have only * one island.</summary> */ void GPGPU::setupIsland() { GLfloat px1, px2, px3, px4; GLfloat py1, py2, py3, py4; srand (time (NULL)); px1 = (float) (rand() % 35) / 100; py1 = (float) (rand() % 35) / 100; px2 = 0.5f + (float) (rand() % 35) / 100; py2 = (float) (rand() % 35) / 100; px3 = (float) (rand() % 35) / 100; py3 = 0.5f + (float) (rand() % 35) / 100; px4 = 0.5f + (float) (rand() % 35) / 100; py4 = 0.5f + (float) (rand() % 35) / 100; // Island #1 island[0].xy[0] = px1; island[0].xy[1] = py1; island[0].xy[2] = 0.1f; setFloat (island[0].height, 1, 2, 5, 20); setFloat (island[0].area, 0.05, 0.05, 0.1, 0.8); // Island #2s island[1].xy[0] = px2; island[1].xy[1] = py2; island[1].xy[2] = 0.086f; setFloat (island[1].height, 1, 3, 5, 20); setFloat (island[1].area, 0.1, 0.1, 0.3, 0.5); // Island #3 island[2].xy[0] = px3; island[2].xy[1] = py3; island[2].xy[2] = 0.125f; setFloat (island[2].height, 1, 4, 8, 2); setFloat (island[2].area, 0.05, 0.05, 0.2, 0.7); // Island #4 island[3].xy[0] = px4; island[3].xy[1] = py4; island[3].xy[2] = 0.06f; setFloat (island[3].height, 1, 3, 6, 20); setFloat (island[3].area, 0.05, 0.1, 0.25, 0.6); }
void DataStore::setDefaultFloat(double value, const char *key) { if(contains(key)) return; setFloat(value, key); }
void Material::addDisplacementValues(float scale, float offset, std::shared_ptr<Texture> texture){ if (texture){ setTexture("dispMap", texture); } float baseBias = scale / 2.0f; setFloat("dispMapScale", scale); setFloat("dispMapBias", -baseBias + baseBias * offset); }
/// Set **real** parameter value from float. The new value must be in /// the defined range of the parameter's values. /// /// @param newRealValue new value /// void ParSwitch::setRealFloat(float newRealValue) { // transform real value to internal value float internalValue = toInternalFloat(newRealValue); // update internal value setFloat(internalValue); }
void Param::set(float value) { if (this->type == ParamInt) { return setInt(value); } else if (this->type == ParamFloat) { return setFloat(value); } }
/// Set parameter value from (correctly) formatted string. /// /// @param newValue new value as formatted string /// void Parameter::setText(const String &newValue) { // transform string to internal value float newInternalValue = getFloatFromText(newValue); // update internal value setFloat(newInternalValue); }
/// Set **real** parameter value from float. The new value must be in /// the defined range of the parameter's values. /// /// @param newRealValue new value /// void PluginParameterContinuous::setRealFloat(float newRealValue) { // transform real value to internal value float internalValue = toInternalFloat(newRealValue); // update internal value setFloat(internalValue); }
void GLProgramState::setUniformFloat(const std::string& uniformName, float value) { auto v = getUniformValue(uniformName); if (v) v->setFloat(value); else CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); }
void GLProgramState::setUniformFloat(GLint uniformLocation, float value) { auto v = getUniformValue(uniformLocation); if (v) v->setFloat(value); else CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation); }
bool Patch::readCommons(json_t *jContainer) { if (!setString(jContainer, PATCH_KEY_HEADER, header)) return 0; if (!setString(jContainer, PATCH_KEY_VERSION, version)) return 0; if (!setInt (jContainer, PATCH_KEY_VERSION_MAJOR, versionMajor)) return 0; if (!setInt (jContainer, PATCH_KEY_VERSION_MINOR, versionMinor)) return 0; if (!setInt (jContainer, PATCH_KEY_VERSION_PATCH, versionPatch)) return 0; if (!setString(jContainer, PATCH_KEY_NAME, name)) return 0; if (!setFloat (jContainer, PATCH_KEY_BPM, bpm)) return 0; if (!setInt (jContainer, PATCH_KEY_BARS, bars)) return 0; if (!setInt (jContainer, PATCH_KEY_BEATS, beats)) return 0; if (!setInt (jContainer, PATCH_KEY_QUANTIZE, quantize)) return 0; if (!setFloat (jContainer, PATCH_KEY_MASTER_VOL_IN, masterVolIn)) return 0; if (!setFloat (jContainer, PATCH_KEY_MASTER_VOL_OUT, masterVolOut)) return 0; if (!setInt (jContainer, PATCH_KEY_METRONOME, metronome)) return 0; if (!setInt (jContainer, PATCH_KEY_LAST_TAKE_ID, lastTakeId)) return 0; if (!setInt (jContainer, PATCH_KEY_SAMPLERATE, samplerate)) return 0; return 1; }
int JSonDB::readDouble(double doubleVal) { if (m_record == 1) { // Set data type to entry. setFieldType(m_entryIdx, TYPE_FLOAT); } setFloat(m_entryIdx, (float)doubleVal); return 1; }
void Param::set(QString value) { if (this->type == ParamInt) { return setInt(value.toInt()); } else if (this->type == ParamFloat) { return setFloat(value.toFloat()); } else { strValue = value; } }
double SimpleConfig::getFloat(const std::string §ion, const std::string &key, double default_, bool set) { ConfigValue *v = _find(section, key); if (v) { return atof(v->getValue().c_str()); } else if (set) { setFloat(section, key, default_); } return default_; }
/// Create a stepped parameter with continuous floating-point values. /// **Real** values range from **real_minimum** to **real_maximum**, /// are quantised by **real_step_size**, and may be transformed to /// exponential or logarithmic scalings using **scaling_factor**. /// **Internal** values simply range from 0.0 to 1.0. /// /// @param real_minimum **real** parameter minimum (may be less than /// **real_maximum**) /// /// @param real_maximum **real** parameter maximum (may be higher than /// **real_minimum**) /// /// @param real_step_size **real** parameter values are quantised /// using this value. For example, a minimum value of 0, /// maximum value of 6 and a step size of 2 will lead to /// (unscaled) parameter values of 0, 2, 4, and 6. /// /// @param scaling_factor set this to positive values for exponential /// scaling and negative values for logarithmic scaling: \f$ /// realValue = \frac{10^{internalValue * scalingFactor} - /// 1}{10^{scalingFactor} - 1} \f$. With \f$ SCF = /// 10^{scalingFactor} - 1 \f$ this can be reduced to \f$ /// realValue = \frac{10^{internalValue * scalingFactor} - /// 1}{SCF} \f$ and \f$ internalValue = /// \frac{log_{10}(realValue * SCF + 1)}{scalingFactor} \f$. A /// value of 0 evokes linear scaling. /// /// @param decimal_places number of decimal places for formatting the /// real value /// /// @param save_from_deletion should parameter be spared from deletion /// in destructor of ParameterJuggler? /// PluginParameterContinuous::PluginParameterContinuous(float real_minimum, float real_maximum, float real_step_size, float scaling_factor, int decimal_places, bool save_from_deletion) { // minimum and maximum real parameter value realMinimum = real_minimum; realMaximum = real_maximum; // range of real parameter values realRange = realMaximum - realMinimum; // real parameter values are quantised using the number of steps // (which depends on step size). For example, 4 steps with a // minimum value of 0 and a maximum value of 6 will lead to // (unscaled) parameter values of 0, 2, 4, and 6. // // So far, this is only reflected in the function // getNumberOfSteps(). Intermediate parameter values are accepted // and left alone. numberOfSteps = int(realRange / real_step_size) + 1; // number of decimal places (for formatting of value only) decimalPlaces = decimal_places; // initialise value suffix (for formatting of value only) valueSuffix = String::empty; // initialise scaling factor (for exponential or logarithmic // parameters) scalingFactor = scaling_factor; // parameter is linear if (scalingFactor == 0.0f) { isNonlinear = false; scalingConstantFactor = 0.0f; } // parameter is non-linear else { isNonlinear = true; // initialise constant scaling factor to increase processing // speed (see formula in description) scalingConstantFactor = powf(10.0f, scalingFactor) - 1.0f; } // may parameter be deleted? doNotDelete = save_from_deletion; // force update value = -1.0f; // set parameter to minimum value (also marks parameter as // changed) setFloat(0.0f); }
void cWaterUberShader::setMaterialParam(cMaterial const* mtl) { setTechnique(m_handle[H_TUBER]); if (m_handle[H_DIFFUSE_TEXTURE]) { cTexture* tex = _getTextureMgr()->getTexture(mtl->m_mapBuid[cMaterial::DIFFUSE]); setTexture(m_handle[H_DIFFUSE_TEXTURE], tex); } if (m_handle[H_NORMAL_TEXTURE]) { cTexture* tex = _getTextureMgr()->getTexture(m_normalTexBuid); setTexture(m_handle[H_NORMAL_TEXTURE], tex); } if (m_handle[H_ENVIRONMENT_TEXTURE]) { cTexture* tex = _getTextureMgr()->getTexture(m_environmentTexBuid); setTexture(m_handle[H_ENVIRONMENT_TEXTURE], tex); } if (m_handle[H_TIMER]) { setFloat(m_handle[H_TIMER], m_time); } setVector(_T("textureScale"), &m_textureScale); setFloat(_T("waveFreq"), m_waveFreq); setFloat(_T("waveAmp"), m_waveAmp); setFloat(_T("bumpScale"), m_bumpScale); setVector(_T("bumpSpeed"), &m_bumpSpeed); setVector(_T("deepColor"), &m_deepColor); setVector(_T("shallowColor"), &m_shallowColor); setFloat(_T("waterAmount"), m_waterAmount); setVector(_T("reflectionColor"), &m_reflectionColor); setFloat(_T("reflectionAmount"), m_reflectionAmount); setFloat(_T("reflectionBlur"), m_reflectionBlur); setFloat(_T("fresnelPower"), m_fresnelPower); setFloat(_T("fresnelBias"), m_fresnelBias); setFloat(_T("hdrMultiplier"), m_hdrMultiplier); }
/// Set **real** default value from float. The new value must be in /// the defined range of the parameter's values. /// /// @param newRealValue new default value /// /// @param updateParameter if this is true, the parameter's value will /// be set to the new default value /// void ParSwitch::setDefaultRealFloat(float newRealValue, bool updateParameter) { // update internal default value defaultValue_ = toInternalFloat(newRealValue); // update real default value defaultRealValue_ = toRealFloat(defaultValue_); // optionally, update current parameter value if (updateParameter) { setFloat(defaultValue_); } }
ATFloatOrDerivedImpl:: ATFloatOrDerivedImpl(const XMLCh* typeURI, const XMLCh* typeName, const XMLCh* value, const StaticContext* context): ATFloatOrDerived(), _typeName(typeName), _typeURI(typeURI) { setFloat(value); // if state is NaN, it could be because it should be INF or -INF if(_state == NaN) { if(XPath2Utils::equals(value, Numeric::NegINF_string)) { _state = NEG_INF; } else if (XPath2Utils::equals(value, Numeric::INF_string)) { _state = INF; } } checkFloatLimits(_state, _float); }
void ConfigValue::setString(const char* val) { switch(type) { case ConfigValue::Bool: setBool(!strcmp(val, "true") || !strcmp(val, "1")); break; case ConfigValue::Integer: setInt(strtol(val, nullptr, 0)); break; case ConfigValue::Float: setFloat((float) atof(val)); break; case ConfigValue::String: setString(std::string(val)); break; } }
void DataWatcher::read(PacketBuffer &buffer) { byte_t item, index; do { buffer.getByte(item); if (item == 0x7f) break; index = item & 0x1f; switch (item >> 5) { case BYTE: { byte_t b; buffer.getByte(b); setByte(index, b); break; } case SHORT: { short_t s; buffer.getShort(s); setShort(index, s); break; } case INT: { int_t i; buffer.getInt(i); setInt(index, i); break; } case FLOAT: { float_t f; buffer.getFloat(f); setFloat(index, f); break; } case STRING: { string_t str; buffer.getString(str); setString(index, str); break; } case ITEMSTACK: { std::shared_ptr<ItemStack> stack; buffer.getItemStack(stack); setItemStack(index, stack); break; } } } while (true); }
void Settings::loadFile() { const std::string path = getHomePath() + "/.emulationstation/es_settings.cfg"; if (!boost::filesystem::exists(path)) return; pugi::xml_document doc; pugi::xml_parse_result result = doc.load_file(path.c_str()); if (!result) { LOG(LogError) << "Could not parse Settings file!\n " << result.description(); return; } for (pugi::xml_node node = doc.child("bool"); node; node = node.next_sibling("bool")) setBool(node.attribute("name").as_string(), node.attribute("value").as_bool()); for (pugi::xml_node node = doc.child("int"); node; node = node.next_sibling("int")) setInt(node.attribute("name").as_string(), node.attribute("value").as_int()); for (pugi::xml_node node = doc.child("float"); node; node = node.next_sibling("float")) setFloat(node.attribute("name").as_string(), node.attribute("value").as_float()); for (pugi::xml_node node = doc.child("string"); node; node = node.next_sibling("string")) setString(node.attribute("name").as_string(), node.attribute("value").as_string()); }
void GFFVariable::read(const GFFStruct &strct, Common::UString &name) { clear(); name = strct.getString("Name"); Type type = (Type) strct.getUint("Type", kTypeNone); if ((type <= kTypeNone) || (type > kTypeLocation)) throw Common::Exception("GFFVariable::read(): Unknown variable type %d", _type); if (type == kTypeInt ) { setInt(strct.getSint("Value")); } else if (type == kTypeFloat ) { setFloat(strct.getDouble("Value")); } else if (type == kTypeString ) { setString(strct.getString("Value")); } else if (type == kTypeObjectID) { setObjectID(strct.getUint("Value")); } else if (type == kTypeLocation) { _type = kTypeLocation; _value.typeLocation = new GFFLocation(); _value.typeLocation->read(strct.getStruct("Value")); } }
/// Set **real** default value from float. The new value must be in /// the defined range of the parameter's values. /// /// @param newRealValue new default value /// /// @param updateParameter if this is true, the parameter's value will /// be set to the new default value /// void PluginParameterContinuous::setDefaultRealFloat(float newRealValue, bool updateParameter) { // confine new default value to real parameter range if (newRealValue < realMinimum) { newRealValue = realMinimum; } else if (newRealValue > realMaximum) { newRealValue = realMaximum; } // update real default value defaultRealValue = newRealValue; // update internal default value defaultValue = toInternalFloat(defaultRealValue); // optionally, update current parameter value if (updateParameter) { setFloat(defaultValue); } }
void Sound::setOffsetSeconds(Real offset) { setFloat(offset, AL_SEC_OFFSET); }
void Sound::setConeOuterGain(Real gain) { setFloat(gain, AL_CONE_OUTER_GAIN); }
jobjectArray read_track_info_internal(JNIEnv *env, jobject thiz, libvlc_media_t* p_m) { /* get java class */ jclass cls = (*env)->FindClass( env, "org/videolan/libvlc/TrackInfo" ); if ( !cls ) { LOGE("Failed to load class (org/videolan/libvlc/TrackInfo)" ); return NULL; } /* get java class contructor */ jmethodID clsCtor = (*env)->GetMethodID( env, cls, "<init>", "()V" ); if ( !clsCtor ) { LOGE("Failed to find class constructor (org/videolan/libvlc/TrackInfo)" ); return NULL; } /* Get the tracks information of the media. */ libvlc_media_track_t **p_tracks; int i_nbTracks = libvlc_media_tracks_get(p_m, &p_tracks); jobjectArray array = (*env)->NewObjectArray(env, i_nbTracks + 1, cls, NULL); unsigned i; if (array != NULL) { for (i = 0; i <= i_nbTracks; ++i) { jobject item = (*env)->NewObject(env, cls, clsCtor); if (item == NULL) continue; (*env)->SetObjectArrayElement(env, array, i, item); // use last track for metadata if (i == i_nbTracks) { setInt(env, item, "Type", 3 /* TYPE_META */); setLong(env, item, "Length", libvlc_media_get_duration(p_m)); setString(env, item, "Title", libvlc_media_get_meta(p_m, libvlc_meta_Title)); setString(env, item, "Artist", libvlc_media_get_meta(p_m, libvlc_meta_Artist)); setString(env, item, "Album", libvlc_media_get_meta(p_m, libvlc_meta_Album)); setString(env, item, "Genre", libvlc_media_get_meta(p_m, libvlc_meta_Genre)); setString(env, item, "ArtworkURL", libvlc_media_get_meta(p_m, libvlc_meta_ArtworkURL)); continue; } setInt(env, item, "Id", p_tracks[i]->i_id); setInt(env, item, "Type", p_tracks[i]->i_type); setString(env, item, "Codec", (const char*)vlc_fourcc_GetDescription(0,p_tracks[i]->i_codec)); setString(env, item, "Language", p_tracks[i]->psz_language); setInt(env, item, "Bitrate", p_tracks[i]->i_bitrate); if (p_tracks[i]->i_type == libvlc_track_video) { setInt(env, item, "Height", p_tracks[i]->video->i_height); setInt(env, item, "Width", p_tracks[i]->video->i_width); setFloat(env, item, "Framerate", (float)p_tracks[i]->video->i_frame_rate_num / p_tracks[i]->video->i_frame_rate_den); } if (p_tracks[i]->i_type == libvlc_track_audio) { setInt(env, item, "Channels", p_tracks[i]->audio->i_channels); setInt(env, item, "Samplerate", p_tracks[i]->audio->i_rate); } } } libvlc_media_tracks_release(p_tracks, i_nbTracks); return array; }
void CC3GLSLUniform::setFloat( GLfloat value ) { setFloat( value, 0 ); }
void Sound::setPitch(Real pitch) { setFloat(pitch, AL_PITCH); }
void Sound::setOffsetSamples(Real offset) { setFloat(offset, AL_SAMPLE_OFFSET); }