Esempio n. 1
0
void Font::render(const vec3& pos, const std::string& text) const {
    if (simpleLayout_) {
        float delta = 0;

        std::string line;
        std::stringstream ss(text);
        std::getline(ss, line);
        FTPoint point(static_cast<double>(pos.x),
                      static_cast<double>(pos.y),
                      static_cast<double>(pos.z));
        FTBBox box = font_->BBox(line.c_str(), -1, point);
        delta -= box.Upper().Yf() - box.Lower().Yf(); // height of first line

        Bounds bounds = getBounds(pos, text);
        float height = bounds.getURB().y - bounds.getLLF().y;
        switch(vAlign_) {
            case Font::Top:
                delta += height;
                break;
            case Font::Middle:
                delta += height * 0.5f;
                break;
            case Font::Bottom:
                break;
        }
        vec3 dpos = vec3(pos.x, pos.y + delta, pos.z);
        glPushMatrix();
        glRasterPos3f(dpos.x, dpos.y, dpos.z);
        glTranslatef(dpos.x, dpos.y, dpos.z);
        simpleLayout_->Render(text.c_str(), -1, FTPoint(dpos.x, dpos.y, dpos.z));
        glPopMatrix();
    }
}
Esempio n. 2
0
bool Bounds::inside(const Bounds& bounds) const {
    tgtAssert(       isDefined(), "This Box ist not defined.");
    tgtAssert(bounds.isDefined(), "Box b ist not defined.");

    vec3 llfb = bounds.getLLF();
    vec3 urbb = bounds.getURB();

    float r0x = min(llf_[0], urb_[0]);
    float r1x = max(llf_[0], urb_[0]);
    float r0y = min(llf_[1], urb_[1]);
    float r1y = max(llf_[1], urb_[1]);
    float r0z = min(llf_[2], urb_[2]);
    float r1z = max(llf_[2], urb_[2]);

    float r2x = min(llfb[0], urbb[0]);
    float r3x = max(llfb[0], urbb[0]);
    float r2y = min(llfb[1], urbb[1]);
    float r3y = max(llfb[1], urbb[1]);
    float r2z = min(llfb[2], urbb[2]);
    float r3z = max(llfb[2], urbb[2]);

    return (r0x >= r2x) && (r1x <= r3x)
        && (r0y >= r2y) && (r1y <= r3y)
        && (r0z >= r2z) && (r1z <= r3z);
}