Page 1 of 1

IllegalStateException starting Timer when using jogl Viewer

Posted: Sat 1. Sep 2012, 09:28
by ted
If I use a timer on a SceneGraphComponent that is ultimately connected to a JRViewer, it works fine, but when using it with de.jreality.jogl.Viewer, it throws an exception when started:

Code: Select all

Exception in thread "main" java.lang.IllegalStateException: timer not attached!
What needs to be done to get it to work with a jogl viewer? Perhaps it should just work the same? I could use a Swing Timer but it doesn't seem to automatically re-render when the scene graph has changed like the does.

Re: IllegalStateException starting Timer when using jogl Vie

Posted: Mon 3. Sep 2012, 11:52
by gunn
I think the distinction is not between JRViewer and de.jreality.jogl.Viewer, since the former uses the latter to render. It's more a question of whether the Viewer you have set up is properly configured to run with instances of, in the same way that JRViewer apparently can.

I tested out such an instance with the tutorial example de.jreality.tutorial.viewer.ViewerFromScratch by adding some code after the tool system is initialized:

Code: Select all

	final Appearance rootApp= new Appearance();
       ToolSystem toolSystem = ToolSystem.toolSystemForViewer(viewer);
       Timer timer = new Timer(10, new ActionListener() {
		int count = 0;
		public void actionPerformed(ActionEvent arg0) {
		    if (count > 255) count = 0;
		    rootApp.setAttribute(CommonAttributes.DIFFUSE_COLOR, new Color(count, 0, (255-count)));
This changes the color of the icosahedron from blue to red. It runs without problems for me. At least in this example, the class de.jreality.jogl.Viewer works fine with instances of de.jreality.tool.Timer.

Perhaps you can isolate the problem in your code in a short example?