从长方形变成梯形
我如何使用 ActionScript3 将矩形转换为梯形
我的梯形是 3D 房间的地板,我想对其进行纹理化(位图图块)。
_____________
| | | |
| |_____| |
| / \ |
| / trapez.\ |
|/__________\|
how can i transform rectangle into trapezoid with ActionScript3
my trapezoid is a floor of 3D room, and i want to texturize it (bitmap tile).
_____________
| | | |
| |_____| |
| / \ |
| / trapez.\ |
|/__________\|
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这取决于“矩形”在程序中的表示方式。几个选项:
如果您的矩形是矢量,并且您可以访问锚点:
<前><代码>---> o-----o <---
| |
| |
哦------哦
变成:
<前><代码> o--o
/\
/\
哦------哦
简单地平移两个顶部点并将它们相互压缩。
如果该“矩形”实际上是一个
DisplayObject
,您将需要“缝合”两个相同的 DisplayObject 以创建一个新的 DisplayObject。 此页面包含您想要的示例以及示例代码。另一种选择是使用 Papervision3D - 它使用上述渲染方法作为基础。< /p>
这有点棘手,但这是一个选择。您可以按照此处所述使用置换贴图。代码是 AS2,但“移植”应该相当简单。
编辑
正如这个答案,我建议您使用Papervision3D(参见第三个选项)为此,您可能想在“房间”周围移动相机。它还会照顾其他墙壁。
It depends on how the "rectangle" is represented in your program. Few options:
If your rectangle is vector, and you have access to the anchor points:
Becomes:
Simply translate the two top points and condense them to each other.
If that 'rectangle' is actually a
DisplayObject
, you will need to 'stitch' two of the same DisplayObject to create a new one. This page has examples of what you want along with example code.Another option would be to use Papervision3D - which is using the above rendering method as a base.
This one's a bit tricky, but it's an option. You can use displacement maps as described here. The code is AS2, but it should be fairly simple to "port".
EDIT
As par this answer, I suggest you use Papervision3D (see 3rd option) to do that, as you might want to move the camera around the "room". It will also take care of the other walls as well.
这个想法是将其分成三角形,然后对它们执行仿射变换(使用矩阵)......
senoptic 提供的示例代码(针对 AS2).. ......
网上也有一些库,但我现在找不到
the idea is to divide it into triangles and then perform an affine transformation (using Matrix) on them ...
senocular provided sample code (for AS2) ...
there's also a handful of libs online, but I can't find any right now ...
如果您的目标是 FlashPlayer 10,则可以通过旋转剪辑的旋转值来实现,请参阅 此帖子来自 Mike Chambers 了解详细信息。
否则您将需要像 Papervision 这样的 3D 引擎。在 Flash Player 9 中没有简单的方法来执行非仿射变换。
祝你好运。
If you're targetting FlashPlayer 10 you can do it by rotating the clip's rotation values, see This post form Mike Chambers for details.
Otherwise you're going to need a 3D engine like Papervision. There's no simple way to do non-affine transformations in Flash Player 9.
Good luck.