コード例 #1
0
ファイル: RenderEffects.cpp プロジェクト: arkana-fts/cegui
//----------------------------------------------------------------------------//
bool ElasticWindowEffect::realiseGeometry(CEGUI::RenderingWindow& window,
        CEGUI::GeometryBuffer& geometry)
{
    using namespace CEGUI;
    TextureTarget& textarget = window.getTextureTarget();
    Texture& tex = textarget.getTexture();

    static const glm::vec4 colour(1.0f, 1.0f, 1.0f, 1.0f);

    bool isTexCoordSysFlipped = textarget.getOwner().isTexCoordSystemFlipped();

    float uvTop = isTexCoordSysFlipped ? 1.0f : 0.0f;
    float uvBot = isTexCoordSysFlipped ? 0.0f : 1.0f;

    const glm::vec3 windowPosition = glm::vec3(window.getPosition(), 0);
    const glm::vec2& currentTopLeft = d_currentPosition ;
    const glm::vec2 currentBottomRight = d_currentPosition +
                                         glm::vec2(window.getSize().d_width, window.getSize().d_height);

    {
        // first triangle

        // vertex 0 - top left
        d_vertices[0].d_position = glm::vec3(currentTopLeft, 0) - windowPosition;
        d_vertices[0].d_colour = colour;
        d_vertices[0].d_texCoords = glm::vec2(0.0f, uvTop);

        // vertex 1 - bottom left
        d_vertices[1].d_position = glm::vec3(currentTopLeft.x, currentBottomRight.y, 0) - windowPosition;
        d_vertices[1].d_colour = colour;
        d_vertices[1].d_texCoords = glm::vec2(0.0f, uvBot);

        // vertex 2 - bottom right
        d_vertices[2].d_position = glm::vec3(currentBottomRight, 0) - windowPosition;
        d_vertices[2].d_colour = colour;
        d_vertices[2].d_texCoords = glm::vec2(1.0f, uvBot);

        // second triangle

        // vertex 3 - bottom right
        d_vertices[3].d_position = glm::vec3(currentBottomRight, 0) - windowPosition;
        d_vertices[3].d_colour = colour;
        d_vertices[3].d_texCoords = glm::vec2(1.0f, uvBot);

        // vertex 4 - top right
        d_vertices[4].d_position = glm::vec3(currentBottomRight.x, currentTopLeft.y, 0) - windowPosition;
        d_vertices[4].d_colour = colour;
        d_vertices[4].d_texCoords = glm::vec2(1.0f, uvTop);

        // vertex 5 - top left
        d_vertices[5].d_position = glm::vec3(currentTopLeft, 0) - windowPosition;
        d_vertices[5].d_colour = colour;
        d_vertices[5].d_texCoords = glm::vec2(0.0f, uvTop);
    }

    geometry.setTexture("texture0", &tex);
    geometry.appendGeometry(d_vertices, ds_vertexCount);

    // false, because we do not want the default geometry added!
    return false;
}
コード例 #2
0
ファイル: RenderEffects.cpp プロジェクト: arkana-fts/cegui
//----------------------------------------------------------------------------//
bool WobblyWindowEffect::realiseGeometry(CEGUI::RenderingWindow& window,
        CEGUI::GeometryBuffer& geometry)
{
    using namespace CEGUI;
    TextureTarget& textarget = window.getTextureTarget();
    Texture& tex = textarget.getTexture();

    static const glm::vec4 colour(1.0f, 1.0f, 1.0f, 1.0f);

    bool isTexCoordSysFlipped = textarget.getOwner().isTexCoordSystemFlipped();

    // qw is the width of one subdivision "box", qh is the height of it
    const float qw = window.getSize().d_width / (ds_xPivotCount - 1);
    const float qh = window.getSize().d_height / (ds_yPivotCount - 1);
    const float tcx = qw * tex.getTexelScaling().x;
    const float tcy =
        (isTexCoordSysFlipped ? -qh : qh) *
        tex.getTexelScaling().y;

    const glm::vec3 windowPosition = glm::vec3(window.getPosition(), 0);

    for (size_t y = 0; y < ds_yPivotCount - 1; ++y)
    {
        for (size_t x = 0; x < ds_xPivotCount - 1; ++x)
        {
            // index of the first vertex of the quad we will construct with
            // this iteration
            const size_t idx = (y * (ds_xPivotCount - 1) + x) * 6;

            // first triangle

            // vertex 0 - top left
            d_vertices[idx + 0].d_position   = glm::vec3(d_pivots[x][y], 0) - windowPosition;
            d_vertices[idx + 0].d_colour = colour;
            d_vertices[idx + 0].d_texCoords = glm::vec2(x * tcx, y * tcy);

            // vertex 1 - bottom left
            d_vertices[idx + 1].d_position   = glm::vec3(d_pivots[x][y + 1], 0) - windowPosition;
            d_vertices[idx + 1].d_colour = colour;
            d_vertices[idx + 1].d_texCoords = glm::vec2(x * tcx, (y + 1) * tcy);

            // vertex 2 - bottom right
            d_vertices[idx + 2].d_position   = glm::vec3(d_pivots[x + 1][y + 1], 0) - windowPosition;
            d_vertices[idx + 2].d_colour = colour;
            d_vertices[idx + 2].d_texCoords = glm::vec2((x + 1) * tcx, (y + 1) * tcy);

            // second triangle

            // vertex 3 - bottom right
            d_vertices[idx + 3].d_position   = glm::vec3(d_pivots[x + 1][y + 1], 0) - windowPosition;
            d_vertices[idx + 3].d_colour = colour;
            d_vertices[idx + 3].d_texCoords = glm::vec2((x + 1) * tcx, (y + 1) * tcy);

            // vertex 4 - top right
            d_vertices[idx + 4].d_position   = glm::vec3(d_pivots[x + 1][y], 0) - windowPosition;
            d_vertices[idx + 4].d_colour = colour;
            d_vertices[idx + 4].d_texCoords = glm::vec2((x + 1) * tcx, y * tcy);

            // vertex 5 - top left
            d_vertices[idx + 5].d_position   = glm::vec3(d_pivots[x][y], 0) - windowPosition;
            d_vertices[idx + 5].d_colour = colour;
            d_vertices[idx + 5].d_texCoords = glm::vec2(x * tcx, y * tcy);
        }
    }

    geometry.setTexture("texture0", &tex);
    geometry.appendGeometry(d_vertices, ds_vertexCount);

    // false, because we do not want the default geometry added!
    return false;
}
コード例 #3
0
ファイル: RenderEffects.cpp プロジェクト: arkana-fts/cegui
//----------------------------------------------------------------------------//
bool OldWobblyWindowEffect::realiseGeometry(CEGUI::RenderingWindow& window,
        CEGUI::GeometryBuffer& geometry)
{
    using namespace CEGUI;
    TextureTarget& textarget = window.getTextureTarget();
    Texture& tex = textarget.getTexture();

    static const glm::vec4 colour(1.0f, 1.0f, 1.0f, 1.0f);

    bool isTexCoordSysFlipped = textarget.getOwner().isTexCoordSystemFlipped();

    const float qw = window.getSize().d_width / tess_x;
    const float qh = window.getSize().d_height / tess_y;
    const float tcx = qw * tex.getTexelScaling().x;
    const float tcy =
        (isTexCoordSysFlipped ? -qh : qh) *
        tex.getTexelScaling().y;

    for (int j = 0; j < tess_y; ++j)
    {
        for (int i = 0; i < tess_x; ++i)
        {
            int idx = static_cast<int>( (j * tess_x + i) * 6 );

            float top_adj = dragX * ((1.0f / tess_x) * j);
            float bot_adj = dragX * ((1.0f / tess_x) * (j+1));
            top_adj = ((top_adj*top_adj) / 3) * (dragX < 0 ? -1 : 1);
            bot_adj = ((bot_adj*bot_adj) / 3) * (dragX < 0 ? -1 : 1);

            float lef_adj = dragY * ((1.0f / tess_y) * i);
            float rig_adj = dragY * ((1.0f / tess_y) * (i+1));
            lef_adj = ((lef_adj*lef_adj) / 3) * (dragY < 0 ? -1 : 1);
            rig_adj = ((rig_adj*rig_adj) / 3) * (dragY < 0 ? -1 : 1);

            // vertex 0
            vb[idx + 0].d_position   = glm::vec3(i * qw - top_adj, j * qh - lef_adj, 0.0f);
            vb[idx + 0].d_colour = colour;
            vb[idx + 0].d_texCoords = glm::vec2(i * tcx, j*tcy);

            // vertex 1
            vb[idx + 1].d_position   = glm::vec3(i * qw - bot_adj, j * qh + qh - lef_adj, 0.0f);
            vb[idx + 1].d_colour = colour;
            vb[idx + 1].d_texCoords = glm::vec2(i*tcx, j*tcy+tcy);

            // vertex 2
            vb[idx + 2].d_position   = glm::vec3(i * qw + qw - bot_adj, j * qh + qh - rig_adj, 0.0f);
            vb[idx + 2].d_colour = colour;
            vb[idx + 2].d_texCoords = glm::vec2(i*tcx+tcx, j*tcy+tcy);

            // vertex 3
            vb[idx + 3].d_position   = glm::vec3(i * qw + qw - bot_adj, j * qh + qh - rig_adj, 0.0f);
            vb[idx + 3].d_colour = colour;
            vb[idx + 3].d_texCoords = glm::vec2(i*tcx+tcx, j*tcy+tcy);

            // vertex 4
            vb[idx + 4].d_position   = glm::vec3(i * qw + qw - top_adj, j * qh - rig_adj, 0.0f);
            vb[idx + 4].d_colour = colour;
            vb[idx + 4].d_texCoords = glm::vec2(i*tcx+tcx, j*tcy);

            // vertex 5
            vb[idx + 5].d_position   = glm::vec3(i * qw - top_adj, j * qh - lef_adj, 0.0f);
            vb[idx + 5].d_colour = colour;
            vb[idx + 5].d_texCoords = glm::vec2(i * tcx, j*tcy);
        }
    }

    geometry.setTexture("texture0", &tex);
    geometry.appendGeometry(vb, buffsize);

    // false, because we do not want the default geometry added!
    return false;
}