예제 #1
0
OGSprite* SpriteFactory::CreateCap(WOGPipe* a_pipe,
                                   const QString& a_id,
                                   bool a_visible)
{
    auto src = CreateImageSource(a_id);

    if (!src || a_pipe->vertex->size() < 2)
        return nullptr;

    QPointF p1 = a_pipe->vertex->at(0);
    QPointF p2 = a_pipe->vertex->at(1);
    auto v = p2 - p1;
    float angle = (v.x() == 0 ? (v.y() > 0 ? 0 : 180) : (v.x() > 0 ? 90 : -90));

    float x = p1.x();
    float y = -p1.y();

    auto spr = std::unique_ptr<OGSprite>(new OGSprite(x, y, src));
    spr->CenterOrigin();
    spr->SetAngle(angle);
    spr->SetVisible(a_visible);
    spr->SetDepth(a_pipe->depth);

    return spr.release();
}
예제 #2
0
OGSprite* SpriteFactory::CreateBend(const QString& a_type,
                     const QPointF& a_p1,
                     const QPointF& a_p2,
                     const QPointF& a_p3,
                     float a_depth)
{
    auto v1 = a_p2 - a_p1;
    auto v2 = a_p3 - a_p2;

    QString id = "IMAGE_GLOBAL_PIPE_BEND_";

    if (v1.y() > 0 || v2.y() < 0)
        id += (v2.x() < 0 || v1.x() > 0 ? "TR_" + a_type : "TL_" + a_type);
    else
        id += (v2.x() < 0 || v1.x() > 0 ? "BR_" + a_type : "BL_" + a_type);

    auto src = CreateImageSource(id);

    if (!src)
        return nullptr;

    auto spr = std::unique_ptr<OGSprite>(new OGSprite(src));
    spr->SetPosition(a_p2.x(), -a_p2.y());
    spr->SetDepth(a_depth);
    spr->CenterOrigin();

    return spr.release();
}
예제 #3
0
ImageSource* OBS::AddGlobalSourceToScene(CTSTR lpName)
{
    XElement *globals = scenesConfig.GetElement(TEXT("global sources"));
    if(globals)
    {
        XElement *globalSourceElement = globals->GetElement(lpName);
        if(globalSourceElement)
        {
            CTSTR lpClass = globalSourceElement->GetString(TEXT("class"));
            if(lpClass)
            {
                ImageSource *newGlobalSource = CreateImageSource(lpClass, globalSourceElement->GetElement(TEXT("data")));
                if(newGlobalSource)
                {
                    App->EnterSceneMutex();

                    GlobalSourceInfo *info = globalSources.CreateNew();
                    info->strName = lpName;
                    info->element = globalSourceElement;
                    info->source = newGlobalSource;

                    info->source->BeginScene();

                    App->LeaveSceneMutex();

                    return newGlobalSource;
                }
            }
        }
    }

    AppWarning(TEXT("OBS::AddGlobalSourceToScene: Could not find global source '%s'"), lpName);
    return NULL;
}