InteractiveVisual3d question

Topics: Developer Forum, User Forum
Jul 9, 2010 at 11:32 AM

Hi,

 I've exported a .3ds model into xaml. My xaml now has several GeometryModel3D elements (it is a complex model). Then I've added the trackball decorartor and all seems to work fine. Now, all I need is that when the user cliks on every the GeometryModel3D element, I am able to catch the MouseDown event and provide an action depending on the clicked GeometryModel3D . I've tried adding the following code, but it works only for one GeometryModel3D.  Infact, it only detects the mouse button on the GeometryModel3D named BLACK_BLAC.

Any suggestion (please see code at bottom) ? thanx for your help.  

Franco

 

          <3DTools:Interactive3DDecorator >  
                      <Viewport3D xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="MainViewport3D">
                <Viewport3D.Camera>
                    <PerspectiveCamera Position="0,0.1706 ,4.755  " LookDirection="0,0.0871557 ,-0.9961  " UpDirection="0,0.9961  ,0.087  "/>
                </Viewport3D.Camera>

            <3DTools:InteractiveVisual3D>
                           <3DTools:InteractiveVisual3D.Geometry>
                              <MeshGeometry3D  Positions="- bla1 bla1" TriangleIndices=" bla bla"/>     <!-- here the same positions and indexes of the GeometryModel3D named BLACK_BLAC -->
                        </dd:InteractiveVisual3D.Geometry>
                    <3DTools:InteractiveVisual3D.Visual>
                        <Image x:Name="AcciaioBlu1" Source="myImage.jpg"  MouseDown="myImage_MouseDown" ToolTip="this is zone 1"/> <!-- this works -->
                    </3DTools:InteractiveVisual3D.Visual>
                </3DTools:InteractiveVisual3D>   

           <3DTools:InteractiveVisual3D>
                           <3DTools:InteractiveVisual3D.Geometry>
                              <MeshGeometry3D  Positions="- bla2 bla2" TriangleIndices=" bl2a bla2"/>     <!-- here the same positions and indexes of the GeometryModel3D named BLACK_MATT
                        </dd:InteractiveVisual3D.Geometry>
                    <3DTools:InteractiveVisual3D.Visual>
                        <Image x:Name="AcciaioBlu1" Source="myImage.jpg"  MouseDown="myImage_MouseDown" ToolTip="this is zone 2"/> <! this does not work :( -->
                    </3DTools:InteractiveVisual3D.Visual>
                </3DTools:InteractiveVisual3D>   

     <ModelVisual3D>
                    <ModelVisual3D.Content >
                         <Model3DGroup >
                   
                            <Model3DGroup>
                                <Model3DGroup x:Name="__RootModelsGroup">
                                    <GeometryModel3D x:Name="BLACK_BLAC">
                                        <GeometryModel3D.Geometry>
                                            <MeshGeometry3D Positions=" a lot of numbers here " TriangleIndices=" a lot of numbers here"/>
                                        </GeometryModel3D.Geometry>
                                        <GeometryModel3D.Material>
                                            <DiffuseMaterial Brush="#FF191919"/>
                                        </GeometryModel3D.Material>
                                    </GeometryModel3D>
                                    <GeometryModel3D x:Name="BLACK_MATT">
                                        <GeometryModel3D.Geometry>
                                            <MeshGeometry3D Positions="  a lot of numbers here" TriangleIndices=" a lot of numbers here"/>
                                        </GeometryModel3D.Geometry>
                                        <GeometryModel3D.Material>
                                            <DiffuseMaterial Brush="#FF262828"/>
                                        </GeometryModel3D.Material>
                                    </GeometryModel3D>  </ModelVisual3D>
                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <DirectionalLight Direction="0,0.0871557427476582,-0.996194698091746 " Color="#FFFFFFFF"/>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
                  
            </Viewport3D>
      </3DTools:Interactive3DDecorator> 
     </3DTool:TrackballDecorator>

  

 

 

 

 

 

 

 

 

 

 

 

 

 

Jul 9, 2010 at 2:22 PM

Hi,

there is a news.

 

In order to better investigate, I've removed a lot of parts of my xaml. This "reduced  version" works  only depending on the row:

<MeshGeometry3D Positions="..." TriangleIndices=" ..."/>
I mean that the solid is always displayed, but the mouseDown event is raised only for certain MeshGeometry3D (in my case, it only works for 2 GeometryModel3D).

So how can I fix this issue ? Is it a bug ?

Thank you.

f

<Window x:Class="Wpf3DCubeWindow.WindowTest"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:dd="clr-namespace:_3DTools;assembly=3DTools"
        Title="WindowTest" Height="768" Width="1024">

    <dd:TrackballDecorator >

        <dd:Interactive3DDecorator >
            <Viewport3D xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="MainViewport3D">
                <Viewport3D.Camera>
                    <PerspectiveCamera Position="0,0.170683893091676,4.75535362630984 " LookDirection="0,0.0871557427476582,-0.996194698091746 " UpDirection="0,0.996194698091746,0.0871557427476582 "/>
                </Viewport3D.Camera>
                <dd:InteractiveVisual3D x:Name="hh" >
                <dd:InteractiveVisual3D.Geometry   >
                        <MeshGeometry3D Positions="-0.8341064453125,0.718420624732971,..." TriangleIndices="0 1 ..."/>  <!-- a lot of numers here.. I've deleted it for better reading -->
                    </dd:InteractiveVisual3D.Geometry>
                <dd:InteractiveVisual3D.Visual>
                    <Image  Source="/Wpf3DCubeWindow;component/images/Desert.jpg" IsEnabled="True"
                            dd:InteractiveVisual3D.IsInteractiveMaterial="True" MouseDown="Image_MouseDown" ToolTip="hh "/>
                </dd:InteractiveVisual3D.Visual>
            </dd:InteractiveVisual3D>
            <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <DirectionalLight Direction="0,0.0871557427476582,-0.996194698091746 " Color="#FFFFFFFF"/>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
            </Viewport3D>
            </dd:Interactive3DDecorator >
    </dd:TrackballDecorator>
</Window>

 

 

Jul 30, 2010 at 11:47 AM

I solved my problem.

bye