Exemplo n.º 1
0
        private void VisitModelItem(Model model, ModelItem mi, NavModelNode node)
        {
            node.DisplayName = ((mi.DisplayName.Length == 0) ? mi.ClassDisplayName : mi.DisplayName);
            this.ReadProperties(mi, node);
            //如果该项目有几何图形
            bool hasGeometry = mi.HasGeometry;

            if (hasGeometry)
            {
                //转换为COM选择集
                Autodesk.Navisworks.Api.Interop.ComApi.InwOaPath inwOaPath = ComApiBridge.ToInwOaPath(mi);
                //创建回调对象
                NavGeometryCallback navGeometryCallback = new NavGeometryCallback();
                navGeometryCallback.UnitScaleToMM = (float)UnitConversion.ScaleFactor(model.Units, Units.Millimeters);
                foreach (InwOaFragment3 inwOaFragment in inwOaPath.Fragments())
                {
                    Autodesk.Navisworks.Api.Interop.ComApi.InwOpState10    state              = ComApiBridge.State;
                    Autodesk.Navisworks.Api.Interop.ComApi.InwOaPath3      inwOaPath2         = (Autodesk.Navisworks.Api.Interop.ComApi.InwOaPath3)inwOaFragment.path;
                    Autodesk.Navisworks.Api.Interop.ComApi.InwLTransform3f localToWorldMatrix = inwOaFragment.GetLocalToWorldMatrix();
                    Array array3 = (Array)(object)localToWorldMatrix.Matrix;


                    InwOaPath path = inwOaFragment.path;
                    ModelItem obj2 = ComApiBridge.ToModelItem(path);
                    bool      flag = !mi.Equals(obj2);
                    if (!flag)
                    {
                        ComApi.InwLTransform3f3 localToWorld = (ComApi.InwLTransform3f3)(object) inwOaFragment.GetLocalToWorldMatrix();
                        //Array array_v1 = (Array)(object)localToWorld.Matrix;

                        InwLTransform3f3 fragmentTransform = (InwLTransform3f3)inwOaFragment.GetLocalToWorldMatrix();
                        // navGeometryCallback.localToWorldMatrix =  inwOaFragment.GetLocalToWorldMatrix();
                        navGeometryCallback.FragmentTransform = fragmentTransform;
                        inwOaFragment.GenerateSimplePrimitives(nwEVertexProperty.eNORMAL, navGeometryCallback);
                    }
                }
                Color    originalColor = mi.Geometry.OriginalColor;
                NavColor color         = new NavColor((float)originalColor.R, (float)originalColor.G, (float)originalColor.B, 1f - (float)mi.Geometry.ActiveTransparency);
                navGeometryCallback.Geometry.Color = color;
                this.Geometries.Add(navGeometryCallback.Geometry);
                this.currentTriangleCount_ += navGeometryCallback.Geometry.Triangles.Count / 3;
                node.GeometryId             = string.Concat(navGeometryCallback.Geometry.Id);
                bool flag2 = this.currentTriangleCount_ >= this.maxTriangleCount_;
                if (flag2)
                {
                    this.WriteModel();
                }
            }
            foreach (ModelItem modelItem in mi.Children)
            {
                bool isHidden = modelItem.IsHidden;
                if (!isHidden)
                {
                    NavModelNode navModelNode = new NavModelNode();
                    node.Children.Add(navModelNode);
                    this.VisitModelItem(model, modelItem, navModelNode);
                }
            }
        }
Exemplo n.º 2
0
        private string GetColorString(NavColor color)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("newmtl " + this.colors_.IndexOf(color));
            stringBuilder.AppendLine(string.Concat(new object[]
            {
                "Kd ",
                color.R,
                " ",
                color.G,
                " ",
                color.B
            }));
            stringBuilder.AppendLine("d " + color.D);
            return(stringBuilder.ToString());
        }
Exemplo n.º 3
0
 // Token: 0x0600000A RID: 10 RVA: 0x000020C0 File Offset: 0x000002C0
 public bool Equals(NavColor target)
 {
     return(this.R == target.R && this.G == target.G && this.B == target.B && this.D == target.D);
 }