raySceneQuery.execute() CRASH

r0ot

04-12-2011 04:34:49

Here's the error I'm getting:
result = self.raySceneQuery.execute()
Boost.Python.ArgumentError: Python argument types in
DefaultRaySceneQuery.execute(DefaultRaySceneQuery)
did not match C++ signature:
execute(struct DefaultRaySceneQuery_wrapper {lvalue}, class Ogre::RaySceneQueryListener * listener)
execute(class Ogre::DefaultRaySceneQuery {lvalue}, class Ogre::RaySceneQueryListener * listener)


I have no clue why I'm getting this error because when I run the intermediate 3 tutorial code (which includes many rayqueries), it runs fine.
But for some reason the rayQueries within my project code are giving me trouble.
Here is the code surrounding my ray query execution()
self.raySceneQuery = self.sceneManager.createRayQuery(ogre.Ray())
mouseRay = self.camera.getCameraToViewportRay(400 / 800.0, 300 / 600.0) #the middle point of an 800x600 window
self.raySceneQuery.setRay(mouseRay)
self.raySceneQuery.setSortByDistance(True)
result = self.raySceneQuery.execute()


PLEASE help :(

dermont

04-12-2011 06:43:29

It looks like your are missing the OctreeSceneManager plugin in your plugins.cfg file:

Plugin=Plugin_OctreeSceneManager

r0ot

04-12-2011 21:16:45

Unfortunately, I checked, and that's not the problem :(
Here's my plugins.cfg:
# Defines plugins to load

# Define plugin folder
PluginFolder=Plugins

# Define D3D rendering implementation plugin
Plugin=RenderSystem_GL.dll
Plugin=RenderSystem_Direct3D9.dll
Plugin=Plugin_ParticleFX.dll
Plugin=Plugin_BSPSceneManager.dll
Plugin=Plugin_OctreeSceneManager.dll
Plugin=Plugin_CgProgramManager.dll


And I checked inside my plugins folder as well, and Plugin_OctreeSceneManager.dll is in it.

Hopefully there is something else wrong that you can think of :?
Thank you though

dermont

05-12-2011 04:27:08

This has been raised in the past but I thought it had been resolved. What version of python-ogre are you using? Do you have a simple demo/ example that illustrates the problem?

http://groups.google.com/group/python-o ... ceneQuery#

In the meantime as a work around you can subclass RaySceneQueryListener , there is an example given in the last link.

I'll try and dig out an old example I had that encountered this problem, it is probably something trivial.

r0ot

05-12-2011 04:54:52

This has been raised in the past but I thought it had been resolved. What version of python-ogre are you using? Do you have a simple demo/ example that illustrates the problem?

http://groups.google.com/group/python-o ... ceneQuery#

In the meantime as a work around you can subclass RaySceneQueryListener , there is an example given in the last link.

I'll try and dig out an old example I had that encountered this problem, it is probably something trivial.


I was afraid of such a "trivial" problem :o
But you are probably right about it.
I'm using whatever the most recent version of python-ogre there is out right now (sorry I'm not at my normal computer right now so I can't check exactly what it is).
For now I will do as you said, subclass RaySceneQueryListener, and see if I can make that work.
Thank you for your help.

r0ot

06-12-2011 01:09:32

The method mentioned in your previous post is working, somewhat.
Here is the class I've created following that example:
class MyRaySceneQueryListener(ogre.RaySceneQueryListener):
"""To get raySceneQueries to work"""
def __init__(self):
"Init"
super(MyRaySceneQueryListener, self).__init__()

def getCoords(self, app, x, y):
"Query Scene"
pos_w = float(x) / 800.0
pos_h = float(y) / 600.0

self.mouseRay = app.camera.getCameraToViewportRay(pos_w, pos_h)
self.raySceneQuery = app.sceneManager.createRayQuery(ogre.Ray())
self.raySceneQuery.setRay(self.mouseRay)
self.raySceneQuery.setSortByDistance(True)
self.raySceneQuery.execute(self)

def queryResult(self, entity, distance):
"No clue what this does"
print ""
print entity.getName(), self.mouseRay.getPoint(distance)
print ""


And here is how I call it:
sq = MyRaySceneQueryListener()
sq.getCoords(self, 400, 300) #I use those numbers because it's the center of my screen


And that prints out the first entity the ray hits and the distance, which is great! Except, how do I return the entity object to the calling class? Something like:

result = sq.getCoords(self, 400, 300)

Because I need a reference to the entity object that the ray hits to be in my calling class?

I've tried adjusting the MyRaySceneQueryListener class by putting return statements at the end of each function:
Like for getCoords, I put
return self.raySceneQuery.execute(self)
and that gave an error

and for queryResult
return entity
which also gave a result

So I don't know what to do at this point.

dermont

06-12-2011 12:01:39

You could try a method similar to the following post, create a list (whatever), clear before you execute the RaySceneQuery, update the list details in queryResult and return the list from getCoords:
http://89.151.96.106/addonforums/viewtopic.php?p=28535

For example something like (untested):

class MyRaySceneQueryListener(ogre.RaySceneQueryListener):
"""To get raySceneQueries to work"""
def __init__(self):
"Init"
super(MyRaySceneQueryListener, self).__init__()
self.result_list = []

def getCoords(self, app, x, y):
"Query Scene"
pos_w = float(x) / 800.0
pos_h = float(y) / 600.0

self.mouseRay = app.camera.getCameraToViewportRay(pos_w, pos_h)
self.raySceneQuery = app.sceneManager.createRayQuery(ogre.Ray())
self.raySceneQuery.setRay(self.mouseRay)
self.raySceneQuery.setSortByDistance(True)
self.result_list = []
self.raySceneQuery.execute(self)
return self.result_list

def queryResult(self, entity, distance):
"Called when a movable objects intersects the ray."
##http://www.ogre3d.org/docs/api/html/classOgre_1_1RaySceneQueryListener.html#ac3c09aba6b71ca28d721be30ed8f06ed

self.result_list.append( (entity, self.mouseRay.getPoint(distance)) )
## return 'true' if further results are required, or 'false' to abandon any further results from the current query.
return True



Edit:
Also the RaySceneQueryListener queryResult may have trouble differentiating between a
world geometry and movable queryResult. If you are using the Terrain SceneManager you can use the RayScene code in the terrain demo. Alternatively with the above you can do a simple check for the movable type.


def queryResult ( self, movable, distance):
if isinstance(movable ,ogre.MovableObject):
print movable.getName()
else: ## isinstance(movable ,ogre.WorldFragment):
print "FRAGMENT TYPE", movable.fragmentType
print "FRAGMENT INTERSECT",
movable.singleIntersection
return False