Google 網路論壇不再支援新的 Usenet 貼文或訂閱項目,但過往內容仍可供查看。

PointHitTestResult.Visual

瀏覽次數:0 次
跳到第一則未讀訊息

casey chesnut

未讀,
2005年10月17日 晚上10:59:322005/10/17
收件者:
i've got a Viewport3D with 4 GeometryModel3D.
when i do the VisualOperations.HitTest() i get a HitTestResult that i can
cast into a PointHitTestResult.
the PointHitTestResult has a Visual property.

my question is how can i use the Visual property to find out which of my 4
GeometryModel3D items was hit?
right now i can only tell that one of them was hit ... but not which one.

the samples i've been looking at show Ray3DHitTestResult ... which my
HitTest() call does not return.

Thanks,
casey


casey chesnut

未讀,
2005年10月18日 上午9:54:172005/10/18
收件者:
this is what my Viewport3D looks like.
its just 4 meshes spread out and facing the camera.
its parent container is a DockPanel.

my HitTest code is from the Carousel sample here
http://www.therhogue.com/WinFX/
so i'm not sure why i'm getting a PointHitTestResult instead of a
Ray3DHitTestResult?

<Window.Resources>
<MeshGeometry3D x:Key="PlaneMesh"
Positions="-10,-10,0 10,-10,0 -10,10,0 10,10,0"
Normals="0,0,1 0,0,1 0,0,1 0,0,1"
TextureCoordinates="0,1 1,1 0,0 1,0"
TriangleIndices="0 1 2 1 3 2" />
</Window.Resources>

<Viewport3D x:Name="myViewport3D">
<Viewport3D.Camera>
<PerspectiveCamera NearPlaneDistance="1" FarPlaneDistance="200"
LookAtPoint="0,0,-5" Up="0,1,0" Position="0,60,120" FieldOfView="45" />
</Viewport3D.Camera>
<Viewport3D.Models>
<Model3DGroup>
<Model3DGroup.Children>
<GeometryModel3D Geometry="{StaticResource PlaneMesh}">
<GeometryModel3D.Transform>
<TranslateTransform3D Offset="0,0,30" />
</GeometryModel3D.Transform>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<SolidColorBrush Color="Green" Opacity="1.0"/>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
</GeometryModel3D>
<GeometryModel3D Geometry="{StaticResource PlaneMesh}">
<GeometryModel3D.Transform>
<TranslateTransform3D Offset="-30,0,0" />
</GeometryModel3D.Transform>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<SolidColorBrush Color="Red" Opacity="1.0"/>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
</GeometryModel3D>
<GeometryModel3D Geometry="{StaticResource PlaneMesh}">
<GeometryModel3D.Transform>
<TranslateTransform3D Offset="0,0,-30" />
</GeometryModel3D.Transform>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<SolidColorBrush Color="Yellow" Opacity="1.0"/>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
</GeometryModel3D>
<GeometryModel3D Geometry="{StaticResource PlaneMesh}">
<GeometryModel3D.Transform>
<TranslateTransform3D Offset="30,0,0" />
</GeometryModel3D.Transform>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<SolidColorBrush Color="Blue" Opacity="1.0"/>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
</GeometryModel3D>
<AmbientLight Color="White" />
</Model3DGroup.Children>
</Model3DGroup>
</Viewport3D.Models>
</Viewport3D>


"casey chesnut" <casey@MORE_SPAMbrains-N-brawn.com> wrote in message
news:%23jyX4$40FHA...@tk2msftngp13.phx.gbl...

Bob Brown[MSFT]

未讀,
2005年10月18日 晚上8:03:442005/10/18
收件者:
Thanks for sharing the sample.  What's happening is that you are using Viewport3D.Models (which is deprecated) to set up your 3D scene.  The old method requires you to cast the HitTestResult to an IHitTestResult3DContainer then iterate on the "Results" property.  Robert Hogue's samples are all using the new Visual3D API instead of Viewport3D.Models.  If you edit your Window.xaml file in the following way, you will start getting ray hit test results:
 
<Viewport3D>
   <Viewport3D.Models>
       <Model3DGroup>
          <!-- 3D stuff goes here -->
       </Model3DGroup>
   </Viewport3D.Models>
</Viewport3D>
 
to:
 
<Viewport3D>
   <ModelVisual3D>
       <ModelVisual3D.Content>
          <Model3DGroup>
             <!-- 3D stuff goes here -->
          </Model3DGroup>
      </ModelVisual3D.Content>
   </ModelVisual3D>
</Viewport3D>

--
Bob Brown [MSFT]
This posting is provided "AS IS" with no warranties, and confers no rights.
 
 
> here is a small sample attached.
> i would like to understand why it returns a PointHitTestResult ... when all
> the other samples i've modeled my Viewport3D after return a
> Ray3DHitTestResult.
> and if it is supposed to return a PointHitTestResult, then how can i use
> that to tell which of my 2 models was hit?
>
> Thanks,
> casey
>
> "casey chesnut" <
casey@MORE_SPAMbrains-N-brawn.com> wrote in message
>
news:uorjvt%230FH...@TK2MSFTNGP12.phx.gbl...
http://www.therhogue.com/WinFX/

casey chesnut

未讀,
2005年10月18日 晚上10:26:062005/10/18
收件者:
Thanks for explaining that.
 
Could you explain the difference between ModelVisual3D.Content and ModelVisual3D.Children?
 
casey
 

TheRHogue

未讀,
2005年10月19日 晚上11:39:052005/10/19
收件者:
ModelVisual3D's can have ModelVisual3D nested children an that is it. The
benefit of a ModelVisual3D is hittesting can be done on a specific
ModelVisual3D - thus eliminating hittest overhead if managed properly.

ModelVisual3D.Content can only have one child, and that is normally a
Model3DGroup which can have nested children.

If your question is why make this change at all, this change is an
architectural change to allow other fun stuff in the future that many of us
are requesting.

0 則新訊息