Пример #1
0
        /// <summary>
        /// 将给定三角形的顶点添加到顶点查找字典并发出三角形。
        /// Add the vertices of the given triangle to our
        /// vertex lookup dictionary and emit a triangle.
        /// </summary>
        void StoreTriangle(MeshTriangle triangle, ObjModel objModel)
        {
            var vFace = new VFace();

            for (int i = 0; i < 3; ++i)
            {
                XYZ p = triangle.get_Vertex(i);

                if (i == 0)
                {
                    vFace.Point1 = _vertices.AddVertex(new PointInt(p)) + 1;
                }
                else if (i == 1)
                {
                    vFace.Point2 = _vertices.AddVertex(new PointInt(p)) + 1;
                }
                else if (i == 2)
                {
                    vFace.Point3 = _vertices.AddVertex(new PointInt(p)) + 1;
                }
            }

            // 添加面数据
            objModel.Faces.Add(vFace);
        }
Пример #2
0
        /// <summary>
        /// Emit a Revit geometry Face object and
        /// return the number of resulting triangles.
        /// </summary>
        public int EmitFace(Element e, Face face, Color color, int transparency)
        {
            ++_faceCount;
            var objModel = new ObjModel()
            {
                UniqueId = e.UniqueId,
                Faces    = new List <VFace>(),
                vt       = new List <object>()
            };

            _objModels.Add(objModel);

            // 保存每个实体的材质颜色
            if (_add_color && _color_transparency_lookup.AddColorTransparency(color, transparency))
            {
                // 设置材质颜色id
                string name = ObjExportUtil.ColorTransparencyString(color, transparency);
                objModel.Mtl = name;
            }

            Mesh mesh = face.Triangulate(0 / 15.0);

            //Mesh mesh = face.Triangulate();

            #region 保存 Vertex 及 Triangle 数据

            int numTriangles = mesh.NumTriangles;

            for (int i = 0; i < numTriangles; ++i)
            {
                ++_triangleCount;

                MeshTriangle meshTriangle = mesh.get_Triangle(i);
                StoreTriangle(meshTriangle, objModel);
            }

            #endregion

            return(numTriangles);
        }