1

我正在使用带有 Helix Toolkit 的 WPF 渲染管道。我意识到提供的函数会生成对我来说太大的三角形图元。

在此处输入图像描述

例如,如果红色三角形是我的图元,我想控制(比如说)三角形的中间部分。我能想到的一种方法是将红色三角形进一步拆分为蓝色三角形,如图所示。谁能指出允许这种拆分的方法或算法?

4

1 回答 1

0
    public struct Triangle
    {
        public Vector3 point1;
        public Vector3 point2;
        public Vector3 point3;

        public Triangle(Vector3 p1, Vector3 p2, Vector3 p3)
        { 
            this.point1 = p1;
            this.point2 = p2;
            this.point3 = p3; 
        }
    }

    public static Vector3 getMiddlePoint(Vector3 point1, Vector3 point2)
    {
        return new Vector3((point1.X + point2.X) / 2.0f, (point1.Y + point2.Y) / 2.0f, (point1.Z + point2.Z) / 2.0f);
    }

    public static List<Triangle> SplitTriangle(Triangle tri)
    {
        Vector3 a = getMiddlePoint(tri.point1, tri.point2);      
        Vector3 b = getMiddlePoint(tri.point2, tri.point3);
        Vector3 c = getMiddlePoint(tri.point3, tri.point1);
        List<Triangle> NewTris = new List<Triangle>();
        NewTris.Add(new Triangle(tri.point1, a, c));
        NewTris.Add(new Triangle(tri.point2, b, a));
        NewTris.Add(new Triangle(tri.point3, c, b));
        NewTris.Add(new Triangle(a, b, c);
        return NewTris;
    }
于 2015-11-06T15:57:49.650 回答