silverlight 中的等距透视

发布于 2024-10-19 19:36:36 字数 663 浏览 1 评论 0原文

如何在 Silverlight 中获得完美的等距透视?

我想在 Silverlight 中创建一个 3D 环境,它必须是等距视角。 如果我使用平面投影,我可以使网格类似于等距透视,但它不是完美的等距透视,因为网格单元不相等。

http://uwconcept.be/projects/uwconceptcity/grid_base_1.jpg

人们将会有能够沿着网格“滚动”;即在其上向前、向后、向左、向右移动。您可以将其视为飞越网格,但始终保持正确的等距视角。不会实现轮换(在第一个版本中)。即使实现了,旋转也将恰好是 90 度,以保持等轴测视角。

编辑:我还注意到,当我尝试在 Silverlight 中重现透视时,“正常”等距 x、y、z 坐标不适用。以下维基百科文章显示了“正常”转换: http://en.wikipedia .org/wiki/文件:Wikipedia_isometric_cube_3.jpg

How can I get a perfect isometric perspective in Silverlight ?

I want to create a 3D environment in Silverlight, which has to be in Isometric perspective.
If I use the planeprojection, I can make a grid resemble the Isometric perspective, but it is not a perfect Isometric perspective, as the gridcells are not equal.

http://uwconcept.be/projects/uwconceptcity/grid_base_1.jpg

People will have to be able to "scroll" along the grid; i.e. move forward, backward, left and right on it. You can see it as flying over the grid, but keeping the correct Isometric perspective at all times. Rotating will not be implemented ( in a first version ). And even if it would be implemented, the rotating would be exactly 90 degrees, as to keep the Isometric perspective.

Edit: I also noticed that the "normal" isometric x,y,z Coordinates do not apply when i tried to reproduce the perspective in Silverlight. The "normal" transformations are shown in the following Wikipedia article: http://en.wikipedia.org/wiki/File:Wikipedia_isometric_cube_3.jpg

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

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

发布评论

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

评论(2

这个俗人 2024-10-26 19:36:36

如果你可以等待SL5发布,它应该有3D API。 Silverlight 5 beta 宣布将于 2011 年上半年发布(现在应该是任何一天)。最终版本计划于 2011 年底发布。

我认为 SL API 应该类似于 WPF 的 3D API。根据我的随意理解,您可以使用正交相机(包含在 WPF 中)的正确角度来创建等角投影。

If you can wait for SL5 to be released, it is supposed to have a 3D API. Silverlight 5 beta was announced for release in the 1st half of 2011 (should be any day now). The final release is planned for the end of 2011.

I assume the SL API should be similar to WPF's 3D API. From my casual understanding, you can create an isometric projection with the correct angling of an OrthographicCamera (which is included in WPF).

假扮的天使 2024-10-26 19:36:36

SL4 中内置的 3D 投影支持可能不足以满足您的需求。它非常有限,通常仅适用于旋转简单的物体。

但您还有其他两个选择:

  • 使用 3D 引擎并将其设置为以等距 3D 渲染。我认为 Balder 可以做到这一点,但可能不是开箱即用的。
  • 通过在正确的位置绘制预渲染的精灵来伪造等距 3D。我想您希望您的“游戏世界”由旋转以适应等距 3D 视角的图块(方块)组成。如果您以正确的角度预先渲染所有图块,那么您可以计算放置它们的位置并获得所需的效果。使用此选项,您不会在显示中获得任何深度,较远的图块将与附近的图块大小相同,但除此之外它并不太难。

我自己曾经尝试过这样做,只是为了好玩。画平坦的风景很容易,但一旦你想支撑斜坡就变得困难了。

如果您最终这样做了,那么我希望您开源该项目,因为等距 3d 可以带来很多乐趣:-)

The built in 3d projection support in SL4 is probably not adequate for you needs. It is very limited and is generally only useful for rotating simple objects.

But you have two other options:

  • Use a 3D engine and set it to render in isometric 3D. I think Balder can do this for instance, but probably not out of the box.
  • Fake the isometric 3D by drawing pre-rendered sprites at the correct position. I suppose you want your "game world" to be built up of tiles (squares) that are rotated to fit the isometric 3D perspective. If you pre render all the tiles in the correct angle then you can calculate where to place them and get the desired effect. Using this option you won't get any depth in the display, tiles farther away will be the same size as those nearby, but apart from that it is not too hard.

I tried to do that latter myself once, just for fun. It was quite easy to draw a flat landscape, but it gets tougher once you want to support slopes.

If you end up doing this, then I hope you open source the project, for there is so much fun you can do with isometric 3d :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文