private void DrawTriangle(Vertex v1, Vertex v2, Vertex v3, Matrix4x4 m, Matrix4x4 v, Matrix4x4 p) { SetModelToWorld(m, ref v1); SetModelToWorld(m, ref v2); SetModelToWorld(m, ref v3); Light.BaseLight(m, light, mesh, camera.eyePosition, ambientColor, ref v1); Light.BaseLight(m, light, mesh, camera.eyePosition, ambientColor, ref v2); Light.BaseLight(m, light, mesh, camera.eyePosition, ambientColor, ref v3); SetWorldToCamera(v, ref v1); SetWorldToCamera(v, ref v2); SetWorldToCamera(v, ref v3); //在相机空间进行背面消隐 if (Camera.BackFaceCulling(v1, v2, v3) == false) { return; } SetProjectionTransform(p, ref v1); SetProjectionTransform(p, ref v2); SetProjectionTransform(p, ref v3); //超出屏幕外剔除 if (Exclude(v1) == false && Exclude(v2) == false && Exclude(v3) == false) { return; } TransformToScreen(ref v1); TransformToScreen(ref v2); TransformToScreen(ref v3); if (isCull) { List <Triangle> outValue; CubeClip(new Triangle(v1, v2, v3), out outValue); for (int i = 0; i < outValue.Count; i++) { Rasterization(outValue[i][0], outValue[i][1], outValue[i][2]); } //Rasterization(p1, p2, p3); } else { Rasterization(v1, v2, v3); } //TriangleRasterization(v1,v2,v3); }