public void DrawGeometryFromRevit(List <string> jsonFiles)
 {
     foreach (var jsonFilePath in jsonFiles)
     {
         var geo = new Serializable.Engine_Geometry().JDeserializemyData(System.IO.File.ReadAllText(jsonFilePath));
         geo.FileName = jsonFilePath;
         CreateCustomShape2(geo);
     }
 }
        public void CreateCustomShape2(Serializable.Engine_Geometry geom)
        {
            Logger.Log($"Generating Geometry [{geom.Name}]");

            if (geom.Engine_Faces.Count == 0)
            {
                Logger.Log($"Geometry: [{geom.Name}] has no faces", "", Logger.ErrorType.Warrning);
                return;
            }

            var geonode = RootNode.CreateChild(geom.Name);

            geonode.Scale(geom.Flip.ToVec3());
            if (geom.Rotation != null)
            {
                geonode.Rotate(new Quaternion(geom.Rotation.ToVec3()));
            }
            float scaleValue = (float)DynConstants.FeettoMeter;

            geonode.Scale(new Vector3(scaleValue, scaleValue, scaleValue));

            geom.GenerateNormals();
            if (!geom.GenerateTangents())
            {
                var failChild = geonode.CreateChild($"{geom.Name} Failed");
                failChild.Position = geom.Position.ToVec3();
                var model  = Cache.GetResource <Model>("Models/Box.mdl");
                var stcomp = failChild.CreateComponent <StaticModel>();
                stcomp.SetModel(model);
                return;
            }

            var    faceColorGroups = geom.Engine_Faces.GroupBy(o => o.FaceColor.ToString());
            string dir             = System.IO.Path.GetDirectoryName(geom.FileName);
            var    files           = System.IO.Directory.GetFiles(dir).ToList();

            foreach (var faceColorGroup in faceColorGroups)
            {
                var      facechild = geonode.CreateChild("Face_Color");
                Material mat       = null;

                var faceColor = faceColorGroup.ElementAt(0).FaceColor;

                if (faceColor.L != 1)
                {
                    mat = Material_Ext.TransParentMaterial(faceColor.ToColor());
                }
                else
                {
                    mat = Material_Ext.ColoredMaterial(faceColor.ToColor());
                }
                mat.CullMode = geom.GeoCullModel;
#if false
                var faceColor = faceColorGroup.ElementAt(0).FaceColor.ToColor();

                // mat = RootNode.Context.Cache.GetResource<Material>("Materials/Stone.xml");
                if (!files.Any(o => o.Contains(faceColor.ToString())))
                {
                    if (faceColor.ToVector4().W != 1)
                    {
                        mat = Material_Ext.TransParentMaterial(faceColor);
                    }
                    else
                    {
                        mat = Material_Ext.ColoredMaterial(faceColor);
                    }
                    mat.CullMode = geom.GeoCullModel;

                    var isSaved = mat.SaveFile(dir + "\\" + mat.Name);
                }

                mat = Cache.GetResource <Material>(dir + "\\" + faceColor.ToString() + ".xml");
#endif

                var cus = facechild.CreateComponent <CustomNodeComponent>();
                cus.OriginalMaterial = mat;

                var cusGeo = facechild.CreateComponent <CustomGeometry>();
                cusGeo.CastShadows = true;

                cusGeo.BeginGeometry(0, PrimitiveType.TriangleList);
                cusGeo.SetMaterial(mat);

                Logger.Log("Begin Geometry");
                foreach (var face in faceColorGroup)
                {
                    var triangles      = face.EngTriangles;
                    var trianglesCount = face.EngTriangles.Count;
                    for (int triIndex = 0; triIndex < trianglesCount; triIndex++)
                    {
                        var triangle  = triangles[triIndex];
                        var triPoints = triangle.GetPoints();
                        foreach (var engpoint in triPoints)
                        {
                            cusGeo.DefineVertex(engpoint.EngPosition.ToVec3());
                            cusGeo.DefineNormal(engpoint.EngNormal.ToVec3());
                            cusGeo.DefineTexCoord(engpoint.EngTexture.ToVec2());
                            cusGeo.DefineTangent(engpoint.EngTangent.ToVec4());
                        }
                    }
                }
                cusGeo.Commit();
                Logger.Log("End Geometry");
            }
        }