From 018e365547e053e21d0d36f18fd01f484e4e8b85 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Tue, 23 Jan 2007 22:54:42 +0000 Subject: [PATCH] Percentual painting works better now, but has still problems --- src/meshlabplugins/editpaint/editpaint.cpp | 203 +++++++++++---------- src/meshlabplugins/editpaint/editpaint.h | 9 +- 2 files changed, 110 insertions(+), 102 deletions(-) diff --git a/src/meshlabplugins/editpaint/editpaint.cpp b/src/meshlabplugins/editpaint/editpaint.cpp index ee328d0c8..0ef3982a7 100755 --- a/src/meshlabplugins/editpaint/editpaint.cpp +++ b/src/meshlabplugins/editpaint/editpaint.cpp @@ -26,7 +26,7 @@ //TODO better to vertex painting switch //TODO bits instead of hashtables //TODO PaintToolbox does not close -//TODO lines problem with percentual painting SOLVED BUT BLAH +//TODO lines problem with percentual painting ----------- SOLVED: ------------ //TODO first paint hang problem -- PROBALLY SOLVED, not shure //TODO trackball zbuffer problem OK @@ -148,11 +148,11 @@ void EditPaintPlugin::mouseMoveEvent(QAction *,QMouseEvent * event, MeshModel &/ //qDebug("mouseMoveEvent: ----"); } else { - gla->makeCurrent(); + /*gla->makeCurrent(); glDrawBuffer(GL_FRONT); DrawXORRect(gla,true); glDrawBuffer(GL_BACK); - glFlush(); + glFlush();*/ } //qDebug() << "moveEnd" << endl; } @@ -172,10 +172,6 @@ void EditPaintPlugin::mouseReleaseEvent (QAction *,QMouseEvent * event, MeshMod } void calcCoord(float x,float y,float z,double matrix[],double *xr,double *yr,double *zr) { - //Dreif num; - //float x=orig.x; - //float y=orig.y; - //float z=orig.z; *xr=x*matrix[0]+y*matrix[4]+z*matrix[8]+matrix[12]; *yr=x*matrix[1]+y*matrix[5]+z*matrix[9]+matrix[13]; *zr=x*matrix[2]+y*matrix[6]+z*matrix[10]+matrix[14]; @@ -194,7 +190,7 @@ void getInv(double orig[],double inv[]) { } -void EditPaintPlugin::DrawXORRect(GLArea * gla, bool doubleDraw) { +void EditPaintPlugin::DrawXORRect(MeshModel &m,GLArea * gla, bool doubleDraw) { int PEZ=18; if (paintType()==1) { glMatrixMode(GL_PROJECTION); @@ -255,31 +251,10 @@ void EditPaintPlugin::DrawXORRect(GLArea * gla, bool doubleDraw) { updateMatrixes(); QPoint mid= QPoint(cur.x(),gla->curSiz.height()-cur.y()); - gluUnProject ((double) mid.x(), mid.y(), 0.0, mvmatrix, projmatrix, viewport, &dX, &dY, &dZ); - //pos_maus = Dreif ( (float) dX, (float) dY, (float) dZ ); - gluUnProject ((double) mid.x(), mid.y(), 1.0, mvmatrix, projmatrix, viewport, &dX2, &dY2, &dZ2); - //pos_maus2 = Dreif ( (float) dX, (float) dY, (float) dZ ); - - - glPushAttrib(GL_ENABLE_BIT); - // glDisable(GL_DEPTH_TEST); - glDisable(GL_LIGHTING); - glDisable(GL_TEXTURE_2D); - glEnable(GL_COLOR_LOGIC_OP); - glLogicOp(GL_XOR); - glColor3f(1,1,1); - - /*for (int lauf=0; lauf=1)qDebug() <<"OK: "<< pix_x << " "<=0 && (int)pix_x=0 && (int)pix_y0) { + circle_points[lauf]=QPoint(pix_x,inv_yy); + //lauf2=1000; + break; + } + } + if (lauf2==STEPS-1 /*|| pix_z>=1*/) { circle_points[lauf]=QPoint(pix_x,inv_yy); break; } + } + } + glEnd(); - glPopAttrib();*/ - //TTTTTTEEEEEEEEESSSSSSSSSSSTTTTTTTTTTTTTT EEEEEEEENNNNNNNDDDDDDDDDEEEEEEEEE + glDisable(GL_COLOR_LOGIC_OP); + glPopAttrib(); + + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0,gla->curSiz.width(),gla->curSiz.height(),0,-1,1); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + glPushAttrib(GL_ENABLE_BIT); + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + glDisable(GL_TEXTURE_2D); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE); + //Color4b co=paintbox->getColor(curr_mouse); + //qDebug() << co[0] << " " << co[1] << " " << co[2] << endl; + glBegin(GL_TRIANGLES); + glColor4d(1,1,1,0.1); + for (int lauf=0; laufcurSiz.height()-mid.y()); + glVertex2f(circle_points[lauf].x(),circle_points[lauf].y()); + glVertex2f(circle_points[(lauf+1)%PEZ].x(),circle_points[(lauf+1)%PEZ].y()); + } + glEnd(); + glDisable(GL_BLEND); + glEnable(GL_COLOR_LOGIC_OP); + glLogicOp(GL_XOR); + glColor3f(1,1,1); + glBegin(GL_LINE_STRIP); + for (int lauf=0; lauf0; return (b.x()-a.x())*(c.y()-a.y())-(b.y()-a.y())*(c.x()-a.x())>0; } @@ -483,7 +491,7 @@ void getInternFaces(MeshModel & m,vector *actual,vectorV(lauf)->P()[0],(fac)->V(lauf)->P()[1],(fac)->V(lauf)->P()[2],mvmatrix,projmatrix,viewport,&tx,&ty,&tz); p[lauf]=QPointF(tx,ty); //qDebug() << "zzz: "<<(int)(((int)ty)*old_size.x()+(int)tx)<<" t: "<=0 && tx=0 && ty<=old_size.y()) + if (tx>=0 && tx=0 && ty *actual,vector *actual,vector *actual,vector *actual,vectorV(lauf)->P()[0],(fac)->V(lauf)->P()[1],(fac)->V(lauf)->P()[2],mvmatrix,projmatrix,viewport,&tx,&ty,&tz); //p[lauf]=QPointF(dx,dy); p[lauf]=QPointF(tx,ty); - if (tx>=0 && tx=0 && ty<=old_size.y()) + if (tx>=0 && tx=0 && ty *actual,vectorV(lauf)->P()[0],(fac)->V(lauf)->P()[1],(fac)->V(lauf)->P()[2],mvmatrix2,&a,&b,&c); gluProject((fac)->V(lauf)->P()[0],(fac)->V(lauf)->P()[1],(fac)->V(lauf)->P()[2],mvmatrix,projmatrix,viewport,&tx,&ty,&tz); - z[lauf]=QPointF(tz,(GLfloat)pixels[(int)(((int)ty)*old_size.x()+(int)tx)]); + if (tx>=0 && tx=0 && tyV(lauf)->P()[0],(fac)->V(lauf)->P()[1],(fac)->V(lauf)->P()[2],mvmatrix,projmatrix,viewport,&tx,&ty,&tz); //p[lauf]=QPointF(tx,ty); @@ -596,8 +607,8 @@ void getInternFaces(MeshModel & m,vector *actual,vectortrackball.track.sca*/radius)==1) { //THE 2*190 should not be a constant !!! - if (isIn(mid,mid_prev,tx,ty,pen.radius*1.0*scale_fac*190.0*4.0*1.0/distance[lauf])==1) { - //if (isIn(QPoint(0,0),QPoint(0,0),tx,ty,radius)==1) { + if (isIn(mid,mid_prev,tx,ty,pen.radius*scale_fac*viewport[3]*0.88/distance[lauf])==1) { + //if (isIn(QPoint(0,0),QPoint(0,0),tx,ty,pen.radius)==1) { intern=true; if (!sel_vert.contains(fac->V(lauf))) { risult->push_back(fac->V(lauf)); @@ -743,7 +754,7 @@ void EditPaintPlugin::Decorate(QAction * ac, MeshModel &m, GLArea * gla) { case PEN: {} } - DrawXORRect(gla,false); + DrawXORRect(m,gla,false); pen.painttype=paintType(); pen.backface=paintbox->getPaintBackface(); diff --git a/src/meshlabplugins/editpaint/editpaint.h b/src/meshlabplugins/editpaint/editpaint.h index b1bb33529..5c105ef8e 100755 --- a/src/meshlabplugins/editpaint/editpaint.h +++ b/src/meshlabplugins/editpaint/editpaint.h @@ -107,9 +107,9 @@ private: bool first; QPoint old_size; - int inverse_y; // gla->curSiz.height() + int inverse_y; // gla->curSiz.height()-cur.y() int paintType(); - void DrawXORRect(GLArea * gla, bool doubleDraw); + void DrawXORRect(MeshModel &m,GLArea * gla, bool doubleDraw); //void getInternFaces(vector *actual,vector * risult, GLArea * gla); bool getFaceAtMouse(MeshModel &,CMeshO::FacePointer &); @@ -125,9 +125,8 @@ private: glGetDoublev (GL_PROJECTION_MATRIX, projmatrix); /*for (int lauf=0; lauf<4; lauf++) { qDebug() <