示例#1
0
        public override bool Equals(object obj)
        {
            XbimTexture t = obj as XbimTexture;

            if (t == null)
            {
                return(false);
            }
            bool isSame = t.ColourMap.Equals(ColourMap) && t.RenderBothFaces == RenderBothFaces && t.SwitchFrontAndRearFaces == SwitchFrontAndRearFaces &&
                          t.DiffuseTransmissionColour == DiffuseTransmissionColour && t.TransmissionColour == TransmissionColour &&
                          t.DiffuseReflectionColour == DiffuseReflectionColour && t.ReflectanceColour == ReflectanceColour;

            return(isSame);
        }
示例#2
0
 public void CreateMaterial(XbimTexture texture)
 {
     if (texture.ColourMap.Count > 1)
     {
         Material = new MaterialGroup();
         _Description = "Texture" ;
         foreach (var colour in texture.ColourMap)
         {
             _Description += " " + colour.ToString();
             ((MaterialGroup)Material).Children.Add(CreateMaterial(colour));
         }
     }
     else if(texture.ColourMap.Count == 1)
     {
         XbimColour colour = texture.ColourMap[0];
         Material = CreateMaterial(colour);
         _Description = "Texture " + colour.ToString();
     }
 }
示例#3
0
 public void CreateMaterial(XbimTexture texture)
 {
     
     if (texture.ColourMap.Count > 1)
     {
         _material = new MaterialGroup();
         _description = "Texture" ; 
         bool transparent = true;
         foreach (var colour in texture.ColourMap)
         {
             if (!colour.IsTransparent) transparent = false; //only transparent if everything is transparent
             _description += " " + colour;
             ((MaterialGroup)_material).Children.Add(MaterialFromColour(colour));
         }
         IsTransparent = transparent;
     }
     else if(texture.ColourMap.Count == 1)
     {
         XbimColour colour = texture.ColourMap[0];
         _material = MaterialFromColour(colour);
         _description = "Texture " + colour;
         IsTransparent = colour.IsTransparent;
     }
 }
示例#4
0
 public void CreateMaterial(XbimTexture texture)
 {
     throw new NotImplementedException();
 }
示例#5
0
 public XbimMeshLayer(XbimColour colour)
 {
     Style = XbimTexture.Create(colour);
 }
示例#6
0
 public XbimMeshLayer(IModel m, XbimTexture xbimTexture)
 {
     Model = m;
     Style = xbimTexture;
 }
示例#7
0
 public XbimMeshLayer(XbimTexture xbimTexture)
 {
     Style = xbimTexture;
 }
示例#8
0
 public XbimMeshLayer(IModel m, IIfcSurfaceStyle style)
 {
     Model = m;
     Style = XbimTexture.Create(style);
 }
示例#9
0
 /// <summary>
 /// Create a new layer that will display meshes in the specified colour
 /// If the mesh geometry item has a style specified in the IFC definition sub layers will be created for each style
 /// </summary>
 /// <param name="colour"></param>
 public XbimMeshLayer(IModel m, XbimColour colour)
 {
     Model = m;
     Style = XbimTexture.Create(colour);
 }
示例#10
0
 public XbimMeshLayer(XbimColour colour)
 {
     Style = new XbimTexture().CreateTexture(colour);
 }
示例#11
0
 public XbimMeshLayer(XbimModel m, IfcSurfaceStyle style)
 {
     Model = m;
     Style = new XbimTexture().CreateTexture(style);
 }
示例#12
0
 /// <summary>
 /// Create a new layer that will display meshes in the specified colour
 /// If the mesh geometry item has a style specified in the IFC definition sub layers will be created for each style
 /// </summary>
 /// <param name="colour"></param>
 public XbimMeshLayer(XbimModel m, XbimColour colour)
 {
     Model = m;
     Style = new XbimTexture().CreateTexture(colour);
 }
示例#13
0
 public void CreateMaterial(XbimTexture texture)
 {
     throw new NotImplementedException();
 }
