创建高级 HUD

发布于 2024-11-10 09:12:23 字数 957 浏览 5 评论 0原文

我正在 WPF 中为 AR 无人机四轴飞行器制作一个界面。

我的 HUD 上需要一些东西才能使其可用。

HUD 上更先进的控制之一是人工地平线,它告诉飞行员飞行器当前与地平线的对齐情况。

我有这 3 个 PNG

背景

outliner 1

outliner 3

我将移动的第一张图像(飞行器的当前俯仰角)并旋转(当前的工艺卷)。

我将把第二个图像放在第一个图像上,这个图像只会绕中心轴旋转,它有一定程度的刻度,这将使飞行器的滚动更加可视化。

我将把最后一张放在第二张的上面,这张图片只是一个视觉改进。

然后我想屏蔽第一张图像,以便您只能看到图像 2 中圆圈内的内容。

最后但并非最不重要的一点是,我想向其中添加一个文本块并显示当前海拔高度

结果将如下所示

Result

我知道如何旋转和移动图像,但如何将图像放在彼此的顶部,以及如何遮盖第一个图像?

编辑:感谢 Ben,我已经做到了这一点:

Rotate no translate

但我还需要翻译图像 Y 位置(飞机的俯仰角)

With Translation

当我添加平移变换时,我也平移剪辑(蒙版),我该如何平移图像不移动掩模?

I'm making an interface for the AR Drone Quadcopter in WPF.

I neen some stuff on my HUD to make it usable.

One of the more advanced controls on the HUD is the artificial horizon, which tells the pilot the craft's current alignment to the horizon.

I have these 3 PNGs

The background

outliner 1

outliner 3

The first image I will move (The current pitch of the craft) and rotate (The current roll of the craft).

I will put the second image over the first, this one will only rotate around the center axis, it has ticks at certain degrees which will visualize the craft's roll even more.

The last one I will put on top of the second, this image just a visual improver.

Then I want to mask first image so that you only see whats inside the circle in image 2.

Last but not least I want to add a textblock to it and display the current altitude

The result will look something like this

Result

I know how to rotate and move the image, but how do I place the images on top of each other, and how do I mask the first image?

edit: Thanks to Ben I've gotten this far:

Rotate no translate

But I also need to translate the image Y position (The pitch of the aircraft)

With translate

When I add the translate transform I also translate the Clip (Mask) how can I translate the image without moving the mask?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

违心° 2024-11-17 09:12:23

一个小示例,说明如何在其中使用 DrawingGroupsClipGeometry

<Grid>
  <Image Source="Images\Background.jpg" />

  <Image>
    <Image.Source>
      <DrawingImage>
        <DrawingImage.Drawing>
          <DrawingGroup>
            <DrawingGroup>
              <!-- You can rotate a DrawingGroup -->
              <DrawingGroup.Transform>
                <RotateTransform Angle="-15" CenterX="50" CenterY="50" />
              </DrawingGroup.Transform>

              <ImageDrawing ImageSource="Images\last.png" Rect="0,0,100,100" />
              <DrawingGroup.ClipGeometry>
                <EllipseGeometry Center="50,50" RadiusX="25" RadiusY="25" />
              </DrawingGroup.ClipGeometry>
            </DrawingGroup>

            <DrawingGroup>
              <ImageDrawing ImageSource="Images\middle.png" Rect="0,0,100,100" />
              <ImageDrawing ImageSource="Images\outer.png" Rect="0,0,100,100" />
            </DrawingGroup>
          </DrawingGroup>
        </DrawingImage.Drawing>
      </DrawingImage>
    </Image.Source>
  </Image>
</Grid>

A little sample that how you can use DrawingGroups and a ClipGeometry inside it.

<Grid>
  <Image Source="Images\Background.jpg" />

  <Image>
    <Image.Source>
      <DrawingImage>
        <DrawingImage.Drawing>
          <DrawingGroup>
            <DrawingGroup>
              <!-- You can rotate a DrawingGroup -->
              <DrawingGroup.Transform>
                <RotateTransform Angle="-15" CenterX="50" CenterY="50" />
              </DrawingGroup.Transform>

              <ImageDrawing ImageSource="Images\last.png" Rect="0,0,100,100" />
              <DrawingGroup.ClipGeometry>
                <EllipseGeometry Center="50,50" RadiusX="25" RadiusY="25" />
              </DrawingGroup.ClipGeometry>
            </DrawingGroup>

            <DrawingGroup>
              <ImageDrawing ImageSource="Images\middle.png" Rect="0,0,100,100" />
              <ImageDrawing ImageSource="Images\outer.png" Rect="0,0,100,100" />
            </DrawingGroup>
          </DrawingGroup>
        </DrawingImage.Drawing>
      </DrawingImage>
    </Image.Source>
  </Image>
</Grid>
独孤求败 2024-11-17 09:12:23

昨晚我很累:D
要使背景旋转和平移而不是剪切,只需将背景放入剪切组的子组中...现在可以了!

    <Image Width="240" Height="240">
        <Image.Source>
            <DrawingImage>
                <DrawingImage.Drawing>
                    <DrawingGroup>
                        <DrawingGroup>
                            <DrawingGroup>
                                <DrawingGroup.Transform>
                                    <TransformGroup>
                                        <RotateTransform Angle="-15" CenterX="120" CenterY="120" />
                                        <TranslateTransform Y="-20" />
                                    </TransformGroup>
                                </DrawingGroup.Transform>

                                <ImageDrawing ImageSource="Images\pNxVK.png" Rect="0,0,240,240" />
                            </DrawingGroup>

                            <DrawingGroup.ClipGeometry>
                                <EllipseGeometry Center="120,120" RadiusX="60" RadiusY="60">
                                </EllipseGeometry>
                            </DrawingGroup.ClipGeometry>
                        </DrawingGroup>

                        <DrawingGroup>
                            <ImageDrawing ImageSource="Images\zUr8D.png" Rect="0,0,240,240" />
                            <ImageDrawing ImageSource="Images\XPZW9.png" Rect="0,0,240,240" />
                        </DrawingGroup>
                    </DrawingGroup>
                </DrawingImage.Drawing>
            </DrawingImage>
        </Image.Source>
    </Image>

I was tired last night :D
To get the background to rotate and translate but not the Clipping was just to put the background in a sub group to the clipping group... Now it works!

    <Image Width="240" Height="240">
        <Image.Source>
            <DrawingImage>
                <DrawingImage.Drawing>
                    <DrawingGroup>
                        <DrawingGroup>
                            <DrawingGroup>
                                <DrawingGroup.Transform>
                                    <TransformGroup>
                                        <RotateTransform Angle="-15" CenterX="120" CenterY="120" />
                                        <TranslateTransform Y="-20" />
                                    </TransformGroup>
                                </DrawingGroup.Transform>

                                <ImageDrawing ImageSource="Images\pNxVK.png" Rect="0,0,240,240" />
                            </DrawingGroup>

                            <DrawingGroup.ClipGeometry>
                                <EllipseGeometry Center="120,120" RadiusX="60" RadiusY="60">
                                </EllipseGeometry>
                            </DrawingGroup.ClipGeometry>
                        </DrawingGroup>

                        <DrawingGroup>
                            <ImageDrawing ImageSource="Images\zUr8D.png" Rect="0,0,240,240" />
                            <ImageDrawing ImageSource="Images\XPZW9.png" Rect="0,0,240,240" />
                        </DrawingGroup>
                    </DrawingGroup>
                </DrawingImage.Drawing>
            </DrawingImage>
        </Image.Source>
    </Image>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文