Thanks for the directions! But I’m running into apparently silly problems. I am basically try to find a way where I can deal with mouse and key events, and ‘tell’ the involved objects to act accordinglt. I would appreciate if someone could spot what’s wrong with the following?
I have a main class, with the following methods:
init() {
start rendering peer, canvas3d, universe,…
addMouseListener( eventManager --> which is a class that holds a Vector of events to be dealt with)
call run();
}
run() {
while(true) {
view.renderOnce();
handleEvents();
}
}
handleEvents() {
goes through events in the queue, and process it.
For example, if mouse was released call pick(x,y)
}
pick(x,y) {
try to pick some objects:
PickRenderResult[] results = view.pick(canvas, x, y, 3, 3);
}
The problem is that I get the following:
java.lang.Error: Pick initiated not from rendering thread
at com.xith3d.render.jogl.CanvasPeerImpl.render(CanvasPeerImpl.java:853)
at com.xith3d.scenegraph.View.pick(View.java:713)
at Main.pickDebug(Main.java:125)
at Main.handleEvents(Main.java:92)
at Main.run(Main.java:116)
at Main.init(Main.java:74)
at Main.main(Main.java:149)
What’s meant by the rendering thread? It’s the thread from where view.renderOnce() is called, right? Can another thread be granted permission to call the View.pick() ?
Is it necessary to have a queue to hold the events? Can’t events be processed straight from the EventListener class? (instead of just setting up some flags)
[All this is very interesting… :)]