how can I render a simple line, not a tube. I mean a line like I draw with graphics.drawLine(...), which has always a thickness of one pixel.
With this piece of code, always a tube is rendered. Unfortunately the JavaDoc of the class CommonAttributes is not complete. I think with a special combination of attributes I could reach my aim.
Many thanks and best regards, Joe
Code: Select all
package de.jreality.tutorial;
import de.jreality.geometry.IndexedLineSetFactory;
import de.jreality.scene.Appearance;
import java.awt.Component;
import javax.swing.JFrame;
import de.jreality.scene.SceneGraphComponent;
import de.jreality.shader.CommonAttributes;
import de.jreality.ui.viewerapp.ViewerApp;
import java.awt.Color;
public class SimpleViewer {
public static void main(String[] args){
double[][] vertices = new double[][]{{-1, -1, 0}, {1, -1, 0}, {1, 1, 0}, {-1, 1, 0},
{-1, -1, 5}, {1, -1, 5}, {1, 1, 5}, {-1, 1, 5}};
int[][] faceIndices = new int[][]{ {0, 1}, {5, 4}, {5, 4}, {1, 5}, {2, 6}, {4, 7}};
IndexedLineSetFactory indexedLineSetFactory = new IndexedLineSetFactory();
indexedLineSetFactory.setVertexCount(vertices.length);
indexedLineSetFactory.setVertexCoordinates(vertices);
indexedLineSetFactory.setLineCount(faceIndices.length);
indexedLineSetFactory.setEdgeIndices(faceIndices);
indexedLineSetFactory.setEdgeColors(new Color[]{Color.RED, Color.RED, Color.RED, Color.RED, Color.RED, Color.RED});
indexedLineSetFactory.update();
SceneGraphComponent sceneGraphComponent = new SceneGraphComponent();
sceneGraphComponent.setGeometry(indexedLineSetFactory.getGeometry());
Appearance appearance = new Appearance();
appearance.setAttribute(CommonAttributes.VERTEX_DRAW, false);
appearance.setAttribute(CommonAttributes.EDGE_DRAW, true);
appearance.setAttribute(CommonAttributes.TUBES_DRAW, false);
appearance.setAttribute(CommonAttributes.FACE_DRAW, false);
sceneGraphComponent.setAppearance(appearance);
ViewerApp viewerApp = new ViewerApp(sceneGraphComponent);
JFrame frame = new JFrame();
frame.getContentPane().add((Component)viewerApp.getViewingComponent());
frame.setSize(512, 512);
frame.validate();
frame.setVisible(true);
}
}