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

    static const CEGUI::Colour c(1, 1, 1, 1);

    float uvTop = window.getTextureTarget().isRenderingInverted() ? 1.0f : 0.0f;
    float uvBot = window.getTextureTarget().isRenderingInverted() ? 0.0f : 1.0f;

    const Vector3f windowPosition = Vector3f(window.getPosition(), 0.0f);
    const Vector2f& currentTopLeft = d_currentPosition ;
    const Vector2f currentBottomRight = d_currentPosition +
        Vector2f(window.getSize().d_width, window.getSize().d_height);

    {
        // first triangle

        // vertex 0 - top left
        d_vertices[0].position   = Vector3f(currentTopLeft, 0.0f) - windowPosition;
        d_vertices[0].colour_val = c;
        d_vertices[0].tex_coords = Vector2f(0.0f, uvTop);

        // vertex 1 - bottom left
        d_vertices[1].position   = Vector3f(currentTopLeft.d_x, currentBottomRight.d_y, 0.0f) - windowPosition;
        d_vertices[1].colour_val = c;
        d_vertices[1].tex_coords = Vector2f(0.0f, uvBot);

        // vertex 2 - bottom right
        d_vertices[2].position   = Vector3f(currentBottomRight, 0.0f) - windowPosition;
        d_vertices[2].colour_val = c;
        d_vertices[2].tex_coords = Vector2f(1.0f, uvBot);

        // second triangle

        // vertex 3 - bottom right
        d_vertices[3].position   = Vector3f(currentBottomRight, 0.0f) - windowPosition;
        d_vertices[3].colour_val = c;
        d_vertices[3].tex_coords = Vector2f(1.0f, uvBot);

        // vertex 4 - top right
        d_vertices[4].position   = Vector3f(currentBottomRight.d_x, currentTopLeft.d_y, 0.0f) - windowPosition;
        d_vertices[4].colour_val = c;
        d_vertices[4].tex_coords = Vector2f(1.0f, uvTop);

        // vertex 5 - top left
        d_vertices[5].position   = Vector3f(currentTopLeft, 0.0f) - windowPosition;
        d_vertices[5].colour_val = c;
        d_vertices[5].tex_coords = Vector2f(0.0f, uvTop);
    }

    geometry.setActiveTexture(&tex);
    geometry.appendGeometry(d_vertices, ds_vertexCount);

    // false, because we do not want the default geometry added!
    return false;
}
コード例 #2
0
ファイル: EffectsDemo.cpp プロジェクト: LiberatorUSA/GUCEF
//----------------------------------------------------------------------------//
bool WobblyWindowEffect::update(const float elapsed, CEGUI::RenderingWindow& window)
{
    using namespace CEGUI;

    // initialise ourself upon the first update call.
    if (!d_initialised)
    {
        syncPivots(window);
        d_initialised = true;
        return true;
    }

    const CEGUI::Rectf pixelRect = CEGUI::Rectf(window.getPosition(), window.getSize());

    const CEGUI::MouseCursor& cursor = d_window->getGUIContext().getMouseCursor();

    bool changed = false;

    for (size_t y = 0; y < ds_yPivotCount; ++y)
    {
        for (size_t x = 0; x < ds_xPivotCount; ++x)
        {
            const float factorMinX = static_cast<float>(ds_xPivotCount - 1- x) / (ds_xPivotCount - 1);
            const float factorMaxX = static_cast<float>(x) / (ds_xPivotCount - 1);
            const float factorMinY = static_cast<float>(ds_yPivotCount - 1 - y) / (ds_yPivotCount - 1);
            const float factorMaxY = static_cast<float>(y) / (ds_yPivotCount - 1);

            const Vector2f desiredPos = Vector2f(
                    factorMinX * pixelRect.d_min.d_x + factorMaxX * pixelRect.d_max.d_x,
                    factorMinY * pixelRect.d_min.d_y + factorMaxY * pixelRect.d_max.d_y);

            const Vector2f delta = desiredPos - d_pivots[x][y];

            float speed = 300.0f;
            const Vector2f cursorDelta = d_window->getTitlebar()->isDragged() ? window.getPosition() + d_window->getTitlebar()->getDragPoint() - d_pivots[x][y] : Vector2f(0.0f, 0.0f);
            const float cursorDeltaLength = sqrtf(cursorDelta.d_x * cursorDelta.d_x + cursorDelta.d_y * cursorDelta.d_y);
            speed /= cursorDeltaLength > 64 ? sqrtf(cursorDeltaLength) * 0.125f : 1;

            d_pivotVelocities[x][y] *= pow(0.00001f, elapsed);
            d_pivotVelocities[x][y] += delta * (speed * elapsed);

            const Vector2f old_pivot(d_pivots[x][y]);
            d_pivots[x][y] += d_pivotVelocities[x][y] * elapsed;
            changed |= (old_pivot != d_pivots[x][y]);
        }
    }

    // note we just need system to redraw the geometry; we do not need a
    // full redraw of all window/widget content - which is unchanged.
    if (changed)
        d_window->getGUIContext().markAsDirty();

    return false;
}
コード例 #3
0
ファイル: EffectsDemo.cpp プロジェクト: LiberatorUSA/GUCEF
void WobblyWindowEffect::syncPivots(CEGUI::RenderingWindow& window)
{
    const CEGUI::Rectf pixelRect = CEGUI::Rectf(window.getPosition(), window.getSize());

    for (size_t y = 0; y < ds_yPivotCount; ++y)
    {
        for (size_t x = 0; x < ds_xPivotCount; ++x)
        {
            const float factorMinX = static_cast<float>(ds_xPivotCount - x) / (ds_xPivotCount - 1);
            const float factorMaxX = static_cast<float>(x) / (ds_xPivotCount - 1);
            const float factorMinY = static_cast<float>(ds_yPivotCount - y) / (ds_yPivotCount - 1);
            const float factorMaxY = static_cast<float>(y) / (ds_yPivotCount - 1);

            d_pivots[x][y] = CEGUI::Vector2f(
                    factorMinX * pixelRect.d_min.d_x + factorMaxX * pixelRect.d_max.d_x,
                    factorMinY * pixelRect.d_min.d_y + factorMaxY * pixelRect.d_max.d_y);

            d_pivotVelocities[x][y] = CEGUI::Vector2f(
                    0.0f,
                    0.0f);
        }
    }
}
コード例 #4
0
ファイル: EffectsDemo.cpp プロジェクト: LiberatorUSA/GUCEF
//----------------------------------------------------------------------------//
bool WobblyWindowEffect::realiseGeometry(CEGUI::RenderingWindow& window,
                               CEGUI::GeometryBuffer& geometry)
{
    using namespace CEGUI;
    Texture& tex = window.getTextureTarget().getTexture();

    static const CEGUI::Colour c(1, 1, 1, 1);

    // 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().d_x;
    const float tcy =
        (window.getTextureTarget().isRenderingInverted() ? -qh : qh) *
            tex.getTexelScaling().d_y;

    const Vector3f windowPosition = Vector3f(window.getPosition(), 0.0f);

    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].position   = Vector3f(d_pivots[x][y], 0.0f) - windowPosition;
            d_vertices[idx + 0].colour_val = c;
            d_vertices[idx + 0].tex_coords = Vector2f(x * tcx, y * tcy);

            // vertex 1 - bottom left
            d_vertices[idx + 1].position   = Vector3f(d_pivots[x][y + 1], 0.0f) - windowPosition;
            d_vertices[idx + 1].colour_val = c;
            d_vertices[idx + 1].tex_coords = Vector2f(x * tcx, (y + 1) * tcy);

            // vertex 2 - bottom right
            d_vertices[idx + 2].position   = Vector3f(d_pivots[x + 1][y + 1], 0.0f) - windowPosition;
            d_vertices[idx + 2].colour_val = c;
            d_vertices[idx + 2].tex_coords = Vector2f((x + 1) * tcx, (y + 1) * tcy);

            // second triangle

            // vertex 3 - bottom right
            d_vertices[idx + 3].position   = Vector3f(d_pivots[x + 1][y + 1], 0.0f) - windowPosition;
            d_vertices[idx + 3].colour_val = c;
            d_vertices[idx + 3].tex_coords = Vector2f((x + 1) * tcx, (y + 1) * tcy);

            // vertex 4 - top right
            d_vertices[idx + 4].position   = Vector3f(d_pivots[x + 1][y], 0.0f) - windowPosition;
            d_vertices[idx + 4].colour_val = c;
            d_vertices[idx + 4].tex_coords = Vector2f((x + 1) * tcx, y * tcy);

            // vertex 5 - top left
            d_vertices[idx + 5].position   = Vector3f(d_pivots[x][y], 0.0f) - windowPosition;
            d_vertices[idx + 5].colour_val = c;
            d_vertices[idx + 5].tex_coords = Vector2f(x * tcx, y * tcy);
        }
    }

    geometry.setActiveTexture(&tex);
    geometry.appendGeometry(d_vertices, ds_vertexCount);

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

    static const CEGUI::Colour c(1, 1, 1, 1);

    const float qw = window.getSize().d_width / tess_x;
    const float qh = window.getSize().d_height / tess_y;
    const float tcx = qw * tex.getTexelScaling().d_x;
    const float tcy =
        (window.getTextureTarget().isRenderingInverted() ? -qh : qh) *
            tex.getTexelScaling().d_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].position   = Vector3f(i * qw - top_adj, j * qh - lef_adj, 0.0f);
            vb[idx + 0].colour_val = c;
            vb[idx + 0].tex_coords = Vector2f(i * tcx, j*tcy);

            // vertex 1
            vb[idx + 1].position   = Vector3f(i * qw - bot_adj, j * qh + qh - lef_adj, 0.0f);
            vb[idx + 1].colour_val = c;
            vb[idx + 1].tex_coords = Vector2f(i*tcx, j*tcy+tcy);

            // vertex 2
            vb[idx + 2].position   = Vector3f(i * qw + qw - bot_adj, j * qh + qh - rig_adj, 0.0f);
            vb[idx + 2].colour_val = c;
            vb[idx + 2].tex_coords = Vector2f(i*tcx+tcx, j*tcy+tcy);

            // vertex 3
            vb[idx + 3].position   = Vector3f(i * qw + qw - bot_adj, j * qh + qh - rig_adj, 0.0f);
            vb[idx + 3].colour_val = c;
            vb[idx + 3].tex_coords = Vector2f(i*tcx+tcx, j*tcy+tcy);

            // vertex 4
            vb[idx + 4].position   = Vector3f(i * qw + qw - top_adj, j * qh - rig_adj, 0.0f);
            vb[idx + 4].colour_val = c;
            vb[idx + 4].tex_coords = Vector2f(i*tcx+tcx, j*tcy);

            // vertex 5
            vb[idx + 5].position   = Vector3f(i * qw - top_adj, j * qh - lef_adj, 0.0f);
            vb[idx + 5].colour_val = c;
            vb[idx + 5].tex_coords = Vector2f(i * tcx, j*tcy);
        }
    }

    geometry.setActiveTexture(&tex);
    geometry.appendGeometry(vb, buffsize);

    // false, because we do not want the default geometry added!
    return false;
}
コード例 #6
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;
}
コード例 #7
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;
}
コード例 #8
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;
}