31 #include "transformation-matrix.hh"
34 using namespace GMap3d;
40 FParameterPreview (APreview),
41 FParameterPosition (APosition),
42 FParameterCreation (AParams),
43 FParameterPolylinePosition(APolylinePosition)
45 assert(FParameterPreview != NULL);
46 assert(FParameterPosition != NULL);
47 assert(FParameterCreation != NULL);
48 assert(FParameterPolylinePosition != NULL);
60 (APrecompile.FParameterPreview->copy())),
61 FParameterPosition (APrecompile.FParameterPosition),
62 FParameterCreation (APrecompile.FParameterCreation),
63 FParameterPolylinePosition(APrecompile.FParameterPolylinePosition)
65 assert(FParameterPreview != NULL);
66 assert(FParameterPosition != NULL);
67 assert(FParameterCreation != NULL);
68 assert(FParameterPolylinePosition != NULL);
93 setPreview(static_cast<CParameterPreview *>(AParameter));
96 setPosition(static_cast<CParameterObjectPosition *>(AParameter));
99 setCreation(static_cast<CParameterCreation *>(AParameter));
108 {
return FParameterPreview; }
112 assert(APreview != NULL);
115 FParameterPreview = APreview;
121 assert(APosition != NULL);
124 FParameterPosition = APosition;
130 assert(ACreation != NULL);
133 FParameterCreation = ACreation;
140 assert(APolylinePosition != NULL);
143 FParameterPolylinePosition = APolylinePosition;
152 if ( AMode!=FCurrentMode )
154 FCurrentMode = AMode;
181 CTransformationMatrix globalMatrix =
186 V =
new CVertex*[P+1];
188 V[i] =
new CVertex[M];
190 CVertex vertex((OX-OZ) / 2);
191 CTransformationMatrix rotationMatrix(CTransformationMatrix::IdentityMatrix);
192 rotationMatrix.rotate(OZ, 360.0/M);
199 globalMatrix.applyOn(V[j][i]);
205 rotationMatrix.applyOn(vertex);
216 LINE(&V[0][i],&V[P][i]);
223 glBegin(GL_LINE_LOOP);
232 TCoordinate x[2],y[2];
236 int k0 = (1+4*i)*M/8;
238 TCoordinate x1= dCos(360.0/M* k0 );
239 TCoordinate y1= dSin(360.0/M* k0 );
240 TCoordinate x2= dCos(360.0/M*(k0+1));
241 TCoordinate y2= dSin(360.0/M*(k0+1));
243 TCoordinate t = (x1-y1) / (x1-x2+y2-y1);
245 x[i] = (x1 + t*(x2-x1)) / 2;
246 y[i] = (y1 + t*(y2-y1)) / 2;
257 v0.setXYZ(x[0], y[0],-0.5); globalMatrix.applyOn(v0);
258 v1.setXYZ(x[1], y[1],-0.5); globalMatrix.applyOn(v1);
LINE(& v0, & v1);
259 v0.setXYZ(x[0],-y[0],-0.5); globalMatrix.applyOn(v0);
260 v1.setXYZ(x[1],-y[1],-0.5); globalMatrix.applyOn(v1);
LINE(& v0, & v1);
265 v0.setXYZ(x[0], y[0], 0.5); globalMatrix.applyOn(v0);
266 v1.setXYZ(x[1], y[1], 0.5); globalMatrix.applyOn(v1);
LINE(& v0, & v1);
267 v0.setXYZ(x[0],-y[0], 0.5); globalMatrix.applyOn(v0);
268 v1.setXYZ(x[1],-y[1], 0.5); globalMatrix.applyOn(v1);
LINE(& v0, & v1);
303 drawMesh1(globalMatrix, -OX/2, OX, mesh<1 ? 1 : sx);
312 drawMesh1(globalMatrix, (-OX-OY)/2, OX, 1);
313 drawMesh1(globalMatrix, (+OX-OY)/2, OY, 1);
314 drawMesh1(globalMatrix, (-OX+OY)/2, OX, 1);
315 drawMesh1(globalMatrix, (-OX-OY)/2, OY, 1);
319 drawMesh1(globalMatrix, (-OX-OY)/2, OX, sx);
320 drawMesh1(globalMatrix, (+OX-OY)/2, OY, sy);
321 drawMesh1(globalMatrix, (-OX+OY)/2, OX, sx);
322 drawMesh1(globalMatrix, (-OX-OY)/2, OY, sy);
326 drawMesh2(globalMatrix, -(OX+OY)/2, OX, sx, OY, sy);
341 drawMesh1(globalMatrix, (-OX-OY-OZ)/2, OZ, sz);
342 if ((F & CUBE_X1) || (F &
CUBE_Y2))
343 drawMesh1(globalMatrix, (-OX+OY-OZ)/2, OZ, sz);
344 if ((F &
CUBE_X2) || (F & CUBE_Y1))
345 drawMesh1(globalMatrix, (+OX-OY-OZ)/2, OZ, sz);
346 if ((F & CUBE_X2) || (F & CUBE_Y2))
347 drawMesh1(globalMatrix, (+OX+OY-OZ)/2, OZ, sz);
349 if ((F & CUBE_X1) || (F &
CUBE_Z1))
350 drawMesh1(globalMatrix, (-OX-OY-OZ)/2, OY, sy);
351 if ((F & CUBE_X1) || (F &
CUBE_Z2))
352 drawMesh1(globalMatrix, (-OX-OY+OZ)/2, OY, sy);
353 if ((F & CUBE_X2) || (F & CUBE_Z1))
354 drawMesh1(globalMatrix, (+OX-OY-OZ)/2, OY, sy);
355 if ((F & CUBE_X2) || (F & CUBE_Z2))
356 drawMesh1(globalMatrix, (+OX-OY+OZ)/2, OY, sy);
358 if ((F & CUBE_Y1) || (F & CUBE_Z1))
359 drawMesh1(globalMatrix, (-OX-OY-OZ)/2, OX, sx);
360 if ((F & CUBE_Y1) || (F & CUBE_Z2))
361 drawMesh1(globalMatrix, (-OX-OY+OZ)/2, OX, sx);
362 if ((F & CUBE_Y2) || (F & CUBE_Z1))
363 drawMesh1(globalMatrix, (-OX+OY-OZ)/2, OX, sx);
364 if ((F & CUBE_Y2) || (F & CUBE_Z2))
365 drawMesh1(globalMatrix, (-OX+OY+OZ)/2, OX, sx);
370 drawMesh2(globalMatrix, (-OX-OY-OZ)/2, OY, sy, OZ, sz);
372 drawMesh2(globalMatrix, (+OX-OY-OZ)/2, OY, sy, OZ, sz);
375 drawMesh2(globalMatrix, (-OX-OY-OZ)/2, OX, sx, OZ, sz);
377 drawMesh2(globalMatrix, (-OX+OY-OZ)/2, OX, sx, OZ, sz);
380 drawMesh2(globalMatrix, (-OX-OY-OZ)/2, OX, sx, OY, sy);
382 drawMesh2(globalMatrix, (-OX-OY+OZ)/2, OX, sx, OY, sy);
386 drawMesh3(globalMatrix, -(OX+OY+OZ)/2, OX, sx, OY, sy, OZ, sz);
397 v[0][0][0] = (-OX-OY-OZ)/2; v[1][0][0]= (+OX-OY-OZ)/2;
398 v[0][0][1] = (-OX-OY+OZ)/2; v[1][0][1]= (+OX-OY+OZ)/2;
399 v[0][1][0] = (-OX+OY-OZ)/2; v[1][1][0]= (+OX+OY-OZ)/2;
400 v[0][1][1] = (-OX+OY+OZ)/2; v[1][1][1]= (+OX+OY+OZ)/2;
402 for (
int i=0; i<8; ++i)
403 globalMatrix.applyOn(v[i/4][(i/2)%2][i%2]);
412 if (sy==1 && sz==1 &&
415 LINE(& v[0][0][0], & v[0][1][1]);
416 LINE(& v[0][0][1], & v[0][1][0]);
419 if (sy==1 && sz==1 &&
420 (!(F &
CUBE_X2)) && ((F & CUBE_RING_X)==CUBE_RING_X))
422 LINE(& v[1][0][0], & v[1][1][1]);
423 LINE(& v[1][0][1], & v[1][1][0]);
426 if (sx==1 && sz==1 &&
429 LINE(& v[0][0][0], & v[1][0][1]);
430 LINE(& v[0][0][1], & v[1][0][0]);
433 if (sx==1 && sz==1 &&
434 (!(F &
CUBE_Y2)) && ((F & CUBE_RING_Y)==CUBE_RING_Y))
436 LINE(& v[0][1][0], & v[1][1][1]);
437 LINE(& v[0][1][1], & v[1][1][0]);
440 if (sx==1 && sy==1 &&
443 LINE(& v[0][0][0], & v[1][1][0]);
444 LINE(& v[0][1][0], & v[1][0][0]);
447 if (sx==1 && sy==1 &&
448 (!(F &
CUBE_Z2)) && ((F & CUBE_RING_Z)==CUBE_RING_Z))
450 LINE(& v[0][0][1], & v[1][1][1]);
451 LINE(& v[0][1][1], & v[1][0][1]);
474 glBegin(GL_LINE_LOOP);
476 CTransformationMatrix matrix(CTransformationMatrix::IdentityMatrix);
477 matrix.rotate(OZ, 360.0/n);
480 for (
int i=0; i<n; ++i)
483 globalMatrix.applyOn(V);
494 glBegin(GL_LINE_LOOP);
496 CTransformationMatrix matrix(CTransformationMatrix::IdentityMatrix);
497 matrix.rotate(OZ, 90.0);
499 CVertex x((OX-OY)/2);
500 for (
int i=0; i<4; ++i)
503 globalMatrix.applyOn(V);
525 glBegin(GL_LINE_STRIP);
527 for (
unsigned int i=0; i<FParameterPolylinePosition->
getNbVertices(); ++i)
544 CVertex top(OZ/2); globalMatrix.applyOn(top);
545 CVertex** V =
new CVertex* [P];
547 V[i] =
new CVertex[M];
549 CTransformationMatrix rotationMatrix(CTransformationMatrix::IdentityMatrix);
550 rotationMatrix.rotate(OZ, 360.0/M);
554 CVertex vertex = (0.5*(P-j)/P)*OX + (((float) j)/P-0.5)*OZ;
559 globalMatrix.applyOn(V[j][i]);
560 rotationMatrix.applyOn(vertex);
563 vertex += OZ / (P+1);
579 LINE(& V[j][i], & V[j][(i+1)%M]);
584 TCoordinate x[2],y[2];
588 int k0 = (1+4*i)*M/8;
590 TCoordinate x1 = dCos(360.0/M* k0 )/2;
591 TCoordinate y1 = dSin(360.0/M* k0 )/2;
592 TCoordinate x2 = dCos(360.0/M*(k0+1))/2;
593 TCoordinate y2 = dSin(360.0/M*(k0+1))/2;
595 TCoordinate t = (x1-y1) / (x1-x2+y2-y1);
597 x[i] = x1 + t*(x2-x1);
598 y[i] = y1 + t*(y2-y1);
609 v0.setXYZ(x[0], y[0],-0.5); globalMatrix.applyOn(v0);
610 v1.setXYZ(x[1], y[1],-0.5); globalMatrix.applyOn(v1);
LINE(& v0, & v1);
611 v0.setXYZ(x[0],-y[0],-0.5); globalMatrix.applyOn(v0);
612 v1.setXYZ(x[1],-y[1],-0.5); globalMatrix.applyOn(v1);
LINE(& v0, & v1);
633 CVertex south= -OZ/2; globalMatrix.applyOn(south);
634 CVertex north= +OZ/2; globalMatrix.applyOn(north);
637 CVertex** grid =
new CVertex*[P];
639 grid[i] =
new CVertex[M];
641 CTransformationMatrix matrix(CTransformationMatrix::IdentityMatrix);
642 matrix.rotate(OZ, 360.0 / M);
646 TCoordinate alpha = 180.0*(j+1)/(P+1) - 90.0;
648 CVertex v = dCos(alpha) / 2 * OX + dSin(alpha) / 2 * OZ;
653 globalMatrix.applyOn(grid[j][i]);
665 glBegin(GL_LINE_STRIP);
678 glBegin(GL_LINE_LOOP);
703 float _R_ = 1/(1+k)/2;
704 float R_ = k/(1+k)/2;
707 CTransformationMatrix matrix1(CTransformationMatrix::IdentityMatrix);
708 CTransformationMatrix matrix2(CTransformationMatrix::IdentityMatrix);
709 CTransformationMatrix matrix3(CTransformationMatrix::IdentityMatrix);
711 matrix1.rotate(OY, 360.0 / P);
712 matrix2.translate(_R_ * OX);
713 matrix3.rotate(OZ, 360.0 / M);
715 CVertex vertex1(R_ * OX);
716 CVertex** grid =
new CVertex*[P];
718 grid[i] =
new CVertex[M];
722 CVertex vertex2(vertex1);
723 matrix2.applyOn(vertex2);
727 grid[j][i] = vertex2;
728 globalMatrix.applyOn(grid[j][i]);
729 matrix3.applyOn(vertex2);
732 matrix1.applyOn(vertex1);
742 glBegin(GL_LINE_LOOP);
753 glBegin(GL_LINE_LOOP);
769 const CVertex & AOrigin,
770 const CVertex & AVector,
int ASx)
776 CVertex current = AOrigin;
777 CVertex dx = AVector / ASx;
779 for (
int i=0; i<=ASx; ++i, current += dx)
781 v1 = current -
K*OX; AMatrix.applyOn(v1);
782 v2 = current +
K*OX; AMatrix.applyOn(v2);
LINE(&v1,&v2);
784 v1 = current -
K*OY; AMatrix.applyOn(v1);
785 v2 = current +
K*OY; AMatrix.applyOn(v2);
LINE(&v1,&v2);
787 v1 = current -
K*OZ; AMatrix.applyOn(v1);
788 v2 = current +
K*OZ; AMatrix.applyOn(v2);
LINE(&v1,&v2);
792 v1 = AOrigin ; AMatrix.applyOn(v1);
793 v2 = AOrigin + AVector; AMatrix.applyOn(v2);
LINE(&v1,&v2);
799 const CVertex & AOrigin,
800 const CVertex & AVectorX,
int ASx,
801 const CVertex & AVectorY,
int ASy)
805 CVertex dx = AVectorX / ASx;
806 CVertex dy = AVectorY / ASy;
811 for (
int i=0; i<=ASx; ++i, current += dx)
813 v1 = current ; AMatrix.applyOn(v1);
814 v2 = current + AVectorY; AMatrix.applyOn(v2);
LINE(& v1, & v2);
818 for (
int j=0; j<=ASy; ++j, current += dy)
820 v1 = current ; AMatrix.applyOn(v1);
821 v2 = current + AVectorX; AMatrix.applyOn(v2);
LINE(& v1, & v2);
826 const CVertex & AOrigin,
827 const CVertex & AVectorX,
int ASx,
828 const CVertex & AVectorY,
int ASy,
829 const CVertex & AVectorZ,
int ASz)
833 CVertex dx = AVectorX / ASx;
834 CVertex dy = AVectorY / ASy;
835 CVertex dz = AVectorZ / ASz;
837 CVertex currentX, currentY, currentZ;
841 for (i=0; i<=ASx; ++i, currentX += dx)
845 for (j=0; j<=ASy; ++j, currentY += dy)
847 v1 = currentY ; AMatrix.applyOn(v1);
848 v2 = currentY + AVectorZ; AMatrix.applyOn(v2);
LINE(& v1, & v2);
853 for (i=0; i<=ASx; ++i, currentX += dx)
857 for (k=0; k<=ASz; ++k, currentZ += dz)
859 v1 = currentZ ; AMatrix.applyOn(v1);
860 v2 = currentZ + AVectorY; AMatrix.applyOn(v2);
LINE(& v1, & v2);
865 for (j=0; j<=ASy; ++j, currentY += dy)
869 for (k=0; k<=ASz; ++k, currentZ += dz)
871 v1 = currentZ ; AMatrix.applyOn(v1);
872 v2 = currentZ + AVectorX; AMatrix.applyOn(v2);
LINE(& v1, & v2);