Scene Queries

From Axiom

Jump to: navigation, search

Contents

Overview

SceneQuery's give a common API to test for intersections in your scene.

There are Query's for Ray hit tests, region test and so on.

They give a coarse result based on aabb or bounding sphere's. The idea is to get a fast first result, then refine that if needed.

Usage

There are two ways to use them:

1. mySceneQuery.Execute()

this will return an arraylist with RaySceneQueryResultEntry's, which contain the SceneObject hit and the distance.

2. mySceneQuery.Execute(mySceneQueryListener)

here you pass an instance of a Inner Class implementing the coresponding Listener interface of the type of Query you created. this gives you more control of how to handle objects. You get a callback per object intersection found.


Examples

Mouse Picking

See the PerformMouseSelection() method of the RealmForge.Player class in RealmForge's Framework project for an example of its use and see the RealmForge.Scene.AxiomMouseRayQuery class for an example RayQuery implementation for mouse picking.

Notes

One thing to note is that it's not necesairy to create the SceneQuery each time you pick something. You only update the Ray it uses and Excute again. (this is true for SceneQueries in general, not just mouse picking)