question

MarinoLiranzo-9878 avatar image
0 Votes"
MarinoLiranzo-9878 asked HuiLiu-MSFT commented

How to Write Text in a WPF Viewport3d That Always Reads Front

Hello, I am using a following method to write text in a wpf viewport3d from Mr. Rod Stephens-CsharpHelper.com.

 textLong = TextCreator.CreateTextLabelModel3D(.ToString(), colorTexto,
                         true, .20, new Point3D(new Point3D(x, y, z)),
              new Vector3D(1, 0, 0), new Vector3D(0, 0, 1));
                         modelg.Children.Add(textLong);

The problem is that the orientation and direction of the text depends on the vectors in the method and in this case the texts will always be seen in the position indicated by the vectors, I would like that when the camera rotates the text reads the same, that is, that the vectors change to adapt to the new position of the camera.

Greeting Marino Liranzo


windows-wpf
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,@MarinoLiranzo-9878 . I can't look at the link in your question, it's pointing incorrectly. Could you show me a minimal code example that reproduces the problem so I can analyze the problem?

0 Votes 0 ·
MarinoLiranzo-9878 avatar image
0 Votes"
MarinoLiranzo-9878 answered HuiLiu-MSFT commented

Hello Huiliu-MSFT, Thank you for your interest.
In this case, in the "Vector3D(1, 0, 0)" method, it indicates that the text will be displayed in the X direction, the vector Vector3D(0, 0, 1) indicates that the text will have its elevation in Z, that is, will be displayed in the xz plane, when I rotate the model the text will rotate as well as the plane it lies on. I want the text to always be displayed as if the model had not rotated, I think that the components of the vectors should be modified in which they are automatically modified with the rotation of the model. My viewport is a Helix Viewport3D and the rotations are done through the mouse.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,@MarinoLiranzo-9878 . Could you show me the minimal code example that reproduces the problem ?

0 Votes 0 ·
MarinoLiranzo-9878 avatar image
0 Votes"
MarinoLiranzo-9878 answered HuiLiu-MSFT commented

Hi,

Attached code snippet.

private void MostrarRepresentacionNudos(Model3DGroup modelg, Vector3D _v1, Vector3D _v2)
{
modelg.Children.Remove(textcreate);
Brush colorTexto = colortextosProp;

if (nudoList != null)
{
for (int i = 0; i < nudoList.Count; i++)
{
clodo = new clNodos();
clodo.pt = nudoList[i];
clodo.name = "N" + i;
cnodo.Add(clodo);
}
for (int i = 0; i < cnodo.Count; i++)
{
clNodos cln = new clNodos();
double x = cnodo[i].pt.X;
double y = cnodo[i].pt.Y;
double z = cnodo[i].pt.Z;
textLong = TextCreator.CreateTextLabelModel3D(cnodo[i].name, colorTexto,
true, .20, new Point3D(x, y + 0.20, z), _v1, _v2);
modelg.Children.Add(textLong);
}
}
if (nList != null)
{
for (int i = 0; i < nList.Count; i++)
{
wlodo = new Node();
wlodo.Location = nList[i].Location;
wlodo.Label = "N" + (nudoList.Count + i);
Wnodo.Add(wlodo);
}
for (int i = 0; i < Wnodo.Count; i++)
{
Node cln = new Node();
double x = Wnodo[i].Location.X;
double y = Wnodo[i].Location.Y;
double z = Wnodo[i].Location.Z;

Draw3DNudos(MainModel3Dgroup, new Point3D(x, y, z), 0.025, colorMuros);

textLong = TextCreator.CreateTextLabelModel3D(Wnodo[i].Label, colorTexto,
true, .20, new Point3D(x, y +.15, z), _v1, _v2);
modelg.Children.Add(textLong);
}
}
}
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,@MarinoLiranzo-9878. I can't reproduce your problem with the method you posted. Is it possible to share the code of your complete project? (For example, create a GitHub repository and provide a link to share the code.
https://docs.microsoft.com/en-us/learn/modules/visual-studio-github-push/ )

0 Votes 0 ·