public void ComputeNormals()
        {
            var builder = new MeshBuilder(false);
            builder.AddPolygon(new List<Vector3>
                {
                    new Vector3(0f, 0f, 0f),
                    new Vector3(7f, 0f, 0f),
                    new Vector3(7f, 0f, 7f),
                });

            Assert.IsNull(builder.Normals);
            Assert.IsFalse(builder.HasNormals);

            builder.ComputeNormalsAndTangents(MeshFaces.Default);

            Assert.IsTrue(builder.HasNormals);
            Assert.AreEqual(3, builder.Normals.Count);
        }
Beispiel #2
0
        /// <summary>
        /// Creates a MeshGeometry3D object from the loaded file. Polygons are triangulated using triangle fans.
        /// </summary>
        /// <returns>
        /// A MeshGeometry3D.
        /// </returns>
        public MeshGeometry3D CreateMeshGeometry3D(ModelInfo info = default(ModelInfo))
        {
            var mb = new MeshBuilder(info.Normals, info.Tangents);
            foreach (var p in this.Vertices)
            {
                mb.Positions.Add(p);
            }

            foreach (var face in this.Faces)
            {
                mb.AddTriangleFan(face);
            }
            mb.ComputeNormalsAndTangents(info.Faces);
            return mb.ToMeshGeometry3D();
        }