/// <summary>
        /// Draws the given range of faces
        /// </summary>
        public override void Draw(Vector2 size, Vector2 origin, Vector2I faceRange, MatrixD[] matrixRef)
        {
            if (_sides > 2 && drawVertices.Count > 5)
            {
                if (updateVertices)
                {
                    GeneratePolygon();
                }

                if (updateMatFit)
                {
                    polyMat.texBounds = matFrame.GetMaterialAlignment(size.X / size.Y);
                    GenerateTextureCoordinates();
                    updateMatFit = false;
                }

                faceRange.Y++;
                faceRange *= 2;
                // Outer vertex indices are even
                faceRange.X -= faceRange.X % 2;
                faceRange.Y -= faceRange.Y % 2;

                // Generate final vertices for drawing from unscaled vertices
                for (int i = faceRange.X; i <= faceRange.Y + 1; i++)
                {
                    drawVertices[i % drawVertices.Count] = origin + size * vertices[i % drawVertices.Count];
                }

                faceRange *= 3;
                BillBoardUtils.AddTriangleRange(faceRange, triangles, drawVertices, ref polyMat, matrixRef);
            }
        }
Esempio n. 2
0
 public static void Init()
 {
     if (instance == null)
     {
         instance = new BillBoardUtils();
     }
 }
Esempio n. 3
0
 public override void Close()
 {
     if (ExceptionHandler.Unloading)
     {
         instance = null;
     }
 }
Esempio n. 4
0
 public QuadBoard(MyStringId textureID, BoundingBox2 matFit, Color color, float skewRatio = 0f)
 {
     materialData.textureID = textureID;
     materialData.texBounds = matFit;
     materialData.bbColor   = BillBoardUtils.GetBillBoardBoardColor(color);
     this.skewRatio         = skewRatio;
 }
Esempio n. 5
0
        /// <summary>
        /// Draws the given range of faces
        /// </summary>
        public virtual void Draw(Vector2 size, Vector2 origin, Vector2I faceRange, MatrixD[] matrixRef)
        {
            if (_sides > 2 && drawVertices.Count > 2)
            {
                if (updateVertices)
                {
                    GeneratePolygon();
                }

                if (updateMatFit)
                {
                    polyMat.texBounds = matFrame.GetMaterialAlignment(size.X / size.Y);
                    GenerateTextureCoordinates();
                    updateMatFit = false;
                }

                // Generate final vertices for drawing from unscaled vertices
                int max = drawVertices.Count - 1;
                drawVertices[max] = origin + size * vertices[max];

                for (int i = 0; i < drawVertices.Count; i++)
                {
                    drawVertices[i] = origin + size * vertices[i];
                }

                faceRange *= 3;
                BillBoardUtils.AddTriangleRange(faceRange, triangles, drawVertices, ref polyMat, matrixRef);
            }
        }
Esempio n. 6
0
                private static void Init()
                {
                    BillBoardUtils.Init();

                    if (_instance == null)
                    {
                        new HudMain();
                    }
                }
Esempio n. 7
0
                /// <summary>
                /// Draws a billboard in world space facing the +Z direction of the matrix specified. Units in meters, matrix
                /// transform notwithstanding.
                /// </summary>
                public void Draw(ref CroppedBox box, MatrixD[] matrixRef)
                {
                    FlatQuad quad = new FlatQuad()
                    {
                        Point0 = box.bounds.Max,
                        Point1 = new Vector2(box.bounds.Max.X, box.bounds.Min.Y),
                        Point2 = box.bounds.Min,
                        Point3 = new Vector2(box.bounds.Min.X, box.bounds.Max.Y),
                    };

                    if (skewRatio != 0f)
                    {
                        Vector2 start = quad.Point0, end = quad.Point3,
                                offset = (end - start) * skewRatio * .5f;

                        quad.Point0  = Vector2.Lerp(start, end, skewRatio) - offset;
                        quad.Point3  = Vector2.Lerp(start, end, 1f + skewRatio) - offset;
                        quad.Point1 -= offset;
                        quad.Point2 -= offset;
                    }

                    BillBoardUtils.AddQuad(ref quad, ref materialData, matrixRef, box.mask);
                }
Esempio n. 8
0
 private void AfterMasterDraw()
 {
     BillBoardUtils.FinishDraw();
 }
Esempio n. 9
0
 private void BeforeMasterDraw()
 {
     UpdateCache();
     cursor.Update();
     BillBoardUtils.BeginDraw();
 }
Esempio n. 10
0
 /// <summary>
 /// Draws a billboard in world space using the quad specified.
 /// </summary>
 public void Draw(ref MyQuadD quad)
 {
     BillBoardUtils.AddQuad(ref materialData, ref quad);
 }