home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 4 / CD_Magazyn_EXEC_nr_4.iso / Recent / dev / c / GSys.lha / gsys / g3d / G3DPolygon.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-10-01  |  14.8 KB  |  728 lines

  1.  
  2. /* Author Anders Kjeldsen */
  3.  
  4. #ifndef G3DPOLYGON_CPP
  5. #define G3DPOLYGON_CPP
  6.  
  7. #include "g3d/G3DPolygon.h"
  8.  
  9. GPolygon::GPolygon()
  10. {
  11.     memset((void *)this, 0, sizeof (class G3DPolygon));
  12.     Visible = TRUE;
  13.     GSortNode.SetData((void *)this);
  14. }
  15.  
  16. GPolygon::~GPolygon()
  17. {
  18.     if (GPolygonA) delete GPolygonA;
  19.     if (GPolygonB) delete GPolygonB;
  20. }
  21.  
  22. BOOL G3DPolygon::ClipZ(float ClipValue, BOOL RightSide )    /* Clip polygon through CHOSEN Z-value */
  23. {
  24.         class G3DVertex PA;
  25.         class G3DVertex PB;
  26.         class G3DVertex *PC = NULL;
  27.         class G3DVertex *PD = NULL;
  28.  
  29.         class G3DVertex *V1 = (class G3DVertex *)&Polygon.v1;
  30.         class G3DVertex *V2 = (class G3DVertex *)&Polygon.v2;
  31.         class G3DVertex *V3 = (class G3DVertex *)&Polygon.v3;
  32. //        class G3DVertex *V1 = &GVertex1;
  33. //        class G3DVertex *V2 = &GVertex2;
  34. //        class G3DVertex *V3 = &GVertex3;
  35.  
  36.         class G3DVector VA;
  37.         class G3DVector VB;
  38.  
  39.         ClippedA = FALSE;
  40.         ClippedB = FALSE;
  41.         Visible = TRUE;
  42.  
  43.  
  44.         if (RightSide == HIGHER)    /* The Point Z should be HIGHER than the ClipValue? */
  45.         {
  46.             if (V1->Z < ClipValue)                     /* CLIP FIRST POINT? */
  47.             { 
  48.                 PC = V2;
  49.                 PD = V3;
  50.  
  51.                 if (V2->Z < ClipValue)                 /* CLIP FIRST SECOND POINT ASWELL? */
  52.                 { 
  53.                     if (V3->Z < ClipValue)             /* CLIP ALL POINTS? */
  54.                     {
  55.                         Visible = FALSE;
  56.                         return TRUE;
  57.                     }
  58.                     else
  59.                     {
  60.                         PC = V3;
  61.                         PD = NULL;
  62.                         ClipLineZ(V2, V3, &PA, &VA, ClipValue);
  63.                     }
  64.                 }
  65.                 else 
  66.                 {
  67.                     ClipLineZ(V1, V2, &PA, &VA, ClipValue);
  68.                 }
  69.  
  70.                 if (V3->Z < ClipValue)
  71.                 { 
  72.                     PC = V2;
  73.                     PD = NULL;
  74.                     ClipLineZ(V3, V2, &PB, &VB, ClipValue);
  75.                 }
  76.                 else 
  77.                 {
  78.                     ClipLineZ(V1, V3, &PB, &VB, ClipValue);
  79.                 }
  80.             }
  81.  
  82.  
  83.             else if (V2->Z < ClipValue)
  84.             { 
  85.                 PC = V1;
  86.                 PD = V3;
  87.  
  88.                 ClipLineZ(V2, V1, &PA, &VA, ClipValue);
  89.  
  90.                 if (V3->Z < ClipValue)
  91.                 { 
  92. //                    PD = V1;
  93. //                    PC = NULL;
  94.                     PD = NULL;
  95.                 
  96.                     ClipLineZ(V3, V1, &PB, &VB, ClipValue);
  97.                 }
  98.                 else 
  99.                 {
  100.                     ClipLineZ(V2, V3, &PB, &VB, ClipValue);
  101.                 }
  102.             }
  103.  
  104.             else if (V3->Z < ClipValue) // clip first point
  105.             { 
  106.                 PC = V1;
  107.                 PD = V2;
  108.                 ClipLineZ(V3, V1, &PA, &VA, ClipValue);
  109.                 ClipLineZ(V3, V2, &PB, &VB, ClipValue);    
  110.  
  111.             }
  112.             else
  113.             {
  114.                 ClippedA = ClippedB = FALSE;
  115.                 V1->CopyVertex((class G3DVertex *)&Polygon.v1);
  116.                 V2->CopyVertex((class G3DVertex *)&Polygon.v2);
  117.                 V3->CopyVertex((class G3DVertex *)&Polygon.v3);
  118.                 return TRUE;
  119.             } 
  120.             
  121.         }
  122.         else
  123.         {
  124.             if (V1->Z > ClipValue)                     /* CLIP FIRST POINT? */
  125.             { 
  126.  
  127.                 PC = V2;
  128.                 PD = V3;
  129.  
  130.                 if (V2->Z > ClipValue)                 /* CLIP FIRST SECOND POINT ASWELL? */
  131.                 { 
  132.                     if (V3->Z > ClipValue)             /* CLIP ALL POINTS? */
  133.                     {
  134.                         Visible = FALSE;
  135.                         return TRUE;
  136.                     }
  137.                     else
  138.                     {
  139.                         PC = V3;
  140.                         PD = NULL;
  141.                         ClipLineZ(V2, V3, &PA, &VA, ClipValue);
  142.                     }
  143.                 }
  144.                 else ClipLineZ(V1, V2, &PA, &VA, ClipValue);
  145.  
  146.  
  147.                 if (V3->Z > ClipValue)
  148.                 { 
  149.                     PC = V2;
  150.                     PD = NULL;
  151.                     ClipLineZ(V3, V2, &PB, &VB, ClipValue);
  152.                 }
  153.                 else ClipLineZ(V1, V3, &PB, &VB, ClipValue);
  154.             }
  155.  
  156.  
  157.  
  158.             else if (V2->Z > ClipValue)
  159.             { 
  160.                 PC = V1;
  161.                 PD = V3;
  162.  
  163.                 ClipLineZ(V2, V1, &PA, &VA, ClipValue);
  164.  
  165.                 if (V3->Z < ClipValue)
  166.                 { 
  167.                     PD = NULL;
  168.                     ClipLineZ(V3, V1, &PB, &VB, ClipValue);
  169.                 }
  170.                 else ClipLineZ(V2, V3, &PB, &VB, ClipValue);
  171.             }
  172.  
  173.             else if (V3->Z > ClipValue) // clip first point
  174.             { 
  175.                 PC = V1;
  176.                 PD = V2;
  177.  
  178.                 ClipLineZ(V3, V1, &PA, &VA, ClipValue);
  179.                 ClipLineZ(V3, V2, &PB, &VB, ClipValue);    
  180.             }
  181.             else 
  182.             {
  183.                 ClippedA = ClippedB = FALSE;
  184.                 V1->CopyVertex((class G3DVertex *)&Polygon.v1);
  185.                 V2->CopyVertex((class G3DVertex *)&Polygon.v2);
  186.                 V3->CopyVertex((class G3DVertex *)&Polygon.v3);
  187.                 return TRUE;
  188.             }
  189.  
  190.         }
  191.  
  192.         if (PC)
  193.         {
  194.             if (!GPolygonA) GPolygonA = new G3DPolygon();
  195.             
  196.             ClippedA = TRUE;
  197.             PC->CopyVertex((class G3DVertex *)&GPolygonA->Polygon.v1);
  198.             PA.CopyVertex((class G3DVertex *)&GPolygonA->Polygon.v2);
  199.             PB.CopyVertex((class G3DVertex *)&GPolygonA->Polygon.v3);
  200.         
  201.             if (PD)
  202.             {
  203.                 if (!GPolygonB) GPolygonB = new G3DPolygon();
  204.                 ClippedB = TRUE;
  205.  
  206.                 PC->CopyVertex((class G3DVertex *)&GPolygonB->Polygon.v1);
  207.                 PB.CopyVertex((class G3DVertex *)&GPolygonB->Polygon.v2);
  208.                 PD->CopyVertex((class G3DVertex *)&GPolygonB->Polygon.v3);
  209.  
  210.                 return TRUE;
  211.             }
  212.             return TRUE;
  213.         }
  214.         else if (PD)
  215.         {
  216.             if (!GPolygonA) GPolygonA = new G3DPolygon();
  217.  
  218.             ClippedA = TRUE;
  219.             PD->CopyVertex((class G3DVertex *)&GPolygonA->Polygon.v1);
  220.             PA.CopyVertex((class G3DVertex *)&GPolygonA->Polygon.v2);
  221.             PB.CopyVertex((class G3DVertex *)&GPolygonA->Polygon.v3);
  222.  
  223.  
  224.             return TRUE;
  225.         }
  226.         return TRUE;
  227. }
  228.  
  229.  
  230. BOOL G3DPolygon::ClipLineX(class G3DVertex *P1, class G3DVertex *P2, class G3DVertex *PD, class G3DVector *V, float ClipValue)
  231. {
  232.     V->Init(P1, P2);
  233.     V->DivideByX();
  234.     V->Multiply(ClipValue - P1->X);
  235.     P1->CopyVertex(PD);
  236.     PD->AddVector(V);
  237.     return TRUE;
  238. } /* Point (x, y, z) will be placed on the position where X == ClipValue (what you want it to be) */
  239.  
  240. BOOL G3DPolygon::ClipLineY(class G3DVertex *P1, class G3DVertex *P2, class G3DVertex *PD, class G3DVector *V, float ClipValue)
  241. {
  242.     V->Init(P1, P2);
  243.     V->DivideByY();
  244.     V->Multiply(ClipValue - P1->Y);
  245.     P1->CopyVertex(PD);
  246.     PD->AddVector(V);
  247.     return TRUE;
  248. } /* Point (x, y, z) will be placed on the position where Y == ClipValue (what you want it to be) */
  249.  
  250. BOOL G3DPolygon::ClipLineZ(class G3DVertex *P1, class G3DVertex *P2, class G3DVertex *PD, class G3DVector *V, float ClipValue)
  251. {
  252.     V->Init(P1, P2);
  253.     V->DivideByZ();
  254.     V->Multiply(ClipValue - P1->Z);    // (1.0 - P1->Z usually)
  255.     P1->CopyVertex(PD);
  256.     PD->AddVector(V);
  257.     return TRUE;
  258. } /* Point (x, y, z) will set to the position where Z == what you want it to be */
  259.  
  260. void G3DPolygon::SetSortWeight()
  261. {
  262.     GSortNode.SetWeight( (float) (Polygon.v1.z + Polygon.v2.z + Polygon.v3.z) / 3.0 ); 
  263.     GSortNode.SetVisited(FALSE);
  264. }
  265.  
  266. void G3DPolygon::Rotate(class G3DMatrix *GMatrix)
  267. {
  268.     Polygon.v1.x =    GVertex1.X * G3DMatrix->Matrix[0][0] +
  269.             GVertex1.Y * G3DMatrix->Matrix[1][0] +
  270.             GVertex1.Z * G3DMatrix->Matrix[2][0] +
  271.             GMatrix->Matrix[3][0];
  272.  
  273.     Polygon.v1.y =    GVertex1.X * G3DMatrix->Matrix[0][1] +
  274.             GVertex1.Y * G3DMatrix->Matrix[1][1] +
  275.             GVertex1.Z * G3DMatrix->Matrix[2][1] +
  276.             GMatrix->Matrix[3][1];
  277.  
  278.     Polygon.v1.z =    GVertex1.X * G3DMatrix->Matrix[0][2] +
  279.             GVertex1.Y * G3DMatrix->Matrix[1][2] +
  280.             GVertex1.Z * G3DMatrix->Matrix[2][2] +
  281.             GMatrix->Matrix[3][2];
  282. // v2
  283.     Polygon.v2.x =    GVertex2.X * G3DMatrix->Matrix[0][0] +
  284.             GVertex2.Y * G3DMatrix->Matrix[1][0] +
  285.             GVertex2.Z * G3DMatrix->Matrix[2][0] +
  286.             GMatrix->Matrix[3][0];
  287.  
  288.     Polygon.v2.y =    GVertex2.X * G3DMatrix->Matrix[0][1] +
  289.             GVertex2.Y * G3DMatrix->Matrix[1][1] +
  290.             GVertex2.Z * G3DMatrix->Matrix[2][1] +
  291.             GMatrix->Matrix[3][1];
  292.  
  293.     Polygon.v2.z =    GVertex2.X * G3DMatrix->Matrix[0][2] +
  294.             GVertex2.Y * G3DMatrix->Matrix[1][2] +
  295.             GVertex2.Z * G3DMatrix->Matrix[2][2] +
  296.             GMatrix->Matrix[3][2];
  297. // v3
  298.     Polygon.v3.x =    GVertex3.X * G3DMatrix->Matrix[0][0] +
  299.             GVertex3.Y * G3DMatrix->Matrix[1][0] +
  300.             GVertex3.Z * G3DMatrix->Matrix[2][0] +
  301.             GMatrix->Matrix[3][0];
  302.  
  303.     Polygon.v3.y =    GVertex3.X * G3DMatrix->Matrix[0][1] +
  304.             GVertex3.Y * G3DMatrix->Matrix[1][1] +
  305.             GVertex3.Z * G3DMatrix->Matrix[2][1] +
  306.             GMatrix->Matrix[3][1];
  307.  
  308.     Polygon.v3.z =    GVertex3.X * G3DMatrix->Matrix[0][2] +
  309.             GVertex3.Y * G3DMatrix->Matrix[1][2] +
  310.             GVertex3.Z * G3DMatrix->Matrix[2][2] +
  311.             GMatrix->Matrix[3][2];
  312. }
  313.  
  314. void G3DPolygon::DrawPoints(class G3DScreen *GScreen)
  315. {
  316.     int x, y, x2, y2, x3, y3;
  317.  
  318.     float z = Polygon.v1.z;
  319. //    z = 1.0;
  320.  
  321.     if (GScreen)
  322.     {
  323.  
  324.     if (z)
  325.     {
  326.         x = (int) ((Polygon.v1.x * G3DScreen->ScrWidth/2) / z);
  327.         y = (int) ((Polygon.v1.y * G3DScreen->ScrHeight/2)/ z);
  328.         x+=(GScreen->ScrWidth/2);
  329.         y+=(GScreen->ScrHeight/2);
  330.  
  331.  
  332.         if (0 <= x <= G3DScreen->ScrWidth)
  333.         {
  334.             if (0 <= y <= G3DScreen->ScrHeight)
  335.             {
  336.                 GScreen->PutPixel( x, y, 0xffffff);
  337.             }
  338.             else y=0;
  339.         }
  340.         else x=0;
  341.  
  342.     }
  343.  
  344.  
  345.     z = Polygon.v2.z;
  346. // v2
  347.     if (z)
  348.     {
  349.         x2 = (int) ((Polygon.v2.x * G3DScreen->ScrWidth/2) / z);
  350.         y2 = (int) ((Polygon.v2.y * GScreen->ScrHeight/2) / z);
  351.         x2+=(GScreen->ScrWidth/2);
  352.         y2+=(GScreen->ScrHeight/2);
  353.         if (0 <= x2 <= GScreen->ScrWidth)
  354.         {
  355.             if (0 <= y2 <= GScreen->ScrHeight)
  356.             {
  357.                 GScreen->PutPixel( x2, y2, 0x0000ff);
  358.             }
  359.             else y2=0;
  360.         }
  361.         else x2=0;
  362.     }
  363.  
  364. // v3
  365.     z = Polygon.v3.z;
  366.  
  367.     if (z)
  368.     {
  369.         x3 = (int) ((Polygon.v3.x * GScreen->ScrWidth/2) / z);
  370.         y3 = (int) ((Polygon.v3.y * GScreen->ScrHeight/2) / z);
  371.         x3+=(GScreen->ScrWidth/2);
  372.         y3+=(GScreen->ScrHeight/2);
  373.         if (0 <= x3 <= GScreen->ScrWidth)
  374.         {
  375.             if (0 <= y3 <= GScreen->ScrHeight)
  376.             {
  377.                 GScreen->PutPixel( x3 , y3 , 0xff0000);
  378.             }
  379.             else y3=0;
  380.         }
  381.         else x3=0;
  382.  
  383.     }
  384.  
  385. //    GScreen->DrawLine(x, y, x2, y2, 20);
  386. //    GScreen->DrawLine(x, y, x3, y3, 20);
  387. //    GScreen->DrawLine(x2, y2, x3, y3, 20);
  388.  
  389.  
  390.     }
  391.  
  392. }
  393.  
  394. void G3DPolygon::DrawLines(class GScreen *GScreen)
  395. {
  396.     int x=0, y=0, x2=0, y2=0, x3=0, y3=0;
  397.     short d1=0, d2=0, d3=0;
  398.  
  399.     if (Visible)
  400.     {
  401.  
  402.     float z = Polygon.v1.z;
  403. //    z = 1.0;
  404.  
  405.     if (GScreen)
  406.     {
  407.  
  408.         if (z)
  409.         {
  410.             x = (int) ((Polygon.v1.x * GScreen->ScrWidth/2) / z);
  411.             y = (int) ((Polygon.v1.y * GScreen->ScrHeight/2) / z);
  412. //            x = (int) (Polygon.v1.x / z);
  413. //            y = (int) (Polygon.v1.y / z);
  414.             x+=(GScreen->ScrWidth/2);
  415.             y+=(GScreen->ScrHeight/2);
  416.  
  417.             if ( (0 <= x) && (x < GScreen->ScrWidth))
  418.             {
  419.                 if ((0 <= y) && (y < GScreen->ScrHeight))
  420.                 {
  421.                     d1 = TRUE;
  422.                 }
  423.             }
  424.         }
  425.  
  426.  
  427.     z = Polygon.v2.z;
  428. // v2
  429.         if (z)
  430.         {
  431.             x2 = (int) ((Polygon.v2.x * GScreen->ScrWidth/2) / z);
  432.             y2 = (int) ((Polygon.v2.y * GScreen->ScrHeight/2) / z);
  433. //            x2 = (int) (Polygon.v2.x / z);
  434. //            y2 = (int) (Polygon.v2.y / z);
  435.             x2+=(GScreen->ScrWidth/2);
  436.             y2+=(GScreen->ScrHeight/2);
  437.             if ((0 <= x2) && (x2 < GScreen->ScrWidth))
  438.             {
  439.                 if ((0 <= y2) && (y2 < GScreen->ScrHeight))
  440.                 {
  441.                     d2 = TRUE;
  442.                 }
  443.             }
  444.         }
  445.  
  446. // v3
  447.     z = Polygon.v3.z;
  448.  
  449.         if (z)
  450.         {
  451.             x3 = (int) ((Polygon.v3.x * GScreen->ScrWidth/2) / z);
  452.             y3 = (int) ((Polygon.v3.y * GScreen->ScrHeight/2) / z);
  453. //            x3 = (int) (Polygon.v3.x / z);
  454. //            y3 = (int) (Polygon.v3.y / z);
  455.             x3+=(GScreen->ScrWidth/2);
  456.             y3+=(GScreen->ScrHeight/2);
  457.             if ((0 <= x3) && (x3 < GScreen->ScrWidth))
  458.             {
  459.                 if ((0 <= y3) && (y3 < GScreen->ScrHeight))
  460.                 {
  461.                     d3 = TRUE;
  462.                 }
  463.             }
  464.         }
  465.  
  466.         if (d1 && d2 && d3)
  467.         {
  468.             GScreen->DrawLine(x, y, x2, y2, 20);
  469.             GScreen->DrawLine(x, y, x3, y3, 20);
  470.             GScreen->DrawLine(x2, y2, x3, y3, 20);
  471.         }
  472.     }
  473.  
  474.     }
  475. }
  476.  
  477. void G3DPolygon::DrawPolygon(class GScreen *GScreen)
  478. {
  479.     class G3DVertex s12, s13, s23;
  480.     
  481.     class G3DVertex *p1, *p2, *p3, *pt;
  482.     class G3DVertex *sl, *sr, *sl2, *sr2;
  483.     class G3DVertex pl, spx;
  484.     float prx;
  485.  
  486.     p1 = (class G3DVertex *)&Polygon.v1;
  487.     p2 = (class G3DVertex *)&Polygon.v2;
  488.     p3 = (class G3DVertex *)&Polygon.v3;
  489.     pt = NULL;
  490.  
  491.     int y1, y2;
  492.  
  493.     if ( p1->Y > p2->Y )
  494.     {
  495.         pt = p2;
  496.         p2 = p1;
  497.         p1 = pt;
  498.     }    
  499.     if ( p2->Y > p3->Y )
  500.     {
  501.         pt = p3;
  502.         p3 = p2;
  503.         p2 = pt;
  504.     }
  505.     if ( p1->Y > p2->Y )
  506.     {
  507.         pt = p2;
  508.         p2 = p1;
  509.         p1 = pt;
  510.     }    
  511.  
  512.     s12 = p2-p1;
  513.     y1 = (int) s12.Y;
  514.     if ( s12.DivideByY() )
  515.     {
  516.         s23 = p3-p2;
  517.         y2 = (int) s23.Y;
  518.         s23.DivideByY();
  519.  
  520.         s13 = p3-p1;
  521.         s13.DivideByY();    
  522.  
  523.         if (s12.X < s13.X)
  524.         {
  525.             spx = s13-s12;
  526.             spx.DivideByX();
  527.             sl = &s12;
  528.             sl2 = &s23;
  529.             sr = &s13;
  530.             sr2 = &s13;
  531.         }
  532.         else
  533.         {
  534.             spx = s12-s13;
  535.             spx.DivideByX();
  536.             sr = &s12;
  537.             sr2 = &s23;
  538.             sl = &s13;
  539.             sl2 = &s13;
  540.         }
  541.     }
  542.     else
  543.     {
  544.         y2 = -1;
  545.  
  546.         if (p1->X > p2->X)
  547.         {
  548.             pt = p1;
  549.             p1 = p2;
  550.             p2 = p1;
  551.         }
  552.  
  553.         s12 = p3-p2;
  554.         s13 = p3-p1;
  555.         y1 = (int) s12.Y;
  556.  
  557.         sr = &s12;
  558.         sr2 = NULL;
  559.         sl = &s13;
  560.         sl2 = NULL;
  561.     }
  562.  
  563.     pl = p1;
  564.     prx = p2->X;
  565.  
  566.  
  567.     if ( GScreen->DDPixByte == 4)
  568.     {
  569.         unsigned int *screenpos = &( (unsigned int *) GScreen->DDBuffer() )[ (ScrWidth * (int)p1.Y) + GScreen->ScrHeight];
  570.  
  571.         while (1)
  572.         {
  573. //            interpolate16( &pl, &spx, (prx>>16) - (pl.xp>>16), texture, screenpos);
  574.             int xx = (int) pl.X + ScrWidth;
  575.             for (int i=0; i < (prx - pl.X); i++)
  576.             {
  577.                 class G3DVertex ppx = pl;
  578.                 screenpos[x+i] = 0x3388ff;
  579.                 ppx += spx;
  580.             }
  581.  
  582.             pl = sl+pl;
  583.             prx+= sr->X;
  584.  
  585.             screenpos+=GScreen->ScrWidth;
  586.             y1--;
  587.             if (y1 < 1)
  588.             {
  589. /*
  590.                 if (y2 > 0)
  591.                 {
  592.                     y1 = y2;
  593.                     y2 = 0;
  594.                     sr = sr2;
  595.                     sl = sl2;
  596.                 }
  597.                 else break;
  598. */
  599.                 break;
  600.             }
  601.         }
  602.     }
  603. }
  604.  
  605. //void G3DPolygon::DrawPolygon()
  606. //{
  607. //    Warp3D/W3D_DrawTriangle
  608. //};
  609.  
  610. /*
  611.  
  612. void G3DPolygon::DrawPolygon()
  613. {
  614.     class G3DVector Line12(GVertex1, G3DVertex2);
  615.     class G3DVector Line13(GVertex1, G3DVertex3);
  616.     class G3DVector Line23(GVertex2, G3DVertex3);
  617.     class G3DVertex LeftVertex, RightVertex;
  618. //    W3D_Vertex LeftVertex, RightVertex;
  619.  
  620.     struct PolyDrawList
  621.     {
  622.         class G3DVector *LineLeft, *LineRight;
  623.     };
  624.  
  625.     struct PolyDrawList PolyDrawList[2];
  626.  
  627.     UWORD Yloops[3];
  628.  
  629.     if (Line12.DeltaY == 0)
  630.     {
  631.         printf(",");
  632.         if (Line12.DeltaX > 0)
  633.         {
  634.             PolyDrawList[0].LineLeft = Line13;
  635.             PolyDrawList[0].LineRight = Line23;
  636.             PolyDrawList[1].LineLeft = NULL;
  637.             PolyDrawList[1].LineRight = NULL;
  638.             GVertex1.CopyVertex(LeftVertex);
  639.             GVertex2.CopyVertex(RightVertex);
  640. //            CopyVertex(&Polygon->v1, &LeftVertex);
  641. //            CopyVertex(&Polygon->v2, &RightVertex);
  642.             Yloops[0] = Line23.DeltaY;
  643.             Yloops[1] = 0;
  644.         }
  645.         else
  646.         {
  647.             PolyDrawList[0].LineLeft = &Line23;
  648.             PolyDrawList[0].LineRight = &Line13;
  649.             PolyDrawList[1].LineLeft = NULL;
  650.             PolyDrawList[1].LineRight = NULL;
  651.             GVertex2.CopyVertex(LeftVertex);
  652.             GVertex1.CopyVertex(RightVertex);
  653. //            CopyVertex(&Polygon->v2, &LeftVertex);
  654. //            CopyVertex(&Polygon->v1, &RightVertex);
  655.             Yloops[0] = Line23.DeltaY;
  656.             Yloops[1] = 0;
  657.         }
  658.     }
  659.     else
  660.     {
  661.         if ( (Line12.DeltaX / Line12.DeltaY) < (Line13.DeltaX / Line13.DeltaY) )
  662.         {
  663.             PolyDrawList[0].LineLeft = &Line12;
  664.             PolyDrawList[0].LineRight = &Line13;
  665.             PolyDrawList[1].LineLeft = &Line23;
  666.             PolyDrawList[1].LineRight = &Line13;
  667.  
  668.             GVertex1.CopyVertex(LeftVertex);
  669.             GVertex1.CopyVertex(RightVertex);
  670. //            CopyVertex(&Polygon->v1, &LeftVertex);
  671. //            CopyVertex(&Polygon->v1, &RightVertex);
  672.             Yloops[0] = Line12.DeltaY;
  673.             Yloops[1] = Line23.DeltaY;
  674.             Yloops[2] = NULL;
  675.         }
  676.         else
  677.         {
  678.             PolyDrawList[0].LineLeft = &Line13;
  679.             PolyDrawList[0].LineRight = &Line12;
  680.             PolyDrawList[1].LineLeft = &Line13;
  681.             PolyDrawList[1].LineRight = &Line23;
  682.             GVertex1.CopyVertex(LeftVertex);
  683.             GVertex1.CopyVertex(RightVertex);
  684. //            CopyVertex(&Polygon->v1, &LeftVertex);
  685. //            CopyVertex(&Polygon->v1, &RightVertex);
  686.             Yloops[0] = Line12.DeltaY;
  687.             Yloops[1] = Line23.DeltaY;
  688.             Yloops[2] = NULL;
  689.         }
  690.     }
  691.  
  692.     class G3DVertex XLineX;
  693. //    W3D_Vertex XlineX;
  694.  
  695.  
  696.     class G3DVector VectorX = PolyDrawList[0].LineRight - PolyDrawList[0].LineLeft);
  697.  
  698.     ULONG *Tex = NULL;
  699.  
  700.     UWORD Ycount;
  701.     UWORD Part = 0;
  702.  
  703.     while(Yloops[Part])
  704.     {
  705.         for (Ycount = Yloops[Part]; Ycount > 0; Ycount--)
  706.         {
  707.             LeftVertex->CopyVertex(XLineX);
  708. //            CopyVertex(&LeftVertex, &XlineX);
  709.  
  710.             ULONG *Buffer = (ULONG *) ((ULONG)TempScreen->Own24BitPixelArray + ((UWORD)LeftVertex.y * GameScr->GetGamePic()->Width) + (UWORD)LeftVertex.x;
  711.             WORD Xcount;
  712.             for (Xcount = ((WORD)RightVertex.x - (WORD)LeftVertex.x); Xcount > 0; Xcount--)
  713.             {
  714.                 Buffer[0] = Tex[(((WORD)XlineX.u)<<8)+(BYTE)XlineX.v];
  715.                 Buffer+=1;
  716.                 VectorX.UpdateVertex(&XlineX);
  717.             }
  718.             PolyDrawList[Part].LineLeft->UpdateVertex(&LeftVertex);
  719.             PolyDrawList[Part].LineRight->UpdateVertex(&RightVertex);
  720.         }
  721.         Part++;
  722.     }
  723. }
  724.  
  725. */
  726.  
  727. #endif /* GPOLYGON_CPP */
  728.