Ejemplo n.º 1
0
        public void VisualizationManager_Planes_Render()
        {
            var openPath = Path.Combine(
                GetTestDirectory(ExecutingDirectory),
                @"core\visualization\Planes.dyn");

            Open(openPath);

            var ws = ViewModel.Model.CurrentWorkspace as HomeWorkspaceModel;

            ws.RunSettings.RunType = RunType.Automatic;

            var numberOfPlanesNode = ws.Nodes.FirstOrDefault(n => n.NickName == "Number of Planes") as DoubleInput;

            Assert.NotNull(numberOfPlanesNode);

            var numberOfPlanes       = int.Parse(numberOfPlanesNode.Value);
            var numberOfTrisPerPlane = 2;
            var numberOfVertsPerTri  = 3;

            // 5 planes, each with two triangles:
            // 30 mesh vertices
            //ensure that the number of visualizations matches the
            //number of pieces of geometry in the collection
            Assert.AreEqual(numberOfPlanes * numberOfVertsPerTri * numberOfTrisPerPlane, BackgroundPreview.PerVertexMesh.Positions.Count);
            var testColor = new SharpDX.Color4(0, 0, 0, 10.0f / 255.0f);

            Assert.True(BackgroundPreview.PerVertexMesh.Colors.All(c => c == testColor));

            // Increase the number of planes
            numberOfPlanes           = numberOfPlanes + 5;
            numberOfPlanesNode.Value = numberOfPlanes.ToString();
            Assert.AreEqual(numberOfPlanes * numberOfVertsPerTri * numberOfTrisPerPlane, BackgroundPreview.PerVertexMesh.Positions.Count);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Function to retrieve palette information for indexed images.
        /// </summary>
        /// <param name="wic">The WIC interface.</param>
        /// <param name="bitmap">The bitmap to derive the palette from (only used when encoding).</param>
        /// <returns>
        /// A tuple containing the palette data, alpha percentage and the type of palette.
        /// </returns>
        internal override Tuple <Palette, double, BitmapPaletteType> GetPaletteInfo(GorgonWICImage wic, Bitmap bitmap)
        {
            Palette palette;

            if (Palette.Count == 0)
            {
                // If decoding, just return the default, otherwise we'll need to generate from the frame.
                if (bitmap == null)
                {
                    return(base.GetPaletteInfo(wic, null));
                }

                palette = new Palette(wic.Factory);
                palette.Initialize(bitmap, 256, true);

                return(new Tuple <Palette, double, BitmapPaletteType>(palette, AlphaThresholdPercent, BitmapPaletteType.Custom));
            }

            // Generate from our custom palette.
            var paletteColors = new DX.Color4[256];
            int size          = paletteColors.Length.Min(Palette.Count);

            for (int i = 0; i < size; i++)
            {
                paletteColors[i] = Palette[i].SharpDXColor4;
            }

            palette = new Palette(wic.Factory);
            palette.Initialize(paletteColors);

            return(new Tuple <Palette, double, BitmapPaletteType>(palette, AlphaThresholdPercent, BitmapPaletteType.Custom));
        }
        private void ClearView()
        {
            // floor plane grid

            var Maxreset = 100;
            var Minreset = -100;

            EffectsManager.Dispose();
            EffectsManager = new DefaultEffectsManager();
            var points = new PointGeometry3D();
            var col    = new Color4Collection();  // gradient na kolory
            var ptPos  = new Vector3Collection(); // pozycje punktów
            var ptIdx  = new IntCollection();     // indeksy punktów

            arrows = lines = new LineBuilder();

            points.Positions = ptPos;
            points.Indices   = ptIdx;
            points.Colors    = col;
            PointsColor      = Colors.White; // <- nie pamiętam po co to tutaj ale bez tego nie działa
            Points           = points;
            PointsTransform  = new Media3D.TranslateTransform3D(0, 0, Minreset);

            CreateGrid(Maxreset, Minreset, Maxreset, Maxreset, Minreset);
            Grid          = lines.ToLineGeometry3D();
            GridColor     = new Color4(153 / 255.0f, 204 / 255.0f, 255 / 255.0f, (float)0.3).ToColor();;
            GridTransform = new Media3D.TranslateTransform3D(0, 0, Minreset);

            // strzałki

            CreateArrows(Maxreset, Minreset, Maxreset, Minreset, Maxreset, Minreset);
            Arrow          = arrows.ToLineGeometry3D();
            ArrowColor     = new Color4(0, 255 / 255.0f, 255 / 255.0f, (float)0.5).ToColor();;
            ArrowTransform = new Media3D.TranslateTransform3D(0, 0, Minreset);
        }
Ejemplo n.º 4
0
 public ByteColor(SharpDX.Color4 color)
 {
     R = (byte)(color.Red * 255);
     G = (byte)(color.Green * 255);
     B = (byte)(color.Blue * 255);
     A = (byte)(color.Alpha * 255);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the transfer function. Please create your own color transfer map.
        /// </summary>
        /// <param name="histogram">The histogram.</param>
        /// <param name="total">The total.</param>
        /// <returns></returns>
        public static Color4[] GetTransferFunction(uint[] histogram, int total,
                                                   float maxPercent = 0.003f, float minPercent = 0.0001f)
        {
            float[] percentage = new float[histogram.Length];
            for (int i = 0; i < histogram.Length; ++i)
            {
                percentage[i] = (float)histogram[i] / total;
                if (percentage[i] > maxPercent || percentage[i] < minPercent)
                {
                    percentage[i] = 0;
                }
            }
            Color4[] ret     = new Color4[histogram.Length];
            int      counter = 0;
            bool     isZero  = true;

            for (int i = 0; i < percentage.Length; ++i)
            {
                if (percentage[i] > 0)
                {
                    ret[i] = ColorCandidates[counter];
                    isZero = false;
                }

                if (!isZero && percentage[i] == 0)
                {
                    counter = (counter + 1) % ColorCandidates.Length;
                    isZero  = true;
                }
            }
            return(ret);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Get the {{blend state}} of the output-merger stage.
        /// </summary>
        /// <remarks>
        /// The reference count of the returned interface will be incremented by one when the blend state is retrieved. Applications must release returned reference(s) when they are no longer needed, or else there will be a memory leak.
        /// </remarks>
        /// <param name="blendFactor">Array of blend factors, one for each RGBA component. </param>
        /// <param name="sampleMaskRef">Pointer to a {{sample mask}}. </param>
        /// <returns>a reference to a blend-state interface (see <see cref="SharpDX.Direct3D10.BlendState"/>).</returns>
        /// <unmanaged>void OMGetBlendState([Out, Optional] ID3D10BlendState** ppBlendState,[Out, Optional] float BlendFactor[4],[Out, Optional] int* pSampleMask)</unmanaged>
        public SharpDX.Direct3D10.BlendState GetBlendState(out SharpDX.Color4 blendFactor, out int sampleMaskRef)
        {
            BlendState blendState;

            GetBlendState(out blendState, out blendFactor, out sampleMaskRef);
            return(blendState);
        }
Ejemplo n.º 7
0
 public static SiliconStudio.Core.Mathematics.Color4 Convert(Color4 color)
 {
     var temp = new SiliconStudio.Core.Mathematics.Color4();
     unsafe
     {
         *((Color4*)&temp) = color;
     }
     return temp;
 }
Ejemplo n.º 8
0
        public static SiliconStudio.Core.Mathematics.Color4 Convert(Color4 color)
        {
            var temp = new SiliconStudio.Core.Mathematics.Color4();

            unsafe
            {
                *((Color4 *)&temp) = color;
            }
            return(temp);
        }
        internal static Color ToColor(this SharpDX.Color4 color)
        {
            Color c;

            c.R = (byte)(color.Red * 255);
            c.G = (byte)(color.Green * 255);
            c.B = (byte)(color.Blue * 255);
            c.A = (byte)(color.Alpha * 255);
            return(c);
        }
Ejemplo n.º 10
0
 public Color GetPixel(int x, int y)
 {
     try
     {
         var output = new uint[1];
         Control.CopyPixels(new s.Rectangle(x, y, 1, 1), output);
         var eto = new s.Color4(new s.ColorBGRA(output[0]).ToRgba()).ToEto();
         if (Control.PixelFormat == sw.PixelFormat.Format24bppBGR)
         {
             return(Color.FromRgb(eto.ToArgb()));
         }
         else
         {
             return(eto);
         }
     }
     catch (s.SharpDXException ex)
     {
         Debug.WriteLine("GetPixel: {0}", ex.ToString());
         throw;
     }
 }
Ejemplo n.º 11
0
        internal CCTexture2D CreateTextSprite(string text, CCFontDefinition textDefinition)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(new CCTexture2D());
            }

            int imageWidth;
            int imageHeight;
            var textDef = textDefinition;
            var contentScaleFactorWidth  = CCLabel.DefaultTexelToContentSizeRatios.Width;
            var contentScaleFactorHeight = CCLabel.DefaultTexelToContentSizeRatios.Height;

            textDef.FontSize          *= contentScaleFactorWidth;
            textDef.Dimensions.Width  *= contentScaleFactorWidth;
            textDef.Dimensions.Height *= contentScaleFactorHeight;

            bool hasPremultipliedAlpha;

            var font = CreateFont(textDef.FontName, textDef.FontSize);

            var _currentFontSizeEm = textDef.FontSize;
            var _currentDIP        = ConvertPointSizeToDIP(_currentFontSizeEm);

            // color
            var foregroundColor = new Color4(1f, 1f, 1f, 1f);

            // alignment
            var horizontalAlignment = textDef.Alignment;
            var verticleAlignement  = textDef.LineAlignment;

            var textAlign = (CCTextAlignment.Right == horizontalAlignment) ? TextAlignment.Trailing
                : (CCTextAlignment.Center == horizontalAlignment) ? TextAlignment.Center
                : TextAlignment.Leading;

            var paragraphAlign = (CCVerticalTextAlignment.Bottom == vertAlignment) ? ParagraphAlignment.Far
                : (CCVerticalTextAlignment.Center == vertAlignment) ? ParagraphAlignment.Center
                : ParagraphAlignment.Near;

            // LineBreak
            var lineBreak = (CCLabelLineBreak.Character == textDef.LineBreak) ? WordWrapping.Wrap
                : (CCLabelLineBreak.Word == textDef.LineBreak) ? WordWrapping.Wrap
                : WordWrapping.NoWrap;

            // LineBreak
            // TODO: Find a way to specify the type of line breaking if possible.

            var dimensions = new CCSize(textDef.Dimensions.Width, textDef.Dimensions.Height);

            var layoutAvailable = true;

            if (dimensions.Width <= 0)
            {
                dimensions.Width = 8388608;
                layoutAvailable  = false;
            }

            if (dimensions.Height <= 0)
            {
                dimensions.Height = 8388608;
                layoutAvailable   = false;
            }

            var fontName   = font.FontFamily.FamilyNames.GetString(0);
            var textFormat = new TextFormat(FactoryDWrite, fontName,
                                            _currentFontCollection, FontWeight.Regular, FontStyle.Normal, FontStretch.Normal, _currentDIP);

            textFormat.TextAlignment      = textAlign;
            textFormat.ParagraphAlignment = paragraphAlign;

            var textLayout = new TextLayout(FactoryDWrite, text, textFormat, dimensions.Width, dimensions.Height);

            var boundingRect = new RectangleF();

            // Loop through all the lines so we can find our drawing offsets
            var textMetrics = textLayout.Metrics;
            var lineCount   = textMetrics.LineCount;

            // early out if something went wrong somewhere and nothing is to be drawn
            if (lineCount == 0)
            {
                return(new CCTexture2D());
            }

            // Fill out the bounding rect width and height so we can calculate the yOffset later if needed
            boundingRect.X      = 0;
            boundingRect.Y      = 0;
            boundingRect.Width  = (int)textMetrics.Width;
            boundingRect.Height = (int)textMetrics.Height;

            if (!layoutAvailable)
            {
                if (dimensions.Width == 8388608)
                {
                    dimensions.Width = boundingRect.Width;
                }
                if (dimensions.Height == 8388608)
                {
                    dimensions.Height = boundingRect.Height;
                }
            }

            imageWidth  = (int)dimensions.Width;
            imageHeight = (int)dimensions.Height;

            // Recreate our layout based on calculated dimensions so that we can draw the text correctly
            // in our image when Alignment is not Left.
            if (textAlign != TextAlignment.Leading)
            {
                textLayout.MaxWidth  = dimensions.Width;
                textLayout.MaxHeight = dimensions.Height;
            }

            // Line alignment
            var yOffset = (CCVerticalTextAlignment.Bottom == verticleAlignement ||
                           boundingRect.Bottom >= dimensions.Height) ? dimensions.Height - boundingRect.Bottom // align to bottom
                : (CCVerticalTextAlignment.Top == verticleAlignement) ? 0                                      // align to top
                : (imageHeight - boundingRect.Bottom) * 0.5f;                                                  // align to center


            if (labelRenderer == null)
            {
                labelRenderer = new CCLabel_Renderer81();
            }

            try
            {
                // The following code creates a .png stream in memory of our Bitmap and uses it to create our Textue2D
                Texture2D tex = null;

                using (var pngStream = labelRenderer.RenderLabelToStream(imageWidth, imageHeight, foregroundColor,
                                                                         new Vector2(boundingRect.X, yOffset), textLayout).Result)
                {
                    // Create the Texture2D from the png stream
                    tex = Texture2D.FromStream(CCDrawManager.SharedDrawManager.XnaGraphicsDevice, pngStream);
                }

                // Return our new CCTexture2D created from the Texture2D which will have our text drawn on it.
                return(new CCTexture2D(tex));
            }
            catch (Exception exc)
            {
                CCLog.Log("CCLabel-Windows: Unable to create the backing image of our text.  Message: {0}", exc.StackTrace);
            }
            finally
            {
                if (textFormat != null)
                {
                    textFormat.Dispose();
                    textFormat = null;
                }

                if (textLayout != null)
                {
                    textLayout.Dispose();
                    textLayout = null;
                }
            }

            // If we have reached here then something has gone wrong.
            return(new CCTexture2D());
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Draw formatted text.
        /// </summary>
        /// <remarks>
        /// The parameters of this method are very similar to those of the {{GDI DrawText}} function. This method supports both ANSI and Unicode strings. Unless the DT_NOCLIP format is used, this method clips the text so that it does not appear outside the specified rectangle. All formatting is assumed to have multiple lines unless the DT_SINGLELINE format is specified. If the selected font is too large for the rectangle, this method does not attempt to substitute a smaller font. This method supports only fonts whose escapement and orientation are both zero.
        /// </remarks>
        /// <param name="sprite">Reference to an ID3DX10Sprite object that contains the string you wish to draw. Can be NULL, in which case Direct3D will render the string with its own sprite object. To improve efficiency, a sprite object should be specified if ID3DX10Font::DrawText is to be called more than once in a row. </param>
        /// <param name="text">Pointer to a string to draw. If UNICODE is defined, this parameter type resolves to an LPCWSTR, otherwise, the type resolves to an LPCSTR. If the Count parameter is -1, the string must be NULL terminated. </param>
        /// <param name="rect">Pointer to a <see cref="SharpDX.Rectangle"/> structure that contains the rectangle, in logical coordinates, in which the text is to be formatted. As with any RECT object, the coordinate value of the rectangle's right side must be greater than that of its left side. Likewise, the coordinate value of the bottom must be greater than that of the top. </param>
        /// <param name="drawFlags">Specify the method of formatting the text. It can be any combination of the following values:    ItemDescription  DT_BOTTOM  Justify the text to the bottom of the rectangle. This value must be combined with DT_SINGLELINE.   DT_CALCRECT  Tell DrawText to automatically calculate the width and height of the rectangle based on the length of the string you tell it to draw. If there are multiple lines of text, ID3DX10Font::DrawText uses the width of the rectangle pointed to by the pRect parameter and extends the base of the rectangle to bound the last line of text. If there is only one line of text, ID3DX10Font::DrawText modifies the right side of the rectangle so that it bounds the last character in the line. In either case, ID3DX10Font::DrawText returns the height of the formatted text but does not draw the text.   DT_CENTER  Center text horizontally in the rectangle.   DT_EXPANDTABS  Expand tab characters. The default number of characters per tab is eight.   DT_LEFT  Align text to the left.   DT_NOCLIP  Draw without clipping. ID3DX10Font::DrawText is somewhat faster when DT_NOCLIP is used.   DT_RIGHT  Align text to the right.   DT_RTLREADING  Display text in right-to-left reading order for bidirectional text when a Hebrew or Arabic font is selected. The default reading order for all text is left-to-right.   DT_SINGLELINE  Display text on a single line only. Carriage returns and line feeds do not break the line.   DT_TOP  Top-justify text.   DT_VCENTER  Center text vertically (single line only).   DT_WORDBREAK  Break words. Lines are automatically broken between words if a word would extend past the edge of the rectangle specified by the pRect parameter. A carriage return/line feed sequence also breaks the line.   ? </param>
        /// <param name="color">Color of the text. See <see cref="SharpDX.Color4"/>. </param>
        /// <returns>If the function succeeds, the return value is the height of the text in logical units. If DT_VCENTER or DT_BOTTOM is specified, the return value is the offset from pRect (top to the bottom) of the drawn text. If the function fails, the return value is zero. </returns>
        /// <unmanaged>int ID3DX10Font::DrawTextW([None] LPD3DX10SPRITE pSprite,[None] const wchar_t* pString,[None] int Count,[None] RECT* pRect,[None] int Format,[None] D3DXCOLOR Color)</unmanaged>
        public unsafe int DrawText(SharpDX.Direct3D10.Sprite sprite, string text, SharpDX.Rectangle rect, FontDrawFlags drawFlags, SharpDX.Color4 color)
        {
            int value = DrawText(sprite, text, text.Length, new IntPtr(&rect), (int)drawFlags, color);

            if (value == 0)
            {
                throw new SharpDXException("Draw failed");
            }
            return(value);
        }
        private void AddPointCloud()
        {
            var points = new PointGeometry3D();
            var col    = new Color4Collection();  // gradient na kolory
            var ptPos  = new Vector3Collection(); // pozycje punktów
            var ptIdx  = new IntCollection();     // indeksy punktów


            int dataSampling = 2; // taki prosty przeskok miedzy punktami /można zrobić coś na podstawie odległości kamery albo różnicy wysokości między kolejnymi punktami

            // wpisywane na sztywno dane (lepiej zrobić funkcję obsługującą odpowiednie typy)
            // path = "C:/Users/astat/Desktop/DaneViewer/xyzi_wrakII.txt";
            //path = "C:/Users/astat/Desktop/DaneViewer/export_xyzi.txt";
            if (filepath != null && positionX != null && positionY != null && positionZ != null)
            {
                dataFromTxt(filepath, positionX, positionY, positionZ);
                //newdataFromTxt(path, positionX, positionY, positionZ);
                double maxX = positionX.Max();
                double minX = positionX.Min();
                double maxY = positionY.Max();
                double minY = positionY.Min();
                double maxZ = positionZ.Max();
                double minZ = positionZ.Min();

                Trace.WriteLine($"{maxX} {minX} {maxY} {minY} {maxZ} {minZ}");

                for (int i = 0; i < positionX.Count(); i += dataSampling) // tutaj powinna być pętla foreach ale potrzebowałem prostego przerzedzenia dannych
                {
                    //  Trace.WriteLine($"{i} {positionX[i]} {positionY[i]} {positionZ[i]}");
                    bool reverse = true;

                    var positionZReversed = maxZ - positionZ[i]; // czasami dostawałem punkty z odwróconą osią Z po to ta zmienna

                    var positionToColour = Math.Abs(positionZ[i] / (maxZ - minZ));

                    ptIdx.Add(ptPos.Count);
                    if (reverse == true)
                    {
                        ptPos.Add(new Vector3((float)positionX[i], (float)positionY[i], (float)positionZReversed));
                    }
                    else
                    {
                        ptPos.Add(new Vector3((float)positionX[i], (float)positionY[i], (float)positionZ[i]));
                    }

                    // Trace.WriteLine($"{i} {positionX[i]} {positionY[i]} {positionZ[i]} {positionToColour}");

                    var colourR = Math.Sqrt(-positionToColour + 0.75);
                    var colourG = (Math.Sin(4 * positionToColour - 0.2)) / 1.6;//tutaj trzeba potworzyć funkcje matematyczne żeby zmieniały się kolorki/ można też użyć warunków i color4.Scale
                    var colourB = Math.Sqrt(positionToColour - 0.25);

                    col.Add(new Color4((float)colourR, (float)colourG, (float)colourB, 1f)); //te kolory to czarna magia ale nie są według żadnej skali tylko żeby ładnie wyglądały hehe
                }                                                                            //Trace.WriteLine($"{i} {positionToColour} {colourR} {colourG} {colourB} {col[i]}");

                points.Positions = ptPos;
                points.Indices   = ptIdx;
                points.Colors    = col;
                PointsColor      = Colors.White; // <- nie pamiętam po co to tutaj ale bez tego nie działa
                Points           = points;
                PointsTransform  = new Media3D.TranslateTransform3D(0, 0, minZ);

                // floor plane grid

                CreateGrid(maxX, minX, maxY, minY, minZ);
                Grid          = lines.ToLineGeometry3D();
                GridColor     = new Color4(153 / 255.0f, 204 / 255.0f, 255 / 255.0f, (float)0.3).ToColor();;
                GridTransform = new Media3D.TranslateTransform3D(0, 0, minZ);

                // strzałki

                CreateArrows((float)maxX, (float)minX, (float)maxY, (float)minY, (float)maxZ, (float)minZ);
                Arrow          = arrows.ToLineGeometry3D();
                ArrowColor     = new Color4(0, 255 / 255.0f, 255 / 255.0f, (float)0.5).ToColor();;
                ArrowTransform = new Media3D.TranslateTransform3D(0, 0, minZ);
            }
        }
Ejemplo n.º 14
0
 public VertexPositionColor(SharpDX.Vector3 position, SharpDX.Color4 color)
 {
     Position = position;
     Color    = color;
 }
Ejemplo n.º 15
0
        private void CreateModels()
        {
            instances.Clear();
            parameters.Clear();

            if (aniDir)
            {
                aniX += 0.1f;
                aniY += 0.2f;
                aniZ += 0.3f;
            }
            else
            {
                aniX -= 0.1f;
                aniY -= 0.2f;
                aniZ -= 0.3f;
            }

            if (aniX > 15)
            {
                aniDir = false;
            }
            else if (aniX < -15)
            {
                aniDir = true;
            }

            for (int i = -num - (int)aniX; i < num + aniX; i++)
            {
                for (int j = -num - (int)aniX; j < num + aniX; j++)
                {
                    var matrix = Matrix.RotationAxis(new Vector3(0, 1, 0), aniX * Math.Sign(j))
                                 * Matrix.Translation(new Vector3(i * 1.2f + Math.Sign(i), j * 1.2f + Math.Sign(j), i * j / 2.0f));
                    var color = new Color4(1, 1, 1, 1);//new Color4((float)Math.Abs(i) / num, (float)Math.Abs(j) / num, (float)Math.Abs(i + j) / (2 * num), 1);
                    //  var emissiveColor = new Color4( rnd.NextFloat(0,1) , rnd.NextFloat(0, 1), rnd.NextFloat(0, 1), rnd.NextFloat(0, 0.2f));
                    var     k = Math.Abs(i + j) % 4;
                    Vector2 offset;
                    if (k == 0)
                    {
                        offset = new Vector2(aniX, 0);
                    }
                    else if (k == 1)
                    {
                        offset = new Vector2(0.5f + aniX, 0);
                    }
                    else if (k == 2)
                    {
                        offset = new Vector2(0.5f + aniX, 0.5f);
                    }
                    else
                    {
                        offset = new Vector2(aniX, 0.5f);
                    }

                    parameters.Add(new InstanceParameter()
                    {
                        DiffuseColor = color, TexCoordOffset = offset
                    });
                    instances.Add(matrix);
                }
            }
            InstanceParam  = parameters.ToArray();
            ModelInstances = instances.ToArray();
            SubTitle       = "Number of Instances: " + parameters.Count.ToString();

            if (BillboardInstances == null)
            {
                for (int i = 0; i < 2 * num; ++i)
                {
                    billboardParams.Add(new BillboardInstanceParameter()
                    {
                        TexCoordOffset = new Vector2(1f / 6 * rnd.Next(0, 6), 1f / 6 * rnd.Next(0, 6)), TexCoordScale = new Vector2(1f / 6, 1f / 6)
                    });
                    billboardinstances.Add(Matrix.Scaling(rnd.NextFloat(0.5f, 4f), rnd.NextFloat(0.5f, 3f), rnd.NextFloat(0.5f, 3f))
                                           * Matrix.Translation(new Vector3(rnd.NextFloat(0, 100), rnd.NextFloat(0, 100), rnd.NextFloat(-50, 50))));
                }
                BillboardInstanceParams = billboardParams.ToArray();
                BillboardInstances      = billboardinstances.ToArray();
            }
            else
            {
                for (int i = 0; i < billboardinstances.Count; ++i)
                {
                    var current = billboardinstances[i];
                    current.M41          += i % 3 == 0? aniX / 50 : -aniX / 50;
                    current.M42          += i % 4 == 0 ? aniY / 50 : -aniY / 30;
                    current.M43          += i % 5 == 0 ? aniZ / 100 : -aniZ / 50;
                    billboardinstances[i] = current;
                }
                BillboardInstances = billboardinstances.ToArray();
            }
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Function to convert a SharpDX color 4 type to a <see cref="GorgonColor"/>.
 /// </summary>
 /// <param name="color">The SharpDX raw color 4 type to convert.</param>
 /// <returns>A new <see cref="GorgonColor"/>.</returns>
 public static GorgonColor ToGorgonColor(this DX.Color4 color) => new GorgonColor(color.Red, color.Green, color.Blue, color.Alpha);
Ejemplo n.º 17
0
 public static Color ToEto(this s.Color4 value)
 {
     return(new Color {
         A = value.Alpha, R = value.Red, G = value.Green, B = value.Blue
     });
 }
Ejemplo n.º 18
0
 public static System.Drawing.Color ToSystemARGB(SharpDX.Color4 c)
 {
     return(System.Drawing.Color.FromArgb((int)(c.Alpha * 255), (int)(c.Red * 255), (int)(c.Green * 255), (int)(c.Blue * 255)));
 }