/// <summary> /// Draws a polygon using billboards /// </summary> public virtual void Draw(Vector2 size, Vector2 origin, 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 for (int i = 0; i < drawVertices.Count; i++) { drawVertices[i] = origin + size * vertices[i]; } BillBoardUtils.AddTriangles(triangles, drawVertices, ref polyMat, matrixRef); } }
/// <summary> /// Draws a billboard in world space facing the +Z direction of the matrix given. Units in meters, /// matrix transform notwithstanding. Dont forget to compensate for perspective scaling! /// </summary public void Draw(ref CroppedBox box, ref MatrixD matrix) { ContainmentType containment = ContainmentType.Contains; if (box.mask != null) { box.mask.Value.Contains(ref box.bounds, out containment); } if (containment != ContainmentType.Disjoint) { if (updateMatFit && matFrame.Material != Material.Default) { Vector2 boxSize = box.bounds.Size; minBoard.texCoords = matFrame.GetMaterialAlignment(boxSize.X / boxSize.Y); updateMatFit = false; } if (containment == ContainmentType.Contains) { minBoard.Draw(ref box, ref matrix); } else if (containment == ContainmentType.Intersects && matFrame.Material == Material.Default) { minBoard.DrawCropped(ref box, ref matrix); } else { minBoard.DrawCroppedTex(ref box, ref matrix); } } }
public Glyph(Material atlas, Vector2 size, Vector2 origin, float aw, float lsb) { advanceWidth = aw; leftSideBearing = lsb; matFrame = new MaterialFrame() { Material = new Material(atlas.TextureID, atlas.size, origin, size), Alignment = MaterialAlignment.FitHorizontal, }; Vector2 bbSize = matFrame.Material.size; texCoords = matFrame.GetMaterialAlignment(bbSize.X / bbSize.Y); MatFrame = matFrame; }
/// <summary> /// Draws a billboard in world space facing the +Z direction of the matrix given. Units in meters, /// matrix transform notwithstanding. Dont forget to compensate for perspective scaling! /// </summary public void Draw(ref CroppedBox box, MatrixD[] matrixRef) { ContainmentType containment = ContainmentType.Contains; if (box.mask != null) { box.mask.Value.Contains(ref box.bounds, out containment); } if (containment != ContainmentType.Disjoint) { if (updateMatFit && matFrame.Material != Material.Default) { Vector2 boxSize = box.bounds.Size; minBoard.materialData.texBounds = matFrame.GetMaterialAlignment(boxSize.X / boxSize.Y); updateMatFit = false; } if (containment != ContainmentType.Disjoint) { minBoard.Draw(ref box, matrixRef); } } }