示例#1
0
 public GlTriangle(Color color, GlNormalizedVertex v0, GlNormalizedVertex v1, GlNormalizedVertex v2)
 {
     Color = color;
     V0    = v0;
     V1    = v1;
     V2    = v2;
 }
示例#2
0
        protected void addShadow()
        {
            Profiler.Instance.LogEvent("mesh: init");

            var edges = new Dictionary <int, GlTriangleEdge>();

            foreach (var triangle in Triangles)
            {
                GlTriangleEdge edge;
                edge             = new GlTriangleEdge(triangle.V0, triangle.V1);
                edges[edge.Hash] = edge;
                edge             = new GlTriangleEdge(triangle.V1, triangle.V2);
                edges[edge.Hash] = edge;
                edge             = new GlTriangleEdge(triangle.V2, triangle.V0);
                edges[edge.Hash] = edge;
            }
            Profiler.Instance.LogEvent("mesh: add edges");

            var color = Color.Black;

            foreach (var edge in edges.Values)
            {
                GlNormalizedVertex v1 = edge.V1, v2 = edge.V2;
                if (edges.TryGetValue(new GlTriangleEdge(v2, v1).Hash, out GlTriangleEdge neighbor))
                {
                    GlNormalizedVertex v3 = neighbor.V1, v4 = neighbor.V2;
                    if (!v3.Normal.Equals(v2.Normal))
                    {
                        ShadowTriangles.Add(new GlTriangle(color, v4, v3, v2));
                        ShadowTriangles.Add(new GlTriangle(color, v4, v2, v1));
                    }
                }
            }
            Profiler.Instance.LogEvent("mesh: add shadow");
        }
示例#3
0
        public GlTriangle(Color color, GlIndexedVertex v0, GlIndexedVertex v1, GlIndexedVertex v2)
        {
            Color = color;
            var normal = Point3D.VectorMult(v1.Position - v0.Position, v2.Position - v0.Position).Normal;

            V0 = new GlNormalizedVertex(v0, normal);
            V1 = new GlNormalizedVertex(v1, normal);
            V2 = new GlNormalizedVertex(v2, normal);
        }