diff --git a/Horde3D/Bindings/C++/Horde3D.h b/Horde3D/Bindings/C++/Horde3D.h
index aef0238..5308202 100644
--- a/Horde3D/Bindings/C++/Horde3D.h
+++ b/Horde3D/Bindings/C++/Horde3D.h
@@ -1306,20 +1306,37 @@ namespace Horde3D
 			Performs a recursive ray collision query.
 		
 		This function checks recursively if the specified ray intersects the specified node or one of its children.
-        The function finds the nearest intersection relative to the ray origin and returns the handle to the
-        corresponding scene node. The ray is a line segment and is specified by a starting point (the origin) and a
-        finite direction vector which also defines its length. Currently this function is limited to returning
-        intersections with Meshes.
+        The function finds intersections relative to the ray origin and returns the number of intersecting scene
+        nodes. The ray is a line segment and is specified by a starting point (the origin) and a finite direction
+		vector which also defines its length. Currently this function is limited to returning intersections with Meshes.
 		
 		Parameters:
 			node		- node at which intersection check is beginning
 			ox, oy, oz	- ray origin
 			dx, dy, dz	- ray direction vector also specifying ray length
+			numNearest	- maximum number of results to return or 0 for all
 			
 		Returns:
-			 handle to nearest intersected node or 0 if no node was hit
+			number of intersections
+		*/
+	DLL int castRay( NodeHandle node, float ox, float oy, float oz, float dx, float dy, float dz, int numNearest );
+
+
+	/*	Function: getCastRayResurt
+			Returns results of a previous castRay query
+
+		This functions copies the results for the specified index into the provided variables.
+
+		Parameters:
+			index			- index in range 0 until return value of castRay exclusive
+			node			- intersecting node
+			distance		- distance from ray origin to intersection
+			intersection	- point of intersection, float[3] array
+
+		Returns:
+			true if index was valid and data could be copied
 	*/
-	DLL NodeHandle castRay( NodeHandle node, float ox, float oy, float oz, float dx, float dy, float dz );
+	DLL bool getCastRayResult( int index, NodeHandle *node, float *distance, float *intersection );
 
 
 	/* Group: Group-specific scene graph functions */
diff --git a/Horde3D/Bindings/C++/Horde3DUtils.h b/Horde3D/Bindings/C++/Horde3DUtils.h
index 7b3e58c..c4a6b3e 100644
--- a/Horde3D/Bindings/C++/Horde3DUtils.h
+++ b/Horde3D/Bindings/C++/Horde3DUtils.h
@@ -194,22 +194,24 @@ namespace Horde3DUtils
 	
 	
 	/*	Group: Scene graph */
-	/* 	Function: pickNode
-			Returns the scene node which is at the specified window coordinates.
+	/* 	Function: pickRay
+	 *  	Calculates the ray originating at the specified camera and window coordinates
 		
 		This utility function takes normalized window coordinates (ranging from 0 to 1 with the
-		origin being the bottom left corner of the window) and returns the scene node which is
-		visible at that location. The function is especially useful for selecting objects by clicking
-		on them. Currently picking is only working for Meshes.
+		origin being the bottom left corner of the window) and returns ray origin and direction for the
+		given camera. The function is especially useful for selecting objects by clicking
+		on them.
 		
 		Parameters:
 			cameraNode	- camera used for picking
 			nwx, nwy	- normalized window coordinates
+			ox, oy, oz  - calculated ray origin
+			dx, dy, dz  - calculated ray direction
 			
 		Returns:
-			handle of picked node or 0 if no node was hit
+			nothing
 	*/
-	DLL NodeHandle pickNode(NodeHandle cameraNode, float nwx, float nwy );
+	DLL void pickRay(NodeHandle cameraNode, float nwx, float nwy, float *ox, float *oy, float *oz, float *dx, float *dy, float *dy );
 	
 	
 	/*	Group: Overlays */
diff --git a/Horde3D/Source/Horde3DEngine/egMain.cpp b/Horde3D/Source/Horde3DEngine/egMain.cpp
index 3df4d80..b46801b 100644
--- a/Horde3D/Source/Horde3DEngine/egMain.cpp
+++ b/Horde3D/Source/Horde3DEngine/egMain.cpp
@@ -782,7 +782,7 @@ namespace Horde3D
 	}
 
 
