Пример #1
0
void MaterialParameter::setAnimationPropertyValue(int propertyId, AnimationValue* value, float blendWeight)
{
    GP_ASSERT(value);
    GP_ASSERT(blendWeight >= 0.0f && blendWeight <= 1.0f);

    switch (propertyId)
    {
        case ANIMATE_UNIFORM:
        {
            switch (_type)
            {
                case FLOAT:
                    _value.floatValue = Curve::lerp(blendWeight, _value.floatValue, value->getFloat(0));
                    break;
                case FLOAT_ARRAY:
                    applyAnimationValue(value, blendWeight, 1);
                    break;
                case INT:
                    _value.intValue = Curve::lerp(blendWeight, _value.intValue, value->getFloat(0));
                    break;
                case INT_ARRAY:
                    GP_ASSERT(_value.intPtrValue);
                    for (unsigned int i = 0; i < _count; i++)
                        _value.intPtrValue[i] = Curve::lerp(blendWeight, _value.intPtrValue[i], value->getFloat(i));
                    break;
                case VECTOR2:
                    applyAnimationValue(value, blendWeight, 2);
                    break;
                case VECTOR3:
                    applyAnimationValue(value, blendWeight, 3);
                    break;
                case VECTOR4:
                    applyAnimationValue(value, blendWeight, 4);
                    break;
                case NONE:
                case MATRIX:
                case METHOD:
                case SAMPLER:
                case SAMPLER_ARRAY:
                    // Unsupported material parameter types for animation.
                    break;
                default:
                    GP_ERROR("Unsupported material parameter type (%d).", _type);
                    break;
            }
        }
        break;
    }
}
Пример #2
0
void MaterialParameter::setAnimationPropertyValue(int propertyId, AnimationValue* value, float blendWeight)
{
    assert(blendWeight >= 0.0f && blendWeight <= 1.0f);

    switch (propertyId)
    {
        case ANIMATE_UNIFORM:
        {
            switch (_type)
            {
                case FLOAT:
                {
                    if (_count == 1)
                    {
                        if ((_animationPropertyBitFlag & ANIMATION_UNIFORM_BIT) != ANIMATION_UNIFORM_BIT)
                        {
                            _animationPropertyBitFlag |= ANIMATION_UNIFORM_BIT;
                            _value.floatValue = value->getFloat(0);
                        }
                        else
                        {
                            _value.floatValue = Curve::lerp(blendWeight, _value.floatValue, value->getFloat(0));
                        }
                    }
                    else
                    {
                        applyAnimationValue(value, blendWeight, 1);
                    }                    
                    break;
                }
                case INT:
                {
                    if (_count == 1)
                    {
                        if ((_animationPropertyBitFlag & ANIMATION_UNIFORM_BIT) != ANIMATION_UNIFORM_BIT)
                        {
                            _animationPropertyBitFlag |= ANIMATION_UNIFORM_BIT;
                            _value.intValue = value->getFloat(0);
                        }
                        else
                        {
                            _value.intValue = Curve::lerp(blendWeight, _value.intValue, value->getFloat(0));
                        }
                    }
                    else
                    {
                        if ((_animationPropertyBitFlag & ANIMATION_UNIFORM_BIT) != ANIMATION_UNIFORM_BIT)
                        {
                            _animationPropertyBitFlag |= ANIMATION_UNIFORM_BIT;
                            for (unsigned int i = 0; i < _count; i++)
                                _value.intPtrValue[i] = value->getFloat(i);
                        }
                        else
                        {
                            for (unsigned int i = 0; i < _count; i++)
                                _value.intPtrValue[i] = Curve::lerp(blendWeight, _value.intPtrValue[i], value->getFloat(i));
                        }
                    }
                    break;
                }
                case VECTOR2:
                {
                    applyAnimationValue(value, blendWeight, 2);
                    break;
                }
                case VECTOR3:
                {
                    applyAnimationValue(value, blendWeight, 3);
                    break;
                }
                case VECTOR4:
                {
                    applyAnimationValue(value, blendWeight, 4);
                    break;
                }
                // UNSUPPORTED: NONE, MATRIX, METHOD, SAMPLER 
            }
        }
        break;
    }
}