Ejemplo n.º 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);
        }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 4
0
 public void CreateMaterial(XbimTexture texture)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
 public XbimMeshLayer(XbimColour colour)
 {
     Style = XbimTexture.Create(colour);
 }
Ejemplo n.º 6
0
 public XbimMeshLayer(IModel m, XbimTexture xbimTexture)
 {
     Model = m;
     Style = xbimTexture;
 }
Ejemplo n.º 7
0
 public XbimMeshLayer(XbimTexture xbimTexture)
 {
     Style = xbimTexture;
 }
Ejemplo n.º 8
0
 public XbimMeshLayer(IModel m, IIfcSurfaceStyle style)
 {
     Model = m;
     Style = XbimTexture.Create(style);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 10
0
 public XbimMeshLayer(XbimColour colour)
 {
     Style = new XbimTexture().CreateTexture(colour);
 }
Ejemplo n.º 11
0
 public XbimMeshLayer(XbimModel m, IfcSurfaceStyle style)
 {
     Model = m;
     Style = new XbimTexture().CreateTexture(style);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 13
0
 public void CreateMaterial(XbimTexture texture)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 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
            }
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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>();
 }