Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 2515c9ed01
commit 90093ef258
  1. 17
      main.cpp

@ -143,6 +143,22 @@ public:
triTranslated.p[1].z = triRotatedZX.p[1].z + 3.0f;
triTranslated.p[2].z = triRotatedZX.p[2].z + 3.0f;
vec3d normal,line1,line2;
line1.x=triTranslated.p[1].x-triTranslated.p[0].x;
line1.y=triTranslated.p[1].y-triTranslated.p[0].y;
line1.z=triTranslated.p[1].z-triTranslated.p[0].z;
line2.x=triTranslated.p[2].x-triTranslated.p[0].x;
line2.y=triTranslated.p[2].y-triTranslated.p[0].y;
line2.z=triTranslated.p[2].z-triTranslated.p[0].z;
normal.x=line1.y*line2.z-line1.z*line2.y;
normal.y=line1.z*line2.x-line1.x*line2.z;
normal.z=line1.x*line2.y-line1.y*line2.x;
float l = sqrtf(normal.x*normal.x+normal.y*normal.y+normal.z*normal.z);
normal.x/=l;normal.y/=l;normal.z/=l;
if (normal.z<0) {
// Project triangles from 3D --> 2D
MultiplyMatrixVector(triTranslated.p[0], triProjected.p[0], matProj);
MultiplyMatrixVector(triTranslated.p[1], triProjected.p[1], matProj);
@ -170,6 +186,7 @@ public:
{0,0},
{0,0},
});
}
}

Loading…
Cancel
Save