GeometryModel3D コンストラクター

定義

新しい GeometryModel3D を構築します。

オーバーロード

GeometryModel3D()

GeometryModel3D の新しいインスタンスを作成します。

GeometryModel3D(Geometry3D, Material)

Geometry3D と Material を指定して、GeometryModel3D の新しいインスタンスを作成します。

public HitTestResultBehavior HTResult(System.Windows.Media.HitTestResult rawresult)
{
    //MessageBox.Show(rawresult.ToString());
    RayHitTestResult rayResult = rawresult as RayHitTestResult;

    if (rayResult != null)
    {
        RayMeshGeometry3DHitTestResult rayMeshResult = rayResult as RayMeshGeometry3DHitTestResult;

        if (rayMeshResult != null)
        {
            GeometryModel3D hitgeo = rayMeshResult.ModelHit as GeometryModel3D;

            UpdateResultInfo(rayMeshResult);
            UpdateMaterial(hitgeo, (side1GeometryModel3D.Material as MaterialGroup));
        }
    }

    return HitTestResultBehavior.Continue;
}
Public Function HTResult(ByVal rawresult As HitTestResult) As HitTestResultBehavior
    Dim rayResult As RayHitTestResult = TryCast(rawresult, RayHitTestResult)

    If rayResult IsNot Nothing Then
        Dim rayMeshResult As RayMeshGeometry3DHitTestResult = TryCast(rayResult, RayMeshGeometry3DHitTestResult)

        If rayMeshResult IsNot Nothing Then
            Dim hitgeo As GeometryModel3D = TryCast(rayMeshResult.ModelHit, GeometryModel3D)

            UpdateResultInfo(rayMeshResult)
            UpdateMaterial(hitgeo, (TryCast(side1GeometryModel3D.Material, MaterialGroup)))
        End If
    End If

    Return HitTestResultBehavior.Continue
End Function

GeometryModel3D()

GeometryModel3D の新しいインスタンスを作成します。

public:
 GeometryModel3D();
public GeometryModel3D ();
Public Sub New ()

次の抜粋は、GeometryModel3D のインスタンスの構文を示しています。

<DockPanel>
  <Viewport3D Name="myViewport">

    <Viewport3D.Camera>
      <PerspectiveCamera FarPlaneDistance="20" LookDirection="5,-2,-3" UpDirection="0,1,0" NearPlaneDistance="0" Position="-5,2,3" FieldOfView="45" />
    </Viewport3D.Camera>

    <ModelVisual3D x:Name="topModelVisual3D">
      <ModelVisual3D.Children>
        <ModelVisual3D>
          <ModelVisual3D.Content>
            <DirectionalLight Color="#FFFFFFFF" Direction="-3,-4,-5" />
          </ModelVisual3D.Content>
        </ModelVisual3D>

        <ModelVisual3D>
          <ModelVisual3D.Content>
            <GeometryModel3D Geometry="{StaticResource myTeapot}">
              <GeometryModel3D.Material>
                <DiffuseMaterial>
                  <DiffuseMaterial.Brush>
                    <SolidColorBrush Color="Blue" Opacity="1.0" />
                  </DiffuseMaterial.Brush>
                </DiffuseMaterial>
              </GeometryModel3D.Material>
              <GeometryModel3D.Transform>
                <RotateTransform3D>
                  <RotateTransform3D.Rotation>
                    <AxisAngleRotation3D x:Name="myAngleRotation" Axis="0,3,0" Angle="1" />
                  </RotateTransform3D.Rotation>
                </RotateTransform3D>
              </GeometryModel3D.Transform>
            </GeometryModel3D>
          </ModelVisual3D.Content>
        </ModelVisual3D>


      </ModelVisual3D.Children>
    </ModelVisual3D>


    <Viewport3D.Triggers>

      <EventTrigger RoutedEvent="Viewport3D.Loaded">
        <BeginStoryboard>
          <Storyboard>
            <DoubleAnimation 
              Storyboard.TargetName="myAngleRotation"
              Storyboard.TargetProperty="Angle"
              From="0" To="360" Duration="0:0:10"
              RepeatBehavior="Forever" />
          </Storyboard>
        </BeginStoryboard>
      </EventTrigger>
    </Viewport3D.Triggers>


  </Viewport3D>
</DockPanel>
<GeometryModel3D.Geometry>
        <MeshGeometry3D 
            Positions="-1 -1 0  1 -1 0  -1 1 0  1 1 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" />
    </GeometryModel3D.Geometry>

適用対象

GeometryModel3D(Geometry3D, Material)

Geometry3D と Material を指定して、GeometryModel3D の新しいインスタンスを作成します。

public:
 GeometryModel3D(System::Windows::Media::Media3D::Geometry3D ^ geometry, System::Windows::Media::Media3D::Material ^ material);
public GeometryModel3D (System.Windows.Media.Media3D.Geometry3D geometry, System.Windows.Media.Media3D.Material material);
new System.Windows.Media.Media3D.GeometryModel3D : System.Windows.Media.Media3D.Geometry3D * System.Windows.Media.Media3D.Material -> System.Windows.Media.Media3D.GeometryModel3D
Public Sub New (geometry As Geometry3D, material As Material)

パラメーター

geometry
Geometry3D

新しいメッシュ プリミティブのジオメトリ。

material
Material

新しいメッシュ プリミティブのマテリアル。

<DockPanel>
  <Viewport3D Name="myViewport">

    <Viewport3D.Camera>
      <PerspectiveCamera FarPlaneDistance="20" LookDirection="5,-2,-3" UpDirection="0,1,0" NearPlaneDistance="0" Position="-5,2,3" FieldOfView="45" />
    </Viewport3D.Camera>

    <ModelVisual3D x:Name="topModelVisual3D">
      <ModelVisual3D.Children>
        <ModelVisual3D>
          <ModelVisual3D.Content>
            <DirectionalLight Color="#FFFFFFFF" Direction="-3,-4,-5" />
          </ModelVisual3D.Content>
        </ModelVisual3D>

        <ModelVisual3D>
          <ModelVisual3D.Content>
            <GeometryModel3D Geometry="{StaticResource myTeapot}">
              <GeometryModel3D.Material>
                <DiffuseMaterial>
                  <DiffuseMaterial.Brush>
                    <SolidColorBrush Color="Blue" Opacity="1.0" />
                  </DiffuseMaterial.Brush>
                </DiffuseMaterial>
              </GeometryModel3D.Material>
              <GeometryModel3D.Transform>
                <RotateTransform3D>
                  <RotateTransform3D.Rotation>
                    <AxisAngleRotation3D x:Name="myAngleRotation" Axis="0,3,0" Angle="1" />
                  </RotateTransform3D.Rotation>
                </RotateTransform3D>
              </GeometryModel3D.Transform>
            </GeometryModel3D>
          </ModelVisual3D.Content>
        </ModelVisual3D>


      </ModelVisual3D.Children>
    </ModelVisual3D>


    <Viewport3D.Triggers>

      <EventTrigger RoutedEvent="Viewport3D.Loaded">
        <BeginStoryboard>
          <Storyboard>
            <DoubleAnimation 
              Storyboard.TargetName="myAngleRotation"
              Storyboard.TargetProperty="Angle"
              From="0" To="360" Duration="0:0:10"
              RepeatBehavior="Forever" />
          </Storyboard>
        </BeginStoryboard>
      </EventTrigger>
    </Viewport3D.Triggers>


  </Viewport3D>
</DockPanel>

適用対象