Ejemplo n.º 1
0
 //计算三角形三个顶点的裁剪空间的坐标
 void CalTriangleScreenSpacePos(HTriangle Triangle)
 {
     //顶点的其他数据
     Triangle.p1InScreenSpace = Triangle.p1InObjectSpace.Copy();
     Triangle.p2InScreenSpace = Triangle.p2InObjectSpace.Copy();
     Triangle.p3InScreenSpace = Triangle.p3InObjectSpace.Copy();
     //归一化然后乘宽高
     Triangle.p1InScreenSpace.pos = Transform.HomogenizeToScreenCoord(Triangle.p1InClipSpace.pos);
     Triangle.p2InScreenSpace.pos = Transform.HomogenizeToScreenCoord(Triangle.p2InClipSpace.pos);
     Triangle.p3InScreenSpace.pos = Transform.HomogenizeToScreenCoord(Triangle.p3InClipSpace.pos);
     //保存Z信息
     Triangle.p1InScreenSpace.pos.w = Triangle.p1InClipSpace.pos.w;
     Triangle.p2InScreenSpace.pos.w = Triangle.p2InClipSpace.pos.w;
     Triangle.p3InScreenSpace.pos.w = Triangle.p3InClipSpace.pos.w;
 }