Light::Light(int number, Vector pos, Vector dir, float* attenuation) { setNumber(number); this->pos = pos; this->dir = dir; setAttenuation(0, attenuation[0]); setAttenuation(1, attenuation[1]); setAttenuation(2, attenuation[2]); initCutoff(); initExponent(); }
Light::Light(int number, Vector pos, Vector dir, float* attenuation, float cutoff, float exponent) { setNumber(number); this->pos = pos; this->dir = dir; setAttenuation(0, attenuation[0]); setAttenuation(1, attenuation[1]); setAttenuation(2, attenuation[2]); setCutoff(cutoff); setExponent(exponent); }
//---------------------------------------- void ofLight::setup() { if(glIndex==-1){ bool bLightFound = false; // search for the first free block for(int i=0; i<OF_MAX_LIGHTS; i++) { if(getActiveLights()[i] == false) { glIndex = i; retain(glIndex); bLightFound = true; break; } } if( !bLightFound ){ ofLog(OF_LOG_ERROR, "ofLight : Trying to create too many lights: " + ofToString(glIndex)); } if(bLightFound) { // run this the first time, since it was not found before // onPositionChanged(); setAmbientColor( getAmbientColor() ); setDiffuseColor( getDiffuseColor() ); setSpecularColor( getSpecularColor() ); setAttenuation( getAttenuationConstant(), getAttenuationLinear(), getAttenuationQuadratic() ); if(getIsSpotlight()) { setSpotlightCutOff(getSpotlightCutOff()); setSpotConcentration(getSpotConcentration()); } if(getIsSpotlight() || getIsDirectional()) { onOrientationChanged(); } } } }
void Sabre::begin(uint8_t mode, uint8_t f_clock, uint8_t defaultAttenuation, bool mute) { this->Reg17.All_Mono = mode == TreuMonoMode; // Set flag, so all DACs can be muted as early as possible this->sReg10 = 0xCE; // use default = 8'b11001110 muteDACS(); // mute DAC's as early as possible this->Fclock = f_clock; // store the crystal frequency (MHz) // Set all register defaults setRegisterDefaults(); // Set output mode if (this->Reg17.All_Mono) { setOutputMode(TreuMonoMode); } else { setOutputMode(NormalMode); } // set the volume if (defaultAttenuation > 0) { setAttenuation(defaultAttenuation); } this->Attenuation = defaultAttenuation; // unmute if needed if (!mute) { unMuteDACS(); } }
SpotLight & SpotLight::operator=(SpotLight const & spotLight) { DirectionalLight::operator=(spotLight); setAngles(spotLight.m_innerAngle, spotLight.m_outerAngle); setAttenuation(spotLight.m_constantAttenuation, spotLight.m_linearAttenuation, spotLight.m_quadraticAttenuation); return (*this); }
void CC3PODLight::initAtIndex( GLint aPODIndex, CC3PODResource* aPODRez ) { super::initAtIndex( aPODIndex, aPODRez ); // Get the light content if (getPodContentIndex() >= 0) { SPODLight* psl = (SPODLight*)aPODRez->getLightPODStructAtIndex(getPodContentIndex()); //LogRez(@"Setting %@ parameters from %@", [self class], NSStringFromSPODLight(psl)); setPodTargetIndex( psl->nIdxTarget ); setAmbientColor( kCC3DefaultLightColorAmbient ); setDiffuseColor( ccc4f(psl->pfColour[0], psl->pfColour[1], psl->pfColour[2], 1.0) ); setSpecularColor( kCC3DefaultLightColorSpecular ); setAttenuation( CC3AttenuationCoefficientsMake(psl->fConstantAttenuation, psl->fLinearAttenuation, psl->fQuadraticAttenuation) ); switch (psl->eType) { case ePODDirectional: setIsDirectionalOnly( true ); break; case ePODPoint: setIsDirectionalOnly( false ); break; case ePODSpot: setIsDirectionalOnly( false ); setSpotCutoffAngle( CC3RadToDeg(psl->fFalloffAngle) ); setSpotExponent( psl->fFalloffExponent ); break; default: break; } } }
Sound& Sound::operator =(const Sound& right) { // Here we don't use the copy-and-swap idiom, because it would mess up // the list of sound instances contained in the buffers // Detach the sound instance from the previous buffer (if any) if (m_buffer) { stop(); m_buffer->detachSound(this); m_buffer = NULL; } // Copy the sound attributes if (right.m_buffer) setBuffer(*right.m_buffer); setLoop(right.getLoop()); setPitch(right.getPitch()); setVolume(right.getVolume()); setPosition(right.getPosition()); setRelativeToListener(right.isRelativeToListener()); setMinDistance(right.getMinDistance()); setAttenuation(right.getAttenuation()); return *this; }
//---------------------------------------- ofLight::ofLight() :data(new Data){ setAmbientColor(ofColor(0,0,0)); setDiffuseColor(ofColor(255,255,255)); setSpecularColor(ofColor(255,255,255)); setPointLight(); // assume default attenuation factors // setAttenuation(1.f,0.f,0.f); }
SoundSource::SoundSource(const SoundSource& copy) : m_channel(copy.m_channel) { setPitch(copy.getPitch()); setVolume(copy.getVolume()); setPosition(copy.getPosition()); setRelativeToListener(copy.isRelativeToListener()); setMinDistance(copy.getMinDistance()); setAttenuation(copy.getAttenuation()); }
void DeferredLight::updateFromParent() { setAttenuation(parentLight->getAttenuationConstant(), parentLight->getAttenuationLinear(), parentLight->getAttenuationQuadric()); setSpecularColour(parentLight->getSpecularColour()); if (getCastChadows()) { ENABLE_BIT(permutation,LightMaterialGenerator::MI_SHADOW_CASTER); } else { DISABLE_BIT(permutation, LightMaterialGenerator::MI_SHADOW_CASTER); } }
void CC3PODLight::initAtIndex( GLint aPODIndex, CC3PODResource* aPODRez ) { init(); setPodIndex( aPODIndex ); SPODNode* psn = (SPODNode*)getNodePODStructAtIndex( aPODIndex, aPODRez ); //LogRez(@"Creating %@ at index %i from: %@", [self class], aPODIndex, NSStringFromSPODNode(psn)); setName( psn->pszName ); setPodContentIndex( psn->nIdx ); setPodParentIndex( psn->nIdxParent ); if ( psn->pfAnimPosition ) setLocation( *(CC3Vector*)psn->pfAnimPosition ); if ( psn->pfAnimRotation ) setQuaternion( *(CC3Quaternion*)psn->pfAnimRotation ); if ( psn->pfAnimScale ) setScale( *(CC3Vector*)psn->pfAnimScale ); if ( CC3PODNodeAnimation::sPODNodeDoesContainAnimation((PODStructPtr)psn) ) setAnimation( CC3PODNodeAnimation::animationFromSPODNode( (PODStructPtr)psn, aPODRez->getAnimationFrameCount() ) ); else if (aPODRez->shouldFreezeInanimateNodes()) setAnimation( CC3FrozenNodeAnimation::animationFromNodeState( this ) ); // Get the light content if (getPodContentIndex() >= 0) { SPODLight* psl = (SPODLight*)aPODRez->getLightPODStructAtIndex(getPodContentIndex()); //LogRez(@"Setting %@ parameters from %@", [self class], NSStringFromSPODLight(psl)); setPodTargetIndex( psl->nIdxTarget ); setAmbientColor( kCC3DefaultLightColorAmbient ); setDiffuseColor( ccc4f(psl->pfColour[0], psl->pfColour[1], psl->pfColour[2], 1.0) ); setSpecularColor( kCC3DefaultLightColorSpecular ); setAttenuation( CC3AttenuationCoefficientsMake(psl->fConstantAttenuation, psl->fLinearAttenuation, psl->fQuadraticAttenuation) ); switch (psl->eType) { case ePODDirectional: setIsDirectionalOnly( true ); break; case ePODPoint: setIsDirectionalOnly( false ); break; case ePODSpot: setIsDirectionalOnly( false ); setSpotCutoffAngle( CC3RadToDeg(psl->fFalloffAngle) ); setSpotExponent( psl->fFalloffExponent ); break; default: break; } } }
//---------------------------------------- ofLight::ofLight(){ glIndex = -1; isEnabled = false; setAmbientColor(ofColor(0,0,0)); setDiffuseColor(ofColor(255,255,255)); setSpecularColor(ofColor(255,255,255)); setPointLight(); // assume default attenuation factors // setAttenuation(1.f,0.f,0.f); }
SoundSource::SoundSource(const SoundSource& copy) { alCheck(alGenSources(1, &m_source)); alCheck(alSourcei(m_source, AL_BUFFER, 0)); setPitch(copy.getPitch()); setVolume(copy.getVolume()); setPosition(copy.getPosition()); setRelativeToListener(copy.isRelativeToListener()); setMinDistance(copy.getMinDistance()); setAttenuation(copy.getAttenuation()); }
void Light::enterScene(Scene* scene) { VisualComponent::enterScene(scene); light = createLight(); setEnabled(isEnabled()); setDiffuseColour(getDiffuseColour()); setSpecularColour(getSpecularColour()); setAttenuation(getAttenuation()); getSceneNode()->attachObject(light); }
SoundSource& SoundSource::operator =(const SoundSource& right) { // Leave m_source untouched -- it's not necessary to destroy and // recreate the OpenAL sound source, hence no copy-and-swap idiom // Assign the sound attributes setPitch(right.getPitch()); setVolume(right.getVolume()); setPosition(right.getPosition()); setRelativeToListener(right.isRelativeToListener()); setMinDistance(right.getMinDistance()); setAttenuation(right.getAttenuation()); return *this; }
SoundSource& SoundSource::operator =(const SoundSource& right) { // Assign the sound attributes setPitch(right.getPitch()); setVolume(right.getVolume()); setPosition(right.getPosition()); setRelativeToListener(right.isRelativeToListener()); setMinDistance(right.getMinDistance()); setAttenuation(right.getAttenuation()); m_channel = right.m_channel; m_ndspWaveBuf = right.m_ndspWaveBuf; return *this; }
PointLight::PointLight() : intensity(1.0f), _animated(false) { genGeometry(); memset(ambient, 0, sizeof(ambient)); memset(diffuse, 0, sizeof(diffuse)); memset(specular, 0, sizeof(specular)); // _light_effective_radius = intensity * _light_max_effective_radius; _animated = false; setAttenuation(1, 0, 0.6); _id = _highest_id++; }
//---------------------------------------- void ofLight::setup() { if(data->glIndex==-1){ bool bLightFound = false; // search for the first free block for(size_t i=0; i<ofLightsData().size(); i++) { if(ofLightsData()[i].expired()) { data->glIndex = i; data->isEnabled = true; ofLightsData()[i] = data; bLightFound = true; break; } } if(!bLightFound && ofIsGLProgrammableRenderer()){ ofLightsData().push_back(data); data->glIndex = ofLightsData().size() - 1; data->isEnabled = true; bLightFound = true; } if( bLightFound ){ // run this the first time, since it was not found before // onPositionChanged(); setAmbientColor( getAmbientColor() ); setDiffuseColor( getDiffuseColor() ); setSpecularColor( getSpecularColor() ); setAttenuation( getAttenuationConstant(), getAttenuationLinear(), getAttenuationQuadratic() ); if(getIsSpotlight()) { setSpotlightCutOff(getSpotlightCutOff()); setSpotConcentration(getSpotConcentration()); } if(getIsSpotlight() || getIsDirectional()) { onOrientationChanged(); } }else{ ofLogError("ofLight") << "setup(): couldn't get active GL light, maximum number of "<< ofLightsData().size() << " reached"; } } }
Light::Light(float r, float g, float b, float a) { handle = lightNumber++; ZeroMemory( &light, sizeof(light) ); setType(D3DLIGHT_POINT); setDiffuse(r, g, b, a); setAmbient(0, 0, 0, 0); setRange((float)sqrt(FLT_MAX)); setSpecular(r, g, b, a); setAttenuation(1, 0, 0); uniSetLightInfo(handle, light); size = 1; int color = ((int)(r * 255) << 16) | ((int)(g * 255) << 8) | ((int)b * 255) | 0xff000000; calc = true; draw = false; // this->sprite = new Sprite(0.6f, color, "lens02"); }
ofxBlenderLight::ofxBlenderLight() { setup(); setAttenuation(1.1, 0, 0); }
void sfSound_setAttenuation(sfSound* sound, float attenuation) { CSFML_CALL(sound, setAttenuation(attenuation)); }
void Light::modifyAttenuation(int mode, float attenuation) { if (mode >= 0 && mode < 3) { setAttenuation(mode, this->attenuation[mode] + attenuation); } }
void sfSoundStream_setAttenuation(sfSoundStream* soundStream, float attenuation) { CSFML_CALL(soundStream, setAttenuation(attenuation)); }
Node::NodeSP SceneLoader::__loadLight(const QDomElement& og_component, Node::NodeSP dt_node) { Node::NodeSP node = dt_node; if ( !og_component.isNull() ) { QString name = og_component.attribute(SL_NAME); if ( node == nullptr ) { node = mScene->addChildNode(new Node(name + "_node")); QDomElement pos = og_component.firstChildElement(SL_POS); QDomElement dir = og_component.firstChildElement(SL_LIGHT_DIRECTION); node->setPosition(pos.attribute(SL_X).toFloat(), pos.attribute(SL_Y).toFloat(), pos.attribute(SL_Z).toFloat()); node->setDirection(Ogre::Vector3(dir.attribute(SL_X).toFloat(), dir.attribute(SL_Y).toFloat(), dir.attribute(SL_Z).toFloat())); } //add light component auto light = node->addComponent<LightComponent>(new LightComponent(name)); auto og_light = light->getOgreLight(); QDomElement colour_diffuse = og_component.firstChildElement(SL_LIGHT_DIFFUSE); QDomElement colour_specular = og_component.firstChildElement(SL_LIGHT_SPECULAR); QDomElement light_attenuation = og_component.firstChildElement(SL_LIGHT_ATTENUATION); //set light attributes og_light->setDiffuseColour(colour_diffuse.attribute(SL_COLOUR_R).toFloat(), colour_diffuse.attribute(SL_COLOUR_G).toFloat(), colour_diffuse.attribute(SL_COLOUR_B).toFloat()); og_light->setSpecularColour(colour_specular.attribute(SL_COLOUR_R).toFloat(), colour_specular.attribute(SL_COLOUR_G).toFloat(), colour_specular.attribute(SL_COLOUR_B).toFloat()); og_light->setAttenuation(light_attenuation.attribute(SL_LIGHT_ATTENUATION_RANGE).toFloat(), light_attenuation.attribute(SL_LIGHT_ATTENUATION_CONSTANT).toFloat(), light_attenuation.attribute(SL_LIGHT_ATTENUATION_LINEAR).toFloat(), light_attenuation.attribute(SL_LIGHT_ATTENUATION_QUADRATIC).toFloat()); QString light_type = og_component.attribute(SL_LIGHT_TYPE); if ( light_type == SL_LIGHT_TYPE_POINT ) { og_light->setType(Ogre::Light::LT_POINT); } else if ( light_type == SL_LIGHT_TYPE_DIRECTIONAL ) { og_light->setType(Ogre::Light::LT_DIRECTIONAL); } else if ( light_type == SL_LIGHT_TYPE_SPOT ) { og_light->setType(Ogre::Light::LT_SPOTLIGHT); QDomElement light_range = og_component.firstChildElement(SL_LIGHT_RANGE); og_light->setSpotlightRange(Ogre::Radian(light_range.attribute(SL_LIGHT_RANGE_INNER).toFloat()), Ogre::Radian(light_range.attribute(SL_LIGHT_RANGE_OUTER).toFloat()), light_range.attribute(SL_LIGHT_RANGE_FALLOFF).toFloat()); } QString cast_shadows = og_component.attribute(SL_CAST_SHADOWS); if ( cast_shadows == SL_TRUE ) { light->setCastShadows(true); } else if ( cast_shadows == SL_FALSE ) { light->setCastShadows(false); } light->enable(); } return node; }