/// <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); } }
public static void Init() { if (instance == null) { instance = new BillBoardUtils(); } }
public override void Close() { if (ExceptionHandler.Unloading) { instance = null; } }
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; }
/// <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); } }
private static void Init() { BillBoardUtils.Init(); if (_instance == null) { new HudMain(); } }
/// <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); }
private void AfterMasterDraw() { BillBoardUtils.FinishDraw(); }
private void BeforeMasterDraw() { UpdateCache(); cursor.Update(); BillBoardUtils.BeginDraw(); }
/// <summary> /// Draws a billboard in world space using the quad specified. /// </summary> public void Draw(ref MyQuadD quad) { BillBoardUtils.AddQuad(ref materialData, ref quad); }