Exemplo n.º 1
0
        /// <summary>
        /// Reads a Color3.
        /// </summary>
        /// <remarks>
        /// In order to provide faster read/write, this operation doesn't check stream bound.
        /// A client must carefully not read/write above the size of this datastream.
        /// </remarks>
        /// <returns>an Color3 from the stream</returns>
        public Color3 ReadColor3()
        {
            unsafe
            {
                if (!_canRead)
                {
                    throw new NotSupportedException();
                }

                Color3 value = *((Color3 *)(_buffer + _position));
                _position += 4 * 3;
                return(value);
            }
        }
Exemplo n.º 2
0
        public unsafe void SetPixelShaderConstants(DeviceContext deviceContext, SharpDX.Color3 color)
        {
            var constants = new PSConstantBuffer();

            for (int i = 0; i < 3; i++)
            {
                constants.color[i] = color[i];
            }

            DataStream dataStream;

            deviceContext.MapSubresource(pixelShaderConstantBuffer, MapMode.WriteDiscard, SharpDX.Direct3D11.MapFlags.None, out dataStream);
            dataStream.Write <PSConstantBuffer>(constants);
            deviceContext.UnmapSubresource(pixelShaderConstantBuffer, 0);
        }
Exemplo n.º 3
0
        public static IfcMeshGeometryModel3D[] GetItems(IfcViewerWrapper model, bool loadTexture = true, string[] filter = null)
        {
            var element   = model.RootIfcItem;
            var modelList = new List <IfcMeshGeometryModel3D>();

            Draw(element, ref modelList, null);

            AssignIfcProperties(model.Tree, ref modelList);

            foreach (var model3D in modelList)
            {
                try
                {
                    model3D.Name = new string(model3D.IfcName.ToCharArray().Where(c => Char.IsLetter(c) || Char.IsNumber(c)).ToArray());
                }
                catch (Exception)
                {
                    LogManager.GetCurrentClassLogger().Info("Can not assign name " + model3D.IfcName + "to IFC element");
                }

                if (true)
                {
                    var returnColor = new SharpDX.Color3(.8f, .8f, .8f);

                    if (model3D.IfcName.Contains("pierCap"))
                    {
                        returnColor = new SharpDX.Color3(0, 0.8f, 0);
                    }
                    else if (model3D.IfcName.Contains("deck"))
                    {
                        returnColor = new SharpDX.Color3(0.8f, 0, 0);
                    }
                    else if (model3D.IfcName.Contains("Concrete-Round-Column"))
                    {
                        returnColor = new SharpDX.Color3(0.8f, 0.8f, 0);
                    }
                    else if (model3D.IfcName.Contains("Surface"))
                    {
                        returnColor = new SharpDX.Color3(0.87f, 0.72f, .53f);
                    }
                    else if (model3D.IfcName.Contains("Foundation"))
                    {
                        returnColor = new SharpDX.Color3(0.12f, 0.56f, 0.8f);
                    }
                    else if (model3D.IfcName.Contains("Floor"))
                    {
                        returnColor = new SharpDX.Color3(0.12f, 0.56f, 0.8f);
                    }
                    else if (model3D.IfcName.Contains("Basic Wall"))
                    {
                        returnColor = new SharpDX.Color3(0.64f, 0.11f, 1f);
                    }
                    else
                    {
                        returnColor = new SharpDX.Color3(0.8f, 0, 0);
                    }

                    model3D.Material = new PhongMaterial()
                    {
                        AmbientColor = new SharpDX.Color4(returnColor.Red * .3f, returnColor.Green * .3f, returnColor.Blue * .3f, 1f),
                        DiffuseColor = new SharpDX.Color4(returnColor, 1f)
                    };
                }
                else
                {
                    model3D.Material = new PhongMaterial()
                    {
                        DiffuseColor      = new Color4(0.1f, 0.1f, 0.15f, 1.0f),
                        AmbientColor      = new Color4(0.1f, 0.1f, 0.15f, 1.0f),
                        SpecularColor     = new Color4(0.1f, 0.1f, 0.15f, 1.0f),
                        EmissiveColor     = new Color4(0.1f, 0.1f, 0.02f, 0.5f),
                        SpecularShininess = 0.5f
                    };
                }
            }

            return(modelList.ToArray());
        }
Exemplo n.º 4
0
 public unsafe void Set(int positionInBytes, Color3 value)
 {
     *(Color3 *)(this._buffer + positionInBytes) = value;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Function to convert a SharpDX color 3 type to a <see cref="GorgonColor"/>.
 /// </summary>
 /// <param name="color">The SharpDX raw color 3 type to convert.</param>
 /// <returns>A new <see cref="GorgonColor"/>.</returns>
 public static GorgonColor ToGorgonColor(this DX.Color3 color) => new GorgonColor(color.Red, color.Green, color.Blue, 1.0f);