コード例 #1
0
ファイル: Units.cpp プロジェクト: Twigg92/CrimeanCrisis
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();
}
コード例 #2
0
ファイル: Units.cpp プロジェクト: Twigg92/CrimeanCrisis
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);
}
コード例 #3
0
//----------------------------------------
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();
            }
        }
	}
}
コード例 #4
0
ファイル: Sabre.cpp プロジェクト: djimoun/SabreCE
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();
	}	
}
コード例 #5
0
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);
}
コード例 #6
0
ファイル: CC3PODLight.cpp プロジェクト: ClAndHHL/cocos3d-x
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;
		}
	}
}
コード例 #7
0
ファイル: Sound.cpp プロジェクト: krruzic/cpp3ds
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;
}
コード例 #8
0
ファイル: ofLight.cpp プロジェクト: 6uclz1/openFrameworks
//----------------------------------------
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);
}
コード例 #9
0
ファイル: SoundSource.cpp プロジェクト: krruzic/cpp3ds
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());
}
コード例 #10
0
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);
    }
}
コード例 #11
0
ファイル: CC3PODLight.cpp プロジェクト: HerdiandKun/cocos3d-x
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;
		}
	}
}
コード例 #12
0
//----------------------------------------
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);
}
コード例 #13
0
ファイル: SoundSource.cpp プロジェクト: 42bottles/SFML
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());
}
コード例 #14
0
ファイル: Light.cpp プロジェクト: summerbreezeex/SolidBlack
void Light::enterScene(Scene* scene) {
    VisualComponent::enterScene(scene);

    light = createLight();

    setEnabled(isEnabled());
    setDiffuseColour(getDiffuseColour());
    setSpecularColour(getSpecularColour());
    setAttenuation(getAttenuation());

    getSceneNode()->attachObject(light);
}
コード例 #15
0
ファイル: SoundSource.cpp プロジェクト: 42bottles/SFML
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;
}
コード例 #16
0
ファイル: SoundSource.cpp プロジェクト: krruzic/cpp3ds
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;
}
コード例 #17
0
ファイル: PointLight.cpp プロジェクト: wqxhouse/VRApp
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++;
}
コード例 #18
0
ファイル: ofLight.cpp プロジェクト: 6uclz1/openFrameworks
//----------------------------------------
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";
        }
	}
}
コード例 #19
0
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");
}
コード例 #20
0
ファイル: ofxBlenderLight.cpp プロジェクト: benben/ofxBlender
ofxBlenderLight::ofxBlenderLight()
{
	setup();
	setAttenuation(1.1, 0, 0);
}
コード例 #21
0
ファイル: Sound.cpp プロジェクト: DJMaster/CSFML
void sfSound_setAttenuation(sfSound* sound, float attenuation)
{
    CSFML_CALL(sound, setAttenuation(attenuation));
}
コード例 #22
0
ファイル: Units.cpp プロジェクト: Twigg92/CrimeanCrisis
void Light::modifyAttenuation(int mode, float attenuation) {
	if (mode >= 0 && mode < 3) {
		setAttenuation(mode, this->attenuation[mode] + attenuation);
	}
}
コード例 #23
0
ファイル: SoundStream.cpp プロジェクト: DJMaster/CSFML
void sfSoundStream_setAttenuation(sfSoundStream* soundStream, float attenuation)
{
    CSFML_CALL(soundStream, setAttenuation(attenuation));
}
コード例 #24
0
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;
}