Beispiel #1
0
void Widget::resizeGL(int width, int height)
{
  glViewport(0, 0, width, height);
  aspect = (qreal)width / (qreal)(height ? height : 1);
  perspectiveProjection();
  textx=(width/2)-50;
  texty=(width/2)+50;
}
Beispiel #2
0
void CameraOffAxis::updateHeadTrackingFrame(glm::dmat4 newHeadFrame)
{
	_headFrame = newHeadFrame;

	// 1. Get the center of the camera (the eye) position from the head position
	glm::dmat4 head2Room = _headFrame;
	glm::dmat4 leftEye2Room = getLeftEyeFrame();
	glm::dmat4 rightEye2Room = getRightEyeFrame();
  
	// 2. Setup projection matrix
	glm::dvec3 head = glm::column((_room2tile * head2Room), 3).xyz();
	glm::dvec3 left = glm::column((_room2tile * leftEye2Room), 3).xyz();
	glm::dvec3 right = glm::column((_room2tile * rightEye2Room), 3).xyz();
	

	double lHead = (-_halfWidth - head.x);
	double rHead = (_halfWidth - head.x);
	double lLeft = (-_halfWidth - left.x);
	double rLeft = (_halfWidth - left.x);
	double bLeft =  (-_halfHeight - left.y);
	double tLeft = (_halfHeight - left.y);
	double kLeft = _nearClip / left.z;
	double lRight = (-_halfWidth - right.x);
	double rRight = (_halfWidth - right.x);
	double bRight =  (-_halfHeight - right.y);
	double tRight = (_halfHeight - right.y);
	double kRight = _nearClip / right.z;

	double b = (-_halfHeight - head.y);
	double t = (_halfHeight - head.y);
	double dist = head.z;
	double k = _nearClip / dist;

	// 3. Add eye position to the projection (eye is in tile coordinates)
	glm::dmat4 r2t = glm::column(glm::dmat4(1.0), 3, glm::dvec4(-head, 1.0)) * _room2tile;
	glm::dmat4 r2tLeft = glm::column(glm::dmat4(1.0), 3, glm::dvec4(-left, 1.0)) * _room2tile;
	glm::dmat4 r2tRight = glm::column(glm::dmat4(1.0), 3, glm::dvec4(-right, 1.0)) * _room2tile;

	_projection = invertYMat() * perspectiveProjection(lHead*k, rHead*k, b*k, t*k, _nearClip, _farClip);
	_projectionLeft = invertYMat() * perspectiveProjection(lLeft*kLeft, rLeft*kLeft, bLeft*kLeft, tLeft*kLeft, _nearClip, _farClip);
	_projectionRight = invertYMat() * perspectiveProjection(lRight*kRight, rRight*kRight, bRight*kRight, tRight*kRight, _nearClip, _farClip);

	_view = r2t;//.inverse();
	_viewLeft = r2tLeft;//.inverse();
	_viewRight = r2tRight;//.inverse();
}
Beispiel #3
0
void renderDofAmountTest()
{
    Options opts;
    opts.xRes = 320;
    opts.yRes = 240;
    opts.gridSize = 8;
    opts.clipNear = 0.1;
    opts.superSamp = Imath::V2i(10,10);
    opts.pixelFilter = makeGaussianFilter(Vec2(2.0,2.0));
    opts.fstop = 100;
    opts.focalLength = 20;
    opts.focalDistance = 3;

    Attributes attrs;
    attrs.shadingRate = 1;
    attrs.smoothShading = true;

    Mat4 camToScreen =
        perspectiveProjection(90, opts.clipNear, opts.clipFar) *
        screenWindow(-2.33333, 0.33333, -1, 1);

    // Output variables.
    VarList outVars;
    outVars.push_back(Stdvar::Cs);

    Renderer r(opts, camToScreen, outVars);

    Mat4 wToO = Mat4().setTranslation(Vec3(-0.5,-0.5,-1)) *
                Mat4().setAxisAngle(Vec3(0,0,1), deg2rad(45)) *
                Mat4().setTranslation(Vec3(-1.5, 0, 2));

    const float P[12] = {0, 0, 0,  1, 0, 0,  0, 1, 0,  1, 1, 0};
    {
        const float Cs[3] = {1, 0.7, 0.7};
        r.add(createPatch(P, Cs, wToO), attrs);
    }
    {
        const float Cs[3] = {0.7, 1, 0.7};
        r.add(createPatch(P, Cs, Mat4().setTranslation(Vec3(0,0,1))*wToO), attrs);
    }
    {
        const float Cs[3] = {0.7, 0.7, 1};
        r.add(createPatch(P, Cs, Mat4().setTranslation(Vec3(0,0,2))*wToO), attrs);
    }
    {
        const float Cs[3] = {1, 0.7, 0.7};
        r.add(createPatch(P, Cs, Mat4().setTranslation(Vec3(0,0,5))*wToO), attrs);
    }
    {
        const float Cs[3] = {0.7, 1, 0.7};
        r.add(createPatch(P, Cs, Mat4().setTranslation(Vec3(0,0,25))*wToO), attrs);
    }

    r.render();
}
Beispiel #4
0
    void Render::fullscreenQuad()
    {
        orthoProjection();
        glBegin(GL_QUADS);
        glTexCoord2f(0.f,0.f);
        glVertex2f(0.f,0.f);

        glTexCoord2f(1.f,0.f);
        glVertex2f(1.f,0.f);

        glTexCoord2f(1.f,1.f);
        glVertex2f(1.f,1.f);

        glTexCoord2f(0.f,1.f);
        glVertex2f(0.f,1.f);
        glEnd();
        perspectiveProjection();
    }