示例#14
0
        private void WriteGeometry(JsonWriter writer)
        {
            XbimMatrix3D globalTrans = GetGlobalModelTransform();
            //write out the material nodes and then the instances for each material
            Dictionary <int, XbimTexture> styles = _context.SurfaceStyles().ToDictionary(s => s.DefinedObjectId);

            foreach (var instanceGroup in _context.ShapeInstancesGroupByStyle())
            {
                if (!instanceGroup.Any())
                {
                    continue;                       //skip emmpty instances;
                }
                int         styleId = instanceGroup.Key;
                XbimTexture style   = styles[styleId];
                writer.WriteStartObject(); //Material node
                {
                    writer.WritePropertyName("type"); writer.WriteValue("material");
                    writer.WritePropertyName("id"); writer.WriteValue("M" + styleId);
                    writer.WritePropertyName("color");
                    writer.WriteStartObject(); //begin color
                    {
                        writer.WritePropertyName("r"); writer.WriteValue(style.ColourMap[0].Red);
                        writer.WritePropertyName("g"); writer.WriteValue(style.ColourMap[0].Green);
                        writer.WritePropertyName("b"); writer.WriteValue(style.ColourMap[0].Blue);
                    } writer.WriteEndObject(); //end color
                    writer.WritePropertyName("alpha"); writer.WriteValue(style.ColourMap[0].Alpha);
                    //all instances of this style
                    writer.WritePropertyName("nodes"); //beginning of the instance nodes
                    writer.WriteStartArray();
                    foreach (var shapeInstance in instanceGroup)
                    {
                        writer.WriteStartObject();                                //start of instance transform
                        {
                            if (_maps.Contains(shapeInstance.ShapeGeometryLabel)) //it is a reference
                            {
                                //write the transform
                                writer.WritePropertyName("type"); //geometry node
                                writer.WriteValue("matrix");
                                writer.WritePropertyName("id");
                                writer.WriteValue("I" + shapeInstance.InstanceLabel);
                                writer.WritePropertyName("elements");
                                XbimMatrix3D m = XbimMatrix3D.Multiply(shapeInstance.Transformation, globalTrans);
                                WriteMatrix(writer, m);
                                writer.WritePropertyName("nodes"); //beginning of the instance nodes
                                writer.WriteStartArray();
                                //write the map
                                writer.WriteStartObject();            //start of map
                                {
                                    writer.WritePropertyName("type"); //geometry node
                                    writer.WriteValue("geometry");
                                    writer.WritePropertyName("coreId");
                                    writer.WriteValue("L" + shapeInstance.ShapeGeometryLabel);
                                } writer.WriteEndObject(); //end of map
                                writer.WriteEndArray();    //end of instance tranform nodes
                            }
                            else //write the actual geometry
                            {
                                writer.WritePropertyName("type");      //geometry node
                                writer.WriteValue("geometry");
                                writer.WritePropertyName("primitive"); //primitive: "
                                writer.WriteValue("triangles");
                                writer.WritePropertyName("id");
                                writer.WriteValue("I" + shapeInstance.InstanceLabel);
                                WriteShapeGeometry(writer, _context.ShapeGeometry(shapeInstance), XbimMatrix3D.Multiply(shapeInstance.Transformation, globalTrans));
                            }
                        } writer.WriteEndObject(); //end of instance transform
                    }
                    writer.WriteEndArray();        //end of instance transform nodes
                } writer.WriteEndObject();         // end of the material node
            }
        }
示例#15
0
        public void CreateMaterial(XbimTexture texture)
        {
            if (texture.ColourMap.Count > 1)
            {
                _Description = "Texture";

                foreach (var colour in texture.ColourMap)
                {
                    BaseMaterial mat = RGBAExists(colour);
                    _Description += " " + colour.ToString();
                    if (mat == null)
                    {
                        Materials.Add(CreateMaterial(colour));
                    }
                    else
                    {
                        EditMaterial(mat, colour);
                    }
                }
            }
            else if (texture.ColourMap.Count == 1)
            {
                XbimColour colour = texture.ColourMap[0];
                Materials.Add(CreateMaterial(colour));
            }
        }
示例#16
0
 private void SetupNewLayer(XbimSurfaceStyle topstyle, XbimModel model)
 {
     XBimMaterial m = new XBimMaterial();
     XbimTexture style;
     if (topstyle.IsIfcSurfaceStyle)
     {
         style = new XbimTexture().CreateTexture(topstyle.IfcSurfaceStyle(model));
     }
     else
     {
         style = new XbimTexture().CreateTexture(TypeMap[topstyle.IfcType.Name]);
     }
     m.CreateMaterial(style);
     m.Material.MaterialID = topstyle.IfcSurfaceStyleLabel;
     xMaterials[topstyle.IfcSurfaceStyleLabel.ToString()] = m;
     xLayers[topstyle.IfcSurfaceStyleLabel.ToString()] = new List<long>();
 }