mycroftholmeslives
28-07-2010 20:34:28
My title mostly summarizes my problem: RayQueries that should intersect with objects in my scene just.... don't.
Ray Queries that should intersect with the first return nothing, whereas ray queries that intersect the second behave as expected. At first I though maybe the bounding box was wrong, or something like that, but showing it and manually printing its coordinates seems to confirm that it exists. I should say as well that I can't get any other .mesh file to work properly in place of ninja.mesh, I've tried most of the other demo mesh's, as well as a basic cube I created and exported from 3dsMax. Just for reference, in case I've done something wrong in the query, the code that actually does that bit follows:
Any help at all that anyone can provide would be greatly appreciated. I've been beating my head against the wall trying to make what seems like it should be a reasonably simple thing work for a good 10 or 12 hours now. I figure there's probably something I just don't know here, so if anyone does, please tell me.
Thanks!
# Setup a mesh object.
ent = self.sceneManager.createEntity('Ninja', 'mycube.mesh')
print ent.getMesh().getBounds().getMaximum()
ent.castShadows = True
self.sceneManager.getRootSceneNode().createChildSceneNode('Ninja').attachObject(ent)
self.sceneManager.getSceneNode('Ninja').showBoundingBox(True)
self.sceneManager.getSceneNode('Ninja').setPosition(0,50,0)
# Setup a ground plane.
plane = ogre.Plane ((0, 1, 0), 0)
meshManager.createPlane ('Ground', 'General', plane,
1500, 1500, 20, 20, True, 1, 5, 5, (0, 0, 1))
ent = self.sceneManager.createEntity('GroundEntity', 'Ground')
self.sceneManager.getRootSceneNode().createChildSceneNode ('GroundEntity').attachObject (ent)
self.sceneManager.getSceneNode('GroundEntity').showBoundingBox(True)
ent.setMaterialName ('Examples/Rockwall')
ent.castShadows = False
Ray Queries that should intersect with the first return nothing, whereas ray queries that intersect the second behave as expected. At first I though maybe the bounding box was wrong, or something like that, but showing it and manually printing its coordinates seems to confirm that it exists. I should say as well that I can't get any other .mesh file to work properly in place of ninja.mesh, I've tried most of the other demo mesh's, as well as a basic cube I created and exported from 3dsMax. Just for reference, in case I've done something wrong in the query, the code that actually does that bit follows:
self.raySceneQuery.setRay(mouseRay)
# Execute query
result = self.raySceneQuery.execute()
print str(self.sceneManager.getEntity('Ninja').getWorldBoundingBox().getMaximum())
print str(mouseRay.intersects(self.sceneManager.getEntity('Ninja').getWorldBoundingBox()).first)
print "Query Length: "+str(len(result))
if len(result) > 0:
for item in result:
print item
item = result[0]
print "HEY!" + str(self.raySceneQuery.getRay().getPoint(item.distance))+str(item.movable.name)
self.currentObject = item.movable
Any help at all that anyone can provide would be greatly appreciated. I've been beating my head against the wall trying to make what seems like it should be a reasonably simple thing work for a good 10 or 12 hours now. I figure there's probably something I just don't know here, so if anyone does, please tell me.
Thanks!