Beispiel #5
0
void MainWindow::_init()
{

    setWindowState(Qt::WindowFullScreen);
    m_bPerspectiveProjection = false;
    ui->radioBtnTransformation->hide();
    m_bHideFaces = false;
    m_pView = new CCoordinateView(this);
    m_pView3D = new C3DView(PROJECTION_DEFAULT,this);
    m_pView3D->hide();
//    m_pView->hide();
    //m_pView->hideGrid(true);
    //m_pView->hideGrid(false);

    ui->viewFrameGrid->addWidget(m_pView);
    ui->viewFrameGrid->addWidget(m_pView3D);

    m_pDebugBox = new CDebugModeBox(this);
    ui->sidePanel->addWidget(m_pDebugBox);
    m_pDebugBox->setDisabled(true);

    m_pTmpUndoStack.clear();

    m_firstPoint = QPoint(0,0);
    m_secondPoint = QPoint(0,0);

    m_btnClickState = MCS_UNDEFINED;

    m_pCurrentListener = NULL;

    m_bHighlightInitPoints = false;
    m_mainColor = QColor(Qt::blue);
    //m_mainColor.setAlpha(10);
    m_secondaryColor = QColor(Qt::red);


    ui->btnSecondaryColor->setAutoFillBackground(true);
    ui->btnMainColor->setAutoFillBackground(true);

    m_mode = MODE_NORMAL;


    ui->radioBtnAlgDDA->setChecked(true);
    ui->radioBtnAlgBrezenhema->setChecked(false);

    ui->radioBtnDefaultMode->setChecked(true);
    //defaultModeEnable();

    //ui->debugInfoBrowser->setUndoRedoEnabled(true);

    m_drawShapeType = DST_LINE;

    //m_pListener = new CListenerLineDDA(m_pView, m_pDebugBox,QColor(Qt::red), QColor(Qt::blue));

    connect(m_pView,SIGNAL(clickOnCell(int,int)),this,SLOT(mouseClickOnCell(int,int)));
    connect(m_pView,SIGNAL(moveOnCell(int,int)),this,SLOT(mouseMoveOnCell(int,int)));
    connect(m_pView,SIGNAL(releaseOnScene(int,int)),this,SLOT(mouseReleaseOnCell(int,int)));
//    connect(ui->btnZoomIn,SIGNAL(clicked()),m_pView,SLOT(zoomIn()));
//    connect(ui->btnZoomOut,SIGNAL(clicked()),m_pView,SLOT(zoomOut()));

    connect(ui->btnMainColor,SIGNAL(clicked()),this,SLOT(setMainColor()));
    connect(ui->btnSecondaryColor,SIGNAL(clicked()),this,SLOT(setSecondaryColor()));

    connect(ui->btnClear,SIGNAL(clicked()),this,SLOT(clearView()));

    connect(ui->radioBtnDebugMode,SIGNAL(clicked()),this,SLOT(debugModeEnable()));
    connect(ui->radioBtnDefaultMode,SIGNAL(clicked()),this,SLOT(defaultModeEnable()));


    connect(ui->checkBoxHightlightEndPoints,SIGNAL(clicked()),this,SLOT(highlightEndPoints()));

    connect(ui->radioBtnAlgBrezenhema,SIGNAL(clicked()),this,SLOT(drawAlgorithmChanged()));
    connect(ui->radioBtnAlgDDA,SIGNAL(clicked()),this,SLOT(drawAlgorithmChanged()));
    connect(ui->radioBtnRound,SIGNAL(clicked()),this,SLOT(drawAlgorithmChanged()));
    connect(ui->radioBtnAlgorithmParabola,SIGNAL(clicked()),this,SLOT(drawAlgorithmChanged()));
    connect(ui->radioBtnBSpline,SIGNAL(clicked()),this,SLOT(drawAlgorithmChanged()));
    connect(ui->radioBtnBese,SIGNAL(clicked()),this,SLOT(drawAlgorithmChanged()));
    connect(ui->radioBtnLineFilling,SIGNAL(clicked()),this,SLOT(drawAlgorithmChanged()));
    connect(ui->radioBtnLineVertexFilling,SIGNAL(clicked()),this,SLOT(drawAlgorithmChanged()));
    connect(ui->radioBtnTransformation,SIGNAL(clicked()),this,SLOT(drawAlgorithmChanged()));


    connect(ui->tabAlgorithms,SIGNAL(currentChanged(int)),this,SLOT(algorithmTabIndexChanged(int)));
    connect(ui->zoomSlider,SIGNAL(valueChanged(int)),this,SLOT(zoomChanged(int)));


    connect(ui->checkBoxHightlight,SIGNAL(clicked()),this,SLOT(perspectiveProjection()));
    connect(ui->checkBoxHideFaces,SIGNAL(clicked()),this,SLOT(hideFaces()));

    //connect(ui->btnRunThread, SIGNAL(clicked()),this,SLOT(runThread()));

    ui->radioBtnAlgDDA->setChecked(true);
    ui->radioBtnAlgBrezenhema->setChecked(false);
    ui->radioBtnDefaultMode->setChecked(true);

    createListeners();
    ui->radioBtnAlgDDA->click();

    _setMainColor(m_mainColor);
    _setSecondaryColor(m_secondaryColor);


//    CAlgorithmVertexLineFilling alg;
//    QList<QPoint> list;
//    list << QPoint(0,0) << QPoint(20,0) << QPoint(10,10) ;//<< QPoint(20,20) << QPoint(20,0);// << QPoint(20,20) << QPoint(-15,3);
//    alg.setPoints(list);
//    //qDebug() << alg.getDrawPoints();
//    StepPoints points = alg.getDrawPoints();
//    for(int i=0; i<points.size();i++)
//    {
//        m_pView->setCellColor(points.at(i),m_mainColor);
//    }

    m_lastZoomValue = ui->zoomSlider->value();
}
Beispiel #6
0
void GLWidget::resizeGL(int width, int height)
{
    glViewport(0, 0, width, height);
    aspect = (qreal)width / (qreal)(height ? height : 1);
    perspectiveProjection();
}