private MapObject GetMapObjectByCursor() { if (!EngineApp.Instance.MouseRelativeMode) { Ray ray = RendererWorld.Instance.DefaultCamera.GetCameraToViewportRay( EngineApp.Instance.MousePosition); MapObject result = null; Map.Instance.GetObjects(ray, delegate(MapObject obj, float scale) { //check by sphere Sphere sphere = new Sphere(obj.Position, .5f); if (sphere.RayIntersection(ray)) { //find entities with Dynamic class only Dynamic dynamic = obj as Dynamic; if (dynamic != null) { result = obj; //stop GetObjects return false; } } //find next object return true; }); return result; } return null; }
private static void AddSphere(Camera camera, Sphere sphere) { if (addSpherePositions == null) GeometryGenerator.GenerateSphere(sphere.Radius, 8, 8, false, out addSpherePositions, out addSphereIndices); Mat4 transform = new Mat4(Mat3.Identity, sphere.Origin); camera.DebugGeometry.AddVertexIndexBuffer(addSpherePositions, addSphereIndices, transform, false, true); }