![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | How can find out which 3D Object was clicked in a viewport? I use hit testing to find out which geometry piece was clicked by the mouse. I want to move/transform the appropriate entire Model3DGgroup instance that includes my hited geometry piece. In the hitreuslt I can get the reference only to the geometry, but not to Model3DGroup. The problem is to find out efficiently which Model3DGroup was clicked, because GeometryModel3D instance doesn't know anything about the parent Model3DGroup. Does anybody know any nice solution for that problem? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: How can find out which 3D Object was clicked in a viewport? There isn't a way to walk backwards up to the Model3DGroup. I can think of a couple of ways to do this. 1) Use ModelVisual3Ds instead of M3DGs and then the VisualHit property will give you the closest Visual3D to ModelHit that contains ModelHit. You can then transform the V3D. This is the nicest "let WPF do the work for you" way to do this. 2) You could make an attached property of type M3DG and when you add a GeometryModel3D to a M3DG, set the property equal to the M3DG. When you find out which GM3D you hit, read the property. This isn't as clean and requires more work on your end. For example, you'd have to be sure to update the property if/when the GM3D is disconnected. Jordan "AlexB" <AlexB@discussions.microsoft.com> wrote in message news BC26869-A13C-4F79-B4E9-E10DB9072CDF@microsoft.com...>I use hit testing to find out which geometry piece was clicked by the >mouse. > I want to move/transform the appropriate entire Model3DGgroup instance > that > includes my hited geometry piece. In the hitreuslt I can get the reference > only to the geometry, but not to Model3DGroup. The problem is to find out > efficiently which Model3DGroup was clicked, because GeometryModel3D > instance > doesn't know anything about the parent Model3DGroup. Does anybody know any > nice solution for that problem? |
My System Specs![]() |
| | #3 (permalink) |
| | Re: How can find out which 3D Object was clicked in a viewport? Thx for help! 1) My 3D objects are represented by Model3DGroups, those can contain lots of GM3Ds. Its very usefull, because for example Zam3D exports 3D objects encapsulated in M3DGs. Therefore I don't really want to change this concept. 2) In 2nd case I have little problems to implement attached property of type M3DG, because M3DG class is seald and can't be inherited. So I wrote waraper like that: public class Model3DProvider : DependencyObject { public static readonly DependencyProperty ParentModel3DGroup = DependencyProperty.RegisterAttached( "ParentModel3DGroup", typeof(Model3DGroup), typeof(GeometryModel3D), new PropertyMetadata(false) ); public static void SetParentModel3DGroup(DependencyObject target, Model3DGroup value) { //should raise exceptions for element or value null target.SetValue(ParentModel3DGroup, value); } public static Model3DGroup GetParentModel3DGroup(DependencyObject target) { return (Model3DGroup)target.GetValue(ParentModel3DGroup); } } I use than static methods to set the property: Model3DProvider.SetParentModel3DGroup(child as GeometryModel3D, this.model3DGroup); but this causes exeption by registering the property .... "Jordan Parker [MSFT]" wrote: > There isn't a way to walk backwards up to the Model3DGroup. I can think of a > couple of ways to do this. > > 1) Use ModelVisual3Ds instead of M3DGs and then the VisualHit property will > give you the closest Visual3D to ModelHit that contains ModelHit. You can > then transform the V3D. This is the nicest "let WPF do the work for you" way > to do this. > > 2) You could make an attached property of type M3DG and when you add a > GeometryModel3D to a M3DG, set the property equal to the M3DG. When you find > out which GM3D you hit, read the property. This isn't as clean and requires > more work on your end. For example, you'd have to be sure to update the > property if/when the GM3D is disconnected. > > Jordan > > > "AlexB" <AlexB@discussions.microsoft.com> wrote in message > news BC26869-A13C-4F79-B4E9-E10DB9072CDF@microsoft.com...> >I use hit testing to find out which geometry piece was clicked by the > >mouse. > > I want to move/transform the appropriate entire Model3DGgroup instance > > that > > includes my hited geometry piece. In the hitreuslt I can get the reference > > only to the geometry, but not to Model3DGroup. The problem is to find out > > efficiently which Model3DGroup was clicked, because GeometryModel3D > > instance > > doesn't know anything about the parent Model3DGroup. Does anybody know any > > nice solution for that problem? > > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: How can find out which 3D Object was clicked in a viewport? Hi, forget the 2nd message. I'v read this blog entry von Daniel Lehenbauer " MV3DG vs. MV3D" and I decided to change the Scene Modeling by using MV3D instead of MV3DG. It works very well. Thank you. "AlexB" wrote: > Thx for help! > > 1) My 3D objects are represented by Model3DGroups, those can contain lots of > GM3Ds. Its very usefull, because for example Zam3D exports 3D objects > encapsulated in M3DGs. Therefore I don't really want to change this concept. > > 2) In 2nd case I have little problems to implement attached property of type > M3DG, because M3DG class is seald and can't be inherited. So I wrote waraper > like that: > > public class Model3DProvider : DependencyObject > { > public static readonly DependencyProperty ParentModel3DGroup = > DependencyProperty.RegisterAttached( > "ParentModel3DGroup", > typeof(Model3DGroup), > typeof(GeometryModel3D), > new PropertyMetadata(false) > ); > > public static void SetParentModel3DGroup(DependencyObject target, > Model3DGroup value) > { > //should raise exceptions for element or value null > target.SetValue(ParentModel3DGroup, value); > } > > public static Model3DGroup GetParentModel3DGroup(DependencyObject > target) > { > return (Model3DGroup)target.GetValue(ParentModel3DGroup); > } > > } > > I use than static methods to set the property: > > Model3DProvider.SetParentModel3DGroup(child as GeometryModel3D, > this.model3DGroup); > > but this causes exeption by registering the property .... > > > > > > "Jordan Parker [MSFT]" wrote: > > > There isn't a way to walk backwards up to the Model3DGroup. I can think of a > > couple of ways to do this. > > > > 1) Use ModelVisual3Ds instead of M3DGs and then the VisualHit property will > > give you the closest Visual3D to ModelHit that contains ModelHit. You can > > then transform the V3D. This is the nicest "let WPF do the work for you" way > > to do this. > > > > 2) You could make an attached property of type M3DG and when you add a > > GeometryModel3D to a M3DG, set the property equal to the M3DG. When you find > > out which GM3D you hit, read the property. This isn't as clean and requires > > more work on your end. For example, you'd have to be sure to update the > > property if/when the GM3D is disconnected. > > > > Jordan > > > > > > "AlexB" <AlexB@discussions.microsoft.com> wrote in message > > news BC26869-A13C-4F79-B4E9-E10DB9072CDF@microsoft.com...> > >I use hit testing to find out which geometry piece was clicked by the > > >mouse. > > > I want to move/transform the appropriate entire Model3DGgroup instance > > > that > > > includes my hited geometry piece. In the hitreuslt I can get the reference > > > only to the geometry, but not to Model3DGroup. The problem is to find out > > > efficiently which Model3DGroup was clicked, because GeometryModel3D > > > instance > > > doesn't know anything about the parent Model3DGroup. Does anybody know any > > > nice solution for that problem? > > > > > > |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| InternetExplorer Com Object Find Utility | PowerShell | |||
| How can you find the lines Compare-Object determines to be differe | PowerShell | |||
| Issues with printing and viewport/clipping | Vista print fax & scan | |||