예제 #1
0
    bool AnimationAtlas::load(const std::string& path, const glm::uvec2& frames, const glm::uvec2& rectMin, const glm::uvec2& rectMax)
    {
        if (!TextureAtlas::load(path, TextureAtlas::LoadMode::TextureOnly))
            return false;

        glm::vec2 size(0, 0);

        if (rectMin.x > 0 || rectMin.y > 0 || rectMax.x > 0 || rectMax.y > 0)
            size = rectMax - rectMin;
        else
            size = getTexture().getSize();

        m_frameSize.x = size.x / frames.x;
        m_frameSize.y = size.y / frames.y;

        for (size_t row = 0; row < frames.y; ++row)
        {
            for (size_t col = 0; col < frames.x; ++col)
            {
                defineTexture(glm::vec2(rectMin.x + (m_frameSize.x * col), rectMin.y + (m_frameSize.y * row)), glm::vec2(rectMin.x + m_frameSize.x + (m_frameSize.x * col), rectMin.y + m_frameSize.y + (m_frameSize.y * row)));
            }
        }

        return true;
    }
예제 #2
0
// check if a texture is connected to this attribute. If yes, return the texture name, if not define the currentColor and return the color name.
MString colorOrMap(renderer::Project* project, MFnDependencyNode& shaderNode, MString& attributeName)
{
    MString definition = defineTexture(shaderNode, attributeName);
    if (definition.length() == 0)
    {
        MColor color = getColorAttr(attributeName.asChar(), shaderNode);
        defineColor(project, (attributeName + "_color").asChar(), color, 1.0f);
        definition = attributeName + "_color";
    }
    return definition;
}