Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

How can find out which 3D Object was clicked in a viewport?

Closed Thread
 
Thread Tools Display Modes
Old 06-14-2006   #1 (permalink)
AlexB
Guest


 

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?
Old 06-14-2006   #2 (permalink)
Jordan Parker [MSFT]
Guest


 

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
newsBC26869-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?



Old 06-21-2006   #3 (permalink)
AlexB
Guest


 

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
> newsBC26869-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?

>
>
>

Old 06-21-2006   #4 (permalink)
AlexB
Guest


 

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
> > newsBC26869-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?

> >
> >
> >

Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can you find the lines Compare-Object determines to be differe Bob Landau PowerShell 2 10-24-2007 02:21 AM
Issues with printing and viewport/clipping JimmyG Vista print fax & scan 2 07-16-2007 07:58 PM
2d control in 3d ViewPort sbarlea@gmail.com Avalon 4 08-21-2006 10:56 PM
how can I find out if an 3D object is visible in the Viewport3D =?Utf-8?B?QWxleEI=?= Avalon 1 07-26-2006 08:27 PM
Adding canonical aliases for Compare-Object, Measure-Object, New-Object Alex K. Angelopoulos [MVP] PowerShell 2 05-26-2006 07:58 AM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50