the U3D writer renders lines with a width of 1.0 as tubes, instead of real lines like the JOGL- and softviewer:
3 lines as triangle (JOGL renderer):
Same geometry exported into U3D file:
Heres the example code to reproduce the two images:
Code: Select all
import java.awt.Color;
import java.io.FileOutputStream;
import javax.swing.JFrame;
import de.jreality.geometry.IndexedLineSetFactory;
import de.jreality.io.JrScene;
import de.jreality.scene.Appearance;
import de.jreality.scene.SceneGraphComponent;
import de.jreality.shader.CommonAttributes;
import de.jreality.ui.viewerapp.ViewerApp;
import de.jreality.util.CameraUtility;
import de.jreality.writer.u3d.WriterU3D;
public class U3DTest {
public static void main(String[] arguments){
double[][] verticesArray = new double[][]{ {9.784843058305507E-21, 1.5823993035485093E-18, 3.6370738623165664E-18},
{0.03703248128294945, 0.03703248128294945, 0.012537581846117973},
{0.04300964996218681, 0.014725378714501858, 0.028867514804005623}};
int[][] lineIndicesArray = new int[][]{{0, 1}, {1, 2}, {2, 0}};
IndexedLineSetFactory indexedLineSetFactory = new IndexedLineSetFactory();
indexedLineSetFactory.setVertexCount(verticesArray.length);
indexedLineSetFactory.setVertexCoordinates(verticesArray);
indexedLineSetFactory.setEdgeCount(lineIndicesArray.length);
indexedLineSetFactory.setEdgeIndices(lineIndicesArray);
indexedLineSetFactory.setEdgeColors(new Color[]{Color.WHITE, Color.WHITE, Color.WHITE});
indexedLineSetFactory.update();
Appearance appearance = new Appearance();
appearance.setAttribute(CommonAttributes.POINT_RADIUS, 1.0);
appearance.setAttribute(CommonAttributes.POINT_SIZE, 1.0);
appearance.setAttribute(CommonAttributes.LINE_WIDTH, 1.0);
appearance.setAttribute(CommonAttributes.VERTEX_DRAW, false);
appearance.setAttribute(CommonAttributes.EDGE_DRAW, true);
appearance.setAttribute(CommonAttributes.FACE_DRAW, false);
appearance.setAttribute(CommonAttributes.TUBES_DRAW, false);
appearance.setAttribute(CommonAttributes.LIGHTING_ENABLED, true);
appearance.setAttribute(CommonAttributes.ANTIALIASING_ENABLED, false);
appearance.setAttribute(CommonAttributes.POLYGON_SHADER + "." + CommonAttributes.SMOOTH_SHADING, false);
SceneGraphComponent sceneGraphComponent = new SceneGraphComponent();
sceneGraphComponent.setGeometry(indexedLineSetFactory.getGeometry());
sceneGraphComponent.setAppearance(appearance);
try {
FileOutputStream u3dFileOutputStream = new FileOutputStream("d:\\test.pdf.u3d");
WriterU3D.write(new JrScene(sceneGraphComponent), u3dFileOutputStream);
u3dFileOutputStream.close();
} catch(Exception exception){
exception.printStackTrace();
}
ViewerApp viewerApp = new ViewerApp(sceneGraphComponent);
viewerApp.setBackgroundColor(Color.DARK_GRAY);
CameraUtility.encompass(viewerApp.getCurrentViewer());
JFrame frame = new JFrame();
frame.setBounds(50, 50, 300, 300);
frame.add(viewerApp.getViewingComponent());
frame.setVisible(true);
}
}