-	DLLEXP NodeHandle castRay( NodeHandle node, float ox, float oy, float oz, float dx, float dy, float dz )
+	DLLEXP NodeHandle castRay( NodeHandle node, float ox, float oy, float oz, float dx, float dy, float dz, int numNearest )
 	{
 		SceneNode* sn = Modules::sceneMan().resolveNodeHandle( node );
 		if ( sn == 0x0 )
@@ -793,11 +793,25 @@ namespace Horde3D
 
 		Modules::sceneMan().updateNodes();
 		
-		float minDist = Math::MaxFloat;
-		sn = Modules::sceneMan().castRay( sn, Vec3f( ox, oy, oz ), Vec3f( dx, dy, dz ), minDist );
+		return Modules::sceneMan().castRay( sn, Vec3f( ox, oy, oz ), Vec3f( dx, dy, dz ), numNearest );
+	}
+
+
+	DLLEXP bool getCastRayResult( int index, NodeHandle *node, float *distance, float *intersection )
+	{
+		CastRayResult crr;
+		if( Modules::sceneMan().getCastRayResult( index, crr ) )
+		{
+			*node = crr.node->getHandle();
+			*distance = crr.distance;
+			intersection[0] = crr.intersection.x;
+			intersection[1] = crr.intersection.y;
+			intersection[2] = crr.intersection.z;
+
+			return true;
+		}
 
-		if( sn == 0x0 ) return 0;
-		else return sn->getHandle();
+		return false;
 	}
 
 
diff --git a/Horde3D/Source/Horde3DEngine/egScene.cpp b/Horde3D/Source/Horde3DEngine/egScene.cpp
index 2f33c65..62c10d9 100644
--- a/Horde3D/Source/Horde3DEngine/egScene.cpp
+++ b/Horde3D/Source/Horde3DEngine/egScene.cpp
@@ -657,31 +657,87 @@ int SceneManager::findNodes( SceneNode *startNode, const string &name, int type
 }
 
 
-SceneNode *SceneManager::castRay( SceneNode *node, const Vec3f &rayOrig, const Vec3f &rayDir, float &minDist )
+void SceneManager::castRayInternal( SceneNode *node )
 {
-	if( !node->_active ) return 0x0;
+	if( !node->_active ) return;
 	
-	static Vec3f intsPos;
-	SceneNode *nearestNode = 0x0;
 
-	if( rayAABBIntersection( rayOrig, rayDir, node->_bBox.getMinCoords(), node->_bBox.getMaxCoords() ) )
+	if( rayAABBIntersection( _rayOrigin, _rayDirection, node->_bBox.getMinCoords(), node->_bBox.getMaxCoords() ) )
 	{
-		if( node->checkIntersection( rayOrig, rayDir, intsPos ) )
+		Vec3f intsPos;
+		if( node->checkIntersection( _rayOrigin, _rayDirection, intsPos ) )
 		{
-			float dist = (intsPos - rayOrig).length();
-			if( dist < minDist )
+			float dist = (intsPos - _rayOrigin).length();
+
+			CastRayResult crr;
+			crr.node = node;
+			crr.distance = dist;
+			crr.intersection = intsPos;
+
+			bool inserted = false;
+			for( vector< CastRayResult >::iterator it = _castRayResults.begin(); it != _castRayResults.end(); ++it )
 			{
-				nearestNode = node;
-				minDist = dist;
+				if( dist < it->distance )
+				{
+					_castRayResults.insert( it, crr );
+					inserted = true;
+					break;
+				}
+			}
+
+			if( !inserted )
+			{
+				_castRayResults.push_back( crr );
+			}
+
+			if( _rayNum > 0 && _castRayResults.size() > _rayNum )
+			{
+				_castRayResults.pop_back();
 			}
 		}
 
 		for( uint32 i = 0; i < node->_children.size(); ++i )
 		{
-			SceneNode *sn = castRay( node->_children[i], rayOrig, rayDir, minDist );
-			if( sn != 0x0 ) nearestNode = sn;
+			castRayInternal( node->_children[i] );
 		}
 	}
 
-	return nearestNode;
+	return;
+}
+
+
+int SceneManager::castRay( SceneNode *node, const Vec3f &rayOrig, const Vec3f &rayDir, int numNearest )
+{
+	_castRayResults.clear();// don't resize here, that's done below
+
+	if( !node->_active ) return 0;
+
+	_rayOrigin = rayOrig;
+	_rayDirection = rayDir;
+	_rayNum = numNearest;
+
+	if( numNearest > 0 )
+	{
+		_castRayResults.reserve( numNearest + 1 );// a bit too optimistic?
+	}
+
+	castRayInternal( node );
+
+	return _castRayResults.size();
 }
