0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

HelixToolkitで、MeshElement3D派生オブジェクトをClickする

0
Posted at

概要

HelixToolkitは、HelixViewport3Dタグの中に3Dオブジェクトが表示されます。
見た目からすると3Dオブジェクトに対して、ユーザー操作することが可能な様に見えるのですが、APIとサンプルコードを調べた限りでは、WPFのUIElement派生クラスのようなイベント操作は出来ないようです。
WPFから見ると3Dオブジェクトは、HelixViewport3Dというコントロールの上に描かれた模様に過ぎないということのようです。

クリック位置の3Dオブジェクトを取得する方法

HelixViewport3DのMouseDownイベントを監視し下記の方法で、3Dオブジェクトの参照を取得します。

Test.xaml.cs
private void MouseDownHandler(object sender, MouseButtonEventArgs e)
        {
            var p = e.GetPosition(this.viewport3d);
            var hit = Viewport3DHelper.FindNearestVisual(this.viewport3d.Viewport, p);

            if (hit != null)
            {
                // クリック操作
            }
        }
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?