void curve::addControlPoint(float pointx, float pointy, float pointz){ ControlX.push_back(pointx); ControlY.push_back(pointy); ControlZ.push_back(pointz); size++; drawControlPoints(); }
void WarpPerspective::draw( bool controls ) { // only draw grid while editing if( isEditModeEnabled() ) { gl::pushModelMatrix(); gl::multModelMatrix( getTransform() ); gl::ScopedGlslProg shader( gl::getStockShader( gl::ShaderDef().color() ) ); gl::ScopedLineWidth linewidth( 1.0f ); glHint( GL_LINE_SMOOTH_HINT, GL_NICEST ); gl::ScopedColor color( Color::white() ); for( int i = 0; i <= 1; i++ ) { float s = i / 1.0f; gl::drawLine( vec2( s * (float)mWidth, 0.0f ), vec2( s * (float)mWidth, (float)mHeight ) ); gl::drawLine( vec2( 0.0f, s * (float)mHeight ), vec2( (float)mWidth, s * (float)mHeight ) ); } gl::drawLine( vec2( 0.0f, 0.0f ), vec2( (float)mWidth, (float)mHeight ) ); gl::drawLine( vec2( (float)mWidth, 0.0f ), vec2( 0.0f, (float)mHeight ) ); gl::popModelMatrix(); if( controls && mSelected < mPoints.size() ) { // draw control points for( int i = 0; i < 4; i++ ) queueControlPoint( mDestination[i], i == mSelected ); drawControlPoints(); } } }
void display(void) { glClear(GL_COLOR_BUFFER_BIT); evaluateGrid(); drawControlPoints(); glutSwapBuffers(); }
void GLWidget::paintGL() { updateAnimation(); updateViewport(); drawCatmullRomSpline(); drawControlPoints(); drawSelectedPoint(); }
/* affichage de la courbe */ void display(void) { int i; char buf[40]; /* Configurer le "viewport" OpenGL. */ glViewport(0, 0, windowWidth, windowHeight); /* Configurer une camera (projection perspective) */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(-windowWidth/2.0,windowWidth/2.0,-windowHeight/2.0,windowHeight/2.0); /* Selectionner la pile de transformations attachee au modele (MODELVIEW) */ glMatrixMode(GL_MODELVIEW); /* Effacer l'ecran */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); drawControlPoints(); switch(selectedCurve){ case Lines: drawLines(); break; case Bezier: drawBezierCurves(); break; case BSpline: drawBSplineCurves(); break; } glPushAttrib( GL_ALL_ATTRIB_BITS ); sprintf(buf," Precision %d",curvePrecision); for (i = 0; i < (int) strlen(buf); i++) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, buf[i]); sprintf(buf," K = %d",paramK); for (i = 0; i < (int) strlen(buf); i++) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, buf[i]); glPopAttrib(); glutSwapBuffers(); }
void curve::draw(){ drawControlPoints(); if(size > 1){ CurveX.resize(0); CurveY.resize(0); CurveZ.resize(0); bezier_curve(ControlX, ControlY, ControlZ); } for(int i = 0; i < CurveX.size(); i++){ glPushMatrix(); glDisable (GL_LIGHTING); glColor3f(0.0,0.0,1.0); glTranslatef(CurveX[i], CurveY[i], CurveZ[i]); glutSolidSphere(0.05, 20, 20); glEnable(GL_LIGHTING); glPopMatrix(); } }
/** * Draws the 2D sketch */ void drawSurface(void) { drawAxis(); drawControlPoints(); // Draw a line connecting the control points in a shade of blue glColor3fv(lineColor); glBegin(GL_LINES); for (int i = 0; i < numControlPoints; i++) { if (i > 0) { glVertex3f(controlPoints[i - 1].x, controlPoints[i - 1].y, 0); } // if else { glVertex3f(controlPoints[i].x, controlPoints[i].y, 0); } // else glVertex3f(controlPoints[i].x, controlPoints[i].y, 0); } // for glEnd(); } // drawSurface
void WarpPerspectiveBilinear::draw( bool controls ) { // apply perspective transform gl::pushModelMatrix(); gl::multModelMatrix( mWarp->getTransform() ); // draw bilinear warp WarpBilinear::draw( false ); // restore transform gl::popModelMatrix(); // draw edit interface if( isEditModeEnabled() ) { if( controls && mSelected < mPoints.size() ) { // draw control points for( unsigned i = 0; i < mPoints.size(); ++i ) queueControlPoint( getControlPoint( i ) * mWindowSize, mSelected == i ); drawControlPoints(); } } }
void GuiFunctionBox::render(RenderDevice* rd, const GuiThemeRef& skin) const { GuiFunctionBox* me = const_cast<GuiFunctionBox*>(this); me->m_clipBounds = skin->canvasToClientBounds(m_rect, m_captionSize); int shrink = 4; // Shrink bounds slightly so that we can see axes and points rendered against the edge me->m_bounds = Rect2D::xywh(m_clipBounds.x0y0() + Vector2(shrink, shrink), m_clipBounds.wh() - Vector2(shrink, shrink) * 2); // Use textbox borders skin->renderCanvas(m_rect, m_enabled, focused(), m_caption, m_captionSize); me->m_scale.x = (m_maxTime - m_minTime) / m_bounds.width(); me->m_scale.y = (m_maxValue - m_minValue) / m_bounds.height(); static int count = 0; count = (count + 1) % 10; if (count == 0) { // Make sure that the spline hasn't been corrupted by the // program since we last checked it. Avoid doing this every // frame, however. me->clampTimes(m_selected); me->clampValues(); } skin->pauseRendering(); { // Scissor region ignores transformation matrix const CoordinateFrame& matrix = rd->objectToWorldMatrix(); rd->setClip2D(m_clipBounds + matrix.translation.xy()); drawBackground(rd, skin); drawSpline(rd, skin); drawControlPoints(rd, skin); } skin->resumeRendering(); }
void Circle::draw(QImage *img) { drawCircle(img); drawControlPoints(img); }
/** * Draws the 3D model to the screen, including the subdivision. Determines if * the user wanted a wireframe or solid model to be drawn as well as whether or * not the user wanted to view control points (only in wireframe mode). * * Limitations: vertical and horizontal subdivision are exclusive. */ void draw3DModel(void) { int drawMode = GL_LINE_LOOP; int index; int index2; glDisable(GL_LIGHTING); subdivideHorizontal(false); if (showControlPoints) { drawControlPoints(); return; } // if glColor3fv(lineColor); if (displayMode == SOLID_FRAME) { glEnable(GL_LIGHTING); drawMode = GL_POLYGON; } // if else if (displayMode == WIRE_FRAME) { drawMode = GL_LINE_LOOP; } // else if else { drawMode = GL_LINE_LOOP; } // else // if (subdiv_h > 0) { for (int i = 0; i < numSub_hPoints - 1; i++) { for (int j = 0; j < numSub_vPoints; j++) { index = (j % numSub_vPoints) * numSub_hPoints + i; index2 = ((j + 1) % (numSub_vPoints)) * numSub_hPoints + i; struct point bot_right = sub_hVertices[index]; struct point bot_left = sub_hVertices[index + 1]; struct point top_right = sub_hVertices[index2]; struct point top_left = sub_hVertices[index2 + 1]; glBegin(drawMode); // if (shadingMode == PHONG_SHADING) { struct point normal = crossAndNormal(bot_right, top_right); glNormal3f(normal.x, normal.y, normal.z); // } // if // // else { // glNormal3f(0.0, 0.0, 1.0); // } // else glVertex3f(bot_right.x, bot_right.y, bot_right.z); glVertex3f(top_right.x, top_right.y, top_right.z); glVertex3f(top_left.x, top_left.y, top_left.z); glVertex3f(bot_left.x, bot_left.y, bot_left.z); glEnd(); } // for } // for // } // if // else { // for (int j = 0; j < 3; j++) { // for (int i = 0; i < numSub_vPoints - 1; i++) { // index = i + (j % 3) * numSub_vPoints; // index2 = i + ((j + 1) % 3) * numSub_vPoints; // // glBegin(drawMode); // // if (shadingMode == PHONG_SHADING) { // struct point normal = crossAndNormal(threeDModelVertices[index], threeDModelVertices[index + 1]); // // glNormal3f(normal.x, normal.y, normal.z); // } // if // // else { // glNormal3f(0.0, 0.0, 1.0); // } // else // // glVertex3f(threeDModelVertices[index].x, // threeDModelVertices[index].y, threeDModelVertices[index].z); // glVertex3f(threeDModelVertices[index + 1].x, // threeDModelVertices[index + 1].y, threeDModelVertices[index + 1].z); // // glVertex3f(threeDModelVertices[index2 + 1].x, // threeDModelVertices[index2 + 1].y, threeDModelVertices[index2 + 1].z); // glVertex3f(threeDModelVertices[index2].x, // threeDModelVertices[index2].y, threeDModelVertices[index2].z); // glEnd(); // } // for // } // for // } // else } // draw3DModel