Java3D graphics: solid line looks dashed

In summary, the two problems Hassan is facing are: 1. The lines look like they are dashed when the line width is set to 1.0f for the edges. 2. The lines have poor quality and are not parallel with the screen sides.
  • #1
Hassan2
426
5
Dear all,

In Java and using Java3D library, I have created a GUI for viewing finite element quad element meshes. I am facing two problems with the graphics:

1. In order to draw the meshes, I draw the quads and the edges separately so that I am able to remove one and leave the other on the screen view. The edges have different color than the quads. The problem is that when I choose line width 1.0f for the edges, they look like they are dashed. In fact they somehow overlap with the quads. If I choose wider lines, then it's fine but the appearance won't be good with thicker lines. How can I solve this problem?

2. The second problem is that even without the quads, the lines have poor quality , that means then they are not parallel with the screen sides, they have teeth ( they are not drawn finely). How can I draw them finer?

Your help would be appreciated.

Thanks

Hassan
 
Technology news on Phys.org
  • #2
Hey Hassan2.

For the second problem you should try to see if you can turn on what is known as Anti-Aliasing (AA). You can do this software side and hardware (driver side) and if you disable it driver side you disable it for all software applications. It should be in your graphics driver options.

The other thing is to check whether the Java3D has a line style parameter. OpenGL has a line style parameter that allows you to set how you want to render lines and you should check if Java3D does as well.

One suggestion for the quads is to choose an offset that is slightly out of place where you don't get overlap.

Also you might want to check the texture options and make sure you have high quality textures and to use mip-mapping if you aren't using it.

Another suggestion is to do one of the following: create a border in your initial texture so that the border is the same color of the line. If you are using a solid fill color as opposed to a texture, then have slightly different vertices for the line and for the actual quads themselves.

The other suggestion is to use double precision for all your co-ordinate data instead of normal floating point numbers: this will make a big difference.
 
  • #3
Thanks chiro,

I didn't find the AA option on my driver side. Enabling it on the software side makes the lines smoother but they are still broken ( due to overlapping).

I think the problem with the brokenness is that I have defined a LineArray as the borders of the quads. I just figured out that there is no need for the LineArray and we can use PloygonAttributes to render the polygons ( here quads) as points, lines or fill. I have not been able to draw both the lines and the fill yet, but I believe we can render both and I expect the lines would have no problem.


Thanks
 

1. Why does my solid line in Java3D graphics look dashed?

This is most likely due to the anti-aliasing feature in Java3D. Anti-aliasing is used to smooth out jagged lines and edges, but it can also make solid lines appear dashed. You can try adjusting the anti-aliasing settings or disabling it altogether to see if that solves the issue.

2. How can I fix the issue of my solid line appearing dashed in Java3D graphics?

One solution is to use the setLineStipple() method to specify a custom pattern for your line. This will override the anti-aliasing and create a solid line. Another option is to use a different rendering technique, such as using a polygon with a very small width instead of a line, to achieve a solid line appearance.

3. Can the issue of solid lines appearing dashed in Java3D graphics be caused by hardware limitations?

Yes, it is possible that the graphics hardware on your computer may not support certain anti-aliasing techniques, which can result in solid lines appearing dashed. In this case, you may need to adjust your graphics settings or use a different computer with more advanced hardware.

4. Are there any known bugs or glitches in Java3D that can cause solid lines to look dashed?

There have been some reported bugs in earlier versions of Java3D where solid lines would sometimes appear dashed. However, these issues have been addressed in more recent versions. If you are experiencing this issue, make sure you are using the latest version of Java3D.

5. Can I use any other libraries or tools to create solid lines in Java3D graphics?

Yes, there are other libraries and tools available that can help you achieve a solid line appearance in Java3D graphics. For example, you can use the JavaFX library, which has more advanced graphics capabilities including the ability to create solid lines. You can also try using third-party tools or plugins specifically designed for creating solid lines in Java3D graphics.

Similar threads

  • Mechanical Engineering
Replies
1
Views
2K
  • General Engineering
Replies
2
Views
2K
Replies
8
Views
4K
  • Special and General Relativity
3
Replies
75
Views
3K
  • Programming and Computer Science
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
4K
  • General Engineering
Replies
1
Views
3K
Replies
1
Views
1K
  • STEM Academic Advising
Replies
16
Views
2K
Back
Top