+
+
+bool SceneManager::getCastRayResult( int index, CastRayResult &crr )
+{
+	if( index < _castRayResults.size() )
+	{
+		crr = _castRayResults[index];
+
+		return true;
+	}
+
+	return false;
+}
+
+
+
diff --git a/Horde3D/Source/Horde3DEngine/egScene.h b/Horde3D/Source/Horde3DEngine/egScene.h
index 39b2b64..cb6af28 100644
--- a/Horde3D/Source/Horde3DEngine/egScene.h
+++ b/Horde3D/Source/Horde3DEngine/egScene.h
@@ -200,6 +200,13 @@ struct NodeRegEntry
 	NodeTypeRenderFunc		renderFunc;
 };
 
+struct CastRayResult
+{
+	SceneNode *node;
+	float distance;
+	Vec3f intersection;
+};
+
 class SceneManager
 {
 protected:
@@ -209,12 +216,18 @@ protected:
 	vector< SceneNode *>		_lightQueue;
 	vector< SceneNode *>		_renderableQueue;
 	vector< SceneNode * >		_findResults;
+	vector< CastRayResult >     _castRayResults;
+
+	Vec3f                       _rayOrigin;// don't put these values during recursive search on the stack
+	Vec3f                       _rayDirection;// dito
+	int                         _rayNum;// dito
 
 	void updateQueuesRec( const Frustum &frustum1, const Frustum *frustum2, bool sorted, 
 						  SceneNode &node, bool lightQueue, bool renderableQueue );
 	NodeHandle parseNode( SceneNodeTpl &tpl, SceneNode *parent );
 	void removeNodeRec( SceneNode *node );
 
+	void castRayInternal( SceneNode *node );
 public:
 
 	SceneManager();
@@ -238,7 +251,8 @@ public:
 	void clearFindResults() { _findResults.resize( 0 ); }
 	SceneNode *getFindResult( int index ) { return (unsigned)index < _findResults.size() ? _findResults[index] : 0x0; }
 	
-	SceneNode *castRay( SceneNode *node, const Vec3f &rayOrig, const Vec3f &rayDir, float &minDist );
+	int castRay( SceneNode *node, const Vec3f &rayOrig, const Vec3f &rayDir, int numNearest );
+	bool getCastRayResult( int index, CastRayResult &crr );
 
 	SceneNode &getRootNode() { return *_nodes[0]; }
 	SceneNode &getDefCamNode() { return *_nodes[1]; }
diff --git a/Horde3D/Source/Horde3DUtils/main.cpp b/Horde3D/Source/Horde3DUtils/main.cpp
index 93e55b1..ee0ef9e 100644
--- a/Horde3D/Source/Horde3DUtils/main.cpp
+++ b/Horde3D/Source/Horde3DUtils/main.cpp
@@ -429,7 +429,7 @@ namespace Horde3DUtils
 	}
 
 
-	DLLEXP NodeHandle pickNode( NodeHandle cameraNode, float nwx, float nwy )
+	DLLEXP void pickRay( NodeHandle cameraNode, float nwx, float nwy, float *ox, float *oy, float *oz, float *dx, float *dy, float *dz )
 	{				
 		// Transform from normalized window [0, 1] to normalized device coordinates [-1, 1]
 		float cx( 2.0f * nwx - 1.0f );
@@ -454,8 +454,12 @@ namespace Horde3DUtils
 		p0.x /= p0.w; p0.y /= p0.w; p0.z /= p0.w;
 		p1.x /= p1.w; p1.y /= p1.w; p1.z /= p1.w;
 		
-		return Horde3D::castRay( RootNode, camTrans[12], camTrans[13], camTrans[14],
-								 p1.x - p0.x, p1.y - p0.y, p1.z - p0.z);
+		*ox = camTrans[12];
+		*oy = camTrans[13];
+		*oz = camTrans[14];
+		*dx = p1.x - p0.x;
+		*dy = p1.y - p0.y;
+		*dz = p1.z - p0.z;
 	}
 }
 
