Example #1
0
 /// <summary>
 /// Load OBJ file
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="faces"></param>
 private void LoadModel(string filename, MeshFaces faces)
 {
     // load model
     var reader   = new ObjReader();
     var objModel = reader.Read(filename, new ModelInfo()
     {
         Faces = MeshFaces.Default
     });
     //this.Model = objModel[0].Geometry as MeshGeometry3D;
     //this.Model.Colors = this.Model.Positions.Select(x => new Color4(1, 0, 0, 1)).ToArray();
 }
Example #2
0
        /// <summary>
        /// load the model from obj-file
        /// </summary>
        /// <param name="filename">filename</param>
        /// <param name="faces">Determines if facades should be treated as triangles (Default) or as quads (Quads)</param>
        private void LoadModel(string filename, MeshFaces faces)
        {
            // load model
            var reader   = new ObjReader();
            var objModel = reader.Read(filename, new ModelInfo()
            {
                Faces = faces
            });
            var model = objModel[0].Geometry as MeshGeometry3D;

            Model = model;
        }
        /// <summary>
        /// load the model from obj-file
        /// </summary>
        /// <param name="filename">filename</param>
        /// <param name="faces">Determines if facades should be treated as triangles (Default) or as quads (Quads)</param>
        private void LoadModel(string filename, MeshFaces faces)
        {
            // load model
            var reader   = new ObjReader();
            var objModel = reader.Read(filename, new ModelInfo()
            {
                Faces = faces
            });
            var model = objModel[0].Geometry as MeshGeometry3D;

            model.Colors = new Color4Collection(model.Positions.Select(x => new Color4(1, 0, 0, 1)));
            DefaultModel = model;
        }
Example #4
0
 /// <summary>
 /// load the model from obj-file
 /// </summary>
 /// <param name="filename">filename</param>
 /// <param name="faces">Determines if facades should be treated as triangles (Default) or as quads (Quads)</param>
 private void LoadModel(string filename, MeshFaces faces)
 {
     // load model
     var reader = new ObjReader();
     var objModel = reader.Read(filename, new ModelInfo() { Faces = faces });
     this.DefaultModel = objModel[0].Geometry as MeshGeometry3D;
     this.DefaultModel.Colors = new Color4Collection(this.DefaultModel.Positions.Select(x => new Color4(1, 0, 0, 1)));
 }  
Example #5
0
        public void ComputeTangents(MeshFaces meshFaces)
        {
            switch (meshFaces)
            {
                case MeshFaces.Default:
                    if (this.positions != null & this.triangleIndices != null & this.normals != null & this.textureCoordinates != null)
                    {
                        Vector3Collection t1, t2;
                        ComputeTangents(this.positions, this.normals, this.textureCoordinates, this.triangleIndices, out t1, out t2);
                        this.tangents = t1;
                        this.bitangents = t2;
                    }
                    break;
                case MeshFaces.QuadPatches:
                    if (this.positions != null & this.triangleIndices != null & this.normals != null & this.textureCoordinates != null)
                    {
                        Vector3Collection t1, t2;
                        ComputeTangentsQuads(this.positions, this.normals, this.textureCoordinates, this.triangleIndices, out t1, out t2);
                        this.tangents = t1;
                        this.bitangents = t2;
                    }
                    break;
                default:
                    break;
            }

        }
Example #6
0
        public void ComputeNormalsAndTangents(MeshFaces meshFaces, bool tangents = false)
        {
            if (!this.HasNormals & this.positions != null & this.triangleIndices != null)
            {
                Vector3D[] n;
                ComputeNormals(this.positions, this.triangleIndices, out n);
                this.normals = n.ToList();
            }

            switch (meshFaces)
            {
                case MeshFaces.Default:
                    if (tangents & this.HasNormals & this.textureCoordinates != null)
                    {
                        Point3DCollection t1, t2;
                        ComputeTangents(this.positions, this.normals, this.textureCoordinates, this.triangleIndices, out t1, out t2);
                        this.tangents = t1;
                        this.bitangents = t2;
                    }
                    break;
                case MeshFaces.QuadPatches:
                    if (tangents & this.HasNormals & this.textureCoordinates != null)
                    {
                        Point3DCollection t1, t2;
                        ComputeTangentsQuads(this.positions, this.normals, this.textureCoordinates, this.triangleIndices, out t1, out t2);
                        this.tangents = t1;
                        this.bitangents = t2;
                    }
                    break;
                default:
                    break;
            }
        }