Пример #1
0
        /// <summary>
        /// Picks an object in 3D space.
        /// </summary>
        internal List <SceneObject> Pick(Vector3 rayStart, Vector3 rayDirection, ViewInformation viewInformation, PickingOptions pickingOptions)
        {
            rayDirection.EnsureNormalized(nameof(rayDirection));
            viewInformation.EnsureNotNull(nameof(viewInformation));
            pickingOptions.EnsureNotNull(nameof(pickingOptions));

            // Query for all objects below the cursor
            List <Tuple <SceneObject, float> > pickedObjects = new List <Tuple <SceneObject, float> >();

            foreach (SceneLayer actLayer in m_sceneLayers)
            {
                foreach (SceneObject actObject in actLayer.Objects)
                {
                    if (!actObject.IsVisible(viewInformation))
                    {
                        continue;
                    }
                    if (!actObject.IsPickingTestVisible)
                    {
                        continue;
                    }

                    float actDistance = actObject.Pick(rayStart, rayDirection, viewInformation, pickingOptions);
                    if (!float.IsNaN(actDistance))
                    {
                        pickedObjects.Add(Tuple.Create(actObject, actDistance));
                    }
                }
            }

            // Return all picked object in correct order
            return(pickedObjects
                   .OrderBy((actObject) => actObject.Item2)
                   .Convert((actObject) => actObject.Item1)
                   .ToList());
        }
Пример #2
0
 /// <summary>
 /// Picks an object in 3D-World.
 /// </summary>
 /// <param name="rayStart">Start of picking ray.</param>
 /// <param name="rayDirection"></param>
 /// <param name="viewInfo">Information about the view that triggered picking.</param>
 /// <param name="pickingOptions">Some additional options for picking calculations.</param>
 /// <returns>Returns the distance to the object or float.NaN if object is not picked.</returns>
 internal virtual float Pick(Vector3 rayStart, Vector3 rayDirection, ViewInformation viewInfo, PickingOptions pickingOptions)
 {
     return(float.NaN);
 }