Vertical billboard text

The code below demonstrates how to override the Text.GetBillboardTransformation() method to rotate the billboard text.

Text entity subclassing:

public class MyText : Text
{
   public MyText(double x, double y, double z, string textString, double height, alignmentType alingment) : base(x, y, z, textString, height, alingment)
   {
   }

   protected override Transformation GetBillboardTransformation(DrawParams data)
   {
      data.Viewport.Camera.GetFrame(out var origin, out var xAxis, out var yAxis, out var zAxis);

      Transformation t = new Rotation(Utility.PI_2, zAxis);

      xAxis.TransformBy(t);
      yAxis.TransformBy(t);

      Plane plnCopy = (Plane) Plane.Clone();
      plnCopy.Origin = Point3D.Origin;

      return new Align3D(plnCopy, new Plane(Point3D.Origin, xAxis, yAxis));
   }
}

Small sample that uses the class above:

LinearPath lp1 = new LinearPath(0, 0, 100, 50);
model1.Entities.Add(lp1);

Text t1 = new Text(0, 0, 0, "Frank Sinatra", 5);
Text t2 = new Text(50, 0, 0, "Elvis Presley", 5, devDept.Eyeshot.Entities.Text.alignmentType.BottomCenter);
MyText t3 = new MyText(100, 0, 0, "Marilyn Monroe", 5, devDept.Eyeshot.Entities.Text.alignmentType.BottomCenter);

t2.Billboard = true;
t3.Billboard = true;
            
model1.Entities.Add(t1, Color.Red);
model1.Entities.Add(t2, Color.Green);
model1.Entities.Add(t3, Color.Blue);

 Screenshot:

2018-12-07_11-20-23.png

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.