Example #1
0
void DeferredLight::rebuildGeometry(float radius)
{
	//Disable all 3 bits
	DISABLE_BIT(mPermutation, LightMaterialGenerator::MI_POINT);
	DISABLE_BIT(mPermutation, LightMaterialGenerator::MI_SPOTLIGHT);
	DISABLE_BIT(mPermutation, LightMaterialGenerator::MI_DIRECTIONAL);

	switch (mParentLight->getType())
	{
	case Ogre::Light::LT_DIRECTIONAL:
		createRectangle2D();
        ENABLE_BIT(mPermutation,LightMaterialGenerator::MI_DIRECTIONAL);
		break;
	case Ogre::Light::LT_POINT:
		/// XXX some more intelligent expression for rings and segments
		createSphere(radius, 10, 10);
		ENABLE_BIT(mPermutation,LightMaterialGenerator::MI_POINT);
		break;
	case Ogre::Light::LT_SPOTLIGHT:
		Ogre::Real height = mParentLight->getAttenuationRange();
		Ogre::Radian coneRadiusAngle = mParentLight->getSpotlightOuterAngle() / 2;
        Ogre::Real rad = Ogre::Math::Tan(coneRadiusAngle) * height;
		createCone(rad, height, 20);
		ENABLE_BIT(mPermutation,LightMaterialGenerator::MI_SPOTLIGHT);
		break;
	}	
}
void DeferredLight::setSpecularColour(const Ogre::ColourValue& colour) {
    if (colour.r != 0.0 || colour.g != 0.0 || colour.b != 0.0) {
        ENABLE_BIT(permutation,LightMaterialGenerator::MI_SPECULAR);
    } else {
        DISABLE_BIT(permutation,LightMaterialGenerator::MI_SPECULAR);
    }
}
Example #3
0
void DeferredLight::SetAttenuation(float c, float b, float a)
{
    float outerRadius = mParentLight->getAttenuationRange();

    // There is attenuation? Set material accordingly
    if (c != 1.0f || b != 0.0f || a != 0.0f)
    {
        ENABLE_BIT(mPermutation, LightMaterialGenerator::MI_ATTENUATED);

        if (mParentLight->getType() == Ogre::Light::LT_POINT)
        {
            // Calculate radius from attenuation
            int thresholdLevel = 10;    // difference of 10-15 levels deemed unnoticeable
            float threshold = 1.0f / ((float)thresholdLevel / 256.0f);

            // Use quadratic formula to Determine outer radius
            c = c - threshold;
            float d = sqrt(b * b - 4.0f * a * c);
            outerRadius = (-2.0f * c) / (b + d);
            outerRadius *= 1.2f;
        }
    }
    else
    {
        DISABLE_BIT(mPermutation, LightMaterialGenerator::MI_ATTENUATED);
    }

    SetupGeometry(outerRadius);
}
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);
    }
}
Example #5
0
void DeferredLight::SetupGeometry(float radius)
{
    // Disable all 3 bits
    DISABLE_BIT(mPermutation, LightMaterialGenerator::MI_POINT);
    DISABLE_BIT(mPermutation, LightMaterialGenerator::MI_SPOTLIGHT);
    DISABLE_BIT(mPermutation, LightMaterialGenerator::MI_DIRECTIONAL);

    mIgnoreWorldTrans = mParentLight->getType() == Ogre::Light::LT_DIRECTIONAL;

    switch (mParentLight->getType())
    {
    case Ogre::Light::LT_DIRECTIONAL:
        // TODO: Effectively infinite bounds
        mRenderOp = mLightRenderOp->mDirectionalLightOp;
        setBoundingBox(Ogre::AxisAlignedBox(-10000, -10000, -10000, 10000, 10000, 10000));
        mRadius = 15000.0f;
        ENABLE_BIT(mPermutation, LightMaterialGenerator::MI_DIRECTIONAL);
        break;

    case Ogre::Light::LT_POINT:
        mRenderOp = mLightRenderOp->mPointLightOp;
        setBoundingBox(Ogre::AxisAlignedBox(
                    Ogre::Vector3(-radius, -radius, -radius),
                    Ogre::Vector3(radius, radius, radius)));
        mRadius = radius;
        ENABLE_BIT(mPermutation, LightMaterialGenerator::MI_POINT);
        break;

    case Ogre::Light::LT_SPOTLIGHT:
        mHeight = mParentLight->getAttenuationRange();
        mRadius = math::Tan(mParentLight->getSpotlightOuterAngle().valueRadians() * 0.5f) * mHeight;
        mRenderOp = mLightRenderOp->mSpotlightOp;
        setBoundingBox(Ogre::AxisAlignedBox(
                    Ogre::Vector3(-mRadius, 0, -mRadius),
                    Ogre::Vector3(mRadius, mHeight, mRadius)));
        ENABLE_BIT(mPermutation, LightMaterialGenerator::MI_SPOTLIGHT);
        break;

    default:
        break;
    }
}
Example #6
0
File: ruby.c Project: ayumin/ruby
static struct cmdline_options *
cmdline_options_init(struct cmdline_options *opt)
{
    MEMZERO(opt, *opt, 1);
    init_ids(opt);
    opt->src.enc.index = src_encoding_index;
    opt->ext.enc.index = -1;
    opt->intern.enc.index = -1;
#if defined DISABLE_RUBYGEMS && DISABLE_RUBYGEMS
    opt->disable |= DISABLE_BIT(gems);
#endif
    return opt;
}
void DeferredLight::rebuildGeometry(Ogre::Real radius) {
    DISABLE_BIT(permutation, LightMaterialGenerator::MI_POINT);
    DISABLE_BIT(permutation, LightMaterialGenerator::MI_SPOTLIGHT);
    DISABLE_BIT(permutation, LightMaterialGenerator::MI_DIRECTIONAL);

    switch (parentLight->getType()) {
        case Ogre::Light::LT_DIRECTIONAL:
            createRectangle2D();
            ENABLE_BIT(permutation,LightMaterialGenerator::MI_DIRECTIONAL);
            break;
        case Ogre::Light::LT_POINT:
            createSphere(radius, 10, 10);
            ENABLE_BIT(permutation,LightMaterialGenerator::MI_POINT);
            break;
        case Ogre::Light::LT_SPOTLIGHT:
            Ogre::Real height = parentLight->getAttenuationRange();
            Ogre::Radian coneRadiusAngle = parentLight->getSpotlightOuterAngle() / 2;
            Ogre::Real rad = Ogre::Math::Tan(coneRadiusAngle) * height;
            createCone(rad, height, 20);
            ENABLE_BIT(permutation,LightMaterialGenerator::MI_SPOTLIGHT);
            break;
    }
}
Example #8
0
void DeferredLight::SetSpecularColour(const Ogre::ColourValue& col)
{
    // setCustomParameter(2, Vector4(col.r, col.g, col.b, col.a));

    // There is a specular component? Set material accordingly
    if (col.r != 0.0f || col.g != 0.0f || col.b != 0.0f)
    {
        ENABLE_BIT(mPermutation, LightMaterialGenerator::MI_SPECULAR);
    }
    else
    {
        DISABLE_BIT(mPermutation, LightMaterialGenerator::MI_SPECULAR);
    }
}
Example #9
0
void DeferredLight::UpdateFromParent()
{
    // TODO : Don't do this unless something changed
    SetAttenuation(mParentLight->getAttenuationConstant(), mParentLight->getAttenuationLinear(),
                    mParentLight->getAttenuationQuadric());
    SetSpecularColour(mParentLight->getSpecularColour());

    if (getCastChadows())
    {
        ENABLE_BIT(mPermutation, LightMaterialGenerator::MI_SHADOW_CASTER);
    }
    else
    {
        DISABLE_BIT(mPermutation, LightMaterialGenerator::MI_SHADOW_CASTER);
    }
}
void DeferredLight::setAttenuation(Ogre::Real c, Ogre::Real b, Ogre::Real a) {
    Ogre::Real outerRadius = parentLight->getAttenuationRange();

    if (c != 1.0 || b != 0.0 || a != 0.0) {
        ENABLE_BIT(permutation, LightMaterialGenerator::MI_ATTENUATED);
        if (parentLight->getType() == Ogre::Light::LT_POINT) {
            int thresholdLevel = 10;
            Ogre::Real threshold = 1.0 / ((Ogre::Real)thresholdLevel / 256.0);

            c -= threshold;
            Ogre::Real d = Ogre::Math::Sqrt(b * b - 4 * a * c);
            outerRadius = (-2 * c) / (b + d);
            outerRadius *= 1.2;
        }
    } else {
        DISABLE_BIT(permutation, LightMaterialGenerator::MI_ATTENUATED);
    }

    rebuildGeometry(outerRadius);
}
Example #11
0
void DeferredLight::setAttenuation(float c, float b, float a)
{
	float outerRadius = mParentLight->getAttenuationRange();
	if (c != 1.0f || b != 0.0f || a != 0.0f)
	{
		ENABLE_BIT(mPermutation, LightMaterialGenerator::MI_ATTENUATED);
		if (mParentLight->getType() == Ogre::Light::LT_POINT)
		{
			float minAttenuation = 1.0f / (MINIMUM_ATTENUATION / 256.0f);
			c -= minAttenuation;
			outerRadius = (-2 * c) / (b + sqrt(b * b - 4 * a * c));
		}
	}
	else
	{
		DISABLE_BIT(mPermutation,LightMaterialGenerator::MI_ATTENUATED);
	}
    
	rebuildGeometry(outerRadius);
}