U3D writer renders lines always as tubes

Found a bug? Post here.
Post Reply
Joe
Posts: 61
Joined: Fri 11. Jul 2008, 19:29

U3D writer renders lines always as tubes

Post by Joe » Fri 12. Jun 2009, 20:40

Hi,
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):
Image

Same geometry exported into U3D file:
Image

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);
	}
}

sechel
Posts: 69
Joined: Tue 2. Oct 2007, 09:20

Re: U3D writer renders lines always as tubes

Post by sechel » Sat 13. Jun 2009, 13:55

Hi Joe,
by the time I wrote the U3D backend the acrobat reader 7.0 did not render line sets at all. So I had to substitute all lines by tubes regardles if those were only lines in jreality. However I expect adobe has been working on the renderer in the meantime and I'll have to sit down and try again. I will do this next week I promise!
Stefan

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: U3D writer renders lines always as tubes

Post by gunn » Tue 16. Jun 2009, 10:47

Here's a suggestion to try, until U3D can actually draw lines.

The idea is to draw tubes that look as much as possible like the lines you want to draw. Here's how:

Assuming sgc is the SceneGraphComponent containing your lines:

Code: Select all

Appearance ap = sgc.getAppearance();
DefaultGeometryShader dgs = ShaderUtility.createDefaultGeometryShader(ap, true);
DefaultLineShader dls = (DefaultLineShader) dgs.createLineShader("default");
dls.setTubeDraw(true);  
dls.setTubeRadius(.02);  // or whatever works
RenderingHintsShader rhs = ShaderUtility.createDefaultRenderingHintsShader(ap, true);
rhs.setLightingEnabled(false);  // don't want shading
jReality core developer

User avatar
steffen
Posts: 186
Joined: Fri 16. Jun 2006, 13:30
Location: TU Berlin
Contact:

Re: U3D writer renders lines always as tubes

Post by steffen » Tue 16. Jun 2009, 11:10

Or (instead of creating the Shader objects) you can also set the attributes directly:

Code: Select all

appearance.setAttribute(CommonAttributes.TUBE_DRAW, true);
appearance.setAttribute(CommonAttributes.TUBE_RADIUS, 0.02);

sechel
Posts: 69
Joined: Tue 2. Oct 2007, 09:20

Re: U3D writer renders lines always as tubes

Post by sechel » Wed 1. Jul 2009, 13:49

Hello,
I started working on various improvements in the U3D Writer. These include:

* Colors for vertices, edges and faces. Actually jreality seems to have bugs when
handling edge colors, so mabe we will have to fix these first.
* Real point and line-sets. Hopefully the Adobe Reader supports them now
* Memory footprint reduction for big models

So stay tuned.
Stefan

STRESS
Posts: 141
Joined: Mon 19. Jan 2009, 12:10

Re: U3D writer renders lines always as tubes

Post by STRESS » Thu 2. Jul 2009, 17:46

sechel wrote:Hello,
I started working on various improvements in the U3D Writer. These include:

* Colors for vertices, edges and faces. Actually jreality seems to have bugs when
handling edge colors, so mabe we will have to fix these first.
* Real point and line-sets. Hopefully the Adobe Reader supports them now
* Memory footprint reduction for big models

So stay tuned.
Stefan
Awesome!

Joe
Posts: 61
Joined: Fri 11. Jul 2008, 19:29

Re: U3D writer renders lines always as tubes

Post by Joe » Wed 16. Dec 2009, 21:45

Hi Sechel,
what's the current status? With the last and the current release, no lines are rendered any more. Also the colors of surfaces still seem to be unsupported.

Are you still working on the new features?

Thanks

Joe
Posts: 61
Joined: Fri 11. Jul 2008, 19:29

Re: U3D writer renders lines always as tubes

Post by Joe » Sat 16. Jan 2010, 21:54

Hi Sechel,
with the release of 2010-01-12, the lines are still not rendered anymore. The colors of surfaces aren't supported. What's the status of your announced improvements?

Best regards, Joe

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: U3D writer renders lines always as tubes

Post by gunn » Mon 22. Mar 2010, 21:02

Please see this thread for new developments with the u3d/pdf writer:

http://www3.math.tu-berlin.de/jreality/ ... ?f=11&t=45
jReality core developer

Post Reply