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:
Comments
it doesn't work. Visual studio say there no suitable method to override. I have did a copy paste.
Hi Antoine,
Text entity now has the Billboard property for this purpose. If you need vertical text, please accept the new list of parameters for GetBillboardTrasformation() method.
thanks Alberto,
but the position of the billboard is not always correct. How can set his position. the first image is Billboard = false and the second with Billboard = true
Antoine,
The billboard flag is not born to resolve 2D dimensioning problems but simply to resolve 3D text readability issues.
Please open a technical support ticket to go deeper on your issue.
Please sign in to leave a comment.