Example #1
0
//--------------------------------------------------------------
void AppCore::resize(float width_, float height_) {
    
    width = width_;
    height = height_;
    
    float uiWidth = width_ * .5f;
    float radius = (height_ / widgets.size()) * .3f;
    float space = radius * .2f;
    float slWidth = uiWidth * .8f;
    float uiHeight = 0.f;
    
    font.loadFont("fonts/verdana.ttf", (int) floorf(MAX(10.f, radius * .7f)));
    
    // set checkboxes radius
    CheckBox * cb = NULL;
    cb = (CheckBox *) widgets[0];
    cb->radius = radius;
    cb = (CheckBox *) widgets[1];
    cb->radius = radius;
    cb = (CheckBox *) widgets[2];
    cb->radius = radius;
    uiHeight += cb->getHeight();
    
    // set sliders radius
    for (int i = 3; i < widgets.size(); i++){
        Slider * sl = (Slider*) widgets[i];
        sl->setCursorRadius(radius);
        sl->setWidth(slWidth);
        uiHeight += sl->getHeight();
    }
    
    uiHeight += (widgets.size() - 2) * space;
    
    ofVec2f wPos((uiWidth - slWidth) * .5f, (height_ - uiHeight) * .5f);
    
    // place check boxes
    cb = (CheckBox *) widgets[0];
    cb->position.set(wPos);
    cb = (CheckBox *) widgets[1];
    cb->position.set(wPos + ofVec2f(slWidth * 1.f / 3.f, 0));
    cb = (CheckBox *) widgets[2];
    cb->position.set(wPos + ofVec2f(slWidth * 2.f / 3.f, 0));
    wPos.y += cb->getHeight() + space;
    
    // place sliders
    for (int i = 3; i < widgets.size(); i++){
        Slider * sl = (Slider*) widgets[i];
        sl->position.set(wPos);
        wPos.y += sl->getHeight() + space;
    }}
Example #2
0
 virtual void prepare(CameraInfo const &cam)
 {
     Vec3 wPos(worldPos());
     Vec3 back(wPos);
     subFrom(back, cam_->lookAt);
     normalize(back);
     cam_->back = back;
     Vec3 up(0, 0, 1);
     Vec3 right;
     cross(right, up, back);
     normalize(right);
     cross(up, back, right);
     cam_->mmat_.setRow(0, right);
     cam_->mmat_.setRow(1, up);
     cam_->mmat_.setRow(2, back);
     Vec3 zPos;
     cam_->mmat_.setTranslation(zPos);
     cam_->mmat_.setRow(3, zPos);
     subFrom(zPos, wPos);
     multiply(cam_->mmat_, zPos);
     cam_->mmat_.setTranslation(zPos);
 }