Beispiel #1
0
        void DrawPlane(int vertexIndex1, int vertexIndex2, int vertexIndex3, int vertexIndex4)
        {
            vertex_t p1 = Def.mesh[vertexIndex1], p2 = Def.mesh[vertexIndex2], p3 = Def.mesh[vertexIndex3], p4 = Def.mesh[vertexIndex4];

            DrawTriangle(p1, p2, p3);
            DrawTriangle(p1, p3, p4);
        }
Beispiel #2
0
        void DrawPlane_1(int vertexIndex1, int vertexIndex2, int vertexIndex3, int vertexIndex4)
        {
            vertex_t v1 = Def.mesh[vertexIndex1], v2 = Def.mesh[vertexIndex2], v3 = Def.mesh[vertexIndex3], v4 = Def.mesh[vertexIndex4];
            vector_t p1, p2, p3, p4, c1, c2, c3, c4;

            c1 = Tools.matrix_apply(v1.pos, mTransformer.transform);
            c2 = Tools.matrix_apply(v2.pos, mTransformer.transform);
            c3 = Tools.matrix_apply(v3.pos, mTransformer.transform);
            c4 = Tools.matrix_apply(v4.pos, mTransformer.transform);

            p1 = Tools.Homogenize(c1);
            p2 = Tools.Homogenize(c2);
            p3 = Tools.Homogenize(c3);
            p4 = Tools.Homogenize(c4);

            point_t _node1 = new point_t((int)p1.x, (int)p1.y);
            point_t _node2 = new point_t((int)p2.x, (int)p2.y);
            point_t _node3 = new point_t((int)p3.x, (int)p3.y);
            point_t _node4 = new point_t((int)p4.x, (int)p4.y);

            DrawLine(_node1, _node2, v1.color);
            DrawLine(_node2, _node3, v2.color);
            DrawLine(_node3, _node4, v3.color);
            DrawLine(_node4, _node1, v4.color);
        }
Beispiel #3
0
 public static void InitMesh_Box()
 {
     for (int i = 0; i < 8; ++i)
     {
         mesh[i]       = new vertex_t();
         mesh[i].pos   = new vector_t(meshData_Box[i, 0], meshData_Box[i, 1], meshData_Box[i, 2], meshData_Box[i, 3]);
         mesh[i].tc    = new texcoord_t(meshData_Box[i, 4], meshData_Box[i, 5]);
         mesh[i].color = Color.FromArgb((int)(meshData_Box[i, 6] * 255), (int)(meshData_Box[i, 7] * 255), (int)(meshData_Box[i, 8] * 255));
         mesh[i].rhw   = meshData_Box[i, 9];
     }
 }
Beispiel #4
0
        void DrawTriangle(vertex_t v1, vertex_t v2, vertex_t v3)
        {
            vector_t p1, p2, p3, c1, c2, c3;

            // 按照 Transform 变化
            c1 = Tools.matrix_apply(v1.pos, mTransformer.transform);
            c2 = Tools.matrix_apply(v2.pos, mTransformer.transform);
            c3 = Tools.matrix_apply(v3.pos, mTransformer.transform);

            p1 = Tools.Homogenize(c1);
            p2 = Tools.Homogenize(c2);
            p3 = Tools.Homogenize(c3);

            point_t _point1 = new point_t((int)p1.x, (int)p1.y);
            point_t _point2 = new point_t((int)p2.x, (int)p2.y);
            point_t _point3 = new point_t((int)p3.x, (int)p3.y);


            //画线框
            //DrawLine(_point1, _point2, Color.Black);
            //DrawLine(_point2, _point3, Color.Black);
            //DrawLine(_point1, _point3, Color.Black);

            //DrawPoint_S(_point1, Color.Red, 3);
            //DrawPoint_S(_point2, Color.Yellow, 3);
            //DrawPoint_S(_point3, Color.Blue, 3);

            if (TriangleCullingJudge_A(c1, c2, c3))
            {
            }
            else
            {
                //光栅化填充
                triangle_2D _triangle = new triangle_2D();
                _triangle.mPoints[0] = _point1; _triangle.mPoints[1] = _point2; _triangle.mPoints[2] = _point3;
                _triangle.mColors[0] = v1.color; _triangle.mColors[1] = v2.color; _triangle.mColors[2] = v3.color;

                Rasterization_Triangle(_triangle);
            }
        }