[solved] RaySceneQueryResult is empty when I'm far

nico008

03-01-2011 13:46:20

Hi

QueryResult is mostly always empty when I'm far from point (0,0,0).
It is not empty only when my camera is facing that point (if I'm right)
Here is my code:

camera2.Position = camera.DerivedPosition;
camera2.Direction = camera.DerivedDirection;
raySceneQuery = sceneMgr.CreateRayQuery(new Ray(camera2.Position, camera2.Direction));
raySceneQuery.SetSortByDistance(true);
raySceneQuery.QueryTypeMask = (uint)SceneManager.ENTITY_TYPE_MASK;
raySceneQuery.Ray = camera2.GetCameraToViewportRay(((float)inputMouse.MouseState.X.abs) / viewport.ActualWidth, ((float)inputMouse.MouseState.Y.abs) / viewport.ActualHeight);
//raySceneQuery.QueryMask = 0x01; //query MO too
raySceneQuery.Execute();
RaySceneQueryResult result2 = raySceneQuery.GetLastResults();



Any idea?
Are there other solution to select entity under mouse cursor?
Thanks in advance for your help!

nico008

03-01-2011 23:03:06

It seems like when I reach a distance of ~2200 (I don't know exactly) from point (0,0,0), then RaySceneQueryResult is not empty only when I click on an entity while I'm facing the origin point. If I look to another direction, result is empty.
I 1st thought that the problem was that I had attached my camera to some nodes but I also get the same probleme without attaching it to anything.

Very strange problem for me.
I hope this "bug" can be solved otherwise the project I'm making will not make sense anymore :-(

Beauty

04-01-2011 02:04:15

Maybe the world size is too small?
(I'm not shure, but in my application I need to increase the world size of my scene manager (Terrain Scene Manager) and also the world size of Newton physics. Maybe this is also needed for ray queries?)

An example for ray queries I published in the wiki:
http://www.ogre3d.org/tikiwiki/Ray+query+with+MOGRE

Maybe it's usable for you.

nico008

04-01-2011 02:08:31

Maybe the world size is too small?
(I'm not shure, but in my application I need to increase the world size of my scene manager (Terrain Scene Manager) and also the world size of Newton physics. Maybe this is also needed for ray queries?)


This is certainly this problem.
How could I change it?
I'm using
YTeleporter.sceneMgr.SetWorldGeometry("Terrain.cfg");
Also I would like to change the offset of the terrain but I don't know of it's possible :-(

Beauty

04-01-2011 02:59:05

For the Terrain Scene Manger I only know the way by the config file. An other option (by code) I didn't found.
Well, the TSM ist a little bit old. The new terrain system will be much more improved in this case :wink:

Here some params for the terrain.cfg file:

PageWorldX, PageWorldZ: This sets the extents of the terrain in world coordinates. The larger the terrain, the lower the detail will be in the terrain, as the number of vertices used for the terrain is based on the heightmap, not the world size. This can be used to scale the terrain to any size you want.

MaxHeight: The maximum height of the terrain in world coordinates. The 0..255 (resp. 0..65535) range from the heightmap is scaled to 0..MaxHeight in world coordinates.
Maybe the maxheight value notes are not correct. In my application I use values larger then 255.

Look here for TSM details:
http://www.ogre3d.org/tikiwiki/Terrain+Scene+Manager

nico008

04-01-2011 03:22:18

Thanks a lot, this solved my problem :-)
I still miss the possibility to change terrain position (it start at (0,x,0) so there is no terrain for x < 0 or z < 0).
I guess that I will have to wait for the new terrain manager ;-)

Now I can go sleep since my app is working

Thanks again!!!

Beauty

04-01-2011 20:34:33

Nice that your problems are solved now.
It seems so that the terrain of the TSM is only available in positive x-z direction.

An alternative could be to attach a SceneNode to the middle of the scene (e.g. with the name worldNode).
All other nodes are not attached to the rootSceneNode. Instead attach them to the worldNode and the positions will be relative to the scene middle.
Of course sometimes you will need a coordinate conversion (add/remove this position offset).
For example for ray query results.
But this way is possible. I use such a "secondary coordinate system" on my application, too.

nico008

04-01-2011 22:14:29

Indeed this is a solution :-)
Anyway I hope that the next terrain manager will allow to change terrain position.
It would be more convenient ;-)

See ya