Exemple #1
0
        void SelectObjectsHirarchy(ISceneNode root, Ray ray, ref ISelectable output_selectedNode, ref float bestDistance)
        {
            if (root.IsVisible)
            {
                if (root is ISelectable selectableNode && selectableNode.IsSelectable)
                {
                    var distance = GeometryIntersection.IntersectObject(ray, selectableNode.Geometry, selectableNode.ModelMatrix);
                    if (distance != null)
                    {
                        if (distance < bestDistance)
                        {
                            bestDistance        = distance.Value;
                            output_selectedNode = selectableNode;
                        }
                    }
                }

                bool isUnselectableGroup = root is GroupNode groupNode && groupNode.IsLockable == true && groupNode.IsSelectable == false;
                if (!isUnselectableGroup)
                {
                    foreach (var child in root.Children)
                    {
                        SelectObjectsHirarchy(child, ray, ref output_selectedNode, ref bestDistance);
                    }
                }
            }
        }
Exemple #2
0
        void SelectObjectsHirarchy(ISceneNode root, BoundingFrustum frustrum, List <ISelectable> output_selectedNodes)
        {
            if (root.IsVisible)
            {
                if (root is ISelectable selectableNode && selectableNode.IsSelectable)
                {
                    if (GeometryIntersection.IntersectObject(frustrum, selectableNode.Geometry, selectableNode.ModelMatrix))
                    {
                        output_selectedNodes.Add(selectableNode);
                    }
                }

                bool isUnselectableGroup = root is GroupNode groupNode && groupNode.IsLockable == true && groupNode.IsSelectable == false;
                if (!isUnselectableGroup)
                {
                    foreach (var child in root.Children)
                    {
                        SelectObjectsHirarchy(child, frustrum, output_selectedNodes);
                    }
                }
            }
        }