Picking, ExtXith3DEnvironment and Perspective Projection

Hi guys,

Things are slowing moving along. I’m getting a better understand of Xith. However, I just hit a snag.

I’m currently workin with the Picking Library and everything looks good when I’m in Parallel projection (using the most excellent ExtXith3DEnvironment ). However, when I switch to perspective projection and try out picking, I get the same result as if I were in Parallel (i.e. not taking into account the Perspective pass).

Is it possible that MultiPass and Picking don’t work ell togheter ?

Alex

Thanks

Picking doesn’t seem to wortk with parallel projected things. Are you using ExtRenderLoop as well? If you do, you can easily call one of the pick methods in ExtXith3DEnvironment. Since picking must be done by the RenderLoop, I implemented picking within ExtXith3DEnvironment in conjunction with an ExtRenderLoop. You easily implement PickListener anywhere and add it to the ExtXith3DEnvironment. Then you are notified of the picking result.

What do you want to pick in you parallel projection? If you use a HUD, picking is done internally in the HUD without the PickingLibrary.

Actually, I wasn’t having problems with the parralel view, its the perspective projection that is giving me incorrect view.

In addition, if I want to implement a game using 3/4 view (ala Diablo for example), then I need parallel view.

As for the PickListener, I could use that, its just that I have to wait for the new frame to render to get my results … this means I’m going to have to change a lot of logic …

Alex

I don’t know Diablo. But do you mean bird’s eye view?

Well you call one or more methods after you get the PickResult. Just call them from the event method. The change shouldn’t too big.

And Xith3D isn’t thread safe by itself. For that reason picking needs to be done by the render thread. So you need to use a scheduled system like with ExtXith3DEnvironment/ExtRenderLoop or write something like it on your own, which wouldn’t make sense.

You certainly call you pick reaction code from within the mouse clicked event method. There shouldn’t be a difference to calling it from within the onObjectPicked method.

If you have some objects created in the mouse clicked method and you don’t want them to be defined class wide, pass them as the user object to the picking call.

Using your ExtEnv and ExtRender loop, I did some experiements and I think I found a bug:

if I do somethig like this:

		
		scenePass = new RenderPass(RenderPass.PERSPECTIVE_PROJECTION);
		hudPass = new RenderPass(RenderPass.PARALLEL_PROJECTION);
						   	
		environment.addRenderPass(hudPass);
		environment.addRenderPass(scenePass);

Then the picking for scenePass gets calculated as if I was in Perspective Project. However, if I switch the addRender calls

		
		scenePass = new RenderPass(RenderPass.PERSPECTIVE_PROJECTION);
		hudPass = new RenderPass(RenderPass.PARALLEL_PROJECTION);
						   	
		environment.addRenderPass(scenePass);
		environment.addRenderPass(hudPass);

then the picking results for scenePass are given to me as if I was in Parallel projection, even if I’m displaying in perspective mode. They way I see it, the picking library is using the last projection to resolve the coordinates, not the for the corresponding branch.

Alex

Well, this bug lays in the implementation of MultiPassView and PickingLibrary. Try to set the env.getView().setProjectionPolicy(pp) propery before you pick. Maybe this solves the problem. But it should be implemented transparently for the user. I will try to do it. But I’m planning to eliminate the MultiPassView and integrate its functionality into the View class. But this will need time. So try it with the above fix.

Yup, I added this line before the pick request and it worked:


environment.getView().setProjectionPolicy(RenderPass.PERSPECTIVE_PROJECTION);

Alex