Пример #1
0
        public void Highlight()
        {
            PhongPatchPNTriangleGeometry g = Origin.Geometries[GeometryID] as PhongPatchPNTriangleGeometry;

            if (g != null && PatchID >= 0)
            {
                IDrawable r = g.ExportRange(PatchID);

                Node = new SelectableSceneNode(r)
                {
                    Selected = true, Priority = 100
                };
                Origin.Add(Node);
            }
            else
            {
                SelectableSceneNode n = Origin as SelectableSceneNode;
                if (n != null)
                {
                    n.Selected = true;
                    Node       = n;
                }
            }
        }
Пример #2
0
        public bool Select(Double2 xy, out PickingResult result)
        {
            bool unselect = inputHandler.IsKeyPressed(Key.ShiftLeft);
            List <PickingResult> r;

            result = null;
            if (sg.Pick(xy, 5, out r))
            {
                if (Validator == null)
                {
                    result = r[0];
                }
                else
                {
                    bool success = false;
                    for (int i = 0; i < r.Count; ++i)
                    {
                        result = r[i];
                        if (Validator(result))
                        {
                            success = true;
                            break;
                        }
                    }
                    if (!success)
                    {
                        return(false);
                    }
                }
            }
            else
            {
                return(false);
            }

            if (Pick != null)
            {
                Pick(result, unselect);
            }

            int geometryID = result.GeometryIndex;


            int id = result.PrimitiveIndex;
            PhongPatchPNTriangleGeometry g = result.Node.Geometries[geometryID] as PhongPatchPNTriangleGeometry;

            if (g != null && patchSelectionEnabled)
            {
                int patchID = g.GetRangeIndex(id);
                int index   = GetIndex(result.Node, patchID);

                if (index < 0 && !unselect)
                {
                    if (!multiSelect)
                    {
                        Clear();
                    }

                    SelectionElement se = new SelectionElement(result.Node, geometryID, patchID);
                    se.Highlight();
                    selection.Add(se);
                }
                else if (index >= 0 && unselect)
                {
                    Unselect(index);
                }
                return(true);
            }
            else
            {
                SelectableSceneNode n = result.Node as SelectableSceneNode;
                if (n != null)
                {
                    int index = GetIndex(result.Node, -1);

                    if (index < 0 && !unselect)
                    {
                        if (!multiSelect)
                        {
                            Clear();
                        }

                        SelectionElement se = new SelectionElement(result.Node, geometryID);
                        se.Highlight();
                        selection.Add(se);
                    }
                    else if (index >= 0 && unselect)
                    {
                        Unselect(index);
                    }
                    return(true);
                }
            }
            return(false);
            //}
            //return false;
            //else if (!multiSelect)
            //    Clear();
        }